ó
ø`9Sc           @   s  d  d l  Z d  d l Td  d l Td  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  d l Td  d l Ty d  d l TWn e k
 r­ e Z n Xe Z y d  d l TWn e k
 rÛ e Z n Xe Z d g Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   *(   t   gui(   t   txtt   OutputViewerWidgetc           B   s¾  e  Z d  Z i  Z i  Z e j d ƒ Z e j d ƒ Z e j d ƒ Z	 e
 d d d d ƒ e
 d d	 d
 d ƒ e
 d d d
 d ƒ e
 d d d
 d ƒ e
 d d d d ƒ e
 d d d
 d ƒ e
 d d d d ƒ e
 d d d d ƒ e
 d  d! d d" ƒ e
 d# d$ d d% ƒ e
 d& d' d d( ƒ e
 d) d* d d+ ƒ e
 d, d- d. d/ e ƒ e
 d0 d1 d. d2 e ƒ e
 d3 d4 d. d5 e	 ƒ e
 d6 d7 d. d8 e ƒ e
 d9 d: d. d; ƒ e
 d< d= d. d> ƒ e
 d? d@ d. dA ƒ e
 dB dC d. dD ƒ e
 dE dF d. dG ƒ e
 dH dI d. dJ ƒ e
 dK dL d. dM ƒ e
 dN dO d. dP ƒ g e e <e e e <e r@e j d ƒ Z e j dQ ƒ Z e
 d d d d ƒ e
 d d	 d
 d ƒ e
 d d d
 d ƒ e
 d d d d ƒ e
 d d d
 d ƒ e
 d d d d ƒ e
 dR dS d dT ƒ e
 dU dV d dW ƒ e
 dX dY d. dZ e ƒ e
 d[ d\ d. d] e ƒ e
 d^ d_ d. d` ƒ e
 da db d. dc ƒ e
 dd de d. df ƒ g e e <e e e <n  e rGe
 d d d d ƒ e
 d d	 d
 d ƒ e
 d d d
 d ƒ e
 d d d d ƒ e
 d d d
 d ƒ e
 d d d d ƒ e
 dg dh di dj ƒ e
 dk dl d. dm ƒ e
 dn do d. dp ƒ e
 dq dr d. ds ƒ e
 dt du d. dv ƒ e
 dw dx d. dy ƒ e
 dz d{ d. d| ƒ g e e <e e e <n  d‰ e d} „ Z d~ „  Z d „  Z d€ „  Z d „  Z e d‚ „ Z dƒ „  Z d„ „  Z d… „  Z d† „  Z  d‡ „  Z! dˆ „  Z" RS(Š   si   Window used to display the contents of an output database of the aerosol
    profile retrieval algorithm.s   button-purples   button-greens
   button-redt	   startDatet   Datet   dates*   Start date for the lidar measurement groupt	   startTimet   TStartt   times*   Start time for the lidar measurement groupt   stopTimet   TStops)   Stop time for the lidar measurement groupt   photometerTimet   TPhotos+   Time of the matching photometer measurementt   retrievalDatet   DRetrs   Retrieval datet   retrievalTimet   TRetrs   Retrieval timet   gridHeightStept   HSteps   %.1fs    Height step of the data grid (m)t   calculatedVFines   V-Fs   %.3fu2   Retrieved concentration of fine aerosol mode (Î¼m)t   calculatedVCoarses   V-Cu4   Retrieved concentration of coarse aerosol mode (Î¼m)t   calculatedVSphericals   V-Csu>   Retrieved concentration of coarse spherical aerosol mode (Î¼m)t   calculatedVSpheroids   V-CnsuB   Retrieved concentration of coarse non-spherical aerosol mode (Î¼m)t   calculatedSphericitys   %sphs5   Retrieved fraction of spherical aerosol particles (%)t   residual355s   R-355s   %.1es!   Lidar equation residual at 355 nmt   residual532s   R-532s!   Lidar equation residual at 532 nmt   residual1064s   R-1064s"   Lidar equation residual at 1064 nmt   residual532Cu	   R-532,âŠ¥s=   Lidar equation residual at 532 nm for cross-polarized channelt   residualFines   R-Fs-   Concentration equation residual for fine modet   residualCoarses   R-Cs/   Concentration equation residual for coarse modet   residualSphericals   R-Css9   Concentration equation residual for coarse spherical modet   residualSpheroids   R-Cnss=   Concentration equation residual for coarse non-spherical modet   resSmoothFines   Rsm-Fs*   Smoothness equation residual for fine modet   resSmoothCoarses   Rsm-Cs,   Smoothness equation residual for coarse modet   resSmoothSphericals   Rsm-Css6   Smoothness equation residual for coarse spherical modet   resSmoothSpheroids   Rsm-Cnss:   Smoothness equation residual for coarse non-spherical modes   button-yellowt   wavelengthSourcet   Sources+   Wavelength of the source lidar channel (nm)t   wavelengthRamant   Ramans.   Wavelength of the receiving lidar channel (nm)t   residualSources   R-sources3   Lidar equation residual at the source lidar channelt   residualRamans   R-Ramans2   Lidar equation residual at the Raman lidar channelt   resSmoothBackscatters   Rsm-Bss:   Smoothness equation residual for backscatter ratio profilet   resSmoothLidars   Rsm-Ls4   Smoothness equation residual for lidar ratio profilet   resDeviateLidars   Rdev-Ls@   Middle value deviation equation residual for lidar ratio profilet   polarizationBaset   Polars   %ds)   Polarization ID of the base lidar channelt   aerBackscatterRatioReft   RsC   Retrieved value of aerosol backscatter ratio at the reference pointt   lidarCorrectiont   QsB   Retrieved value of the cross-polarized lidar correcion coefficientt   residualBases   R-Bases2   Lidar equation residual for the base lidar channelt   residualCrosss   R-Crosss=   Lidar equation residual for the cross-polarized lidar channelt   resSmoothParallels   Rsm-ParallelsC   Smoothness equation residual for parallel backscatter ratio profilet   resSmoothCrosss	   Rsm-CrosssJ   Smoothness equation residual for cross-polarized backscatter ratio profilec         C   s®  t  j |  | ƒ |  j t j ƒ g  |  _ d |  _ t ƒ  } t	 d d d d ƒ |  _
 |  j
 j d ƒ |  j
 j j |  j ƒ | j |  j
 ƒ t ƒ  |  _ |  j j j |  j ƒ i  |  _ t ƒ  |  _ x? |  j D]4 } |  j | ƒ  |  j | <|  j j |  j | ƒ qÊ Wt t j ƒ |  _ |  j j t ƒ |  j j |  j ƒ |  j j |  j ƒ | j |  j ƒ t ƒ  |  _ | j |  j ƒ t d ƒ |  _  |  j  j! t" j# d ƒ ƒ |  j  j$ j |  j% ƒ t d ƒ |  _& |  j& j! t" j# d	 ƒ ƒ |  j& j$ j |  j' ƒ t( ƒ  } | j |  j  ƒ | j |  j& ƒ | j) ƒ  | j* | ƒ |  j+ | ƒ |  j, d
 ƒ |  j- t" j# d ƒ ƒ |  j j. |  j/ t0 ƒ |  j j1 |  j t0 ƒ |  j2 | ƒ |  j j3 ƒ  d S(   sß   If 'skipDatabaseLoading' is 'True', no database file is loaded upon
        construction; otherwise, the database file whose name is stored in the
        interface settings is loaded (without selecting any of the records).s!   Aerosol profile &output database:s"   Microsoft Access databases (*.mdb)s&   Select aerosol profile output databases5   Open an existing aerosol profile output database files=   Reload the currently selected aerosol profile output databases   &Save plots ass   print-frames&   &Export the database to the Excel files   microsoft-office-excels   Output viewers   institute-of-physicsN(4   t   QWidgett   __init__t   setAttributet   Qtt   WA_DeleteOnCloset   datat   Nonet   dataTypet   QVBoxLayoutt   FileSelectionWidgett   fileSelectort   showReloadButtont
   fileOpenedt   connectt   onFileOpenedt	   addWidgett   DataTableWidgett   tablet   itemSelectionChangedt   onSelectionChangedt   plotWidgetst   QStackedWidgett   plotWidgetStackt   plotWidgetClassest	   QSplittert   Verticalt   splittert   setChildrenCollapsiblet   Falset   StatusLabelWidgett   statusLabelt   QPushButtont   savePlotsButtont   setIconR   t   loadIcont   clickedt   onSavePlotsButtonClickedt   exportButtont   onExportButtonClickedt   QHBoxLayoutt
   addStretcht	   addLayoutt	   setLayoutt   setWindowTitlet   setWindowIcont
   setColumnst   tableColumnListst   LiricOutputt   setCurrentWidgett   loadSettingst   setFocus(   t   selft   parentt   skipDatabaseLoadingt   layoutR?   t   buttonBoxLayout(    (    s   code\OutputViewerWidget.pyR9   Ø   s^    						
c         C   s   |  j  j | ƒ d S(   s'   Load or reload the given database file.N(   RB   t   openFile(   Rk   t
   dbFilePath(    (    s   code\OutputViewerWidget.pyt   openDatabase$  s    c         C   sL   |  j  j | ƒ |  j j ƒ  d k rH |  j j |  j j ƒ  d d ƒ n  d S(   sU   Load or reload the given database file and select its last record on
        success.i    i   N(   RB   Rp   RI   t   rowCountt   setCurrentCell(   Rk   Rq   (    (    s   code\OutputViewerWidget.pyt   openLastDatabaseRecord)  s    c         C   s   |  j  ƒ  | j ƒ  d  S(   N(   t   saveSettingst   accept(   Rk   t   event(    (    s   code\OutputViewerWidget.pyt
   closeEvent2  s    
c         C   s   t  d t  j ƒ } t j |  | ƒ |  j j | d ƒ | j d |  j j ƒ  ƒ | j d t	 j
 |  j ƒ ƒ | j d |  j ƒ d  S(   Ns)   settings/interface/OutputViewerWidget.init   filePatht   splitterStatet   savePlotsDirt   savePlotsFileFormat(   t	   QSettingst	   IniFormatR   t   saveWindowSettingsRB   Rv   t   setValueRR   t	   saveStateR   t   portablePathR|   R}   (   Rk   t   settings(    (    s   code\OutputViewerWidget.pyRv   7  s    c         C   sÎ   t  d t  j ƒ } t j |  | ƒ | s> |  j j | d ƒ n  | j d ƒ ro |  j j | j	 d ƒ j
 ƒ  ƒ n |  j j d d g ƒ t j | j	 d d ƒ j ƒ  ƒ |  _ t | j	 d d ƒ j ƒ  ƒ |  _ d  S(	   Ns)   settings/interface/OutputViewerWidget.iniRz   R{   iè  R|   t   .R}   t   png(   R~   R   R   t   loadWindowSettingsRB   Ri   t   containsRR   t   restoreStatet   valuet   toByteArrayt   setSizesR   t   absolutePatht   toStringR|   t   unicodeR}   (   Rk   Rm   R„   (    (    s   code\OutputViewerWidget.pyRi   E  s    	c         C   s€   |  j  2t j |  j ƒ  |  j j ƒ  Wd QX|  j d k	 r\ |  j |  j j ƒ  d |  _ n  |  j	 j
 t ƒ |  j j
 t ƒ d S(   s>   Silently remove all the data and clear table and plot widgets.N(   R=   R   t   SignalBlockerRI   t
   clearTableR?   R>   RL   t   clearRX   t
   setEnabledRT   R]   (   Rk   (    (    s   code\OutputViewerWidget.pyR’   \  s    c         C   s?   |  j  j ƒ  } | d  k r. |  j j d ƒ n |  j j ƒ  | S(   Ns-   Aerosol profile output record is not selected(   RI   t   getSelectedRowR>   RV   t   setInfoR’   (   Rk   t   selectedRow(    (    s   code\OutputViewerWidget.pyt   updateStatusLabell  s    	
c         C   s  |  j  ƒ  |  j j ƒ  } | d  k r9 |  j j d ƒ d  S|  j j d t ƒ d  } x |  j D]… } y | j	 | ƒ |  _
 Wn. t j k
 r¨ } | d  k rá | j } qá q\ X|  j j |  j | ƒ |  j j |  j | ƒ | |  _ Pq\ W|  j d  k r|  j j | ƒ d  St |  j
 ƒ d k r1|  j j d ƒ d  S|  j j |  j
 ƒ |  j j t |  j
 ƒ d d ƒ |  j ƒ  |  j j t ƒ |  j j ƒ  d  S(   Ns/   Aerosol profile output database is not selecteds*   Loading aerosol profile output database...i    s3   Aerosol profile output database contains no recordsi   (   R’   RB   t   getFilePathR>   RV   t   setErrort   setProgresst   TrueRf   t   readDataListR=   R   t   Errort   textRI   Re   RN   Rh   RL   R?   t   lenR•   t   populateTableRt   RK   R]   R“   Rj   (   Rk   Rz   t   firstErrorMessageR?   t   e(    (    s   code\OutputViewerWidget.pyRF   x  s@    
		
			 
c         C   s±   |  j  ƒ  } | d  k r+ |  j j t ƒ n‚ |  j | j ƒ  } | d  k	 r€ |  j j | ƒ |  j	 j
 ƒ  j ƒ  |  j j t ƒ n- |  j	 j
 ƒ  j |  j | ƒ |  j j t ƒ d  S(   N(   R—   R>   RX   R“   RT   R=   t   getErrorMessageRV   t
   setWarningRN   t   currentWidgetR’   t   plotDataR›   (   Rk   R–   t   errorMessage(    (    s   code\OutputViewerWidget.pyRK   ¯  s    c         C   s  |  j  j ƒ  } |  j j | ƒ } t j j | ƒ rx t j |  d d t	 j
 | ƒ t j t j Bƒ } | t j k rx d  Sn  |  j j d t ƒ y |  j j | |  j ƒ f Wn6 t	 j k
 rà } t j |  d | j ƒ |  j ƒ  n X|  j j d t	 j
 | ƒ ƒ |  j j ƒ  d  S(   Ns   File already existssC   The excel file (%s) already exists. Would you like to overwrite it?s+   Exporting the database to the Excel file...s   Failed to save the files/   The Excel file (%s) has been saved successfully(   RB   R˜   R?   t   getExcelExportFilePatht   ost   patht   existst   QMessageBoxt   questionR   t	   quotePatht   Yest   NoRV   Rš   R›   t   exportDataListToExcelR=   R   t   criticalRž   R—   t   setCompletedRI   Rj   (   Rk   Rq   t   excelFilePatht   answerR¢   (    (    s   code\OutputViewerWidget.pyR^   Á  s(    	
	c            s¨  t  j j |  j ƒ s! d |  _ n  d d g } i d d 6d d 6‰  t d k  rW | d =n  |  j | k rr d |  _ n  t j |  d |  j d j ‡  f d	 †  | Dƒ ƒ ˆ  |  j ƒ } | j	 ƒ  rÀ d  St
 j | ƒ } t  j j | ƒ |  _ t  j j | ƒ d
 j d ƒ j ƒ  } | |  _ |  j j d t ƒ |  j |  j d | d k rGd n d ƒ } | j |  j |  j j ƒ  ƒ | j | ƒ |  j j d t
 j | ƒ ƒ |  j j ƒ  d  S(   NR…   R†   t   emfs!   Portable network graphics (*.png)s!   Windows enhanced metafile (*.emf)i  s   Save plots ass   ;;c         3   s   |  ] } ˆ  | Vq d  S(   N(    (   t   .0t   id(   t   fileFormatStrings(    s   code\OutputViewerWidget.pys	   <genexpr>   s    i   s   Saving the image file...t   displayModet   images   Image file (%s) has been saved(   R©   Rª   t   isdirR|   t   PYQT_VERSIONR}   t   QFileDialogt   getSaveFileNamet   joint   isNullR   R   t   dirnamet   splitextt   lstript   lowerRV   Rš   R›   RO   R?   R¦   R=   RI   R”   t   saveAsImageR³   R®   Rj   (   Rk   t   fileFormatIdst   imageFilePatht   imageFileExtt   imagePlotWidget(    (   R¹   s   code\OutputViewerWidget.pyR\   è  s8    

%		N(#   t   __name__t
   __module__t   __doc__Rf   RO   R   RZ   t   icon355t   icon532t   icon1064t   TableWidgetColumnRg   t   LiricPlotWidgett   ramanOutputPluginLoadedt
   iconSourcet	   iconRamant   RamanOutputt   RamanPlotWidgett   polarOutputPluginLoadedt   PolarOutputt   PolarPlotWidgetR>   RT   R9   Rr   Ru   Ry   Rv   Ri   R’   R—   RF   RK   R^   R\   (    (    (    s   code\OutputViewerWidget.pyR   4   s   			
L								7		'(   t   os.pathR©   t   PyQt4.QtCoret   PyQt4.QtGuit   PyQt4.QtSvgt
   PyQt4.Qwt5t   common.utilsR   R   t   common.DataTableWidgett   common.FileSelectionWidgett   common.StatusLabelWidgetRg   t   PlotWidgetsRÖ   t   ImportErrorRT   RÓ   R›   RÙ   RØ   t   __all__R8   R   (    (    (    s   code\OutputViewerWidget.pyt   <module>   s.   










	