
    rbiGk                        d Z ddlZddlmZmZmZ ddlmZmZm	Z	m
Z
mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZ ddlmZ d Z d Z!d	 Z"d
 Z#d Z$d Z%d Z&d Z'd Z(d Z)d Z*d Z+d Z,d Z-d Z.d Z/d Z0d Z1e#e$e%e&e'e(e)e*e+e,e-e.e/e0dZ2de1iZ3d Z4d Z5d Z6d Z7d Z8d  Z9d! Z:d" Z;d# Z<d$ Z=d% Z>d& Z?d' Z@d( ZAd) ZBd* ZCd+ ZDi d,e5d-e6d.e6d/e7d0e7d1e8d2e9d3e9d4e:d5e;d6e;d7e<d8e=d9e>d:e>d;e?d<e@eAeBd=ZEeCeCeCeCeDd>ZFdS )?z
This module contains mappings necessary to convert from
a CRS to a CF-1.8 compliant projection.

http://cfconventions.org/cf-conventions/cf-conventions.html#appendix-grid-mappings

    N)Datum	EllipsoidPrimeMeridian)AlbersEqualAreaConversionAzimuthalEquidistantConversion GeostationarySatelliteConversion HotineObliqueMercatorBConversion#LambertAzimuthalEqualAreaConversion"LambertConformalConic1SPConversion"LambertConformalConic2SPConversion%LambertCylindricalEqualAreaConversion*LambertCylindricalEqualAreaScaleConversionMercatorAConversionMercatorBConversionOrthographicConversionPolarStereographicAConversionPolarStereographicBConversionPoleRotationNetCDFCFConversionSinusoidalConversionStereographicConversionTransverseMercatorConversionVerticalPerspectiveConversion)CustomDatumCustomEllipsoidCustomPrimeMeridian)CRSErrorc           	         |                      d          }|r)|dvr%	 t          j        |          S # t          $ r Y nw xY wd }|                      d          }	 t	          |pd|                      d          |                      d          |                      d          |                      d          	          }n*# t          $ r |r|dvrt          j        |          }Y nw xY wd }|                      d
          }	 t          |pd| d                   }n*# t          $ r |r|dvrt          j        |          }Y nw xY w|s|rt          |pd|pd|pd          S d S )Nhorizontal_datum_name)	undefinedunknownreference_ellipsoid_namer   semi_major_axissemi_minor_axisinverse_flatteningearth_radius)namer"   r#   r$   radiusprime_meridian_namelongitude_of_prime_meridian)r&   	longitudezWGS 84	Greenwich)r&   	ellipsoidprime_meridian)
getr   	from_namer   r   r   r   KeyErrorr   r   )	cf_params
datum_namer,   ellipsoid_namer-   r(   s         a/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/pyproj/crs/_cf1x8.py_horizontal_datum_from_paramsr5   %   s   677J j(@@@	?:... 	 	 	D	 I]]#=>>N
<#.;%MM*;<<%MM*;<<(}}-ABB==00
 
 
		  < < < 	<n4LLL!+N;;I<
 N#--(=>>J,$3 =>
 
 
  J J J 	J#6>V#V#V*45HIINJ
  
N 
*{+8)8[
 
 
 	

 4s1   1 
>>A"B< <$C#"C#>D $D?>D?c                     t          | t                    s| S |                     d          }t          |          dk    rd |D             S | S )z=
    Attempt to convert string to list if it is a string
    ,   c                 P    g | ]#}t          |                                          $S  )floatstrip).0svals     r4   
