o
    Ae2                     @   s   d dl Zd dlZd dlmZ dd Zdd Zdd Z	
	d'ddZd(ddZ	d(ddZ
G dd dZG dd deZG dd deZG dd deZG dd deZG dd deZG dd  d eZG d!d" d"ZG d#d$ d$eZG d%d& d&eZdS ))    N)ExtremeFinderSimplec                 C      g d}g d}dgt | }g d}g d}t|d }dgt | }t|d }d	gt | }	g |||}
g |||}g |	||}t|
| }|| }|| }||fS )
N)
      ?            (   F   x   i  i  )
         
         -   Z      ih        ?)r         @      @            r   )r   r   r   r   r   r   r   r   <         N@        @lennparrayZsearchsorted)dvZdegree_limits_Zdegree_steps_Zdegree_factorsminsec_limits_minsec_steps_minute_limits_minute_factorssecond_limits_second_factorsZdegree_limitsZdegree_stepsnstepfactor r.   e/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/mpl_toolkits/axisartist/angle_helper.pyselect_step_degree       r0   c                 C   r   )
N)	r   r   r   r   r   r   r      $   )	r   r   r         r      r      r   )r   r   r   g      @g      @r   r      r   r   r   )r   r   r   r4   r   r5   r   r6   r   r   r   r   r   r   r   r    )r$   Zhour_limits_Zhour_steps_Zhour_factorsr%   r&   r'   r(   r)   r*   Zhour_limitsZ
hour_stepsr+   r,   r-   r.   r.   r/   select_step_hour!   r1   r9   c                 C   sz   dt t| d  }d| }d| | krd}||fS d| | kr'd}||fS d| | kr3d}||fS d}d	| }||fS )
Ng      $@r   r   r   g      @r   g      @r   g?)intmathlog10)r$   tmpr-   r,   r.   r.   r/   select_step_sub;   s   	r>   FTr   c                 C   s   | |kr	|| } }||  | }|rt }d}nt}d}|d| kr'||\}	}
nt|| \}	}
|
| }
tjt| |
 |	 t||
 |	 d td|	 }t|}|
dkr|d |d | krt||	 }|rw|d td|d d|	  }n|d td|d|	  }t|}t	|||
fS )	Ng      8@     v@r   g      ?)Zdtyper   r   )
r9   r0   r>   r"   Zarangefloorceilr:   r!   r#   )v1v2nvhourinclude_lastthreshold_factorr$   Z_select_stepcycler,   r-   levsr+   r.   r.   r/   select_stepO   s4   
	 rK   r   c                 C   s:   | d |d } }t | ||d||d\}}}|d ||fS )Nr   TrF   rG   rH   rK   )rC   rD   rE   rG   rH   rJ   r+   r-   r.   r.   r/   select_step24   s   
