Skip to content

Commit

Permalink
fix lookup problems with TimeSeriesSubsetArrayField
Browse files Browse the repository at this point in the history
  • Loading branch information
jpprins1 committed Dec 15, 2023
1 parent 079728d commit 428f127
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 3 additions & 2 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ History
2.2.2 (unreleased)
------------------

- Nothing changed yet.

- Bugfix: correct sorting of timeseries in all `TimeSeriesSubsetArrayField`. This
affected: Nodes [infiltration_rate_simple, ucx, ucy, leak, intercepted_volume, q_sss]
Lines: [qp, up1, breach_depth, breach_width]

2.2.1 (2023-12-05)
------------------
Expand Down
6 changes: 2 additions & 4 deletions threedigrid/orm/base/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ def get_value(self, datasource, name, **kwargs):
# to support h5py >= 3.1.0
timeseries_filter_to_use = np.argwhere(timeseries_filter).flatten()

lookup_index = kwargs.get("lookup_index")
if self._source_name not in list(datasource.keys()):
return np.array([])
source_data = datasource[self._source_name][timeseries_filter_to_use, :]
Expand All @@ -249,11 +248,10 @@ def get_value(self, datasource, name, **kwargs):
if source_data.shape[1] == subset_index.shape[0] - 1:
subset_index = subset_index[1:]

# Note: subset_index already contains correct sorting
# that matches with the NetCDF timeseries.
templ[:, subset_index] = source_data

# sort the stacked array by lookup
if lookup_index is not None:
return templ[:, lookup_index]
return templ

def __repr__(self):
Expand Down

0 comments on commit 428f127

Please sign in to comment.