<listcomp>z'_try_list_if_string.<locals>.<listcomp>Y   s(    :::djjll##:::    )
isinstancestrsplitlen)	input_str	val_splits     r4   _try_list_if_stringrG   Q   sX     i%% $$I
9~~::	::::r@   c                 x    t          |           } 	 t          |           }d }n# t          $ r | \  }}Y nw xY w||fS )N)rG   r;   	TypeError)standard_parallelfirst_parallelsecond_parallels      r4   _get_standard_parallelsrM   ]   s_    +,=>><011 < < <*;'<?**s   # 55c                     t          | d                   \  }}t          ||pd|                     dd          |                     dd          |                     dd          |                     dd                    S )zX
    http://cfconventions.org/cf-conventions/cf-conventions.html#_albers_equal_area
    rJ           latitude_of_projection_originlongitude_of_central_meridianfalse_eastingfalse_northinglatitude_first_parallellatitude_second_parallellatitude_false_originlongitude_false_origineasting_false_originnorthing_false_origin)rM   r   r.   r1   rK   rL   s      r4   _albers_conical_equal_arear\   g   s     '>%&' '#NO % .!0!7C'mm,KSQQ(}}-LcRR&]]?C@@'mm,<cBB   r@   c           	          t          |                     dd          |                     dd          |                     dd          |                     dd                    S )[
    http://cfconventions.org/cf-conventions/cf-conventions.html#azimuthal-equidistant
    rP   rO   longitude_of_projection_originrR   rS   latitude_natural_originlongitude_natural_originrR   rS   )r   r.   r1   s    r4   _azimuthal_equidistantrd   x   sc     * ).Ms S S!*/OQT!U!UmmOS99 }}%5s;;	   r@   c                 R   	 | d         }n3# t           $ r& ddd| d                                                  }Y nw xY wt          || d         |                     dd          |                     d	d          |                     d
d          |                     dd                    S )_
    http://cfconventions.org/cf-conventions/cf-conventions.html#_geostationary_projection
    sweep_angle_axisyx)ri   rh   fixed_angle_axisperspective_point_heightrP   rO   r_   rR   rS   )rg   satellite_heightra   rb   rR   rS   )r0   lowerr   r.   )r1   rg   s     r4   _geostationaryrn      s    W$%78 W W W!$3//	:L0M0S0S0U0UVW+)"#=> ).Ms S S!*/OQT!U!UmmOS99 }}%5s;;   s    -;;c           	          t          |                     dd          |                     dd          |                     dd          |                     dd                    S )b
    http://cfconventions.org/cf-conventions/cf-conventions.html#lambert-azimuthal-equal-area
    rP   rO   r_   rR   rS   r`   )r
   r.   rc   s    r4   _lambert_azimuthal_equal_arearq      sc     / ).Ms S S!*/OQT!U!UmmOS99 }}%5s;;	   r@   c                    t          | d                   \  }}|et          |||                     dd          |                     dd          |                     dd          |                     dd                    S t          ||                     dd          |                     dd          |                     dd          	          S )
X
    http://cfconventions.org/cf-conventions/cf-conventions.html#_lambert_conformal
    rJ   NrP   rO   rQ   rR   rS   rT   r`   )rM   r   r.   r   r[   s      r4   _lambert_conformal_conicrt      s     '>%&' '#NO "1$2%4"+--0OQT"U"U#,==1PRU#V#V!*!D!D"+--0@#"F"F
 
 
 	
 . .!*/NPS!T!TmmOS99 }}%5s;;	   r@   c           	      z   d| v rUt          | d         |                     dd          |                     dd          |                     dd                    S t          |                     dd          |                     dd          |                     dd          |                     dd                    S )	e
    http://cfconventions.org/cf-conventions/cf-conventions.html#_lambert_cylindrical_equal_area
    !scale_factor_at_projection_originrQ   rO   rR   rS   )scale_factor_natural_originrb   rR   rS   rJ   rU   rb   rR   rS   )r   r.   r   rc   s    r4   _lambert_cylindrical_equal_arearz      s     +i779(12U(V%.]]/& & $--==$==)93??
 
 
 	
 1 ).A3 G G!*/NPS!T!TmmOS99 }}%5s;;	   r@   c           	         d| v rjt          |                     dd          |                     dd          |                     dd          |                     dd          | d                   S t          |                     dd          |                     dd          |                     dd          |                     dd                    S )	O
    http://cfconventions.org/cf-conventions/cf-conventions.html#_mercator
    rw   rJ   rO   r_   rR   rS   ra   rb   rR   rS   rx   ry   )r   r.   r   rc   s    r4   	_mercatorr~      s     +i77"$-MM2Es$K$K%.]]0#& & $--==$==)93??(12U(V
 
 
 	
  ).A3 G G!*/OQT!U!UmmOS99 }}%5s;;	   r@   c                     t          | d         | d         | d         d|                     dd          |                     dd          |                     dd          	          S )
