3
$ßL]s  ã               @   s<   d Z ddlZddljZddljZdgZG dd„ dej	ƒZ
dS )z6EpochConverter module containing class EpochConverter.é    NÚEpochConverterc               @   s\   e Zd ZdZdZedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
edd„ ƒZdS )r   z‚: A matplotlib converter class.  Provides matplotlib conversion
          functionality for Monte Epoch and Duration classes.
    g   €QD:Aé   c             C   s"   t jƒ }t j|ƒ}tj||| d�S )ae  : Returns information on how to handle an axis that has Epoch data.

        = INPUT VARIABLES
        - unit     The units to use for a axis with Epoch data.

        = RETURN VALUE
        - Returns a matplotlib AxisInfo data structure that contains
          minor/major formatters, major/minor locators, and default
          label information.
        )ÚmajlocÚmajfmtÚlabel)Údate_tickerZAutoDateLocatorZAutoDateFormatterÚunitsZAxisInfo)ÚunitÚaxisr   r   © r   úS/tmp/pip-install-edjban26/matplotlib/matplotlib/testing/jpl_units/EpochConverter.pyÚaxisinfo   s    
zEpochConverter.axisinfoc             C   s0   ddl jj}| d |jddƒ }|j||tjƒS )a\  : Convert a matplotlib floating-point date into an Epoch of the
              specified units.

        = INPUT VARIABLES
        - value     The matplotlib floating-point date.
        - unit      The unit system to use for the Epoch.

        = RETURN VALUE
        - Returns the value converted to an Epoch in the specified time system.
        r   Ng     õ@g      ð?Úsec)Úmatplotlib.testing.jpl_unitsÚtestingÚ	jpl_unitsZUnitDblÚEpochr   ÚjdRef)Úvaluer	   ÚUZ
secPastRefr   r   r   Úfloat2epoch&   s    zEpochConverter.float2epochc             C   s   | j |ƒtj S )ae  : Convert an Epoch value to a float suitable for plotting as a
              python datetime object.

        = INPUT VARIABLES
        - value    An Epoch or list of Epochs that need to be converted.
        - unit     The units to use for an axis with Epoch data.

        = RETURN VALUE
        - Returns the value parameter converted to floats.
        )Z
julianDater   r   )r   r	   r   r   r   Úepoch2float8   s    zEpochConverter.epoch2floatc             C   s   | j ƒ d S )a+  : Convert a Duration value to a float suitable for plotting as a
              python datetime object.

        = INPUT VARIABLES
        - value    A Duration or list of Durations that need to be converted.

        = RETURN VALUE
        - Returns the value parameter converted to floats.
        g     õ@)Úseconds)r   r   r   r   Úduration2floatF   s    zEpochConverter.duration2floatc                s¼   ddl jj}d}d}tj| ƒrNt| tƒ rNt| ƒdkr:g S ‡ ‡fdd„| D ƒS t| |jƒr`d}nt| |j	ƒrpd}|rŠ| rŠt
jj| ƒrŠ| S ˆdkržtj| ˆ ƒ‰|r¬tj| ƒS tj| ˆƒS dS )ah  : Convert value using unit to a float.  If value is a sequence, return
        the converted sequence.

        = INPUT VARIABLES
        - value    The value or list of values that need to be converted.
        - unit     The units to use for an axis with Epoch data.

        = RETURN VALUE
        - Returns the value parameter converted to floats.
        r   NTFc                s   g | ]}t j|ˆˆ ƒ‘qS r   )r   Úconvert)Ú.0Úx)r
   r	   r   r   ú
<listcomp>i   s    z*EpochConverter.convert.<locals>.<listcomp>)r   r   r   ÚnpÚiterableÚ
isinstanceÚstrÚlenr   ZDurationr   ÚConversionInterfaceZ
is_numliker   Údefault_unitsr   r   )r   r	   r
   r   Z
isNotEpochZ
isDurationr   )r
   r	   r   r   S   s&    

zEpochConverter.convertc             C   s6   d}t j| ƒr*t| tƒ r*tj| d |ƒS | jƒ }|S )zß: Return the default unit for value, or None.

        = INPUT VARIABLES
        - value    The value or list of values that need units.

        = RETURN VALUE
        - Returns the default units to use for value.
        Nr   )r   r   r    r!   r   r$   Úframe)r   r
   r%   r   r   r   r$   |   s
    
zEpochConverter.default_unitsNg   €PD:A)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Ústaticmethodr   r   r   r   r   r$   r   r   r   r   r      s   ))r)   Znumpyr   Zmatplotlib.unitsr   Zmatplotlib.datesÚdatesr   Ú__all__r#   r   r   r   r   r   Ú<module>   s
   

