
`9Sc           @   sU   d  d l  Z  d  d l Z d  d l m Z d  d l Td g Z d e f d     YZ d S(   iN(   t   txt(   t   *t   LiricOutputc           B   s}  e  Z d  Z d Z e d d d  e d d d  e d d d  e d	 d
 d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d  d!  e d" d# d! d$ e e d% d& d! d$ e e d' d( d! d$ e e d) d* d! d$ e e d+ d, d- e j  e d. d/ d- e j  e d0 d1 d- e j  e d2 d3 d- e j  e d4 d5 d- e j  e d6 d7 d- e j  e d8 d9 d- e j  e d: d; d- e j  e d< d= d- e j  e d> d? d- e j  e d@ dA d- e j  e dB dC d- e j  e dD dE dF  e dG dH dF  e dI dJ dF  e dK dL dF  e dM dN dF  e dO dP dF  e dQ dR dF  e dS dT dF  e dU dV d  e dW dX d  e dY dZ d  e d[ d\ dF  e d] d^ d! d$ e e d_ d` d! d$ e e da db d! d$ e e dc dd d- e j d$ e e de df d- e j d$ e e dg dh d- e j d$ e e di dj d- e j d$ e e dk dl d  e dm dn d d$ e e do dp d d$ e e dq dr d  e ds dt d d$ e e du dv d  e dw dx d  e dy dz d d$ e e d{ d| d d$ e e d} d~ d  e d d d d$ e e d d d d$ e e d d d  e d d d d$ e e d d d  e d d d  e d d d d$ e e d d d d$ e e d d d  e d d d d$ e e d d d d$ e e d d d  e d d d d$ e e d d d  e d d d  e d d d d$ e e d d d d$ e e d d d  e d d d d$ e e d d d d$ e e d d d  e d d d d$ e e d d d  e d d d  e d d d d$ e e d d d d$ e e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e d d d  e ddd  e ddd  e ddd  e ddd  e d	d