W
    http://cfconventions.org/cf-conventions/cf-conventions.html#_oblique_mercator
    rP   r_   azimuth_of_central_linerO   rw         ?rR   rS   )latitude_projection_centrelongitude_projection_centreazimuth_projection_centre!angle_from_rectified_to_skew_gridscale_factor_projection_centreeasting_projection_centrenorthing_projection_centre)r	   r.   rc   s    r4   _oblique_mercatorr      st     ,#,-L#M$-.N$O"+,E"F*-'0}}/(
 (
 #,--"E"E#,==1A3#G#G
 
 
 
r@   c           	          t          |                     dd          |                     dd          |                     dd          |                     dd                    S )S
    http://cfconventions.org/cf-conventions/cf-conventions.html#_orthographic
    rP   rO   r_   rR   rS   r`   )r   r.   rc   s    r4   _orthographicr      sc     " ).Ms S S!*/OQT!U!UmmOS99 }}%5s;;	   r@   c           
      P   d| v rGt          | d         | d         |                     dd          |                     dd                    S t          | d         | d         |                     dd          |                     dd          |                     dd	          
          S )Y
    http://cfconventions.org/cf-conventions/cf-conventions.html#polar-stereographic
    rJ   %straight_vertical_longitude_from_polerR   rO   rS   )latitude_standard_parallellongitude_originrR   rS   rP   rw   r   r}   )r   r.   r   rc   s    r4   _polar_stereographicr     s     i'','01D'E&'NO#--==$==)93??	
 
 
 	
 ) )*I J!*+R!SmmOS99 }}%5s;;$-MM/%
 %
   r@   c                     t          |                     dd          |                     dd          |                     dd                    S )Q
    http://cfconventions.org/cf-conventions/cf-conventions.html#_sinusoidal
    r_   rO   rR   rS   )rb   rR   rS   )r   r.   rc   s    r4   _sinusoidalr     sQ      !*/OQT!U!UmmOS99 }}%5s;;   r@   c           
          t          |                     dd          |                     dd          |                     dd          |                     dd          |                     dd                    S )	T
    http://cfconventions.org/cf-conventions/cf-conventions.html#_stereographic
    rP   rO   r_   rR   rS   rw   r   r}   )r   r.   rc   s    r4   _stereographicr   #  sy     # ).Ms S S!*/OQT!U!UmmOS99 }}%5s;;$-MM/%
 %
   r@   c           
          t          |                     dd          |                     dd          |                     dd          |                     dd          |                     dd                    S )	Z
    http://cfconventions.org/cf-conventions/cf-conventions.html#_transverse_mercator
    rP   rO   rQ   rR   rS    scale_factor_at_central_meridianr   r}   )r   r.   rc   s    r4   _transverse_mercatorr   2  sy     ( ).Ms S S!*/NPS!T!TmmOS99 }}%5s;;$-MM.%
 %
   r@   c           
          t          | d         |                     dd          |                     dd          |                     dd          |                     dd                    S )Z
    http://cfconventions.org/cf-conventions/cf-conventions.html#vertical-perspective
    rk   rP   rO   r_   rR   rS   )viewpoint_heightlatitude_topocentric_originlongitude_topocentric_originrR   rS   )r   r.   rc   s    r4   _vertical_perspectiver   A  sr     )"#=>$-MM2QSV$W$W%.]],c&
 &
  mmOS99 }}%5s;;   r@   c                 f    t          | d         | d         |                     dd                    S )S
    http://cfconventions.org/cf-conventions/cf-conventions.html#_rotated_pole
    grid_north_pole_latitudegrid_north_pole_longitudenorth_pole_grid_longituderO   )r   r   r   )r   r.   rc   s    r4   _rotated_latitude_longituder   P  s?     *!*+E!F"+,G"H"+--0KS"Q"Q   r@   )albers_conical_equal_areaazimuthal_equidistantgeostationarylambert_azimuthal_equal_arealambert_conformal_coniclambert_cylindrical_equal_areamercatoroblique_mercatororthographicpolar_stereographic
sinusoidalstereographictransverse_mercatorvertical_perspectiverotated_latitude_longitudec                     i }| j         D ]7}|j        ||j                                                            dd          <   8|S )N _)paramsvaluer&   rm   replace)	operation
param_dictparams      r4   _to_dictr   q  sN    J! G G;@;
5:##%%--c37788r@   c                 ~    t          |           }d|d         |d         f|d         |d         |d         |d         dS )	zY
    http://cfconventions.org/cf-conventions/cf-conventions.html#_albers_equal_area

    r   !latitude_of_1st_standard_parallel!latitude_of_2nd_standard_parallellatitude_of_false_originlongitude_of_false_origineasting_at_false_originnorthing_at_false_origingrid_mapping_namerJ   rP   rQ   rR   rS   r   
conversionr   s     r4   !_albers_conical_equal_area__to_cfr   x  s`    
 j!!F86767
 *00J)K)/0K)L 9: !;<
 
 
