umr-lops / xsar

Synthetic Aperture Radar (SAR) Level-1 GRD python mapper for efficient xarray/dask based processing
https://cyclobs.ifremer.fr/static/sarwing_datarmor/xsar/
MIT License
24 stars 8 forks source link

issue WV noise patch #181

Closed agrouaze closed 9 months ago

agrouaze commented 10 months ago

traceback

ff = 'SENTINEL1_DS:/home/datawork-cersat-public/cache/project/mpc-sentinel1/data/esa/sentinel-1a/L1/WV/S1A_WV_SLC__1S/2018/002/S1A_WV_SLC__1SSV_20180102T001727_20180102T003647_019968_022027_5FBD.SAFE
   ...: /:WV_001'

In [9]: xsar.open_dataset(ff,resolution=100)
path: /home/datawork-cersat-public/cache/project/mpc-sentinel1/data/esa/sentinel-1a/L1/WV/S1A_WV_SLC__1S/2018/002/S1A_WV_SLC__1SSV_20180102T001727_20180102T003647_019968_022027_5FBD.SAFE/
---------------------------------------------------------------------------
KeyError                                  Traceback (most recent call last)
File /opt/conda-envs/dev/lib/python3.10/site-packages/xarray/core/dataset.py:1393, in Dataset._construct_dataarray(self, name)
   1392 try:
-> 1393     variable = self._variables[name]
   1394 except KeyError:

KeyError: 'noise_lut'

During handling of the above exception, another exception occurred:

KeyError                                  Traceback (most recent call last)
Cell In[9], line 1
----> 1 xsar.open_dataset(ff,resolution=100)

File /home1/datahome/agrouaze/sources/git/xsar/src/xsar/utils.py:94, in timing.<locals>.wrapper(*args, **kwargs)
     92     startrss = process.memory_info().rss
     93 starttime = time.time()
---> 94 result = f(*args, **kwargs)
     95 endtime = time.time()
     96 if mem_monitor:

File /home1/datahome/agrouaze/sources/git/xsar/src/xsar/xsar.py:68, in open_dataset(*args, **kwargs)
     66 # TODO: check product type (S1, RS2), and call specific reader
     67 if isinstance(dataset_id, Sentinel1Meta) or isinstance(dataset_id, str) and "S1" in dataset_id:
---> 68     sar_obj = Sentinel1Dataset(*args, **kwargs)
     69 elif isinstance(dataset_id, RadarSat2Meta) or isinstance(dataset_id, str) and "RS2" in dataset_id:
     70     sar_obj = RadarSat2Dataset(*args, **kwargs)

File /home1/datahome/agrouaze/sources/git/xsar/src/xsar/sentinel1_dataset.py:153, in Sentinel1Dataset.__init__(***failed resolving arguments***)
    151 ds_noise_azi = self.sar_meta.get_noise_azi_raw
    152 if self.sar_meta.swath == 'WV':
--> 153     ds_noise_azi['noise_lut'] = self._patch_lut(ds_noise_azi[
    154                                                     'noise_lut'])  # patch applied here is distinct to same patch applied on interpolated noise LUT
    155 ds_noise_azi.attrs['history'] = 'noise'
    157 self.datatree = datatree.DataTree.from_dict({'measurement': DN_tmp, 'geolocation_annotation': geoloc,
    158                                              'bursts': bu, 'FMrate': FM, 'doppler_estimate': dop,
    159                                              # 'image_information':
   (...)
    164                                              'noise_azimuth': ds_noise_azi
    165                                              })

File /opt/conda-envs/dev/lib/python3.10/site-packages/xarray/core/dataset.py:1484, in Dataset.__getitem__(self, key)
   1482     return self.isel(**key)
   1483 if utils.hashable(key):
-> 1484     return self._construct_dataarray(key)
   1485 if utils.iterable_of_hashable(key):
   1486     return self._copy_listed(key)

File /opt/conda-envs/dev/lib/python3.10/site-packages/xarray/core/dataset.py:1395, in Dataset._construct_dataarray(self, name)
   1393     variable = self._variables[name]
   1394 except KeyError:
-> 1395     _, name, variable = _get_virtual_variable(self._variables, name, self.dims)
   1397 needed_dims = set(variable.dims)
   1399 coords: dict[Hashable, Variable] = {}

File /opt/conda-envs/dev/lib/python3.10/site-packages/xarray/core/dataset.py:196, in _get_virtual_variable(variables, key, dim_sizes)
    194 split_key = key.split(".", 1)
    195 if len(split_key) != 2:
--> 196     raise KeyError(key)
    198 ref_name, var_name = split_key
    199 ref_var = variables[ref_name]

KeyError: 'noise_lut'