1414
1515import os
1616import warnings
17- from typing import Any , Dict , List , Optional , Sequence , Tuple , TypeVar
17+ from typing import Any , Optional , Sequence , TypeVar
1818
1919import fsspec
2020import numpy as np
3535def get_fs_path (
3636 urlpath_or_path : esa_safe .PathType ,
3737 fs : Optional [fsspec .AbstractFileSystem ] = None ,
38- storage_options : Optional [Dict [str , Any ]] = None ,
39- ) -> Tuple [fsspec .AbstractFileSystem , str ]:
38+ storage_options : Optional [dict [str , Any ]] = None ,
39+ ) -> tuple [fsspec .AbstractFileSystem , str ]:
4040 if fs is not None and storage_options is not None :
4141 raise TypeError ("only one of 'fs' and 'storage_options' can be not None" )
4242
@@ -58,7 +58,7 @@ def get_fs_path(
5858 return fs , path
5959
6060
61- def normalise_group (group : Optional [str ]) -> Tuple [str , Optional [int ]]:
61+ def normalise_group (group : Optional [str ]) -> tuple [str , Optional [int ]]:
6262 if group is None :
6363 group = ""
6464 if group .startswith ("/" ):
@@ -72,7 +72,7 @@ def normalise_group(group: Optional[str]) -> Tuple[str, Optional[int]]:
7272
7373
7474def open_calibration_dataset (
75- calibration : esa_safe .PathType , attrs : Dict [str , Any ] = {}
75+ calibration : esa_safe .PathType , attrs : dict [str , Any ] = {}
7676) -> xr .Dataset :
7777 calibration_vectors = esa_safe .parse_tag_as_list (
7878 calibration , ".//calibrationVector" , "calibration"
@@ -122,7 +122,7 @@ def open_calibration_dataset(
122122
123123
124124def open_reference_replica_dataset (
125- annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
125+ annotation_path : esa_safe .PathType , attrs : dict [str , Any ] = {}
126126) -> xr .Dataset :
127127 reference_replica = esa_safe .parse_tag_as_list (
128128 annotation_path , ".//replicaInformationList/replicaInformation/referenceReplica"
@@ -146,7 +146,7 @@ def open_reference_replica_dataset(
146146 float (v ) for v in reference_replica ["phaseCoefficients" ]["$" ].split ()
147147 ]
148148
149- coords : Dict [str , Any ] = {
149+ coords : dict [str , Any ] = {
150150 "degree" : range (len (reference_replica_amplitude_coefficients ))
151151 }
152152 data_vars = {
@@ -158,7 +158,7 @@ def open_reference_replica_dataset(
158158
159159
160160def open_antenna_pattern (
161- annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
161+ annotation_path : esa_safe .PathType , attrs : dict [str , Any ] = {}
162162) -> xr .Dataset :
163163 antenna_pattern_list = esa_safe .parse_tag_as_list (
164164 annotation_path , ".//antennaPattern/antennaPatternList/antennaPattern"
@@ -227,7 +227,7 @@ def open_antenna_pattern(
227227
228228
229229def open_replica_dataset (
230- annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
230+ annotation_path : esa_safe .PathType , attrs : dict [str , Any ] = {}
231231) -> xr .Dataset :
232232 replicaList = esa_safe .parse_tag_as_list (
233233 annotation_path ,
@@ -268,7 +268,7 @@ def open_replica_dataset(
268268 )
269269 internal_time_delay_list .append (replica ["internalTimeDelay" ])
270270
271- coords : Dict [str , Any ] = {
271+ coords : dict [str , Any ] = {
272272 "azimuth_time" : [np .datetime64 (dt , "ns" ) for dt in azimuth_time_list ],
273273 }
274274 data_vars = {
@@ -305,7 +305,7 @@ def open_replica_dataset(
305305
306306
307307def open_noise_range_dataset (
308- noise : esa_safe .PathType , attrs : Dict [str , Any ] = {}
308+ noise : esa_safe .PathType , attrs : dict [str , Any ] = {}
309309) -> xr .Dataset :
310310 noise_vectors = esa_safe .parse_tag_as_list (noise , ".//noiseRangeVector" , "noise" )
311311
@@ -338,7 +338,7 @@ def open_noise_range_dataset(
338338
339339
340340def open_noise_azimuth_dataset (
341- noise : esa_safe .PathType , attrs : Dict [str , Any ] = {}
341+ noise : esa_safe .PathType , attrs : dict [str , Any ] = {}
342342) -> xr .Dataset :
343343 noise_vectors = esa_safe .parse_tag_as_list (noise , ".//noiseAzimuthVector" , "noise" )
344344
@@ -365,7 +365,7 @@ def open_noise_azimuth_dataset(
365365
366366
367367def open_coordinate_conversion_dataset (
368- annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
368+ annotation_path : esa_safe .PathType , attrs : dict [str , Any ] = {}
369369) -> xr .Dataset :
370370 coordinate_conversion = esa_safe .parse_tag_as_list (
371371 annotation_path , ".//coordinateConversionList/coordinateConversion"
@@ -377,8 +377,8 @@ def open_coordinate_conversion_dataset(
377377 sr0 = []
378378 azimuth_time = []
379379 slant_range_time = []
380- srgrCoefficients : List [ List [float ]] = []
381- grsrCoefficients : List [ List [float ]] = []
380+ srgrCoefficients : list [ list [float ]] = []
381+ grsrCoefficients : list [ list [float ]] = []
382382 for values in coordinate_conversion :
383383 sr0 .append (values ["sr0" ])
384384 gr0 .append (values ["gr0" ])
@@ -391,8 +391,8 @@ def open_coordinate_conversion_dataset(
391391 [float (v ) for v in values ["grsrCoefficients" ]["$" ].split ()]
392392 )
393393
394- coords : Dict [str , Any ] = {}
395- data_vars : Dict [str , Any ] = {}
394+ coords : dict [str , Any ] = {}
395+ data_vars : dict [str , Any ] = {}
396396 coords ["azimuth_time" ] = [np .datetime64 (dt , "ns" ) for dt in azimuth_time ]
397397 coords ["degree" ] = list (range (len (srgrCoefficients [0 ])))
398398
@@ -405,13 +405,13 @@ def open_coordinate_conversion_dataset(
405405 return xr .Dataset (data_vars = data_vars , coords = coords , attrs = attrs )
406406
407407
408- def is_clockwise (poly : List [ Tuple [float , float ]]) -> bool :
408+ def is_clockwise (poly : list [ tuple [float , float ]]) -> bool :
409409 start = np .array (poly [0 ])
410410 return float (np .cross (poly [1 ] - start , poly [2 ] - start )) < 0
411411
412412
413413def open_gcp_dataset (
414- annotation : esa_safe .PathOrFileType , attrs : Dict [str , Any ] = {}
414+ annotation : esa_safe .PathOrFileType , attrs : dict [str , Any ] = {}
415415) -> xr .Dataset :
416416 geolocation_grid_points = esa_safe .parse_tag_as_list (
417417 annotation , ".//geolocationGridPoint"
@@ -468,8 +468,8 @@ def get_footprint_linestring(
468468 slant_range_time : xr .DataArray ,
469469 gcp : xr .Dataset ,
470470 method : xr .core .types .InterpOptions = "linear" ,
471- kwargs : Dict [str , Any ] = {"fill_value" : "extrapolate" },
472- ) -> List [ Tuple [float , float ]]:
471+ kwargs : dict [str , Any ] = {"fill_value" : "extrapolate" },
472+ ) -> list [ tuple [float , float ]]:
473473 azimuth_time_mm = [azimuth_time .min (), azimuth_time .max ()]
474474 slant_range_time_mm = [slant_range_time .min (), slant_range_time .max ()]
475475
@@ -504,8 +504,8 @@ def get_footprint_linestring(
504504
505505
506506def make_geospatial_attributes (
507- footprint : Sequence [Tuple [float , float ]],
508- ) -> Dict [str , Any ]:
507+ footprint : Sequence [tuple [float , float ]],
508+ ) -> dict [str , Any ]:
509509 wkt = "POLYGON((" + "," .join (f"{ y } { x } " for y , x in footprint ) + "))"
510510 geospatial_attrs = {
511511 "geospatial_bounds" : wkt ,
@@ -518,13 +518,13 @@ def make_geospatial_attributes(
518518
519519
520520def open_attitude_dataset (
521- annotation : esa_safe .PathOrFileType , attrs : Dict [str , Any ] = {}
521+ annotation : esa_safe .PathOrFileType , attrs : dict [str , Any ] = {}
522522) -> xr .Dataset :
523523 attitudes = esa_safe .parse_tag_as_list (annotation , ".//attitude" )
524524
525525 variables = ["q0" , "q1" , "q2" , "q3" , "wx" , "wy" , "wz" , "pitch" , "roll" , "yaw" ]
526- azimuth_time : List [Any ] = []
527- data_vars : Dict [str , Any ]
526+ azimuth_time : list [Any ] = []
527+ data_vars : dict [str , Any ]
528528 data_vars = {var : ("azimuth_time" , [], attrs ) for var in variables }
529529 for attitude in attitudes :
530530 azimuth_time .append (attitude ["time" ])
@@ -541,10 +541,10 @@ def open_attitude_dataset(
541541
542542
543543def make_orbit (
544- azimuth_time : List [Any ],
545- positions : List [ List [Any ]],
546- velocities : List [ List [Any ]],
547- attrs : Dict [str , Any ] = {},
544+ azimuth_time : list [Any ],
545+ positions : list [ list [Any ]],
546+ velocities : list [ list [Any ]],
547+ attrs : dict [str , Any ] = {},
548548) -> xr .Dataset :
549549 position = xr .Variable (data = positions , dims = ("axis" , "azimuth_time" ))
550550 velocity = xr .Variable (data = velocities , dims = ("axis" , "azimuth_time" ))
@@ -564,7 +564,7 @@ def make_orbit(
564564
565565
566566def open_orbit_dataset (
567- annotation : esa_safe .PathOrFileType , attrs : Dict [str , Any ] = {}
567+ annotation : esa_safe .PathOrFileType , attrs : dict [str , Any ] = {}
568568) -> xr .Dataset :
569569 orbits = esa_safe .parse_tag_as_list (annotation , ".//orbit" )
570570
@@ -573,9 +573,9 @@ def open_orbit_dataset(
573573 if reference_system is not None :
574574 attrs .update ({"reference_system" : reference_system })
575575
576- azimuth_times : List [Any ] = []
577- positions : List [ List [Any ]] = [[], [], []]
578- velocities : List [ List [Any ]] = [[], [], []]
576+ azimuth_times : list [Any ] = []
577+ positions : list [ list [Any ]] = [[], [], []]
578+ velocities : list [ list [Any ]] = [[], [], []]
579579 for orbit in orbits :
580580 azimuth_times .append (orbit ["time" ])
581581 positions [0 ].append (orbit ["position" ]["x" ])
@@ -594,7 +594,7 @@ def open_orbit_dataset(
594594
595595
596596def open_dc_estimate_dataset (
597- annotation : esa_safe .PathOrFileType , attrs : Dict [str , Any ] = {}
597+ annotation : esa_safe .PathOrFileType , attrs : dict [str , Any ] = {}
598598) -> xr .Dataset :
599599 dc_estimates = esa_safe .parse_tag_as_list (annotation , ".//dcEstimate" )
600600
@@ -656,7 +656,7 @@ def open_dc_estimate_dataset(
656656
657657
658658def open_azimuth_fm_rate_dataset (
659- annotation : esa_safe .PathOrFileType , attrs : Dict [str , Any ] = {}
659+ annotation : esa_safe .PathOrFileType , attrs : dict [str , Any ] = {}
660660) -> xr .Dataset :
661661 azimuth_fm_rates = esa_safe .parse_tag_as_list (annotation , ".//azimuthFmRate" )
662662
@@ -693,13 +693,13 @@ def open_azimuth_fm_rate_dataset(
693693
694694
695695def find_available_groups (
696- product_files : Dict [str , Tuple [str , str , str , str , str ]],
696+ product_files : dict [str , tuple [str , str , str , str , str ]],
697697 product_path : str ,
698698 product_type : str ,
699699 check_files_exist : bool = False ,
700700 fs : fsspec .AbstractFileSystem = fsspec .filesystem ("file" ),
701- ) -> Dict [str , List [str ]]:
702- groups : Dict [str , List [str ]] = {}
701+ ) -> dict [str , list [str ]]:
702+ groups : dict [str , list [str ]] = {}
703703 for path , (type , _ , swath , polarization , _ ) in product_files .items ():
704704 swath_pol_group = f"{ swath } /{ polarization } " .upper ()
705705 abspath = os .path .join (product_path , os .path .normpath (path ))
@@ -738,7 +738,7 @@ def find_available_groups(
738738def open_rasterio_dataarray (
739739 measurement : esa_safe .PathOrFileType ,
740740 fs : Optional [fsspec .AbstractFileSystem ],
741- chunks : Optional [Dict [str , int ]],
741+ chunks : Optional [dict [str , int ]],
742742) -> xr .DataArray :
743743 # fsspec needs rasterio >= 1.3.0, but we allow earlier rasterio versions for local files
744744 if fs is None or isinstance (fs , fsspec .implementations .local .LocalFileSystem ):
@@ -776,7 +776,7 @@ def open_pol_dataset(
776776 measurement : esa_safe .PathOrFileType ,
777777 annotation : esa_safe .PathOrFileType ,
778778 fs : Optional [fsspec .AbstractFileSystem ] = None ,
779- attrs : Dict [str , Any ] = {},
779+ attrs : dict [str , Any ] = {},
780780 gcp : Optional [xr .Dataset ] = None ,
781781) -> xr .Dataset :
782782 product_information = esa_safe .parse_tag (annotation , ".//productInformation" )
@@ -811,7 +811,7 @@ def open_pol_dataset(
811811 )
812812 encoding = {}
813813 swap_dims = {}
814- chunks : Optional [Dict [str , int ]] = None
814+ chunks : Optional [dict [str , int ]] = None
815815
816816 azimuth_time = make_azimuth_time (
817817 product_first_line_utc_time ,
@@ -1145,8 +1145,8 @@ def ground_range_to_slant_range_time(
11451145
11461146
11471147def do_override_product_files (
1148- template : str , product_files : Dict [str , Tuple [str , str , str , str , str ]]
1149- ) -> Dict [str , Tuple [str , str , str , str , str ]]:
1148+ template : str , product_files : dict [str , tuple [str , str , str , str , str ]]
1149+ ) -> dict [str , tuple [str , str , str , str , str ]]:
11501150 overridden_product_files = {}
11511151 for path , description in product_files .items ():
11521152 type , prefix , swath , polarization , date = description
@@ -1160,10 +1160,10 @@ def do_override_product_files(
11601160def open_sentinel1_dataset (
11611161 product_urlpath : esa_safe .PathType ,
11621162 * ,
1163- drop_variables : Optional [Tuple [str ]] = None ,
1163+ drop_variables : Optional [tuple [str ]] = None ,
11641164 group : Optional [str ] = None ,
11651165 fs : Optional [fsspec .AbstractFileSystem ] = None ,
1166- storage_options : Optional [Dict [str , Any ]] = None ,
1166+ storage_options : Optional [dict [str , Any ]] = None ,
11671167 check_files_exist : bool = False ,
11681168 override_product_files : Optional [str ] = None ,
11691169 parse_geospatial_attrs : bool = True ,
0 commit comments