³ò
bÄGJc           @   s   d  Z  d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k	 Z	 d d k
 Z
 d e	 i f d „  ƒ  YZ d S(   sÿ   
Manipulating the Paroscientific pressure logs.

Log format:
[:,0] (1) Time (sec, since 1 January 1970)
[:,1] (2) T_p (usec)
[:,3] (3) T_t (usec)
[:,4] (4) T_p zero (usec),
[:,5] (5) T_t zero (usec)
[:,6] (6) P (mbar)
[:,7] (7) T (degC)

27 May 2008, Lev
iÿÿÿÿNt   ParoLogc           B   sõ   e  Z d  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z h  d	 d
 <d d <d d <Z h  d d
 <d d <d d <Z e d „  ƒ Z d „  Z e d d d „ ƒ Z e d d d „ ƒ Z e d d d „ ƒ Z RS(   s¼  
    Represents a ULT Paroscientific log over a certain time.
    Two logs can be concatenated with a '&' sign

    'self.device' is the gauge name, two logs must have the same gauge names in order to concatenate them.

    log format:

    [:,0] (1) Time (sec, since 1 January 1970)
    [:,1] (2) T_p (usec)
    [:,2] (3) T_t (usec)
    [:,3] (4) T_p zero (usec)
    [:,4] (5) T_t zero (usec)
    [:,5] (6) P (mbar)
    [:,6] (7) T (degC)
    c           C   s   d S(   s)   return number of columns in the self.datai   (    (    (    (    s   c:\py\lib\parolog.pyt
   fieldcount4   s    c         C   s   |  i  d d … d f S(   s   pressure [mbar]Ni   (   t   data(   t   self(    (    s   c:\py\lib\parolog.pyt   P7   s    c         C   s   |  i  d d … d f S(   s   temperature [degC]Ni   (   R   (   R   (    (    s   c:\py\lib\parolog.pyt   T8   s    c         C   s   |  i  d d … d f S(   s"   pressure period raw reading [usec]Ni   (   R   (   R   (    (    s   c:\py\lib\parolog.pyt   T_p9   s    c         C   s   |  i  d d … d f S(   s%   temperature period raw reading [usec]Ni   (   R   (   R   (    (    s   c:\py\lib\parolog.pyt   T_t:   s    c         C   s   |  i  d d … d f S(   s.   zero-offset pressure period raw reading [usec]Ni   (   R   (   R   (    (    s   c:\py\lib\parolog.pyt   T_p0;   s    c         C   s   |  i  d d … d f S(   s1   zero-offset temperature period raw reading [usec]Ni   (   R   (   R   (    (    s   c:\py\lib\parolog.pyt   T_t0<   s    c         C   s   d |  i  ƒ  |  i f S(   Ns!   Paroscientific Log %s, gauge='%s'(   t   datespant   device(   R   (    (    s   c:\py\lib\parolog.pyt   __repr__>   s    t   highPs   _Paro_high_P_sample.txtt   MCTs   _Paro_MCT.txtt   lowPs   _Paro_2D_sample.txtg      ð?g     @@c         C   s¸   t  i i |  ƒ } | d } t i i | ƒ p d Sn t i |  d t i	 ƒ  ƒ} t
 i | d d … d f ƒ | d d … d f <| d d … d f c t i | 9<t | t i | ƒ S(   s¸  
        Load a Paroscientific log from a given file
        A gauge is infered from the filename suffix. The following gauges are known:
        
            filename suffix            gauge name           pressure units
            
        "_Paro_high_P_sample.txt"       "highP"             mbar   
        "_Paro_MCT.txt"                 "MCT"               bar
        "_Paro_2D_sample.txt"           "lowP"              mbar
        i   t   colsNi    i   (   t   ost   patht   basenameR    t
   gaugeNamest   has_keyt   Nonet   ascii2numpyt	   loadasciiR   t   flibt
   labview2tmt   pressureFactors(   t   filenameR   t   suffixR   (    (    s   c:\py\lib\parolog.pyt   loadJ   s    
/#c         C   s?   |  i  ƒ  } t i | d d !| d  g ƒ } |  i | | j ƒ S(   s   
        return a subset of the log with only those entries, where T_t is
        the same as in the previous line. This is a nasty way to remove
        entries, when temperature was measured, rather than pressure.
        However if temperature is stable, no detection is made.
        i    i   iÿÿÿÿ(   R   t   numpyt   concatenatet   subset(   R   t   Ttt	   Tt_before(    (    s   c:\py\lib\parolog.pyt   only_Tt_repeatsj   s     c         C   s2   t  i t i d |  ƒ d | d | ƒi | | ƒ S(   sƒ   
        Return high pressure paroscientific log for a given run, withing [start, end] period if boundaries are specified.
        s.   //phpc338/Run%d/Paroscientific/highP-cell-parot   startt   end(   R    t   loaddirR   t   smbpatht   period(   t   runR%   R&   (    (    s   c:\py\lib\parolog.pyt	   loadHighPu   s    c         C   s2   t  i t i d |  ƒ d | d | ƒi | | ƒ S(   sy   
        Return MCT paroscientific log for a given run, withing [start, end] period if boundaries are specified.
        s'   //phpc338/Run%d/Paroscientific/MCT_paroR%   R&   (   R    R'   R   R(   R)   (   R*   R%   R&   (    (    s   c:\py\lib\parolog.pyt   loadMCT|   s    c         C   s2   t  i t i d |  ƒ d | d | ƒi | | ƒ S(   s‚   
        Return low pressure paroscientific log for a given run, withing [start, end] period if boundaries are specified.
        s1   //phpc338/Run%d/Paroscientific/low-field-NMR-paroR%   R&   (   R    R'   R   R(   R)   (   R*   R%   R&   (    (    s   c:\py\lib\parolog.pyt   loadLowPƒ   s    N(   t   __name__t
   __module__t   __doc__t   staticmethodR   R   R   R   R   R   R	   R   R   R   R   R$   R   R+   R,   R-   (    (    (    s   c:\py\lib\parolog.pyR    "   s2   											 	(   R0   R   t   os.patht   timet   datetimeR   t   matplotlib.datest
   matplotlibR   t   timelogR   t   TimeLogR    (    (    (    s   c:\py\lib\parolog.pys   <module>   s   