rN   c                 C   s   t | ||d||dS )NFrL   rM   )rC   rD   rE   rG   rH   r.   r.   r/   select_step360   s   
rO   c                   @   s    e Zd ZdddZdddZdS )	LocatorBaseTc                 C   s   || _ || _d S N)nbins_include_last)selfrR   rG   r.   r.   r/   __init__   s   
zLocatorBase.__init__Nc                 C   s   |d urt || _d S d S rQ   )r:   rR   )rT   rR   r.   r.   r/   
set_params   s   zLocatorBase.set_params)TrQ   )__name__
__module____qualname__rU   rV   r.   r.   r.   r/   rP      s    
rP   c                   @      e Zd Zdd ZdS )
LocatorHMSc                 C      t ||| j| jS rQ   rN   rR   rS   rT   rC   rD   r.   r.   r/   __call__      zLocatorHMS.__call__NrW   rX   rY   r_   r.   r.   r.   r/   r[          r[   c                   @   rZ   )	LocatorHMc                 C      t ||| j| jddS Nr   rH   r]   r^   r.   r.   r/   r_         zLocatorHM.__call__Nra   r.   r.   r.   r/   rc      rb   rc   c                   @   rZ   )LocatorHc                 C   rd   Nr   rf   r]   r^   r.   r.   r/   r_      rg   zLocatorH.__call__Nra   r.   r.   r.   r/   rh      rb   rh   c                   @   rZ   )
LocatorDMSc                 C   r\   rQ   rO   rR   rS   r^   r.   r.   r/   r_      r`   zLocatorDMS.__call__Nra   r.   r.   r.   r/   rj      rb   rj   c                   @   rZ   )	LocatorDMc                 C   rd   re   rk   r^   r.   r.   r/   r_      rg   zLocatorDM.__call__Nra   r.   r.   r.   r/   rl      rb   rl   c                   @   rZ   )LocatorDc                 C   rd   ri   rk   r^   r.   r.   r/   r_      rg   zLocatorD.__call__Nra   r.   r.   r.   r/   rm      rb   rm   c                   @   s   e Zd ZdZdZdZde d Zde d Zde d e d Zde d	 e d Z	de d e d
 Z
de d Zde d Zdd Zdd ZdS )FormatterDMSz^{\circ}z	^{\prime}z^{\prime\prime}$%d$$%d.%s$%s%d\,%02d	\,%02d.%s\,%02d%02d.%sc                 C   st   d }dD ]1}||kr ||fS || }t tt|}d| |kr5|dkr5|}|d|  }||f  S q||fS )N)r   r   r   r   r   )r:   r"   rA   r<   )rT   r-   number_fraction	thresholddZ	int_log_dr.   r.   r/   _get_number_fraction   s   	z!FormatterDMS._get_number_fractionc                    s"  t |dkrg S t|}dd |D }|\}}t|}|d ur;t|d| \}}d|f   fdd|D }|dkr\|d u rOfddt||D S fd	dt|||D S |d
krt|d
\}	}
|d u rxfddt||	|
D S fddt||	|
|D S |dkr|d dkrd}|d d d }|d d d }nd}d}g }t|d\}	}t|d
\}
}|d u rćfdd|D }nfddt||D }t||	|
|D ]$\}}}}j|||f }||kr|}|| }nd| | }|| q|r|d d d S |S dd || D S )Nr   c                 S   s   g | ]
}|d k r
dndqS )r   - r.   .0vr.   r.   r/   
<listcomp>   s    z)FormatterDMS.__call__.<locals>.<listcomp>r   z%%0%ddc                    s   g | ]} |f qS r.   r.   )r   f1)frac_fmtr.   r/   r      s    r   c                    s$   g | ]\}} j |t| f qS r.   )fmt_dr:   )r   sr   rT   r.   r/   r      s   $ c                    s(   g | ]\}}} j |t| |f qS r.   )fmt_dsr:   )r   r   r   r   r   r.   r/   r      s    r   c                    s"   g | ]\}}} j |||f qS r.   )fmt_d_m)r   s1d1m1r   r.   r/   r      s    c                    s&   g | ]\}}}} j ||||f qS r.   )fmt_d_ms)r   r   r   r   r   r   r.   r/   r      s    
r   r@   TFr}   c                    s   g | ]} j |f qS r.   )fmt_s_partial)r   r   r   r.   r/   r     s    c                    s   g | ]\}} j ||f qS r.   )fmt_ss_partial)r   r   r   r   r.   r/   r     s    rp   c                 S   s   g | ]}d | qS )z$%s^{\circ}$r.   r~   r.   r.   r/   r     s    )	r!   r"   signr{   absdivmodzipfmt_d_m_partialappend)rT   	directionr-   valuesssZsignsrx   Z	frac_partZfrac_strZdeg_partZmin_partZinverse_orderZl_hm_oldrZ	min_part_Zsec_partsec_strr   r   r   r   Zl_hmlr.   )r   rT   r/   r_      sf   










zFormatterDMS.__call__N)rW   rX   rY   deg_markmin_marksec_markr   r   r   r   r   r   r   r{   r_   r.   r.   r.   r/   rn      s    rn   c                       s   e Zd ZdZdZdZde d Zde d Zde d e d Zde d	 e d Z	de d e d
 Z
de d Zde d Z fddZ  ZS )FormatterHMSz^\mathrm{h}z^\mathrm{m}z^\mathrm{s}ro   rp   rq   rr   rs   rt   ru   rv   rw   c                    s   t  ||t|d S )Nr   )superr_   r"   Zasarray)rT   r   r-   r   	__class__r.   r/   r_   2  s   zFormatterHMS.__call__)rW   rX   rY   r   r   r   r   r   r   r   r   r   r   r_   __classcell__r.   r.   r   r/   r   "  s    r   c                   @   s"   e Zd Z		dddZdd ZdS )	ExtremeFinderCycler?   Nir   c                 C   s,   ||| _ | _||| _| _|| _|| _dS )aB  
        This subclass handles the case where one or both coordinates should be
        taken modulo 360, or be restricted to not exceed a specific range.

        Parameters
        ----------
        nx, ny : int
            The number of samples in each direction.

        lon_cycle, lat_cycle : 360 or None
            If not None, values in the corresponding direction are taken modulo
            *lon_cycle* or *lat_cycle*; in theory this can be any number but
            the implementation actually assumes that it is 360 (if not None);
            other values give nonsensical results.

            This is done by "unwrapping" the transformed grid coordinates so
            that jumps are less than a half-cycle; then normalizing the span to
            no more than a full cycle.

            For example, if values are in the union of the [0, 2] and
            [358, 360] intervals (typically, angles measured modulo 360), the
            values in the second interval are normalized to [-2, 0] instead so
            that the values now cover [-2, 2].  If values are in a range of
            [5, 1000], this gets normalized to [5, 365].

        lon_minmax, lat_minmax : (float, float) or None
            If not None, the computed bounding box is clipped to the given
            range in the corresponding direction.
        N)nxny	lon_cycle	lat_cycle
lon_minmax
lat_minmax)rT   r   r   r   r   r   r   r.   r.   r/   rU   9  s    
zExtremeFinderCycle.__init__c                 C   s  t t ||| jt ||| j\}}|t |t |\}}	t jdd0 | jd ur<t |}
|d||
 dk 8 }| j	d urPt |	}|	d|	| dk 8 }	W d    n1 sZw   Y  t |t 
|}}t |	t 
|	}}| ||||\}}}}| jrt||| j }| j	rt||| j	 }| jd ur| jd }t||}| jd }t||}| jd ur| jd }t||}| jd }t||}||||fS )Nignore)invalidr?   g     f@r   r   )r"   ZmeshgridZlinspacer   r   ZravelZerrstater   Znanminr   ZnanmaxZ_add_padminr   maxr   )rT   Ztransform_xyx1y1Zx2y2xyZlonZlatZlon0Zlat0Zlon_minZlon_maxZlat_minZlat_maxZmin0Zmax0r.   r.   r/   r_   ^  s@   














zExtremeFinderCycle.__call__)r?   NNr   )rW   rX   rY   rU   r_   r.   r.   r.   r/   r   6  s
    
%r   )FTr   )Tr   )numpyr"   r;   Z#mpl_toolkits.axisartist.grid_finderr   r0   r9   r>   rK   rN   rO   rP   r[   rc   rh   rj   rl   rm   rn   r   r   r.   r.   r.   r/   <module>   s*    

1

h