Skip to content

Commit 987ed14

Browse files
committed
Fix for failing pytest regarding duplicate TIME values
1 parent 5d83875 commit 987ed14

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

aodntools/timeseries_products/common.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,11 @@ def in_water(nc):
190190
:param nc: xarray dataset
191191
:return: xarray dataset
192192
"""
193-
194-
condition = in_water_index(nc) # This returns a numpy array
195-
# Wrap the condition in a DataArray so that it aligns with the TIME coordinate.
196-
cond_da = xr.DataArray(condition, dims=["TIME"], coords={"TIME": nc["TIME"].values})
197-
return nc.where(cond_da, drop=True)
198-
193+
condition = in_water_index(nc) # NumPy boolean array
194+
# Get the integer indices where condition is True.
195+
indices = np.nonzero(condition)[0]
196+
# Use positional indexing to select the TIME entries that satisfy the condition.
197+
return nc.isel(TIME=indices)
199198

200199
def current_utc_timestamp(format=TIMESTAMP_FORMAT):
201200
return datetime.now(timezone.utc).strftime(format)

0 commit comments

Comments
 (0)