r@   c                 `    t          |           }d|d         |d         |d         |d         dS )r^   r   latitude_of_natural_originlongitude_of_natural_originrR   rS   r   rP   r_   rR   rS   r   r   s     r4   _azimuthal_equidistant__to_cfr     sF     j!!F4)/0L)M*01N*O0 !12  r@   c                    t          |           }d}| j                                                            dd                              d          rd}d||d         |                    dd	          |d
         |d         |d         dS )rf   rh   r   r   z	(sweep_x)ri   r   rl   r   rO   r   rR   rS   )r   rg   rk   rP   r_   rR   rS   )r   method_namerm   r   endswithr.   )r   r   rg   s      r4   _geostationary__to_cfr     s     j!!F##%%--c377@@MM ,,$*+=$> *04PRU)V)V*01N*O0 !12
 
 
r@   c                 `    t          |           }d|d         |d         |d         |d         dS )rp   r   r   r   rR   rS   r   r   r   s     r4   $_lambert_azimuthal_equal_area__to_cfr     sF     j!!F;)/0L)M*01N*O0 !12  r@   c                    t          |           }| j                                                            d          r/d|d         |d         f|d         |d         |d         |d         d	S d|d
         |d         |d         |d         dS )rs   z(2sp)r   r   r   r   r   r   r   r   r   r   rR   rS   r   rJ   rQ   rR   rS   r   r   rm   r   r   s     r4   _lambert_conformal_conic__to_cfr     s     j!!F##%%..w77 
!::;:;" .44N-O-34O-P#$=>$%?@

 

 
	
 7#$@A)/0M)N0 !12  r@   c                 `    t          |           }d|d         |d         |d         |d         dS )rv   r   r   r   rR   rS   r   r   r   s     r4   &_lambert_cylindrical_equal_area__to_cfr     sF     j!!F=#$GH)/0M)N0 !12  r@   c                 .   t          |           }| j                                                            dd                              d          r'd|d         |d         |d         |d         |d	         d
S d|d         |d         |d         |d         dS )r|   r   r   z(variant_a)r   r   r   rR   rS   scale_factor_at_natural_origin)r   rJ   r_   rR   rS   rw   r   )r   rJ   r_   rR   rS   )r   r   rm   r   r   r   s     r4   _mercator__to_cfr     s     j!!F##%%--c377@@OO 

!+!'(D!E.45R.S#O4$%561702	
 	
 		
 (#$GH*01N*O0 !12  r@   c                 ,   t          |           }|d         dk    rt          j        d           	 |d         }n# t          $ r |d         }Y nw xY w	 |d         }n# t          $ r |d         }Y nw xY wd|d	         |d
         |||d         |d         dS )r   r   r   zDangle from rectified to skew grid parameter lost in conversion to CFazimuth_of_initial_lineazimuth_at_projection_centrescale_factor_on_initial_line!scale_factor_at_projection_centrer   latitude_of_projection_centrelongitude_of_projection_centreeasting_at_projection_centrenorthing_at_projection_centre)r   rP   r_   r   rw   rR   rS   )r   warningswarnr0   )r   r   r   rw   s       r4   _oblique_mercator__to_cfr     s    j!!F12a77R	
 	
 	
I"()B"C I I I"()G"HIX,23Q,R)) X X X,23V,W)))X 0)/0O)P*01Q*R#:-N >? !@A  s!   : AAA A10A1c                 `    t          |           }d|d         |d         |d         |d         dS )r   r   r   r   rR   rS   r   r   r   s     r4   _orthographic__to_cfr     sF     j!!F+)/0L)M*01N*O0 !12  r@   c                    t          |           }| j                                                            d          r d|d         |d         |d         |d         dS d|d         |d	         |d         |d         |d
         dS )r   z(variant b)r   latitude_of_standard_parallellongitude_of_originrR   rS   )r   rJ   r   rR   rS   r   r   r   )r   rP   r   rR   rS   rw   r   r   s     r4   _polar_stereographic__to_cfr   '  s     j!!F##%%..}== 
