ó
ø`9Sc           @   s  d  Z  d d l Z d d l Z d d l Td d l Td d l Td d l m Z d 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 d d g Z e rá e d g 7Z n  e r÷ e d	 g 7Z n  d
 f  d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ e rd e f d „  ƒ  YZ n  e r d	 e f d „  ƒ  YZ n  e d ƒ d „ Z e d ƒ e d „ Z e d ƒ d „ Z e d ƒ d „ Z  e d „ Z! d „  Z" d „  Z# d „  Z$ d „  Z% d S(   sZ   Widgets for visual representation of data used in the aerosol profile
retrieval algorithm.iÿÿÿÿN(   t   *(   t
   emf_exportt   LidarPlotWidgett   DispersionPlotWidgett   LiricPlotWidgett   RamanPlotWidgett   PolarPlotWidgett   _PlotDisplayStylec           B   s_   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z RS(
   sµ  Common appearance settings, used in construction and population of plot
    widgets.

    To achieve best results both when the data are displayed on the screen and
    saved to image files, several consistent setting sets are provided,
    selected by the 'displayMode' attribute passed to constructor. Thus, to
    save a plot to a file, one has to create a separate instance of the plot
    widget, using an appropriate 'displayMode'.c         C   s   | d k s t  ‚ | |  _ d S(   sm  Parameters:
          - 'displayMode': purpose of the plot widget to retrieve the settings
            for. May be 'screen' for an ordinary plot widget, 'image' for a
            special widget instance used to save the data to a raster image
            file, or 'emf' for a special instance used to export the data to
            Windows enhanced metafile format.t   screent   imaget   emfN(   R   s   imageR
   (   t   AssertionErrort   displayMode(   t   selfR   (    (    s   code\PlotWidgets.pyt   __init__B   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s   code\PlotWidgets.pyt   getDisplayModeN   s    c         C   s*   |  j  d k r | j ƒ  St d d ƒ Sd S(   s$   Return 'QFont' used for axes labels.R   t   Ariali   N(   R   t   fontt   QFont(   R   t
   plotWidget(    (    s   code\PlotWidgets.pyt   getAxesFontQ   s    
c         C   s   |  j  | ƒ S(   s8   Return 'QFont' used for text messages printed on canvas.(   R   (   R   R   (    (    s   code\PlotWidgets.pyt   getTextFontZ   s    c         C   s*   |  j  d k r d S|  j  d k r& d Sd S(   sp   Return resolution of the image file, in pixels per inch.

        Not to be used with the 'screen' display mode.R	   iÈ   R
   i°  N(   R   (   R   (    (    s   code\PlotWidgets.pyt   getDpi^   s    c         C   s   d S(   s;   Return width of the pen to draw the axes scales, in pixels.i    (    (   R   (    (    s   code\PlotWidgets.pyt   getScalePenWidthm   s    c         C   sU   |  j  d k rM d } t | d |  j ƒ  ƒ } | t j ƒ  j ƒ  |  j ƒ  Sd Sd S(   s;   Return pen width for plots, axes and grid lines, in pixels.R
   g333333Ó?gffffff9@i    N(   R   t   roundR   t   QApplicationt   desktopt   logicalDpiX(   R   t
   penWidthMmt   deviceWidth(    (    s   code\PlotWidgets.pyt   getPenWidthv   s
    c         C   s   t  d d d ƒ S(   NiÅ   (   t   QColor(   R   (    (    s   code\PlotWidgets.pyt   getMajorGridColor†   s    c         C   s   t  d d d ƒ S(   Niç   (   R   (   R   (    (    s   code\PlotWidgets.pyt   getMinorGridColor‰   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   R   R   R   R    R!   (    (    (    s   code\PlotWidgets.pyR   8   s   										t   _QwtPlotForPrintingc           B   s   e  Z d  Z d „  Z RS(   sk   A variation of 'QwtPlot' for special plot widget instances used solely
    to save the data to image files.c         C   s0   | t  j t  j f k r d St j |  | ƒ Sd S(   s#   Redefinition of a virtual function.i`   N(   t   QPaintDevicet   PdmDpiXt   PdmDpiYt   QwtPlott   metric(   R   R*   (    (    s   code\PlotWidgets.pyR*   ’   s    (   R"   R#   R$   R*   (    (    (    s   code\PlotWidgets.pyR%      s   c           B   s/   e  Z d  Z d d „ Z d „  Z d d „ Z RS(   sC   Plot of a set of normalized lidar signals at different wavelengths.c         C   s_   t  j |  | ƒ t ƒ  } t |  ƒ |  _ | j |  j ƒ | j d d d d ƒ |  j | ƒ d  S(   Ni    (   t   QWidgetR   t   QHBoxLayoutt   createPlotWidgett   plott	   addWidgett   setContentsMarginst	   setLayout(   R   t   parentt   layout(    (    s   code\PlotWidgets.pyR   £   s    	c         C   s   |  j  j ƒ  |  j  j ƒ  d  S(   N(   R.   t   cleart   replot(   R   (    (    s   code\PlotWidgets.pyR4   ­   s    c            sk  |  j  j ƒ  t | ƒ d k r0 |  j  j ƒ  d SxI | D]A } t |  j  t j | j | j d ƒ | j	 t
 | j ƒ  ƒ ƒ q7 Wt |  j  d d t j ƒ | d k	 r½ t |  j  | d t j ƒ n  g  } d ‰ d } x` t t ˆ ƒ ƒ D]L ‰  t ‡  ‡ f d †  | Dƒ ƒ râ | j t | ˆ  t
 ˆ ˆ  ƒ ƒ ƒ qâ qâ Wt | ƒ d k sJt ‚ t |  j  | ƒ |  j  j ƒ  d S(   s  Parameters:
          - 'lidarInputs': a list of valid 'PreparedLidarInput' instances;
          - 'joinIndex': data grid index of the joint point between near and
            far signal zones or 'None' if the value is not known or if the
            signal has not been joined.i    Ni   g        t   355t   387Rt   532t   607Rt   1064t   532Cs   355 nms   387 nm Rs   532 nms   607 nm Rs   1064 nmu
   532 nm âŠ¥c         3   s%   |  ] } | j  ƒ  ˆ ˆ  k Vq d  S(   N(   t   getChannelId(   t   .0t   input(   t   it
   channelIds(    s   code\PlotWidgets.pys	   <genexpr>Ò   s   (   s   355s   387Rs   532s   607Rs   1064s   532C(   s   355 nms   387 nm Rs   532 nms   607 nm Rs   1064 nmu
   532 nm âŠ¥(   R.   R4   t   lenR5   t   addPlott   numpyt   aranget   firstInputIndext   lastInputIndext   normalizedSignalt   getPlotColorByChannelIdR<   t	   addMarkert   QwtPlotMarkert   Crosst   Nonet   VLinet   ranget   anyt   appendt   getLegendEntryStrR   t   addTextMessages(   R   t   lidarInputst	   joinIndext
   lidarInputt   textMessagest   channelLabels(    (   R?   R@   s   code\PlotWidgets.pyt   plotData±   s.     	"N(   R"   R#   R$   RL   R   R4   RX   (    (    (    s   code\PlotWidgets.pyR   Ÿ   s   
	c           B   s2   e  Z d  Z d d „ Z d „  Z d d d „ Z RS(   sB   Plot of a set of lidar dispersion arrays at different wavelengths.c         C   s_   t  j |  | ƒ t ƒ  } t |  ƒ |  _ | j |  j ƒ | j d d d d ƒ |  j | ƒ d  S(   Ni    (   R+   R   R,   R-   R.   R/   R0   R1   (   R   R2   R3   (    (    s   code\PlotWidgets.pyR   â   s    	c         C   s   |  j  j ƒ  |  j  j ƒ  d  S(   N(   R.   R4   R5   (   R   (    (    s   code\PlotWidgets.pyR4   ì   s    c         C   s¥  |  j  j ƒ  t | ƒ d k r0 |  j  j ƒ  d Sxt | D]l } | j j ƒ  } | d k	 rk d | | | k <n  t |  j  t j	 | j
 | j d ƒ | t | j ƒ  ƒ ƒ q7 W| d k	 rS|  j  j ƒ  |  j  j t j ƒ j ƒ  } |  j  j ƒ  xh | D]] } | j j ƒ  } | | | | k <t |  j  t j	 | j
 | j d ƒ | t | j ƒ  ƒ ƒ qï Wn  t |  j  d d t j ƒ | d k	 r”t |  j  | d t j ƒ n  |  j  j ƒ  d S(   sž  Parameters:
          - 'lidarInputs': a list of valid 'PreparedLidarInput' instances;
          - 'joinIndex': data grid index of the joint point between near and
            far signal zones or 'None' if the value is not known or if the
            signal has not been joined.
          - 'infiniteDispersion': dispersion value that has to be considered as
            an infinite one, and displayed accordingly.i    Ng        i   (   R.   R4   RA   R5   t   lidarDispersiont   copyRL   RB   RC   RD   RE   RF   RH   R<   t
   updateAxest   axisScaleDivR)   t   yLeftt
   upperBoundRI   RJ   RK   RM   (   R   RS   RT   t   infiniteDispersionRU   t   dispersionDataR^   (    (    s   code\PlotWidgets.pyRX   ð   s2    
N(   R"   R#   R$   RL   R   R4   RX   (    (    (    s   code\PlotWidgets.pyR   Þ   s
   
	c           B   s8   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z RS(   s:  A series of plots visually representing a 'LiricOutput' instance.

    This class may be used to save the data to an image file. In order to do
    so, create its separate instance, passing an appropriate 'displayMode' to
    constructor (see '_PlotDisplayStyle'), call 'plotData', and then call
    'saveAsImage'.R   c         C   sú  t  j |  | ƒ t | ƒ |  _ t ƒ  } t |  |  j ƒ |  _ | j |  j d d ƒ t |  |  j ƒ |  _ | j |  j d d ƒ t |  |  j ƒ |  _	 | j |  j	 d d ƒ t |  |  j ƒ |  _
 t d ƒ |  _ |  j j t j t j Bƒ |  j j t ƒ t ƒ  |  _ |  j j |  j ƒ |  j j |  j
 ƒ |  j j |  j ƒ | j |  j d d ƒ t |  |  j ƒ |  _ | j |  j d d d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d d d ƒ |  j | ƒ d  S(   Ni    i   s)   Polarimetric measurement is not availablei   (   R+   R   R   t   displayStylet   QGridLayoutR-   t   plot355R/   t   plot532t   plot1064t   plot532Ct   QLabelt   plot532CLabelt   setAlignmentt   Qtt   AlignHCentert   AlignBottomt   setWordWrapt   Truet   QStackedWidgett   plot532CStackt   setCurrentWidgett   concentrationPlott   setRowStretcht   setColumnStretchR0   R1   (   R   R   R2   R3   (    (    s   code\PlotWidgets.pyR   2  s8    	c         C   s™   |  j  j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j  j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j |  j	 ƒ d  S(   N(
   Rc   R4   Rd   Re   Rf   Rr   R5   Rp   Rq   Rh   (   R   (    (    s   code\PlotWidgets.pyR4   [  s    c      
   C   s–  |  j  j ƒ  d k r d } n | j d } xa| j ƒ  D]S} t |  d | ƒ } t | d | ƒ } t | d | ƒ } | j ƒ  t | d | ƒ } | d k r© d } n  t | t j	 | t
 | ƒ ƒ | | | t | ƒ |  j  ƒ t | t j	 t
 | ƒ ƒ | | t j |  j  ƒ t | d	 d	 t j |  j  ƒ | j d k	 r^t | | j d	 t j |  j  ƒ n  | j } d	 }	 d	 }
 x— | j ƒ  D]‰ } t | d
 | | ƒ } t | d | | d k r¼| n d ƒ } t | d | ƒ } |	 | | j ƒ  | 7}	 |
 | | j ƒ  | 7}
 q€W|	 |
 } | } | d k r2d } n  t | t d | ƒ t d d |	 ƒ t d d |
 ƒ t d d | ƒ g |  j  ƒ | j ƒ  q8 Wd | j ƒ  k rÑ|  j j ƒ  |  j j ƒ  |  j j |  j ƒ n |  j j |  j ƒ |  j j ƒ  g  } xâ | j ƒ  D]Ô } t | d | ƒ } t |  j | t j	 t
 | ƒ ƒ | t | ƒ |  j  ƒ t | d | ƒ } | d k	 r¶t |  j | | t j	 t
 | ƒ ƒ | t | ƒ |  j  d t j ƒn  | j t  | j! ƒ  t | ƒ ƒ ƒ qWt" | j# | j$ d d ƒ } | j t d d | j# | ƒ ƒ t" | j% | j& d d ƒ } | j t d d | j% | ƒ ƒ | j' d k	 r®| j( d k	 r®t" | j( | j' d d ƒ } | j t d d | j( | ƒ ƒ n  | j) d k	 r
| j* d k	 r
t" | j* | j) d d ƒ } | j t d d | j* | ƒ ƒ n  t |  j d	 d	 t j |  j  ƒ | j d k	 r]t |  j | j d	 t j |  j  ƒ n  t
 | ƒ d k sut+ ‚ t |  j | ƒ |  j j ƒ  d S(    sF   Parameters:
          - 'liricOutput': a valid 'LiricOutput' instance.R   g      ð?gü©ñÒMbP?R.   t   measuredSignalt   calculatedSignalRE   i    g        t   bt   aR;   R8   t   profileu   532,âŠ¥u   Î»t   AOTs   %.3ft   Bints   %.2et   Ps   %.1ft   profileDispersiont   penStylegš™™™™™©?gš™™™™™¹?s   V-Fs   V-Cs   V-Css   V-CnsN(,   Ra   R   t   gridHeightStept   lidarChannelIdst   getattrR4   RL   RB   RC   RD   RA   RH   Rj   t   blackRI   RJ   RK   RT   RM   t   aerosolModeSuffixest   sumRR   t   getNameValueStrR5   Rf   Rp   Rq   Rh   Rr   t   getPlotColorByModeSuffixt   DashLineRP   RQ   t   lowert   getValueColort   calculatedVFinet   vFinet   calculatedVCoarset   vCoarset
   vSphericalt   calculatedVSphericalt	   vSpheroidt   calculatedVSpheroidR   (   R   t   liricOutputt   heightConversiont	   channelIdR   Ru   Rv   t
   firstIndext
   heightStept   aott   bIntt
   modeSuffixt   backscattert   attenuationRy   t
   lidarRatiot   wavelengthStrRV   R}   t
   vFineColort   vCoarseColort   vSphericalColort   vSpheroidColor(    (    s   code\PlotWidgets.pyRX   j  sÀ    	
	
	

				
	
c         C   sf  d } d } d } d } |  j  j ƒ  d k rí t t | d |  j  j ƒ  ƒ ƒ } t t | d |  j  j ƒ  ƒ ƒ } t t | | ƒ t j ƒ } t t | | d ƒ ƒ }	 | j |	 ƒ | j	 |	 ƒ t
 | ƒ }
 |
 j d d | | t j ƒ ne |  j  j ƒ  d k rRt j | d | d d	 |  j  j ƒ  ƒ} | j ƒ  } | j ƒ  } t
 | ƒ }
 n  t t | | | ƒ ƒ } t t | | | ƒ ƒ } | d
 | | } | d | | } t | | | | ƒ } t | | d d | | | ƒ } t | d
 | | | | ƒ } t | d
 | | d d | | | ƒ } t | d d d
 | | | | | d ƒ } t ƒ  } t j } | t j O} | j | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |  j j ƒ  |  j k rò|  j j |
 | | ƒ n  |  j j |
 | | ƒ |
 j ƒ  |  j  j ƒ  d k r7| j  | ƒ n+ |  j  j ƒ  d k rb| j! ƒ  j" | ƒ n  d S(   s6   Save the plots to an image file at the specified path.g      e@g      U@g      ð?R	   gffffff9@g     @@i    R
   t   dpii   i   i   N(#   Ra   R   t   intR   R   t   QImaget   QSizet   Format_RGB32t   setDotsPerMeterXt   setDotsPerMeterYt   QPaintert   fillRectRj   t   whiteR   t   EMFPaintDevicet   widtht   heightt   QRectt   QwtPlotPrintFiltert   PrintAllt   PrintFrameWithScalest
   setOptionsRc   t   print_Rd   Re   Rp   t   currentWidgetRf   Rr   t   endt   savet   paintEnginet   saveFile(   R   t   imageFilePatht   imageWidthMmt   imageHeightMmt   outerPlotMarginMmt   innerPlotMarginMmt
   imageWidtht   imageHeightR	   t   imageDotsPerMetert   paintert   emfPaintDevicet   outerPlotMargint   innerPlotMargint	   plotWidtht
   plotHeightt   rect355t   rect1064t   rect532t   rect532Ct   concentrationRectt   printFiltert   printOptions(    (    s   code\PlotWidgets.pyt   saveAsImage  sx    		
N(   R"   R#   R$   RL   R   R4   RX   RÏ   (    (    (    s   code\PlotWidgets.pyR   )  s
   )		œc           B   s8   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z RS(   sA   A series of plots visually representing a 'RamanOutput' instance.R   c         C   s˜  t  j |  | ƒ t | ƒ |  _ t ƒ  } t |  |  j ƒ |  _ | j |  j d d ƒ t |  |  j ƒ |  _ | j |  j d d ƒ t |  |  j ƒ |  _	 | j |  j	 d d d d ƒ t |  |  j ƒ |  _
 | j |  j
 d d d d ƒ t |  |  j ƒ |  _ | j |  j d d d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d d d ƒ |  j | ƒ d  S(   Ni    i   i   i   (   R+   R   R   Ra   Rb   R-   t
   plotSourceR/   t	   plotRamant   plotBackscattert   plotExtinctiont	   plotLidarRs   Rt   R0   R1   (   R   R   R2   R3   (    (    s   code\PlotWidgets.pyR   o  s*    	c         C   s†   |  j  j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j  j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  d  S(   N(   RÐ   R4   RÑ   RÒ   RÓ   RÔ   R5   (   R   (    (    s   code\PlotWidgets.pyR4     s    c         C   sX  |  j  j ƒ  d k r d } n | j d } xed d g D]W} t |  d | ƒ } t | d | ƒ } t | d | ƒ } t | d	 | ƒ } | j ƒ  d
 t | d | ƒ } | d k rÄ | d 7} n  t | t j | t | ƒ ƒ | | | t	 | ƒ |  j  ƒ t | t j | t | ƒ ƒ | | | t
 j |  j  ƒ t | d d t j |  j  ƒ d
 t | d | ƒ }	 t | t d |	 ƒ g |  j  ƒ | j ƒ  q8 W|  j j ƒ  |  j j ƒ  |  j j ƒ  t | j | j ƒ }
 t d d d ƒ } t |  j | j |
 t j |
 t | j ƒ ƒ | | |  j  ƒ | j } | d k	 r‚t |  j | j |
 | |
 t j |
 t | j ƒ ƒ | | |  j  d t
 j ƒn  t |  j d d t j |  j  ƒ t |  j t d | ƒ g ƒ |  j j ƒ  t |  j | j |
 | j |
 t j |
 t | j ƒ ƒ | | |  j  ƒ t |  j d d t j |  j  ƒ t |  j t d | ƒ g ƒ |  j j ƒ  t d d d ƒ } t |  j | j |
 t j |
 t | j ƒ ƒ | | |  j  ƒ | j } | d k	 rt |  j | j |
 | |
 t j |
 t | j ƒ ƒ | | |  j  d t
 j ƒn  t |  j d d t j |  j  ƒ t |  j t d | ƒ g ƒ |  j j ƒ  d S(   sJ   Parameters:
              - 'ramanOutput': a valid 'RamanOutput' instance.R   g      ð?gü©ñÒMbP?t   Sourcet   RamanR.   Ru   Rv   RE   s   %.0ft
   wavelengtht   Rg        u   Î»i    iÿ   R~   s   backscatter ratio minus 1t
   extinctioni„   s   lidar ratioN(    Ra   R   R   R   R4   RB   RC   RD   RA   RH   Rj   R‚   RI   RJ   RK   RR   R…   R5   RÒ   RÓ   RÔ   t   mint   firstInputIndexSourcet   firstInputIndexRamanR   t   profileBackscattert   profileDispersionBackscatterRL   R‡   RQ   t   profileLidart   profileDispersionLidar(   R   t   ramanOutputR“   R”   R   Ru   Rv   RE   t   wavelengthIdR   t   firstOutputIndext   backscatterColort   backscatterDispersiont
   lidarColorRY   (    (    s   code\PlotWidgets.pyRX   œ  s°    	
	
	
		
			
	
	
	
	
			
	
c         C   s[  d } d } d } d } |  j  j ƒ  d k rí t t | d |  j  j ƒ  ƒ ƒ } t t | d |  j  j ƒ  ƒ ƒ } t t | | ƒ t j ƒ } t t | | d ƒ ƒ }	 | j |	 ƒ | j	 |	 ƒ t
 | ƒ }
 |
 j d d | | t j ƒ ne |  j  j ƒ  d k rRt j | d | d d	 |  j  j ƒ  ƒ} | j ƒ  } | j ƒ  } t
 | ƒ }
 n  t t | | | ƒ ƒ } t t | | | ƒ ƒ } | d
 | | } | d | | } t | | | | ƒ } t | | d d | | | ƒ } t | d d
 | | | | | d ƒ } t | d d d
 | | | | | d ƒ } t | d d d
 | | | | | d ƒ } t ƒ  } t j } | t j O} | j | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |
 j ƒ  |  j  j ƒ  d k r,| j | ƒ n+ |  j  j ƒ  d k rW| j ƒ  j  | ƒ n  d S(   s6   Save the plots to an image file at the specified path.g      l@g      U@g      ð?R	   gffffff9@g     @@i    R
   R¢   i   i   i   i   N(!   Ra   R   R£   R   R   R¤   R¥   R¦   R§   R¨   R©   Rª   Rj   R«   R   R¬   R­   R®   R¯   R°   R±   R²   R³   RÐ   R´   RÑ   RÒ   RÓ   RÔ   R¶   R·   R¸   R¹   (   R   Rº   R»   R¼   R½   R¾   R¿   RÀ   R	   RÁ   RÂ   RÃ   RÄ   RÅ   RÆ   RÇ   t
   rectSourcet	   rectRamant   rectBackscattert   rectExtinctiont	   rectLidarRÍ   RÎ   (    (    s   code\PlotWidgets.pyRÏ   !  st    		
N(   R"   R#   R$   RL   R   R4   RX   RÏ   (    (    (    s   code\PlotWidgets.pyR   k  s
    		…c           B   s8   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z RS(   sA   A series of plots visually representing a 'PolarOutput' instance.R   c         C   s¡  t  j |  | ƒ t | ƒ |  _ t ƒ  } t |  |  j ƒ |  _ | j |  j d d ƒ t |  |  j ƒ |  _ | j |  j d d ƒ t |  |  j ƒ |  _	 | j |  j	 d d ƒ t |  |  j ƒ |  _
 | j |  j
 d d ƒ t |  |  j ƒ |  _ | j |  j d d ƒ t |  |  j ƒ |  _ | j |  j d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d ƒ | j d d d d ƒ |  j | ƒ d  S(   Ni    i   i   (   R+   R   R   Ra   Rb   R-   t   plotBaseR/   t	   plotCrosst   plotBsParallelt   plotBsCrosst   plotBsTotalt   plotDepolarRs   Rt   R0   R1   (   R   R   R2   R3   (    (    s   code\PlotWidgets.pyR   ‹  s,    	c         C   s    |  j  j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j  j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  d  S(   N(   Rì   R4   Rí   Rî   Rï   Rð   Rñ   R5   (   R   (    (    s   code\PlotWidgets.pyR4   ­  s    c         C   s³  |  j  j ƒ  d k r d } n | j d } x—d d g D]‰} t |  d | ƒ } t | d | ƒ } t | d | ƒ } t | d	 | ƒ } | j ƒ  t | t j | t | ƒ ƒ | | | t	 d
 ƒ |  j  ƒ t | t j | t | ƒ ƒ | | | t
 j |  j  ƒ t | d d t j |  j  ƒ | d k r4d
 } n d } t d | ƒ g }	 | d k rx|	 j t d d | j ƒ ƒ n  | d k r¤|	 j t d d | j ƒ ƒ n  t | |	 |  j  ƒ | j ƒ  q8 W|  j j ƒ  |  j j ƒ  |  j j ƒ  |  j j ƒ  t | j | j ƒ }
 t |  j t j |
 t | j ƒ ƒ | | j |
 t	 d
 ƒ |  j  ƒ | j } | d k	 r»t |  j t j |
 t | j ƒ ƒ | | j |
 | |
 t	 d
 ƒ |  j  d t
 j ƒn  t |  j d d t j |  j  ƒ t |  j t  d t	 d
 ƒ ƒ g ƒ |  j j ƒ  t |  j t j |
 t | j! ƒ ƒ | | j! |
 t	 d ƒ |  j  ƒ t |  j d d t j |  j  ƒ t |  j t  d t	 d ƒ ƒ g ƒ |  j j ƒ  | j |
 | j! |
 } t |  j t j |
 t | j ƒ ƒ | | t" d d d ƒ |  j  ƒ t |  j d d t j |  j  ƒ | j } | j# ƒ  | d |
 | } | | j$ } t |  j t  d t" d d d ƒ ƒ t d d | ƒ t d d | ƒ g ƒ |  j j ƒ  | j! |
 | j |
 } t |  j t j |
 t | j ƒ ƒ | | t" d d d ƒ |  j  ƒ | j% } | d k	 r[t |  j t j |
 t | j ƒ ƒ | | | |
 t" d d d ƒ |  j  d t
 j ƒn  t |  j d d t j |  j  ƒ t |  j t  d t" d d d ƒ ƒ g ƒ |  j j ƒ  d S(   sJ   Parameters:
              - 'polarOutput': a valid 'PolarOutput' instance.R   g      ð?gü©ñÒMbP?t   BaseRK   R.   Ru   Rv   RE   R8   g        u   532 âŠ¥u   Î»RØ   s   %.1et   QR~   s   parallel backscatterR;   s   cross backscatteri    iÿ   s   total backscatterRz   s   %.3fR{   s   %.2et   depolarizationN(&   Ra   R   R   R   R4   RB   RC   RD   RA   RH   Rj   R‚   RI   RJ   RK   R…   RP   t   aerBackscatterRatioReft   lidarCorrectionRR   R5   Rî   Rï   Rð   Rñ   RÚ   t   firstInputIndexBaset   firstInputIndexCrosst   backscatterParallelt   backscatterDispersionParallelRL   R‡   RQ   t   backscatterCrossR   R„   Rœ   t   depolarizationDispersion(   R   t   polarOutputR“   R”   R   Ru   Rv   RE   R   RV   Rã   Rå   t   totalBackscatterR–   R˜   R—   Rô   Rü   (    (    s   code\PlotWidgets.pyRX   ¼  sÜ    	

				
			

		


		
		
					
c         C   s’  d } d } d } d } |  j  j ƒ  d k rí t t | d |  j  j ƒ  ƒ ƒ } t t | d |  j  j ƒ  ƒ ƒ } t t | | ƒ t j ƒ } t t | | d ƒ ƒ }	 | j |	 ƒ | j	 |	 ƒ t
 | ƒ }
 |
 j d d | | t j ƒ ne |  j  j ƒ  d k rRt j | d | d d	 |  j  j ƒ  ƒ} | j ƒ  } | j ƒ  } t
 | ƒ }
 n  t t | | | ƒ ƒ } t t | | | ƒ ƒ } | d
 | | } | d | | } t | | | | ƒ } t | | d d | | | ƒ } t | d d
 | | | | ƒ } t | d d
 | | d d | | | ƒ } t | d d d
 | | | | ƒ } t | d d d
 | | d d | | | ƒ } t ƒ  } t j } | t j O} | j | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |  j j |
 | | ƒ |
 j ƒ  |  j  j ƒ  d k rc| j | ƒ n+ |  j  j ƒ  d k rŽ| j  ƒ  j! | ƒ n  d S(   s6   Save the plots to an image file at the specified path.g      e@g      U@g      ð?R	   gffffff9@g     @@i    R
   R¢   i   i   i   i   N("   Ra   R   R£   R   R   R¤   R¥   R¦   R§   R¨   R©   Rª   Rj   R«   R   R¬   R­   R®   R¯   R°   R±   R²   R³   Rì   R´   Rí   Rî   Rï   Rð   Rñ   R¶   R·   R¸   R¹   (   R   Rº   R»   R¼   R½   R¾   R¿   RÀ   R	   RÁ   RÂ   RÃ   RÄ   RÅ   RÆ   RÇ   t   rectBaset	   rectCrosst   rectBsParallelt   rectBsCrosst   rectBsTotalt   rectDepolarRÍ   RÎ   (    (    s   code\PlotWidgets.pyRÏ   g  s€    		
N(   R"   R#   R$   RL   R   R4   RX   RÏ   (    (    (    s   code\PlotWidgets.pyR   ‡  s
   "		«R   c   	      C   sS  | j  d k r t |  ƒ } n t |  ƒ } | j | ƒ } | j t j ƒ | j t j | ƒ | j t j	 | ƒ | j
 ƒ  } | j ƒ  } | j t j	 ƒ j | ƒ | j t j ƒ j | ƒ t ƒ  } t t | j ƒ  ƒ | ƒ } t t | j ƒ  ƒ | ƒ } | j | ƒ | j | ƒ | j t ƒ | j t ƒ | j | ƒ | j t j t j ƒ | S(   sc   Create a 'QwtPlot' with the specified parent widget and apply common
    appearance settings to it.R   (   R   R)   R%   R   t   setCanvasBackgroundRj   R«   t   setAxisFontt   xBottomR]   R   R   t
   axisWidgett   setPenWidtht   QwtPlotGridt   QPent   QBrushR    R!   t	   setMajPent	   setMinPent
   enableXMinRn   t
   enableYMint   attacht   setSizePolicyt   QSizePolicyt   Ignored(	   R2   Ra   R   t   axesFontt   penWidtht   scalePenWidtht   plotGridt   majorGridPent   minorGridPen(    (    s   code\PlotWidgets.pyR-   Ò  s*    	c         C   sn   t  ƒ  } t t | ƒ | j ƒ  ƒ } | d k	 r@ | j | ƒ n  | j | ƒ | j | | ƒ | j |  ƒ d S(   s]   Attach a polyline with the given coordinates and color to an existing
    'QwtPlot' instance.N(	   t   QwtPlotCurveR  R  R   RL   t   setStylet   setPent   setDataR  (   R   t   xArrayt   yArrayt	   plotColorRa   R~   t   curvet   pen(    (    s   code\PlotWidgets.pyRB   ÷  s    	c         C   s\   t  ƒ  } | j | | ƒ | j | ƒ | j t t t j ƒ | j ƒ  ƒ ƒ | j	 |  ƒ d S(   s©   Add a horizontal or vertical line or both, depending on 'lineStyle',
    to an existing 'QwtPlot' instance.

    'lineStyle' has to be one of 'QwtPlotMarker.LineStyle's.N(
   RJ   t   setValuet   setLineStylet
   setLinePenR  R  Rj   R‚   R   R  (   R   t   xt   yt	   lineStyleRa   t   marker(    (    s   code\PlotWidgets.pyRI     s
    	%c         C   s  d d j  | ƒ d } t | t j ƒ } | j t t j ƒ ƒ | j t t | j	 ƒ  ƒ | j
 ƒ  ƒ ƒ | j | j |  ƒ ƒ |  j ƒ  |  j t j ƒ j ƒ  } |  j t j ƒ j ƒ  } t ƒ  } | j | | ƒ | j | ƒ | j t j ƒ | j t j t j Bƒ | j |  ƒ d S(   sÄ   Add a marker displaying a set of rich text messages defined by 'strList'
    to the top right corner of the plot's canvas.

    Warning: all the plots have to be added prior to this function call.s   <p align="left">&nbsp;s   &nbsp;<br>&nbsp;s
   &nbsp;</p>N(   t   joint   QwtTextt   RichTextt   setBackgroundBrushR  Rj   R«   t   setBackgroundPenR  R!   R   t   setFontR   R[   R\   R)   R  R^   R]   RJ   R$  t   setLabelR%  t   NoLinet   setLabelAlignmentRl   t	   AlignLeftR  (   R   t   strListRa   t
   textStringt   textt
   rightBoundt   topBoundR*  (    (    s   code\PlotWidgets.pyRR     s     
	c         C   s»   | d k	 r¯ d | j ƒ  k o) d k n s4 t ‚ d | j ƒ  k oQ d k n s\ t ‚ d | j ƒ  k oy d k n s„ t ‚ d | j ƒ  | j ƒ  | j ƒ  | f } n  |  d | S(   s‰   Construct a rich text string representing a name-value pair with value
    marked with the specified color (a 'QColor' instance), if any.i    iÿ   s%   <font color="#%02x%02x%02x">%s</font>s    = N(   RL   t   redR   t   greent   blue(   t   nameStrt   valueStrt
   valueColor(    (    s   code\PlotWidgets.pyR…   9  s    ((((c         C   s†   d } t d d d ƒ } t d d d ƒ } | d k rJ |  | k rF | S| St | |  | ƒ } | | k rn | S| | k r~ | S| Sd S(   s¥  Return a 'QColor' instance for the value part of a name-value pair
    string depending on difference between 'value' and 'referenceValue'.

    The returned color is 'None' if absolute value of relative residual between
    'value' and 'relativeValue' is smaller than or equal to 'fitThreshold'. If
    the residual is smaller than or equal to 'semiFitThreshold', the returned
    color is dark red; otherwise it is red.i˜   i    iÿ   g        N(   RL   R   t   abs(   t   valuet   referenceValuet   fitThresholdt   semiFitThresholdt   fitColort   semiFitColort   nonFitColort   residual(    (    s   code\PlotWidgets.pyR‰   G  s    	c         C   sž   d | j  ƒ  k o d k n s( t ‚ d | j ƒ  k oE d k n sP t ‚ d | j ƒ  k om d k n sx t ‚ d | j  ƒ  | j ƒ  | j ƒ  |  f S(   s}   Construct a rich text string visually resempling a legend entry for a
    line plot of the given color (a 'QColor' instance).i    iÿ   sE   <font color="#%02x%02x%02x"><s>&nbsp;&nbsp;&nbsp;&nbsp;</s></font> %s(   R:  R   R;  R<  (   t	   textLabelt	   lineColor(    (    s   code\PlotWidgets.pyRQ   a  s
    (((c         C   s¬   |  d k r t  d d d ƒ S|  d k r8 t  d d d ƒ S|  d k rT t  d d	 d ƒ S|  d
 k rp t  d d d ƒ S|  d k rŒ t  d d d ƒ S|  d k r¨ t  d d d ƒ Sd S(   sB   Return a common color for data related to the given lidar channel.R6   iØ   i    i÷   R7   ij   iÕ   R8   iè   R9   i¦   i½   R:   iÿ   R;   i„   N(   R   (   R”   (    (    s   code\PlotWidgets.pyRH   n  s    c         C   st   |  d k r t  d d d ƒ S|  d k r8 t  d d d ƒ S|  d k rT t  d d d ƒ S|  d k rp t  d d d ƒ Sd S(	   sA   Return a common color for data related to the given aerosol mode.t   Finei    iÿ   t	   Sphericalt   Spheroidi„   t   CoarseN(   R   (   R™   (    (    s   code\PlotWidgets.pyR†   ~  s    (&   R$   RC   t   os.patht   ost   PyQt4.QtCoret   PyQt4.QtGuit
   PyQt4.Qwt5t   common.utils.third_partyR   t   LiricOutputt   PreparedLidarInputt   RamanOutputt   ImportErrort   Falset   ramanOutputPluginLoadedRn   t   PolarOutputt   polarOutputPluginLoadedt   __all__R   R)   R%   R+   R   R   R   R   R   R-   RL   RB   RI   RR   R…   R‰   RQ   RH   R†   (    (    (    s   code\PlotWidgets.pyt   <module>   sX   






U?Kÿ Bÿ ÿ L&$			