a
    ìÝEb 2  ã                   @   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   sº   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-   úd/home/ja/django-apps/lartica_env/lib/python3.9/site-packages/mpl_toolkits/axisartist/angle_helper.pyÚselect_step_degree   s     r/   c                 C   sº   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)	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   r2   r   r3   r   r4   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!   s     r7   c                 C   sh   dt t | ¡ƒd  }d| }d| | kr0d}n0d| | krBd}nd| | krTd}n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rN||ƒ\}	}
nt|| ƒ\}	}
|
| }
tjt | |
 |	 ¡t ||
 |	 ¡d td�|	 }t|ƒ}|
dk�r|d |d | k�rt||	 ƒ}|rò|d t d|d d¡|	  }n|d t d|d¡|	  }t|ƒ}t 	|¡||
fS )	Ng      8@ç     €v@r   g      à?)Zdtyper   éÿÿÿÿr   )
r7   r/   r<   r!   ZarangeÚfloorÚceilr8   r    r"   )Úv1Úv2ÚnvÚhourÚinclude_lastÚthreshold_factorr#   Z_select_stepÚcycler+   r,   Úlevsr*   r-   r-   r.   Úselect_stepO   s4    
þþ	  rI   r   c                 C   s:   | d |d  } }t | ||d||d�\}}}|d ||fS )Nr   T©rD   rE   rF   ©rI   )rA   rB   rC   rE   rF   rH   r*   r,   r-   r-   r.   Úselect_step24€   s    
þrL   c                 C   s   t | ||d||d�S )NFrJ   rK   )rA   rB   rC   rE   rF   r-   r-   r.   Úselect_step360ˆ   s    
þrM   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)ÚselfrP   rE   r-   r-   r.   Ú__init__�   s    zLocatorBase.__init__Nc                 C   s   |d urt |ƒ| _d S rO   )r8   rP   )rR   rP   r-   r-   r.   Ú
set_params“   s    zLocatorBase.set_params)T)N)Ú__name__Ú
__module__Ú__qualname__rS   rT   r-   r-   r-   r.   rN   Ž   s   
rN   c                   @   s   e Zd Zdd„ ZdS )Ú
LocatorHMSc                 C   s   t ||| j| jƒS rO   ©rL   rP   rQ   ©rR   rA   rB   r-   r-   r.   Ú__call__™   s    zLocatorHMS.__call__N©rU   rV   rW   r[   r-   r-   r-   r.   rX   ˜   s   rX   c                   @   s   e Zd Zdd„ ZdS )Ú	LocatorHMc                 C   s   t ||| j| jdd�S ©Nr   ©rF   rY   rZ   r-   r-   r.   r[   ž   s    ÿzLocatorHM.__call__Nr\   r-   r-   r-   r.   r]   �   s   r]   c                   @   s   e Zd Zdd„ ZdS )ÚLocatorHc                 C   s   t ||| j| jdd�S ©Nr   r_   rY   rZ   r-   r-   r.   r[   ¤   s    ÿzLocatorH.__call__Nr\   r-   r-   r-   r.   r`   £   s   r`   c                   @   s   e Zd Zdd„ ZdS )Ú
LocatorDMSc                 C   s   t ||| j| jƒS rO   ©rM   rP   rQ   rZ   r-   r-   r.   r[   ª   s    zLocatorDMS.__call__Nr\   r-   r-   r-   r.   rb   ©   s   rb   c                   @   s   e Zd Zdd„ ZdS )Ú	LocatorDMc                 C   s   t ||| j| jdd�S r^   rc   rZ   r-   r-   r.   r[   ¯   s    ÿzLocatorDM.__call__Nr\   r-   r-   r-   r.   rd   ®   s   rd   c                   @   s   e Zd Zdd„ ZdS )ÚLocatorDc                 C   s   t ||| j| jdd�S ra   rc   rZ   r-   r-   r.   r[   µ   s    ÿzLocatorD.__call__Nr\   r-   r-   r-   r.   re   ´   s   re   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   sn   d }dD ]\}||kr qf|| }t t t |¡¡ƒ}d| |kr|dkr|}|d|  }||f  S q||fS )N)r   r   r   r   r   )r8   r!   r?   r:   )rR   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rvt|d| ƒ\}}d|f ‰ ‡ fdd„|D ƒ}|dkr¼|d u rž‡fdd„t||ƒD ƒS ‡fd	d„t|||ƒD ƒS �nz|d
k�rt|d
ƒ\}	}
|d u rö‡fdd„t||	|
ƒD ƒS ‡fdd„t||	|
|ƒD ƒS �n |dk�r$|d dk�rPd}|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 ]L\}}}}ˆj|||f }||k�rð|}|| }nd| | }| |¡ �q¼|�r|d d d… S |S ndd„ || D ƒS d S )Nr   c                 S   s   g | ]}|d k rdnd‘qS )r   ú-Ú r-   ©Ú.0Úvr-   r-   r.   Ú
<listcomp>á   ó    z)FormatterDMS.__call__.<locals>.<listcomp>r   z%%0%ddc                    s   g | ]}ˆ |f ‘qS r-   r-   )rw   Úf1)Úfrac_fmtr-   r.   ry   ê   rz   r   c                    s$   g | ]\}}ˆ j |t|ƒ f ‘qS r-   )Úfmt_dr8   )rw   Úsrx   ©rR   r-   r.   ry   î   rz   c                    s(   g | ] \}}}ˆ j |t|ƒ |f ‘qS r-   )Úfmt_dsr8   )rw   r~   rx   r{   r   r-   r.   ry   ð   s   ÿr   c                    s"   g | ]\}}}ˆ j |||f ‘qS r-   )Úfmt_d_m)rw   Ús1Úd1Úm1r   r-   r.   ry   õ   s   ÿc                    s&   g | ]\}}}}ˆ j ||||f ‘qS r-   )Úfmt_d_ms)rw   r~   rƒ   r„   r{   r   r-   r.   ry   ø   s   
ÿr   r>   TFru   c                    s   g | ]}ˆ j |f ‘qS r-   )Úfmt_s_partial)rw   r‚   r   r-   r.   ry     rz   c                    s   g | ]\}}ˆ j ||f ‘qS r-   )Úfmt_ss_partial)rw   r‚   r{   r   r-   r.   ry     s   ÿrh   c                 S   s   g | ]}d t |ƒf ‘qS )z$%s^{\circ}$)Ústrrv   r-   r-   r.   ry     rz   )	r    r!   Úsignrs   ÚabsÚdivmodÚzipÚfmt_d_m_partialÚappend)rR   Ú	directionr,   ÚvaluesÚssZsignsrp   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|   rR   r.   r[   Ü   sf    




ÿ



ÿ
þ



ÿ

zFormatterDMS.__call__N)rU   rV   rW   Údeg_markÚmin_markÚsec_markr}   r€   r�   r…   r�   r†   r‡   rs   r[   r-   r-   r-   r.   rf   º   s   rf   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}rg   rh   ri   rj   rk   rl   rm   rn   ro   c                    s   t ƒ  ||t |¡d ¡S )Nr   )Úsuperr[   r!   Zasarray)rR   r�   r,   r�   ©Ú	__class__r-   r.   r[   2  s    zFormatterHMS.__call__)rU   rV   rW   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©i¦ÿÿÿr   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)rR   rŸ   r    r¡   r¢   r£   r¤   r-   r-   r.   rS   9  s     zExtremeFinderCycle.__init__c                 C   s¦  t  t  ||| j¡t  ||| j¡¡\}}|t  |¡t  |¡ƒ\}}	t jdd��` | jd urxt  |¡}
|d||
 dk 8 }| j	d ur t  |	¡}|	d|	| dk 8 }	W d   ƒ n1 s´0    Y  t  |¡t  
|¡ }}t  |	¡t  
|	¡ }}|  ||||¡\}}}}| j�rt||| j ƒ}| j	�r2t||| j	 ƒ}| jd u�rf| 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¤   )rR   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<    ÿ



2ÿ








zExtremeFinderCycle.__call__)r=   NNrž   )rU   rV   rW   rS   r[   r-   r-   r-   r.   r�   6  s     þ
%r�   )FTr   )Tr   )Tr   )Únumpyr!   r9   Z#mpl_toolkits.axisartist.grid_finderr   r/   r7   r<   rI   rL   rM   rN   rX   r]   r`   rb   rd   re   rf   r˜   r�   r-   r-   r-   r.   Ú<module>   s(     ÿ
1


h