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
No related branches found
No related tags found
1 merge request!11Creation of first beta release version
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment