ó
ø`9Sc           @   sB  d  d l  Td  d l Td  d l m Z d  d l m Z d  d l m Z d  d l Td  d l Td  d l Td  d l	 Td  d l
 Td  d l Td  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 e ró d  d l Tn  d g Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d S(   iÿÿÿÿ(   t   *(   t   gui(   t   txt(   t   utilst   RamanRetrieverWidgetc           B   st   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e r` d „  Z n  d	 „  Z d
 „  Z RS(   sq   Main GUI window of the aerosol backscatter and lidar ratio retrieval
    algorithm utilizing Raman lidar signals.c         C   s  t  j |  | ƒ |  j t j ƒ d  |  _ t j ƒ  |  _	 t
 rP t j ƒ  |  _ n  t ƒ  } t ƒ  |  _ |  j j j |  j ƒ t ƒ  |  _ |  j j t d d ƒ t d d ƒ g ƒ |  j j t d d ƒ t d d ƒ g ƒ t ƒ  } | j |  j ƒ | j |  j d ƒ | j d d d d ƒ | j | ƒ t ƒ  |  _ | j |  j ƒ t ƒ  |  _ | j |  j ƒ t d ƒ |  _ |  j j  t! j" d	 ƒ ƒ |  j j# j |  j$ ƒ t
 rÊt d
 ƒ |  _% |  j% j# j |  j& ƒ n  t d ƒ |  _' |  j' j# j |  j( ƒ t d ƒ |  _) |  j) j# j |  j* ƒ t+ ƒ  } | j |  j ƒ t
 rF| j |  j% ƒ n  | j, ƒ  | j |  j' ƒ | j |  j) ƒ | j | ƒ |  j- | ƒ |  j. d ƒ |  j/ t! j" d ƒ ƒ xI |  j |  j |  j f D]/ } | j0 j |  j1 ƒ | j2 j |  j j3 ƒ qÆW|  j4 ƒ  |  j j5 ƒ  j6 ƒ  d  S(   Ng     0v@i    i   g     0x@i   g      €@g     ø‚@s   &Parameterst
   parameterss   Per&turbance optionss	   &Retrieves   &View outputs   Raman aerosol retrievers   institute-of-physics(   i    i   (   i    i   (7   t   QWidgett   __init__t   setAttributet   Qtt   WA_DeleteOnCloset   Nonet   outputViewerWidgett   RamanParamst   loadFromFilet   algorithmParamst#   ramanPerturbanceProcessPluginLoadedt   RamanPerturbanceParamst   perturbanceParamst   QVBoxLayoutt   LidarDatabaseWidgett   lidarDatabaseWidgett   dataListChangedt   connectt   onLidarDataListChangedt   LidarTableWidgett   lidarTableWidgett   addAllowedChannelSequencet   LidarChannelInfot	   addWidgett   setContentsMarginst	   addLayoutt   RamanRetrievalSelectionWidgett   retrievalSelectionWidgett   StatusLabelWidgett   statusLabelt   QPushButtont   paramsButtont   setIconR   t   loadIcont   clickedt   onParamsButtonClickedt   perturbanceButtont   onPerturbanceButtonClickedt   retrieveButtont   onRetrieveButtonClickedt   viewOutputButtont   onViewOutputButtonClickedt   QHBoxLayoutt
   addStretcht	   setLayoutt   setWindowTitlet   setWindowIcont   statusMessageChangedt   onStatusMessageChangedt   repaintRequestedt   repaintParentWindowt   loadSettingst   getTableWidgett   setFocus(   t   selft   parentt   layoutt   lidarLayoutt   buttonBoxLayoutt   widget(    (    s   code\RamanRetrieverWidget.pyR   8   sn    		
				
	
c         C   s   |  j  ƒ  | j ƒ  d  S(   N(   t   saveSettingst   accept(   R<   t   event(    (    s   code\RamanRetrieverWidget.pyt
   closeEventŽ   s    
c         C   sV   t  d t  j ƒ } t j |  | ƒ |  j j | ƒ |  j j | ƒ |  j j | ƒ d  S(   Ns+   settings/interface/RamanRetrieverWidget.ini(   t	   QSettingst	   IniFormatR   t   saveWindowSettingsR   RB   R   R!   (   R<   t   settings(    (    s   code\RamanRetrieverWidget.pyRB   “   s    c         C   sV   t  d t  j ƒ } t j |  | ƒ |  j j | ƒ |  j j | ƒ |  j j | ƒ d  S(   Ns+   settings/interface/RamanRetrieverWidget.ini(   RF   RG   R   t   loadWindowSettingsR   R9   R   R!   (   R<   RI   (    (    s   code\RamanRetrieverWidget.pyR9   Ÿ   s    c         C   s9   |  j  j ƒ  } |  j j | ƒ t | ƒ d k r5 d Sd S(   sN   Populate lidar table with contents of the newly loaded lidar
        database.i    N(   R   t   getDataListR   t   connectDataListt   len(   R<   t   lidarDataList(    (    s   code\RamanRetrieverWidget.pyR   ¬   s    c         C   s%  |  j  j |  j j ƒ  d k ƒ |  j |  j |  j f } g  | D] } | j ƒ  ^ q> } t d „  | Dƒ ƒ r |  j j	 | ƒ |  j
 j t ƒ d S|  j j ƒ  } t | ƒ d k s· t ‚ d | d j } d | d j } |  j j d t j | d t ƒt j | d t ƒf ƒ |  j
 j t ƒ d S(	   sd   Update Retrieve button state and show the most relevant error
        message in 'self.statusLabel'.c         s   s   |  ] } | d  k	 Vq d  S(   N(   R   (   t   .0t   message(    (    s   code\RamanRetrieverWidget.pys	   <genexpr>Æ   s    Ni   s   %.0f nmi    i   sL   The data are ready for the retrieval (source channel: %s, Raman channel: %s)t	   addQuotes(   R.   t
   setEnabledR!   t   getStatusMessageR   R   R   t   anyR#   t   setMostSevereStatusMessageR,   t   Falset   getDataRM   t   AssertionErrort
   wavelengtht   setCompletedR   t   quotet   True(   R<   t
   widgetListRA   t   statusMessagest   lidarInputst	   sourceStrt   ramanStr(    (    s   code\RamanRetrieverWidget.pyR6   ¸   s"    	c         C   s    t  |  |  j ƒ } | j ƒ  d  S(   N(   t   RamanParamsDialogR   t   exec_(   R<   t   paramsDialog(    (    s   code\RamanRetrieverWidget.pyR)   Ú   s    c         C   s    t  |  |  j ƒ } | j ƒ  d  S(   N(   t   RamanPerturbanceParamsDialogR   Rc   (   R<   Rd   (    (    s   code\RamanRetrieverWidget.pyR+   ß   s    c         C   s†   |  j  j ƒ  d k s t ‚ |  j  j ƒ  } t | |  j ƒ } t r] t | |  j |  j	 ƒ } n  t
 |  | |  j j ƒ  ƒ } | j ƒ  d S(   s"   Launch the retrieval modal dialog.N(   R   RS   R   RX   RW   t   RamanRetrievalProcessR   R   t   RamanPerturbanceProcessR   t   RamanRetrievalDialogR!   t   getFilePathRc   (   R<   R_   t   retrievalProcesst   progressDialog(    (    s   code\RamanRetrieverWidget.pyR-   å   s    	c         C   s›   |  j  d k	 r@ y |  j  j ƒ  Wq@ t k
 r< d |  _  q@ Xn  |  j  d k rd t d t ƒ |  _  n  |  j  j |  j j ƒ  ƒ |  j  j	 ƒ  |  j  j
 ƒ  d S(   sÝ   Open the output database in the output viewer window, select the
        last database record and activate the window.

        If there is no output viewer window yet, or if the window has been
        closed, create it.t   skipDatabaseLoadingN(   R   R   t
   objectNamet   RuntimeErrort   OutputViewerWidgetR\   t   openLastDatabaseRecordR!   Ri   t   showt   activateWindow(   R<   (    (    s   code\RamanRetrieverWidget.pyR/   ø   s    	N(   t   __name__t
   __module__t   __doc__R   R   RE   RB   R9   R   R6   R)   R   R+   R-   R/   (    (    (    s   code\RamanRetrieverWidget.pyR   3   s   V					"		R    c           B   sG   e  Z d  Z d d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s¼   Widget responsible for selection and initialization of the output
    aerosol database in the the aerosol backscatter and lidar ratio retrieval
    algorithm utilizing Raman lidar signals.c         C   s§   t  j |  | ƒ t ƒ  } t d d d d ƒ |  _ |  j j d d ƒ |  j j j |  j ƒ |  j j	 j |  j
 ƒ | j |  j ƒ | j d d d d ƒ |  j | ƒ d  S(   Ns!   Raman retrieval &output database:s"   Microsoft Access databases (*.mdb)s&   Select Raman retrieval output databases5   Open an existing Raman retrieval output database files5   Select name for a new Raman retrieval output databases7   Create a new empty Raman retrieval output database filei    (   t   StatusSignalingWidgetR   R   t   FileSelectionWidgett   fileSelectort   showCreateButtont
   fileOpenedR   t   onFileOpenedt   fileCreatedt   onFileCreatedR   R   R2   (   R<   R=   R>   (    (    s   code\RamanRetrieverWidget.pyR     s    		c         C   s   |  j  j ƒ  S(   N(   Rx   Ri   (   R<   (    (    s   code\RamanRetrieverWidget.pyRi   .  s    c         C   s0   t  j | d ƒ  |  j j | d ƒ Wd  QXd  S(   NR    t   filePath(   R   t   SettingsGrouperRx   RB   (   R<   RI   (    (    s   code\RamanRetrieverWidget.pyRB   1  s    c         C   s0   t  j | d ƒ  |  j j | d ƒ Wd  QXd  S(   NR    R~   (   R   R   Rx   R9   (   R<   RI   (    (    s   code\RamanRetrieverWidget.pyR9   5  s    c         C   s…   |  j  j ƒ  } | d k r, |  j d ƒ d Sy! |  j d t ƒ t j | ƒ Wn' t j	 k
 rv } |  j | j
 ƒ d SX|  j ƒ  d S(   s?   Check format of an existing database file selected by the user.s0   Raman retrieval output database is not specifiedNs+   Checking Raman retrieval output database...(   Rx   Ri   R   t   setErrorMessaget   setProgressMessageR\   t   RamanOutputt   checkDataFormatR   t   Errort   textt   clearStatusMessage(   R<   R~   t   e(    (    s   code\RamanRetrieverWidget.pyR{   :  s    
c         C   su   |  j  j ƒ  } y! |  j d t ƒ t j | ƒ Wn4 t j k
 rf } |  j | j	 ƒ |  j  j
 ƒ  d SX|  j ƒ  d S(   sA   Create a new database file at the file path selected by the user.s+   Creating Raman retrieval output database...N(   Rx   Ri   R   R\   R‚   t   createDatabaseR   R„   R€   R…   t   invalidateFilePathR{   (   R<   R~   R‡   (    (    s   code\RamanRetrieverWidget.pyR}   O  s    
N(
   Rs   Rt   Ru   R   R   Ri   RB   R9   R{   R}   (    (    (    s   code\RamanRetrieverWidget.pyR      s   				Rh   c           B   s    e  Z d  Z d „  Z d „  Z RS(   s6   Graphical user interface for the optimization process.c         C   s   t  ƒ  S(   N(   t   RamanPlotWidget(   R<   (    (    s   code\RamanRetrieverWidget.pyt   createPlotWidgetf  s    c         C   s   d S(   Ns+   settings/interface/RamanRetrievalDialog.ini(    (   R<   (    (    s   code\RamanRetrieverWidget.pyt   getSettingsFilePathi  s    (   Rs   Rt   Ru   R‹   RŒ   (    (    (    s   code\RamanRetrieverWidget.pyRh   b  s   	N(   t   PyQt4.QtCoret   PyQt4.QtGuit   common.utilsR   R   R   t   common.FileSelectionWidgett   common.StatusLabelWidgett   common.StatusSignalingWidgetR   R   Ro   t   PlotWidgetsR‚   R   Rf   t   RetrievalProgressDialogRg   t   ImportErrorRV   R   R\   R   t   __all__R   R   Rv   R    Rh   (    (    (    s   code\RamanRetrieverWidget.pyt   <module>   s4   













	áN