o
    i3                     @   s  d dl Zd dlZd dlm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)cbook)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arraysearchsorted)dvdegree_limits_degree_steps_degree_factorsminsec_limits_minsec_steps_minute_limits_minute_factorssecond_limits_second_factorsdegree_limitsdegree_stepsnstepfactor r5   _/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/mpl_toolkits/axisartist/angle_helper.pyselect_step_degree       r7   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   r;   r   r<   r   r=   r   r	   r   r   r   r   r    r!   )r&   hour_limits_hour_steps_hour_factorsr*   r+   r,   r-   r.   r/   hour_limits
hour_stepsr2   r3   r4   r5   r5   r6   select_step_hour"   r8   rE   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&   tmpr4   r3   r5   r5   r6   select_step_sub<   s   	rJ   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      ?)dtyper   r   )
rE   r7   rJ   r#   arangefloorceilrF   r"   r$   )v1v2nvhourinclude_lastthreshold_factorr&   _select_stepcycler3   r4   levsr2   r5   r5   r6   select_stepP   s4   
	 rZ   r   c                 C   s:   | d |d } }t | ||d||d\}}}|d ||fS )Nr   TrT   rU   rV   rZ   )rQ   rR   rS   rU   rV   rY   r2   r4   r5   r5   r6   select_step24   s   
r]   c                 C   s   t | ||d||dS )NFr[   r\   )rQ   rR   rS   rU   rV   r5   r5   r6   select_step360   s   
r^   c                   @   sV   e Zd ZeddddddZejdddedd	 Zej	d
d	 ZdddZ
dS )LocatorBasez3.3dennbinsTc                 C   s   || _ || _d S N)ra   _include_last)selfra   rU   r5   r5   r6   __init__   s   
zLocatorBase.__init__)alternativec                 C   s   | j S rb   ra   rd   r5   r5   r6   r`      s   zLocatorBase.denc                 C   s
   || _ d S rb   rg   )rd   vr5   r5   r6   r`      s   
Nc                 C   s   |d urt || _d S d S rb   )rF   ra   )rd   ra   r5   r5   r6   
set_params   s   zLocatorBase.set_params)Trb   )__name__
__module____qualname__r   _rename_parameterre   
deprecatedpropertyr`   setterrj   r5   r5   r5   r6   r_      s    
r_   c                   @      e Zd Zdd ZdS )
LocatorHMSc                 C      t ||| j| jS rb   r]   ra   rc   rd   rQ   rR   r5   r5   r6   __call__      zLocatorHMS.__call__Nrk   rl   rm   rw   r5   r5   r5   r6   rs          rs   c                   @   rr   )	LocatorHMc                 C      t ||| j| jddS Nr   rV   ru   rv   r5   r5   r6   rw         zLocatorHM.__call__Nry   r5   r5   r5   r6   r{      rz   r{   c                   @   rr   )LocatorHc                 C   r|   Nr   r~   ru   rv   r5   r5   r6   rw      r   zLocatorH.__call__Nry   r5   r5   r5   r6   r      rz   r   c                   @   rr   )
LocatorDMSc                 C   rt   rb   r^   ra   rc   rv   r5   r5   r6   rw      rx   zLocatorDMS.__call__Nry   r5   r5   r5   r6   r      rz   r   c                   @   rr   )	LocatorDMc                 C   r|   r}   r   rv   r5   r5   r6   rw      r   zLocatorDM.__call__Nry   r5   r5   r5   r6   r      rz   r   c                   @   rr   )LocatorDc                 C   r|   r   r   rv   r5   r5   r6   rw      r   zLocatorD.__call__Nry   r5   r5   r5   r6   r      rz   r   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   )rF   r#   rO   rH   )rd   r4   number_fraction	thresholdd	int_log_dr5   r5   r6   _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   - r5   .0ri   r5   r5   r6   
<listcomp>   s    z)FormatterDMS.__call__.<locals>.<listcomp>r   z%%0%ddc                    s   g | ]} |f qS r5   r5   )r   f1)frac_fmtr5   r6   r      s    r   c                    s$   g | ]\}} j |t| f qS r5   )fmt_drF   )r   sri   rh   r5   r6   r      s   $ c                    s(   g | ]\}}} j |t| |f qS r5   )fmt_dsrF   )r   r   ri   r   rh   r5   r6   r      s    r   c                    s"   g | ]\}}} j |||f qS r5   )fmt_d_m)r   s1d1m1rh   r5   r6   r      s    c                    s&   g | ]\}}}} j ||||f qS r5   )fmt_d_ms)r   r   r   r   r   rh   r5   r6   r     s    
r   rM   TFr   c                    s   g | ]} j |f qS r5   )fmt_s_partial)r   r   rh   r5   r6   r     s    c                    s   g | ]\}} j ||f qS r5   )fmt_ss_partial)r   r   r   rh   r5   r6   r     s    r   c                 S   s   g | ]	}d t |f qS )z$%s^{\circ}$)strr   r5   r5   r6   r   *  s    )	r"   r#   signr   absdivmodzipfmt_d_m_partialappend)rd   	directionr4   valuessssignsr   	frac_partfrac_strdeg_partmin_partinverse_orderl_hm_oldr	min_part_sec_partsec_strr   r   r   r   l_hmlr5   )r   rd   r6   rw      sf   










zFormatterDMS.__call__N)rk   rl   rm   deg_markmin_marksec_markr   r   r   r   r   r   r   r   rw   r5   r5   r5   r6   r      s    r   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}r   r   r   r   r   r   r   r   r   c                    s   t  ||t|d S )Nr   )superrw   r#   asarray)rd   r   r4   r   	__class__r5   r6   rw   =  s   zFormatterHMS.__call__)rk   rl   rm   r   r   r   r   r   r   r   r   r   r   rw   __classcell__r5   r5   r   r6   r   -  s    r   c                   @   s"   e Zd Z		dddZdd ZdS )	ExtremeFinderCyclerK   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)rd   r   r   r   r   r   r   r5   r5   r6   re   D  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)invalidrK   g     f@r   r   )r#   meshgridlinspacer   r   ravelerrstater   nanminr   nanmax_add_padminr   maxr   )rd   transform_xyx1y1x2y2xylonlatlon0lat0lon_minlon_maxlat_minlat_maxmin0max0r5   r5   r6   rw   i  s@   














zExtremeFinderCycle.__call__)rK   NNr   )rk   rl   rm   re   rw   r5   r5   r5   r6   r   A  s
    
%r   )FTr    )Tr   )numpyr#   rG   
matplotlibr   #mpl_toolkits.axisartist.grid_finderr   r7   rE   rJ   rZ   r]   r^   r_   rs   r{   r   r   r   r   r   r   r   r5   r5   r5   r6   <module>   s,    

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