!6!'(G!H5;<Q5R#O4$%56
 
 	
 3)/0L)M178U1V0 !12-34T-U  r@   c                 R    t          |           }d|d         |d         |d         dS )r   r   r   rR   rS   )r   r_   rR   rS   r   r   s     r4   _sinusoidal__to_cfr   >  s=     j!!F)*01N*O0 !12	  r@   c                 n    t          |           }d|d         |d         |d         |d         |d         dS )r   r   r   r   rR   rS   r   )r   rP   r_   rR   rS   rw   r   r   s     r4   _stereographic__to_cfr   K  sO     j!!F,)/0L)M*01N*O0 !12-34T-U  r@   c                 n    t          |           }d|d         |d         |d         |d         |d         dS )r   r   r   r   rR   rS   r   )r   rP   rQ   rR   rS   r   r   r   s     r4   _transverse_mercator__to_cfr   Z  sO     j!!F2)/0L)M)/0M)N0 !12,23S,T  r@   c                 n    t          |           }d|d         |d         |d         |d         |d         dS )r   r   r   latitude_of_topocentric_originlongitude_of_topocentric_originrR   rS   )r   rk   rP   r_   rR   rS   r   r   s     r4   _vertical_perspective__to_cfr   i  sO     j!!F3$*+=$>)/0P)Q*01R*S0 !12  r@   c                 X    t          |           }d|d         |d         dz
  |d         dS )r   r   o_lat_plon_0   o_lon_pr   r   r   r   r   r   s     r4   "_rotated_latitude_longitude__to_cfr  x  s?     j!!F9$*9$5%+G_s%:%+I%6  r@   c                 R    t          |           }d|d         |d         |d         dS )z
    http://cfconventions.org/cf-conventions/cf-conventions.html#_rotated_pole

    https://github.com/OSGeo/PROJ/pull/2835
    r   z/grid_north_pole_latitude_(netcdf_cf_convention)z0grid_north_pole_longitude_(netcdf_cf_convention)z0north_pole_grid_longitude_(netcdf_cf_convention)r  r   r   s     r4   _pole_rotation_netcdf__to_cfr    sH     j!!F9$*=%
 &,>&
 &,>&
  r@   albers_equal_areamodified_azimuthal_equidistantr   z!geostationary_satellite_(sweep_x)z!geostationary_satellite_(sweep_y)r   zlambert_conic_conformal_(2sp)zlambert_conic_conformal_(1sp)r   zmercator_(variant_a)zmercator_(variant_b)z#hotine_oblique_mercator_(variant_b)r   zpolar_stereographic_(variant_a)zpolar_stereographic_(variant_b)r   r   )r   r   )zproj ob_tran o_proj=longlatzproj ob_tran o_proj=lonlatzproj ob_tran o_proj=latlonzproj ob_tran o_proj=latlongz$pole rotation (netcdf cf convention))G__doc__r   pyproj._crsr   r   r   pyproj.crs.coordinate_operationr   r   r   r	   r
   r   r   r   r   r   r   r   r   r   r   r   r   r   r   pyproj.crs.datumr   r   r   pyproj.exceptionsr   r5   rG   rM   r\   rd   rn   rq   rt   rz   r~   r   r   r   r   r   r   r   r   _GRID_MAPPING_NAME_MAP!_GEOGRAPHIC_GRID_MAPPING_NAME_MAPr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  _INVERSE_GRID_MAPPING_NAME_MAP)_INVERSE_GEOGRAPHIC_GRID_MAPPING_NAME_MAPr:   r@   r4   <module>r     s     7 7 7 7 7 7 7 7 7 7                                         * O N N N N N N N N N & & & & & &) ) )X	 	 	+ + +  "	 	 	  $	 	 	  0  *  ,  "	 	 	  ,           "<3#$A7&E)!/#/1  $ !"=% !
    &    *    4    2  8    .
 
 
          *":"$&C" :" ()>	"
 ()>" #$H" $%D" $%D" %&L" ," ," *+C" (" &'B" &'B"  $!"" *#"$ 78'" " " . $F"D"D#E,H- - ) ) )r@   