Skip to content
Snippets Groups Projects

Resolve "release v1.4.0"

Merged Ghost User requested to merge release_v1.4.0 into master
1 file
+ 22
3
Compare changes
  • Side-by-side
  • Inline
+ 22
3
@@ -212,20 +212,36 @@ class ClimateFIRFilter:
# apriori starts after data
if dates[0] < apriori.coords[time_dim].values[0]:
logging.info(f"{data.coords['Stations'].values[0]}: apriori starts after data")
# add difference in full years
date_diff = abs(dates[0] - apriori.coords[time_dim].values[0]).astype("timedelta64[D]")
extend_range = np.ceil(date_diff / (np.timedelta64(1, "D") * 365)).astype(int) * 365
coords = apriori.coords
# create new time axis
start = coords[time_dim][0].values.astype("datetime64[%s]" % td_type) - np.timedelta64(extend_range, "D")
# start = coords[time_dim][0].values.astype("datetime64[%s]" % td_type) - np.timedelta64(extend_range, "D")
# end = coords[time_dim][0].values.astype("datetime64[%s]" % td_type)
# new_time_axis = np.arange(start, end).astype("datetime64[ns]")
factor = 1 if td_type == "D" else 24
start = coords[time_dim][0].values.astype("datetime64[%s]" % td_type) - np.timedelta64(
extend_range * factor + 1,
td_type)
end = coords[time_dim][0].values.astype("datetime64[%s]" % td_type)
new_time_axis = np.arange(start, end).astype("datetime64[ns]")
logging.info(f"{data.coords['Stations'].values[0]}: shape of new_time_axis = {new_time_axis.shape}")
# extract old values to use with new axis
start = coords[time_dim][0].values.astype("datetime64[D]")
end = coords[time_dim][0].values.astype("datetime64[D]") + np.timedelta64(extend_range - 1, "D")
# start = coords[time_dim][0].values.astype("datetime64[D]")
# end = coords[time_dim][0].values.astype("datetime64[D]") + np.timedelta64(extend_range - 1, "D")
# new_values = apriori.sel({time_dim: slice(start, end)})
# new_values.coords[time_dim] = new_time_axis
start = coords[time_dim][0].values.astype("datetime64[%s]" % td_type)
end = coords[time_dim][0].values.astype("datetime64[%s]" % td_type) + np.timedelta64(
extend_range * factor - 1, td_type)
new_values = apriori.sel({time_dim: slice(start, end)})
logging.info(f"{data.coords['Stations'].values[0]}: shape of new_values = {new_values.shape}")
new_values.coords[time_dim] = new_time_axis
# add new values to apriori
@@ -233,6 +249,7 @@ class ClimateFIRFilter:
# apriori ends before data
if dates[-1] + np.timedelta64(365, "D") > apriori.coords[time_dim].values[-1]:
logging.info(f"{data.coords['Stations'].values[0]}: apriori ends before data")
# add difference in full years + 1 year (because apriori is used as future estimate)
date_diff = abs(dates[-1] - apriori.coords[time_dim].values[-1]).astype("timedelta64[D]")
extend_range = np.ceil(date_diff / (np.timedelta64(1, "D") * 365)).astype(int) * 365 + 365
@@ -245,6 +262,7 @@ class ClimateFIRFilter:
extend_range * factor + 1,
td_type)
new_time_axis = np.arange(start, end).astype("datetime64[ns]")
logging.info(f"{data.coords['Stations'].values[0]}: shape of new_time_axis = {new_time_axis.shape}")
# extract old values to use with new axis
start = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type) - np.timedelta64(
@@ -253,6 +271,7 @@ class ClimateFIRFilter:
# extend_range * factor, td_type)
end = coords[time_dim][-1].values.astype("datetime64[%s]" % td_type)
new_values = apriori.sel({time_dim: slice(start, end)})
logging.info(f"{data.coords['Stations'].values[0]}: shape of new_values = {new_values.shape}")
new_values.coords[time_dim] = new_time_axis
# add new values to apriori
Loading