diff --git a/toargridding/metadata.py b/toargridding/metadata.py index 6584952be0ed3491f92050ad9f51f3c593642682..ad4794fa80be2b9fb024687390ec0681750a1c9f 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 fec25bc0be9f8a97a3c17fbd00534bee28c43720..82bd14f86874cb2b8c5f551e7465d54ace76c0fc 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