ó
ø`9Sc           @   s   d  d l  Z  d  d l Td  d l Td  d l m Z d  d l m Z d  d l Td  d l Td  d l Td g Z	 d e
 f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   *(   t   gui(   t   txtt   PhotometerTableWidgetc           B   sž   e  Z d  Z e j d d ƒ Z d d „ Z d „  Z e	 d „  ƒ Z
 d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s|   Widget responsible for selection of photometer input data for the manual
    version of aerosol profile retrieval algorithm.t   hoursi   c      '   C   sQ  t  j |  | ƒ g  |  _ t j d ƒ |  _ t j d ƒ |  _ t j d ƒ |  _ t j d ƒ |  _ t j d ƒ |  _	 t j d ƒ |  _
 t j d ƒ |  _ d  |  _ d  |  _ d  |  _ t ƒ  } t ƒ  |  _ |  j j j |  j ƒ |  j j j |  j ƒ |  j j j |  j ƒ |  j j j |  j ƒ | j |  j ƒ | j d d d d ƒ |  j | ƒ t j d	 ƒ } t j d
 ƒ } t j d ƒ } |  j j t  d  d d  d ƒ t  d d d d ƒ t  d d d d ƒ t  d d d d ƒ t  d d d d ƒ t  d d d d ƒ t  d d d d  ƒ t  d! d" d d# ƒ t  d$ d% d d& ƒ t  d' d( d) d* ƒ t  d+ d, d- d. ƒ t  d/ d0 d- d1 ƒ t  d2 d3 d) d4 | ƒ t  d5 d6 d7 d8 | ƒ t  d9 d: d d; | ƒ t  d< d= d d> | ƒ t  d? d@ d dA | ƒ t  dB dC d dD | ƒ t  dE dF d dG | ƒ t  dH d3 d) d4 | ƒ t  dI d6 d7 d8 | ƒ t  dJ d: d d; | ƒ t  dK d= d d> | ƒ t  dL d@ d dA | ƒ t  dM dC d dD | ƒ t  dN dF d dG | ƒ t  dO d3 d) d4 | ƒ t  dP d6 d7 d8 | ƒ t  dQ d: d d; | ƒ t  dR d= d d> | ƒ t  dS d@ d dA | ƒ t  dT dC d dD | ƒ t  dU dF d dG | ƒ g! ƒ |  j j! d ƒ |  _" |  j j# d ƒ j$ |  _% d  S(V   Ns
   arrow-greys   arrow-greent   equalss	   not-equals
   equals-reds   not-equal-redt   warningi    s   button-purples   button-greens
   button-redt    s   Lidar synchronization markerst   datet   Dates"   Date of the photometer measurementt   timet   Times"   Time of the photometer measurementt   aot675s   AOT 675s   %.3fs.   Photometer aerosol optical thickness at 675 nmt
   aot675Corrs   AOT corrs6   Manually corrected aerosol optical thickness at 675 nmt	   vFineCorrs   V-Fu3   Volumetric concentration of fine aerosol mode (Î¼m)t   vCoarseCorrs   V-Cu5   Volumetric concentration of coarse aerosol mode (Î¼m)t   vSphericalCorrs   V-Csu?   Volumetric concentration of coarse spherical aerosol mode (Î¼m)t   vSpheroidCorrs   V-CnsuC   Volumetric concentration of coarse non-spherical aerosol mode (Î¼m)t
   sphericitys   %sphs   %.1fs+   Fraction of spherical aerosol particles (%)t   evRatio2Modest   EVR2s   %.1es:   Eigenvalue ratio for the 2-mode aerosol backscatter matrixt   evRatio3Modest   EVR3s:   Eigenvalue ratio for the 3-mode aerosol backscatter matrixt   wl355t   Waves   Wavelength (nm)t   re355t   Res   %.2fs%   Real part of aerosol refractive indext   im355t   Ims*   Imaginary part of aerosol refractive indext
   ext355Corrt   exts(   Total aerosol extinction (optical depth)t   ssa355t   ssas    Aerosol single scattering albedot   f11_355t   F11s+   Main component of aerosol scattering matrixt   f22by11_355s   F2/1s8   Normalized second component of aerosol scattering matrixt   wl532t   re532t   im532t
   ext532Corrt   ssa532t   f11_532t   f22by11_532t   wl1064t   re1064t   im1064t   ext1064Corrt   ssa1064t   f11_1064t   f22by11_1064(&   t   StatusSignalingWidgett   __init__t   dataListR   t   loadIcont	   matchIcont   bestMatchIcont
   equalsIcont   notEqualIcont   equalsIconRedt   notEqualIconRedt   warningIcont   Nonet   firstMatchRowt   lastMatchRowt   bestMatchRowt   QVBoxLayoutt   DataTableWidgett   tablet   itemSelectionChangedt   connectt   onSelectionChangedt   itemChangedt   onItemChangedt   itemEditingStartedt   onItemEditingStartedt   itemEditingFinishedt   onItemEditingFinishedt	   addWidgett   setContentsMarginst	   setLayoutt
   setColumnst   TableWidgetColumnt   getColumnIndexByAttributeNamet   aot675CorrColumnt   getColumnByAttributeNamet   formatStringt   aot675CorrFormat(   t   selft   parentt   layoutt   icon355t   icon532t   icon1064(    (    s   code\PhotometerTableWidget.pyR3   ,   s¾    																										c         C   s   |  j  S(   N(   RC   (   RW   (    (    s   code\PhotometerTableWidget.pyt   getTableWidget¯   s    c           C   s   d S(   sR   Return index of the table column holding lidar synchronization hint
        icons.i    (    (    (    (    s   code\PhotometerTableWidget.pyt   getIconColumn²   s    c      
   C   s§  t  j |  j ƒ - |  j j ƒ  d  |  _ d  |  _ d  |  _ Wd  QX| |  _ t	 |  j ƒ d k rp |  j
 d ƒ d  St  j |  j ƒ |  j j |  j ƒ xú t t	 |  j ƒ ƒ D]ã } t ƒ  } | j t j t j Bƒ |  j j | |  j ƒ  | ƒ |  j j | |  j ƒ } | j | j ƒ  t j Bƒ | j t j t j Bƒ |  j |  j | j |  j |  j | j k r‚|  j | j |  j | _ n  |  j | ƒ q¬ WWd  QX|  j ƒ  d  S(   Ni    s-   Photometer data file contains no data records(    R   t   SignalBlockerRC   t
   clearTableR=   R>   R?   R@   R4   t   lent   setErrorMessaget   populateTablet   ranget   QTableWidgetItemt   setFlagst   Qtt   ItemIsEnabledt   ItemIsSelectablet   setItemR^   t   itemRS   t   flagst   ItemIsEditablet   setTextAlignmentt	   AlignLeftt   AlignVCenterRV   R   R   t   updateAot675CorrIconRF   (   RW   t   photometerDataListt   it   iconItemt
   aot675Item(    (    s   code\PhotometerTableWidget.pyt   connectDataList¸   s0    				c         C   s<   |  j  j ƒ  } | d k s- |  j ƒ  d k	 r1 d S|  j | S(   sk   Return a 'PhotometerInput' instance or 'None' if the photometer
        measurement is bad or not selected.N(   RC   t   getSelectedRowR=   t   getStatusMessageR4   (   RW   t   selectedRow(    (    s   code\PhotometerTableWidget.pyt   getDataé   s    c      
   C   s  t  |  j ƒ d k r d S|  j d k	 r t j |  j ƒ N xF t |  j |  j d ƒ D]+ } |  j j	 | |  j
 ƒ  ƒ j t ƒ  ƒ qU WWd QXn  d |  _ | d k r² | d k r² d S| | k sÄ t ‚ | |  j } | |  j } g  } | | | d } d |  _ t | |  j d j ƒ  ƒ } xŠ t t  |  j ƒ ƒ D]s } |  j | j ƒ  }	 | |	 k ob| k n rw| j | ƒ n  t | |	 ƒ }
 |
 | k  r2| |  _ |
 } q2q2Wt  | ƒ d k rÐd |  _ d |  _ n | d |  _ | d |  _ |  j d k	 r†t j |  j ƒ v xn t |  j |  j d ƒ D]S } |  j j	 | |  j
 ƒ  ƒ } | |  j k ri| j |  j ƒ q&| j |  j ƒ q&WWd QXn  t j d |  j ƒ d S(   s±  Update lidar synchronization icons according to the given lower and
        upper bounds of the lidar measurement time, and then update table's
        scrolling so that row that best matches the measurement time interval
        will appear at the center of the displayed table area.

        If 'startDateTime' and 'stopDateTime' are 'None', just clear the
        synchronization icons and leave table's scrolling position intact.i    Ni   i   iÿÿÿÿ(   Ra   R4   R>   R=   R   R_   RC   Rd   R?   Rk   R^   t   setIcont   QIconR@   t   AssertionErrort   lidarSynchronizationTolerancet   abst   getDateTimet   appendR7   R6   t   QTimert
   singleShott   onScrollToBestMatch(   RW   t   startDateTimet   stopDateTimet   rowt   minDateTimet   maxDateTimet   matchingRowst   matchDateTimet   bestTimeDeltat   dateTimet	   timeDeltaRt   (    (    s   code\PhotometerTableWidget.pyt   updateSynchronizationHintsô   sJ    
 2				 	c         C   sC  t  |  j ƒ |  j j ƒ  k o) | k n s4 t ‚ |  j | } | j d k r\ |  j } nÄ | j | j k o| | j	 k n r |  j
 } n“ | j | j k o­ | j	 k n r¾ |  j } nb | j | j k oÞ | j	 k n rï |  j } n1 | j | j k o| j	 k n r |  j } n  |  j j | |  j ƒ j | ƒ d S(   sŒ  Set the editable AOT 675 item icon based on its data:
          - set the icon to a warning sign if the value entered is not a valid
            floating point number;
          - set the icon to a not equal sign if the editable AOT 675 value is
            different from the static one;
          - set the icon color to red if the editable value is different from
            the original one.N(   Ra   R4   RC   t   rowCountR}   R   R=   R<   R   t   aot675CorrOriginalR8   R9   R:   R;   Rk   RS   R{   (   RW   R‡   t   inputt   icon(    (    s   code\PhotometerTableWidget.pyRq   V  s    	4%%%%c         C   s±   t  |  j ƒ |  j j ƒ  k o) d k n s4 t ‚ |  j j ƒ  } | d k r` |  j d ƒ d S|  j | j d k r£ |  j d t	 j
 |  j j d ƒ j ƒ ƒ d S|  j ƒ  d S(   s†   Check if a completely valid photometer input data is currently
        selected in the widget and set the error message appropriately.i    s%   Photometer mesurement is not selectedNsQ   Photometer input: the value in the %s column is not a valid floating point numberR   (   Ra   R4   RC   R   R}   Rw   R=   Rb   R   R   t   quoteRT   t   columnLabelt   clearStatusMessage(   RW   Ry   (    (    s   code\PhotometerTableWidget.pyt   updateErrorMessagep  s    4	c         C   sc  t  |  j ƒ |  j j ƒ  k o/ | j ƒ  k n s: t ‚ | j ƒ  |  j k sU t ‚ |  j | j ƒ  } t j	 | j
 ƒ  ƒ } | d k	 r• | | _ n t j |  d d ƒ t j |  j ƒ ™ |  j | j |  j | j k rê | j | _ n  |  j | j |  j | j k r| j | _ n  | j ƒ  |  j j | j ƒ  | ƒ |  j | j ƒ  ƒ Wd QX|  j ƒ  d S(   s8   Process user interaction in the editable AOT 675 column.s   AOT corrs6   The value entered is not a valid floating point numberN(   Ra   R4   RC   R   R‡   R}   t   columnRS   R   t   stringToFloatt   textR=   R   t   QMessageBoxR   R   R_   RV   R   R‘   t   updateCorrectedThicknessest   updateTableRowRq   R—   (   RW   Rk   t	   inputDatat	   itemValue(    (    s   code\PhotometerTableWidget.pyRH   ‡  s&    :
c         C   s   |  j  ƒ  d  S(   N(   R—   (   RW   (    (    s   code\PhotometerTableWidget.pyRF   ²  s    c         C   s   |  j  d ƒ d  S(   Ns-   Press Enter to apply editing or Esc to cancel(   t   setInfoMessage(   RW   (    (    s   code\PhotometerTableWidget.pyRJ   µ  s    c         C   s   |  j  ƒ  d  S(   N(   R—   (   RW   (    (    s   code\PhotometerTableWidget.pyRL   º  s    c         C   s8   |  j  j |  j |  j ƒ  ƒ } |  j  j | t j ƒ d  S(   N(   RC   Rk   R@   R^   t   scrollToItemt   QAbstractItemViewt   PositionAtCenter(   RW   t
   scrollItem(    (    s   code\PhotometerTableWidget.pyR„   ¾  s    N(   t   __name__t
   __module__t   __doc__t   datetimet	   timedeltaR~   R=   R3   R]   t   staticmethodR^   Rv   Rz   R   Rq   R—   RH   RF   RJ   RL   R„   (    (    (    s   code\PhotometerTableWidget.pyR   "   s   ƒ		1		b			+			(   R¨   t   PyQt4.QtCoret   PyQt4.QtGuit   common.utilsR   R   t   common.DataTableWidgett   common.StatusSignalingWidgett   PhotometerInputt   __all__R2   R   (    (    (    s   code\PhotometerTableWidget.pyt   <module>   s   




	