
    
3j3                     8   S SK rS SKrS SKJr  S SKJr  S rS rS r	  SS jr
SS jrSS	 jr " S
 S5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S\5      r " S S5      r " S S\5      r " S S\5      rg)     N)Bbox)ExtremeFinderSimplec                 R   / SQn/ SQnS/[        U5      -  n/ SQn/ SQn[        R                  " U5      S-  nS/[        U5      -  n[        R                  " U5      S-  nS	/[        U5      -  n	/ UQUQUQn
/ UQUQUQn/ U	QUQUQn[        R                  " X5      nX   nX<   nX4$ )
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factors                  ^/home/wildlama/miniconda3/lib/python3.13/site-packages/mpl_toolkits/axisartist/angle_helper.pyselect_step_degreer7      s    ?N?MTC..N7N7MXXn-2NUS00NXXn-4NWs>22NGnG~GGMC]C]C]CLH~HHHN
*A?DF<    c                 R   / SQn/ SQnS/[        U5      -  n/ SQn/ SQn[        R                  " U5      S-  nS/[        U5      -  n[        R                  " U5      S-  nS	/[        U5      -  n	/ UQUQUQn
/ UQUQUQn/ U	QUQUQn[        R                  " X5      nX   nX<   nX4$ )
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/   r0   hour_limits
hour_stepsr3   r4   r5   s                  r6   select_step_hourrF   "   s    8L8K4#k**LENEMXXn-2NUS00NXXn-4NWs>22NCNC^ClCK?=?=?;?JD^DnD|DL
(A=D_F<r8   c                     S[        [        R                  " U 5      5      S-
  -  nSU-  nSU-  U :  a  SnX24$ SU-  U :  a  SnX24$ SU-  U :  a  SnX24$ SnS	U-  nX24$ )
Ng      $@r   r   r   g      @r   g      @r   g?)intmathlog10)r'   tmpr5   r4   s       r6   select_step_subrL   <   s     DJJrN#B&
'CVF
3w"} < 
C2 < 
C2
 < V<r8   c                 z   X:  a  XpX-
  U-  nU(       a	  [         nSnO[        nSnUSU-  :  a  U" U5      u  pO[        Xe-  5      u  pX-  n
[        R                  " [        R
                  " X
-  U	-  5      [        R                  " X-  U	-  5      S-   [        S9U	-  n[        U5      nU
S:X  at  US   US   U-   :  ae  [        X-  5      nU(       a%  US   [        R                  " SUS-   S5      U	-  -   nO!US   [        R                  " SUS5      U	-  -   n[        U5      n[        R                  " U5      X4$ )	Ng      8@     v@r   g      ?)dtyper   r   )
rF   r7   rL   r$   arangefloorceilrH   r#   r%   )v1v2nvhourinclude_lastthreshold_factorr'   _select_stepcycler4   r5   levsr3   s                r6   select_stepr]   P   s>    
wB
'RB') 
A   #B'f&r':;*99RXXbkD01WWR[4/036 "&'D 	D	A
 |RDGeO37RYYq"Q$2T99D7RYYq"a0477DI88D>1$$r8   c           	      B    U S-  US-  p[        XUSUUS9u  pVnUS-  Xg4$ )Nr   TrW   rX   rY   r]   )rT   rU   rV   rX   rY   r\   r3   r5   s           r6   select_step24ra      s=    "Wb2g!""4/;3CEODV "9ar8   c           	          [        XUSUUS9$ )NFr_   r`   )rT   rU   rV   rX   rY   s        r6   select_step360rc      s    rr$0(8: :r8   c                   (    \ rS rSrSS jrSS jrSrg)LocatorBase   c                     Xl         X l        g N)nbins_include_last)selfri   rX   s      r6   __init__LocatorBase.__init__   s    
)r8   Nc                 ,    Ub  [        U5      U l        g g rh   )rH   ri   )rk   ri   s     r6   
set_paramsLocatorBase.set_params   s    UDJ r8   )rj   ri   )Trh   )__name__
__module____qualname____firstlineno__rl   ro   __static_attributes__ r8   r6   re   re      s    *$r8   re   c                       \ rS rSrS rSrg)
LocatorHMS   c                 D    [        XU R                  U R                  5      $ rh   ra   ri   rj   rk   rT   rU   s      r6   __call__LocatorHMS.__call__   s    RTZZ1C1CDDr8   rv   Nrq   rr   rs   rt   r}   ru   rv   r8   r6   rx   rx      s    Er8   rx   c                       \ rS rSrS rSrg)	LocatorHM   c                 B    [        XU R                  U R                  SS9$ Nr   rY   r{   r|   s      r6   r}   LocatorHM.__call__   s"    RTZZ1C1C.02 	2r8   rv   Nr   rv   r8   r6   r   r          2r8   r   c                       \ rS rSrS rSrg)LocatorH   c                 B    [        XU R                  U R                  SS9$ Nr   r   r{   r|   s      r6   r}   LocatorH.__call__   s"    RTZZ1C1C./1 	1r8   rv   Nr   rv   r8   r6   r   r      s    1r8   r   c                       \ rS rSrS rSrg)
LocatorDMS   c                 D    [        XU R                  U R                  5      $ rh   rc   ri   rj   r|   s      r6   r}   LocatorDMS.__call__   s    bdjj$2D2DEEr8   rv   Nr   rv   r8   r6   r   r      s    Fr8   r   c                       \ rS rSrS rSrg)	LocatorDM   c                 B    [        XU R                  U R                  SS9$ r   r   r|   s      r6   r}   LocatorDM.__call__   s"    bdjj$2D2D/13 	3r8   rv   Nr   rv   r8   r6   r   r      s    3r8   r   c                       \ rS rSrS rSrg)LocatorD   c                 B    [        XU R                  U R                  SS9$ r   r   r|   s      r6   r}   LocatorD.__call__   s"    bdjj$2D2D/02 	2r8   rv   Nr   rv   r8   r6   r   r      r   r8   r   c                       \ rS rSrSrSrSrS\-   S-   rS\-   S-   rS\-   S	-   \-   S-   r	S\-   S
-   \-   S-   r
S\-   S	-   \-   S-   rS\-   S-   rS\-   S-   rS rS rSrg)FormatterDMS   z^{\circ}z	^{\prime}z^{\prime\prime}$%d$$%d.%s$%s%d\,%02d	\,%02d.%s\,%02d%02d.%sc                     S nS Hc  nX::  a    X4$ X-  n[        [        R                  " [        R                  " U5      5      5      nSU-  U:X  d  MN  US:w  d  MV  UnUSU-  -  nX4s  $    X4$ )N)r   r   r    r   r   )rH   r$   rR   rJ   )rk   r5   number_fraction	thresholdd	int_log_ds         r6   _get_number_fraction!FormatterDMS._get_number_fraction   s     'I" && #ABHHRXXa[12I9}!a1f"+2y=0.. ' &&r8   c                    [        U5      S:X  a  / $ [        R                  " U5      nU Vs/ s H  oUS:  a  SOSPM     nnU R                  U5      u  p'[        R                  " U5      nUb,  [        USU-  5      u  p8SU4-  n	U V
s/ s H  oU
4-  PM
     nn
US:X  a|  Uc:  [        XC5       VVs/ s H!  u  pU R                  U[        U5      -  4-  PM#     snn$ [        XCW5       VVV
s/ s H#  u  pn
U R                  U[        U5      -  U
4-  PM%     sn
nn$ US:X  a  [        US5      u  pUc5  [        XmU5       VVVs/ s H  u  nnnU R                  UUU4-  PM     snnn$ [        XmUW5       VVVV
s/ s H  u  nnnn
U R                  UUUU
4-  PM     sn
nnn$ US:X  a  US	   S	:X  a  S
nUS S S	2   nUS S S	2   nOSnSn/ n[        US5      u  nn[        US5      u  nnUc   U Vs/ s H  oR                  U4-  PM     nnO.[        UW5       VV
s/ s H  u  pU R                  X4-  PM     nnn
[        XmUU5       HA  u  nnnnU R                  UUU4-  nUU:w  a  UnUU-   nOSU-   U-   nUR                  U5        MC     U(       a  US S S	2   $ U$ XC-   Vs/ s H  nSU-  PM
     sn$ s  snf s  sn
f s  snnf s  sn
nnf s  snnnf s  sn
nnnf s  snf s  sn
nf s  snf )Nr   - r   z%%0%ddr   r   r    rP   TFr   z$%s^{\circ}$)r#   r$   signr   absdivmodzipfmt_drH   fmt_dsfmt_d_mfmt_d_msfmt_s_partialfmt_ss_partialfmt_d_m_partialappend)rk   	directionr5   valuesssvsignsr   	frac_partfrac_fmtf1frac_strsdeg_partmin_parts1d1m1inverse_orderl_hm_oldr	min_part_sec_partsec_strl_hmls                             r6   r}   FormatterDMS.__call__   sS   v;!IWWV_/56v!A2%v6"&";";F"C& &vr_/D EF?"44H3<=9RB5(9H=Q;&?B2Otq

a#a&j]2OO ),B(AC(AHA" q3q6z2&66(AC Cr\!'!3H&*-ex*HJ*HJBB B|3*HJ J
 u(CEC *Ar2r BB7CE E t^"v| $"dd %HA"("6Hi!'	2!6Hh&@HI"--5I *-Xx)@B)@vr  .."9)@  B "%Uh!H2r2++q"bk98##Hr	Aa"A "I 2w 24;AOa';;} 7 > PC
JE& JB$ <s5   J3J80(J=,*K K
9"K
.KK!K$rv   N)rq   rr   rs   rt   deg_markmin_marksec_markr   r   r   r   r   r   r   r   r}   ru   rv   r8   r6   r   r      s    HH!HHs"E!C'F !I-83>G("\1H<sBH(94x?%GOX%+M)C/N'$C<r8   r   c                      ^  \ rS rSrSrSrSrS\-   S-   rS\-   S-   rS\-   S	-   \-   S-   r	S\-   S
-   \-   S-   r
S\-   S	-   \-   S-   rS\-   S-   rS\-   S-   rU 4S jrSrU =r$ )FormatterHMSi#  z^\mathrm{h}z^\mathrm{m}z^\mathrm{s}r   r   r   r   r   r   r   r   r   c                 R   > [         TU ]  X[        R                  " U5      S-  5      $ )Nr   )superr}   r$   asarray)rk   r   r5   r   	__class__s       r6   r}   FormatterHMS.__call__3  s#    w	2::f3E3JKKr8   rv   )rq   rr   rs   rt   r   r   r   r   r   r   r   r   r   r   r}   ru   __classcell__)r   s   @r6   r   r   #  s    HHHHs"E!C'F !I-8<G("\1H<S@H(94x?%GOX%+M)C/NL Lr8   r   c                   (    \ rS rSr  SS jrS rSrg)ExtremeFinderCyclei7  Nc                 T    XsU l         U l        X4sU l        U l        XPl        X`l        g)a  
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)rk   r   r   r   r   r   r   s          r6   rl   ExtremeFinderCycle.__init__:  s+    @ )2&$$r8   c           
      d   [         R                  " [         R                  " [         R                  " UR                  UR
                  U R                  5      [         R                  " UR                  UR                  U R                  5      5      S5      R                  nUR                  U5      R                  u  pE[         R                  " SS9   U R                  b#  [         R                  " U5      nUSXF-
  S:  -  -  nU R                  b#  [         R                  " U5      nUSXW-
  S:  -  -  nS S S 5        [         R"                  " 5       nUR%                  [         R&                  " XE/5      5        UR)                  SSU R                  -  -   SSU R                  -  -   5      nUR*                  u  ppU R                  (       a  [-        XU R                  -   5      nU R                  (       a  [-        XU R                  -   5      nU R.                  b4  U R.                  S   n[1        X5      n	U R.                  S   n[-        X5      nU R2                  b4  U R2                  S   n[1        X5      n
U R2                  S   n[-        X5      n[         R4                  " XX5      $ ! , (       d  f       GNv= f)	N)r   rP   ignore)invalidrN   g     f@r   r   r   )r$   reshapemeshgridlinspacex0x1r   y0y1r   T	transformerrstater   nanminr   r   nullupdate_from_data_xycolumn_stackexpandedextentsminr   maxr   from_extents)rk   transbboxgridlonlatlon0lat0tbboxlon_minlat_minlon_maxlat_maxmin0max0s                  r6   _find_transformed_bbox)ExtremeFinderCycle._find_transformed_bbox_  s   zz"++bkk$''477DGG&L&(kk$''477DGG&LN!##$1 	 ??4(** [[*~~)yy~t
d233~~)yy~t
d233 + 		!!"//3*"=>q1tww;AK@-2]]*' >>'T^^#;<G>>'T^^#;<G??&??1%D$(G??1%D$(G??&??1%D$(G??1%D$(G  7DD? +*s   A!J  
J/)r   r   r   r   r   r   )rN   NN)ir   )rq   rr   rs   rt   rl   r  ru   rv   r8   r6   r   r   7  s     ,0-6#%J,Er8   r   )FTr!   )Tr    )numpyr$   rI   matplotlib.transformsr   #mpl_toolkits.axisartist.grid_finderr   r7   rF   rL   r]   ra   rc   re   rx   r   r   r   r   r   r   r   r   rv   r8   r6   <module>r     s      & C44( 6:!&.%b :$ $E E
2 21{ 1F F
3 32{ 2e< e<PL< L(TE, TEr8   