d  e ddd  e ddd  e ddd  e ddd  e ddd  e ddd  e ddd  e ddd  e ddd  e ddd  e dd d- e j d$ e e d!d"d- e j d$ e e d#d$d- e j d$ e e d%d&d- e j d$ e e d'd(d d$ e e d)d*d d$ e e d+d,d d$ e e d-d.d d$ e e d/d0d! d$ e e d1d2d d$ e e d3d4d d$ e e d5d6d d$ e e d7d8d d$ e e d9d:d d$ e e d;d<d d$ e e d=d>d d$ e e d?d@d d$ e e dAdBd d$ e e dCdDd d$ e e dEdFd d$ e e dGdHd d$ e e dIdJd d$ e e dKdLd d$ e e dMdNd d$ e e dOdPd d$ e e dQdRd d$ e e dSdTd d$ e e dUdVd d$ e e dWdXd d$ e e dYdZd d$ e e d[d\d d$ e e d]d^d d$ e e d_d`d d$ e g Z daZ	 dbZ
 dcZ ddZ deZ dfZ dgZ dh  Z di  Z dj  Z dk  Z dl  Z RS(m  s  Output data for a single aerosol profile retrieval.

    Attributes to be read from a database:
      - 'latitude', 'longitude', 'altitude', 'startDate', 'stopDate',
        'startTime', 'stopTime': same as in 'PreparedLidarInput'.
      - 'photometerDate', 'photometerTime': date and time of the photometer
        measurement (same as in 'PhotometerInput').
      - 'retrievalDate', 'retrievalTime': date and time of the retrieval;
      - 'gridStep', 'gridZenithAngle': parameters of the data grid used for
        output data profiles (similar to those of 'PreparedLidarInput').
      - 'joinIndex': first index of the data grid that belongs to the far
        measurement zone, as opposed to the near one. This is used in automated
        aerosol retrieval only.

      - 'profileFine', 'profileSpherical', 'profileSpheroid', 'profileCoarse':
        retrieved aerosol concentration profiles for different aerosol modes,
        in ppb. Index zero of the arrays corresponds to index zero of the data
        grid. For polarimetric retrievals, 'Coarse' mode would not be directly
        available, and should be obtained as a sum of 'Spherical' and
        'Spheroid' modes. For not-polarimetric retrievals, 'Spherical' and
        'Spheroid' aerosol modes would not be available at all.
      - 'measuredSignal<...>', 'calculatedSignal<...>': measured and calculated
        lidar signals for different lidar channels, divided by their average
        values around the reference points, with molecular components removed.
      - 'signalId<...>': 'localId' fields of lidar inputs for the main (far)
        measurement zone.
      - 'signalId<...>Near': 'localId' fields of lidar inputs for the near
        measurement zone or 'None' for outputs generated by the manual version
        of the algorithm.
      - 'vFine', 'vCoarse': corrected values for 'vFine' and 'vCoarse' from the
        'PhotometerInput' instance. Correction factor is 'aot675Corr / aot675'.
      - 'sphericity': same as in 'PhotometerInput'.

      - 'atmosphereModel': copy of 'atmoModel' from the 'PreparedLidarInput'
        instances (this value should be the same among the inputs).
      - 'polarization<...>': 'polarization' values from the lidar inputs.
      - 'dispersion<...>': 'lidarDispersion' arrays from the lidar inputs.

      - 'b<...><...>': aerosol backscatter coefficients used in the retrieval
        equations, with parallel signal leakage not taken into account for
        cross-polarized channels. Used to calculate integrated backscatters
        displayed in the plot widgets.
      - 'a<...><...>': aerosol attenuation coefficients used in the retrieval
        equations. Used to calculate aerosol optical thicknesses displayed
        in the plot widgets.

      - 'weighting<...>' 'weightSmooth<...>', 'molDepolarization<...>',
        'parallelLeakage<...>': a copy of some of the algorithm parameters that
        had been used in the retrieval.
      - 'molThicknessError<...>', 'aerosolThicknessError<...>',
        'totalBackscatterError<...>': estimations of the atmospheric relative
        errors copied from the corresponding 'PreparedLidarInput' instances.

      - 'ratio<...>': retrieved backscatter ratios at the reference points.
      - 'residual<wavelength>': square root of the squared lidar equation
        residual, integrated over the retrieval interval.
      - 'residual<mode>': absolute value of the photometer equation residual
        for the given aerosol mode.
      - 'resSmooth<mode>': square root of the squared approximated second order
        derivative of the retrieved concentration profile, integrated over the
        retrieval interval.

      - 'profileDispersion<...>', 'ratioDispersion<...>': dispersions of the
        corresponding 'profile<...>' and 'ratio<...>' retrieved parameters that
        had been obtained while applying a predefined set of perturbances to
        the input data.

    Attributes that are calculated manually in 'onDataLoaded':
      - 'gridHeightStep': height step of the data grid (similar to
        'PreparedLidarInput').
      - 'vSpherical', 'vSpheroid': the value of 'vCoarse', divided into two
        parts according to the value of 'sphericity' attribute.
      - 'calculatedVFine', 'calculatedVCoarse', 'calculatedVSpherical',
        'calculatedVSpheroid': volumetric concentrations of retrieved aerosol
        modes, in micrometers, obtained by summation of the corresponding
        'profile<...>' arrays (i.e., the values retrieved by the aerosol
        profile retrieval algorithm, in contrast to 'vFine' and 'vCoarse' etc.
        taken from the photometer data). Note: for non-polarimetric retrievals,
        'calculatedVSpherical' and 'calculatedVSpheroid' are obtained from
        'profileCoarse' using 'sphericity' attribute.
      - 'calculatedSphericity': ratio of 'calculatedVSpherical' to the sum of
        'calculatedVSpherical' and 'calculatedVSpheroid', in percent.

    For non-polarimetric retrievals, all the attributes for 'Spherical' and
    'Spheroid' aerosol modes (with an exception for 'calculatedVSpherical' and
    'calculatedVSpheroid') will be 'None', as well as attributes related to the
    cross-polarized lidar channel. For polarimetric retrievals, all the
    attributes for 'Coarse' aerosol mode will be 'None'.t   AerosolProfilest   latitudet   Latitudet   SINGLEt	   longitudet	   Longitudet   altitudet   Altitudet	   startDatet	   StartDatet   DATEt   stopDatet   StopDatet	   startTimet	   StartTimet   TIMEt   stopTimet   StopTimet   photometerDatet   PhotometerDatet   photometerTimet   PhotometerTimet   retrievalDatet   RetrievalDatet   retrievalTimet   RetrievalTimet   gridStept   Stept   gridZenithAnglet   Zenitht	   joinIndext	   JoinIndext   SMALLINTt   firstInputIndex355t   Left_355t   requiredt   firstInputIndex532t   Left_532t   firstInputIndex1064t	   Left_1064t   firstInputIndex532Ct	   Left_532Ct   profileFinet   FineProfilet
   LONGBINARYt   profileSphericalt   CoarseSphericalProfilet   profileSpheroidt   CoarseSpheroidProfilet   profileCoarset   CoarseProfilet   measuredSignal355t   Measured_355t   measuredSignal532t   Measured_532t   measuredSignal1064t   Measured_1064t   measuredSignal532Ct   Measured_532Ct   calculatedSignal355t   Calculated_355t   calculatedSignal532t   Calculated_532t   calculatedSignal1064t   Calculated_1064t   calculatedSignal532Ct   Calculated_532Ct   signalId355t   IDLocal_355t   VARCHARt   signalId532t   IDLocal_532t   signalId1064t   IDLocal_1064t   signalId532Ct   IDLocal_532Ct   signalId355Neart   IDLocalNear_355t   signalId532Neart   IDLocalNear_532t   signalId1064Neart   IDLocalNear_1064t   signalId532CNeart   IDLocalNear_532Ct   vFinet   PhotometerVFinet   vCoarset   PhotometerVCoarset
   sphericityt
   Sphericityt   atmosphereModelt	   AtmoModelt   polarization355t   Polarization_355t   polarization532t   Polarization_532t   polarization1064t   Polarization_1064t   dispersion355t   StdDeviation_355t   dispersion532t   StdDeviation_532t   dispersion1064t   StdDeviation_1064t   dispersion532Ct   StdDeviation_532Ct   bFine355t	   BFine_355t	   bFine355Pt
   BFine_355Pt	   bFine355Ct
   BFine_355Ct   bFine532t	   BFine_532t	   bFine532Pt
   BFine_532Pt	   bFine532Ct
   BFine_532Ct	   bFine1064t
   BFine_1064t
   bFine1064Pt   BFine_1064Pt
   bFine1064Ct   BFine_1064Ct   bSpherical355t   BSpherical_355t   bSpherical355Pt   BSpherical_355Pt   bSpherical355Ct   BSpherical_355Ct   bSpherical532t   BSpherical_532t   bSpherical532Pt   BSpherical_532Pt   bSpherical532Ct   BSpherical_532Ct   bSpherical1064t   BSpherical_1064t   bSpherical1064Pt   BSpherical_1064Pt   bSpherical1064Ct   BSpherical_1064Ct   bSpheroid355t   BSpheroid_355t   bSpheroid355Pt   BSpheroid_355Pt   bSpheroid355Ct   BSpheroid_355Ct   bSpheroid532t   BSpheroid_532t   bSpheroid532Pt   BSpheroid_532Pt   bSpheroid532Ct   BSpheroid_532Ct   bSpheroid1064t   BSpheroid_1064t   bSpheroid1064Pt   BSpheroid_1064Pt   bSpheroid1064Ct   BSpheroid_1064Ct
   bCoarse355t   BCoarse_355t   bCoarse355Pt   BCoarse_355Pt   bCoarse355Ct   BCoarse_355Ct
   bCoarse532t   BCoarse_532t   bCoarse532Pt   BCoarse_532Pt   bCoarse532Ct   BCoarse_532Ct   bCoarse1064t   BCoarse_1064t   bCoarse1064Pt   BCoarse_1064Pt   bCoarse1064Ct   BCoarse_1064Ct   aFine355t	   AFine_355t   aFine532t	   AFine_532t	   aFine1064t
   AFine_1064t   aSpherical355t   ASpherical_355t   aSpherical532t   ASpherical_532t   aSpherical1064t   ASpherical_1064t   aSpheroid355t   ASpheroid_355t   aSpheroid532t   ASpheroid_532t   aSpheroid1064t   ASpheroid_1064t
   aCoarse355t   ACoarse_355t
   aCoarse532t   ACoarse_532t   aCoarse1064t   ACoarse_1064t   weighting355t
   Weight_355t   weighting532t
   Weight_532t   weighting1064t   Weight_1064t   weighting532Ct   Weight_532Ct   weightingFinet   Weight_Finet   weightingSphericalt   Weight_Sphericalt   weightingSpheroidt   Weight_Spheroidt   weightingCoarset   Weight_Coarset   weightSmoothFinet   WeightSmooth_Finet   weightSmoothSphericalt   WeightSmooth_Sphericalt   weightSmoothSpheroidt   WeightSmooth_Spheroidt   weightSmoothCoarset   WeightSmooth_Coarset   molDepolarization532t   MolDepolar_532t   parallelLeakage532t   Leakage_532t   molThicknessError355s
   RE OMT_355t   molThicknessError532s
   RE OMT_532t   molThicknessError1064s   RE OMT_1064t   molThicknessError532Cs   RE OMT_532Ct   aerosolThicknessError355s
   RE OAT_355t   aerosolThicknessError532s
   RE OAT_532t   aerosolThicknessError1064s   RE OAT_1064t   aerosolThicknessError532Cs   RE OAT_532Ct   totalBackscatterError355s
   RE GBS_355t   totalBackscatterError532s
   RE GBS_532t   totalBackscatterError1064s   RE GBS_1064t   totalBackscatterError532Cs   RE GBS_532Ct   ratio355t	   Ratio_355t   ratio532t	   Ratio_532t	   ratio1064t
   Ratio_1064t	   ratio532Ct
   Ratio_532Ct   residual355t   Residual_355t   residual532t   Residual_532t   residual1064t   Residual_1064t   residual532Ct   Residual_532Ct   residualFinet   Residual_Finet   residualSphericalt   Residual_Sphericalt   residualSpheroidt   Residual_Spheroidt   residualCoarset   Residual_Coarset   resSmoothFinet   ResSmooth_Finet   resSmoothSphericalt   ResSmooth_Sphericalt   resSmoothSpheroidt   ResSmooth_Spheroidt   resSmoothCoarset   ResSmooth_Coarset   profileDispersionFinet   FineDispersiont   profileDispersionSphericalt   CoarseSphericalDispersiont   profileDispersionSpheroidt   CoarseSpheroidDispersiont   profileDispersionCoarset   CoarseDispersiont   ratioDispersion355t   RatioDispersion_355t   ratioDispersion532t   RatioDispersion_532t   ratioDispersion1064t   RatioDispersion_1064t   ratioDispersion532Ct   RatioDispersion_532Ct   perturbanceEvaluationst   PerturbanceEvaluationst   whiteNoise355t   WhiteNoise_355t   whiteNoise532t   WhiteNoise_532t   whiteNoise1064t   WhiteNoise_1064t   whiteNoise532Ct   WhiteNoise_532Ct   linearNoise355t   LinearNoise_355t   linearNoise532t   LinearNoise_532t   linearNoise1064t   LinearNoise_1064t   linearNoise532Ct   LinearNoise_532Ct
   vFineNoiset   PhotometerVFineNoiset   vCoarseNoiset   PhotometerVCoarseNoiset   sphericityNoiset   SphericityNoiset   f11NoiseFine355t   F11NoiseFine_355t   f11NoiseFine532t   F11NoiseFine_532t   f11NoiseFine1064t   F11NoiseFine_1064t   f11NoiseCoarse355t   F11NoiseCoarse_355t   f11NoiseCoarse532t   F11NoiseCoarse_532t   f11NoiseCoarse1064t   F11NoiseCoarse_1064t   f11NoiseSpherical355t   F11NoiseSpherical_355t   f11NoiseSpherical532t   F11NoiseSpherical_532t   f11NoiseSpherical1064t   F11NoiseSpherical_1064t   f11NoiseSpheroid355t   F11NoiseSpheroid_355t   f11NoiseSpheroid532t   F11NoiseSpheroid_532t   f11NoiseSpheroid1064t   F11NoiseSpheroid_1064t   f22NoiseSpheroid532t   F22NoiseSpheroid_532s9   Aerosol profile output database file could not be createds[   Aerosol profile output file is not a valid Access database or may not be opened for readingsC   Aerosol profile output: failed to query data from the database files/   Aerosol profile output file format is invalid: s;   Failed to write the data to the aerosol profile output files+   Failed to read the data from the Excel files*   Failed to write the data to the Excel filec         C   s  |  j  d  k s |  j d  k r* d  |  _ n' |  j  t j |  j t j d  |  _ |  j d  k	 r |  j	 |  j d |  _
 |  j	 d |  j d |  _ n d  |  _
 d  |  _ |  j |  j  |  _ |  j d  k r|  j |  j  |  _ |  j |  j  |  _ |  j |  j |  _ nk |  j |  j  |  _ |  j d  k	 rd|  j |  j d |  _ |  j d |  j d |  _ n d  |  _ d  |  _ |  j d  k s|  j d  k rd  |  _ n |  j |  j |  j d |  _ d  S(   Ng     f@g{Gz?g      ?g      Y@(   R   t   NoneR   t   gridHeigthStept   matht   cost   pit   gridHeightStepR[   RY   t
   vSphericalt	   vSpheroidt   getCalculatedThicknessR-   t   calculatedVFineR4   R0   t   calculatedVSphericalR2   t   calculatedVSpheroidt   calculatedVCoarset   calculatedSphericity(   t   self(    (    s   code\LiricOutput.pyt   onDataLoaded  s:    !				c         C   s  |  j  d k } x|  j   D] } t |  |  d k	 r= q n  | rV | d k rV q n  | rw | j d  d k rw q n  | r | j d  d k s | j d  d k s | j d  d k r q n  | r | d k r q n  | j d	  s | d k r q n  d t j |  j |   SWd S(   s   Return an error message describing the malformed data or 'None' if
        all the attribute values are plausible and consistent.R[   t   Coarseit   532Ct	   Sphericalt   SpheroidR   R   t   NearR!   t	   fineErrort   coarseErrorR]   s"   %s database field contains no dataN(   R   R   (   s	   joinIndexRl  Rm  R]   (	   R4   RW  t   getRequiredAttributeNamest   getattrt   findt   endswithR    t   quotet   getFieldName(   Re  t   isPolarimetrict   name(    (    s   code\LiricOutput.pyt   getErrorMessage  s&    *
		c         C   s!   |  j  d k } | r d Sd Sd S(   sU   Return a list of attribute suffixes for lidar channels used in the
        retrieval.t   355t   532t   1064Rh  N(   s   355s   532s   1064s   532C(   s   355s   532s   1064(   R4   RW  (   Re  Rt  (    (    s   code\LiricOutput.pyt   lidarChannelIds  s    c         C   s!   |  j  d k } | r d Sd Sd S(   sc   Return a list of attribute suffixes for aerosol modes that are
        available in this retrieval.t   FineRi  Rj  Rg  N(   s   Fines	   Sphericals   Spheroid(   s   Fines   Coarse(   R4   RW  (   Re  Rt  (    (    s   code\LiricOutput.pyt   aerosolModeSuffixes  s    c         C   s%   | d  k r d  S| j   d |  j S(   NgMbP?(   RW  t   sumR\  (   Re  t   aerosolProfile(    (    s   code\LiricOutput.pyR_    s    (   t   __name__t
   __module__t   __doc__t	   tableNamet	   DataFieldt   Falset   numpyt   float32t   fieldst   createDatabaseErrorMessaget   openDatabaseErrorMessaget   queryFailureErrorMessaget   invalidFormatErrorPrefixt   writeDataErrorMessaget   importDataFromExcelErrorPrefixt   exportDataToExcelErrorPrefixRf  Rv  Rz  R|  R_  (    (    (    s   code\LiricOutput.pyR      s  X																		5	 		(   RY  R  t   common.utilsR    t   common.DataRecordt   __all__t
   DataRecordR   (    (    (    s   code\LiricOutput.pyt   <module>   s
   
	