Skip to content
Snippets Groups Projects
Commit 6388b981 authored by Carsten Hinz's avatar Carsten Hinz
Browse files

changed id in metadata to include additional input data.

uncommented some debug output
update to dropping of timestamps that is required for some datasets...
parent a27250e0
Branches
Tags
1 merge request!11Creation of first beta release version
...@@ -61,8 +61,8 @@ class TimeSample: ...@@ -61,8 +61,8 @@ class TimeSample:
def as_datetime_index(self) -> pd.DatetimeIndex: def as_datetime_index(self) -> pd.DatetimeIndex:
"""Conversion to array with all sampled time points """Conversion to array with all sampled time points
""" """
print(self.start) #print(self.start)
print(self.end) #print(self.end)
return pd.period_range(self.start, self.end, freq=self.frequency).to_timestamp() return pd.period_range(self.start, self.end, freq=self.frequency).to_timestamp()
@property @property
...@@ -149,7 +149,8 @@ class Metadata: ...@@ -149,7 +149,8 @@ class Metadata:
For example, used for saving link to results of a request in the cache. 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: def get_title(self) -> str:
"""creation of a title for metadata of a xarray according to the CF convention """creation of a title for metadata of a xarray according to the CF convention
......
...@@ -351,12 +351,15 @@ class AnalysisService: ...@@ -351,12 +351,15 @@ class AnalysisService:
##here we observe some differences in the number of timestamps. ##here we observe some differences in the number of timestamps.
# remove data where utc -> sun/local ? time conversion leads to dateshift # remove data where utc -> sun/local ? time conversion leads to dateshift
newDates = metadata.time.as_datetime_index() newDates = metadata.time.as_datetime_index()
if len(timeseries.columns) == len(newDates)+2: lenDiff = len(timeseries.columns) - len(newDates)
print(f"Info: removed columns {timeseries.columns[0]} and {timeseries.columns[-1]} to match data range of {newDates[0]} to {newDates[-1]}") if lenDiff == 0:
timeseries.drop(columns=[first, last], inplace=True) print(f"Info: Obtained data range covers {newDates[0]} to {newDates[-1]}")
elif len(timeseries.columns) == len(newDates)+1: elif lenDiff == 1:
print(f"Info: removed columns {timeseries.columns[-1]} to match data range of {newDates[0]} to {newDates[-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) 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: else:
raise RuntimeError(f"There is a mismatch in the timestamps...\nDownloaded:{timeseries.columns}\nFrom Metadata: {newDates}") raise RuntimeError(f"There is a mismatch in the timestamps...\nDownloaded:{timeseries.columns}\nFrom Metadata: {newDates}")
timeseries.columns = newDates timeseries.columns = newDates
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment