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
28 stars 8 forks source link

RCM start_date #164

Closed vincelhx closed 1 year ago

vincelhx commented 1 year ago
filename_RCM1 = '/home/datawork-cersat-public/provider/asc-csa/satellite/l1/rcm/rcm1/SCLNB/GRD/2022/357/RCM1_OK2411022_PK2411802_1_SCLNB_20221223_124819_VV_VH_GRD'
filename_RCM2 = "/home/datawork-cersat-public/provider/asc-csa/satellite/l1/rcm/rcm1/SCLNC/GRD/2023/048/RCM1_OK2448377_PK2450339_1_SCLNC_20230217_002007_VV_VH_GRD"
m1 = xsar.RcmMeta(filename_RCM1)
m2 = xsar.RcmMeta(filename_RCM2)
m1.start_date,m2.start_date

gives ('2022-12-23 12:48:04.736000', '2023-02-17 00:20:06')

can we be homogeneous and use format '%Y-%m-%d %H:%M:%S.%f' to avoid these errors :

File ~/libs_last/xsar_forkVinc/xsar/src/xsar/base_dataset.py:828, in BaseDataset._load_rasters_vars(self)
    824 get_function = infos['get_function']
    825 resource = infos['resource']
    827 kwargs_get = {
--> 828     'date': datetime.strptime(self.sar_meta.start_date, '%Y-%m-%d %H:%M:%S.%f'),
    829     'footprint': self.sar_meta.footprint
    830 }
    832 logger.debug('adding raster "%s" from resource "%s"' % (name, str(resource)))
    833 if get_function is not None:

File /home1/datawork/vlheureu/conda-env/xsar_N/lib/python3.10/_strptime.py:568, in _strptime_datetime(cls, data_string, format)
    565 def _strptime_datetime(cls, data_string, format="%a %b %d %H:%M:%S %Y"):
    566     """Return a class cls instance based on the input string and the
    567     format string."""
--> 568     tt, fraction, gmtoff_fraction = _strptime(data_string, format)
    569     tzname, gmtoff = tt[-2:]
    570     args = tt[:6] + (fraction,)

File /home1/datawork/vlheureu/conda-env/xsar_N/lib/python3.10/_strptime.py:349, in _strptime(data_string, format)
    347 found = format_regex.match(data_string)
    348 if not found:
--> 349     raise ValueError("time data %r does not match format %r" %
    350                      (data_string, format))
    351 if len(data_string) != found.end():
    352     raise ValueError("unconverted data remains: %s" %
    353                       data_string[found.end():])

ValueError: time data '2023-02-17 00:20:06' does not match format '%Y-%m-%d %H:%M:%S.%f'

else i can do a little modification but i think it would be clearer to be homogeneous

yreynaud commented 1 year ago

A PR is solving this issue : https://github.com/umr-lops/xsar/pull/167