From 6388b9810e97105ef0240b95eef7414c47d758ac Mon Sep 17 00:00:00 2001 From: Carsten Hinz <c.hinz@fz-juelich.de> Date: Wed, 8 May 2024 15:17:31 +0200 Subject: [PATCH] changed id in metadata to include additional input data. uncommented some debug output update to dropping of timestamps that is required for some datasets... --- toargridding/metadata.py | 7 ++++--- toargridding/toar_rest_client.py | 11 +++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/toargridding/metadata.py b/toargridding/metadata.py index 6584952..ad4794f 100644 --- a/toargridding/metadata.py +++ b/toargridding/metadata.py @@ -61,8 +61,8 @@ class TimeSample: def as_datetime_index(self) -> pd.DatetimeIndex: """Conversion to array with all sampled time points """ - print(self.start) - print(self.end) + #print(self.start) + #print(self.end) return pd.period_range(self.start, self.end, freq=self.frequency).to_timestamp() @property @@ -149,7 +149,8 @@ class Metadata: For example, used for saving link to results of a request in the cache. """ - return f"{self.variable.name}_{self.statistic}_{self.time.daterange_option}_at_{datetime.now().date().isoformat()}" + addition = "_".join(str(i) for i in self.moreOptions.values()) + return "_".join(str(i) for i in [self.variable.name, self.statistic, self.time.daterange_option, addition, "at", datetime.now().date().isoformat()]) def get_title(self) -> str: """creation of a title for metadata of a xarray according to the CF convention diff --git a/toargridding/toar_rest_client.py b/toargridding/toar_rest_client.py index fec25bc..82bd14f 100644 --- a/toargridding/toar_rest_client.py +++ b/toargridding/toar_rest_client.py @@ -351,12 +351,15 @@ class AnalysisService: ##here we observe some differences in the number of timestamps. # remove data where utc -> sun/local ? time conversion leads to dateshift newDates = metadata.time.as_datetime_index() - if len(timeseries.columns) == len(newDates)+2: - print(f"Info: removed columns {timeseries.columns[0]} and {timeseries.columns[-1]} to match data range of {newDates[0]} to {newDates[-1]}") - timeseries.drop(columns=[first, last], inplace=True) - elif len(timeseries.columns) == len(newDates)+1: + lenDiff = len(timeseries.columns) - len(newDates) + if lenDiff == 0: + print(f"Info: Obtained data range covers {newDates[0]} to {newDates[-1]}") + elif lenDiff == 1: print(f"Info: removed columns {timeseries.columns[-1]} to match data range of {newDates[0]} to {newDates[-1]}") timeseries.drop(columns=[last], inplace=True) + elif lenDiff == 2: + print(f"Info: removed columns {timeseries.columns[0]} and {timeseries.columns[-1]} to match data range of {newDates[0]} to {newDates[-1]}") + timeseries.drop(columns=[first, last], inplace=True) else: raise RuntimeError(f"There is a mismatch in the timestamps...\nDownloaded:{timeseries.columns}\nFrom Metadata: {newDates}") timeseries.columns = newDates -- GitLab