³ò
{TKc           @   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 ULT fridge Kelvinox logs.
IMPORTANT: Logs prior to Run 20 are not supported - information on daylight saving shifts
needs to be programmed in to add support.
iÿÿÿÿNt   KelvinoxLogc           B   s€   e  Z d  Z e d „  ƒ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z e d	 „  ƒ Z e d d d
 „ ƒ Z RS(   s  
    Represents a ULT Kelvinox log over a certain time.
    Two logs can be concatenated with a '&' sign

    log format:
    1  [:,0]  Time (sec, since 00:00 1 January 1970 GMT)
    2  [:,1]  G1 [mbar]
    3  [:,2]  G2 [mbar]
    4  [:,3]  T_MixCh [mK]
    5  [:,4]  R_s [Ohm]
    6  [:,5]  R_cp [Ohm]
    7  [:,6]  R_mc [Ohm]
    8  [:,7]  T_s [K]
    9  [:,8]  T_cp [K]
    10 [:,9]  T_mc [K]
    c           C   s   d S(   s)   return number of columns in the self.datai
   (    (    (    (    s   c:\py\lib\kelvinoxlog.pyt
   fieldcount#   s    c         C   s   |  i  d d … d f S(   s	   G1 [mbar]Ni   (   t   data(   t   self(    (    s   c:\py\lib\kelvinoxlog.pyt   G1&   s    c         C   s   |  i  d d … d f S(   s	   G2 [mbar]Ni   (   R   (   R   (    (    s   c:\py\lib\kelvinoxlog.pyt   G2'   s    c         C   s   |  i  d d … d f S(   s   MixCh temperature [K]Ni   (   R   (   R   (    (    s   c:\py\lib\kelvinoxlog.pyt   T_MixCh(   s    c         C   s   |  i  d d … d f S(   s   Still temperature [K]Ni   (   R   (   R   (    (    s   c:\py\lib\kelvinoxlog.pyt   T_s)   s    c         C   s   |  i  d d … d f S(   s   Cold Plate temperature [K]Ni   (   R   (   R   (    (    s   c:\py\lib\kelvinoxlog.pyt   T_cp*   s    c         C   s   |  i  d d … d f S(   s   Mixing Chamber temperature [K]Ni	   (   R   (   R   (    (    s   c:\py\lib\kelvinoxlog.pyt   T_mc+   s    c         C   s   d |  i  ƒ  S(   Ns   KelvinoxLog %s(   t   datespan(   R   (    (    s   c:\py\lib\kelvinoxlog.pyt   __repr__-   s    c         C   s  t  i i |  ƒ } | d j oÖ | i ƒ  d j oÃ t i |  d d ƒ} t i | d d … d f ƒ | d d … d f <| d d … d f c d	 :<t i	 | d d … d
 d … f | d d … d
 d … f d j <t
 | d d … d d … f ƒ Sn| d j o	t i |  d d ƒ} t | d d !ƒ } t | d d !ƒ } t | d d !ƒ } | d  d j oF | d d … d f } | | d j c d 8<| | d d … d f <nÊ | d  d j | d  d j  @o  | d d … d f c d 8<n‹ | d  d j oy | d d … d f } t | ƒ d j oL t i t i | ƒ d j  ƒ d } | | c  d 8*| | d d … d f <qpn | d d … d f c t i d | | | f ƒ 7<| d d … d f c d	 :<t i	 | d d … d
 d … f | d d … d
 d … f d j <t
 | ƒ Sn d Sd S(   s  
        Load Kelvinox log from a given file
        The function determines file format from the date:
            1: modern format, since 21 December 2008
            2: old format, does not contain absolute time. winter/summer time changes are not handled correctly.
        t   20081221s)   20081221_kelvinoxmonitor-beforechange.datt   colsi   Ni   i    i   g     @@i   i	   i
   t   20080206i   i   i   t   20080330i<   t   20081026s   %02d/%02d/%04d 00:00:00 UTCi  i  i  i  (   t   ost   patht   basenamet   lowert   ascii2numpyt	   loadasciit   flibt
   labview2tmt   numpyt   NaNR    t   intt   lent   argwheret   difft   tmt   None(   t   filenameR   R   t   yeart   montht   dayt   tt   i(    (    s   c:\py\lib\kelvinoxlog.pyt   load/   s:     /?$ "2?c         C   s8   t  i d |  ƒ } t i | d | d | ƒi | | ƒ S(   sj   
        Return plm log for a given run, withing [start, end] period if boundaries are specified.
        s5   /data/archive/pc144/shared_data/KelvinoxMonitor/Run%dt   startt   end(   R   t   smbpathR    t   loaddirt   period(   t   runR(   R)   t   logdir(    (    s   c:\py\lib\kelvinoxlog.pyt   loadrun‰   s    N(   t   __name__t
   __module__t   __doc__t   staticmethodR   R   R   R   R   R   R	   R   R'   R    R/   (    (    (    s   c:\py\lib\kelvinoxlog.pyR       s   							Z(   R2   R   t   os.patht   timet   datetimeR   t   matplotlib.datest
   matplotlibR   t   timelogR   t   TimeLogR    (    (    (    s   c:\py\lib\kelvinoxlog.pys   <module>   s   