File tree Expand file tree Collapse file tree
aodntools/timeseries_products Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22from datetime import datetime , timezone
33
44import numpy as np
5+ import xarray as xr
56
67# Common date/time format strings
78TIMESTAMP_FORMAT = '%Y-%m-%dT%H:%M:%SZ'
@@ -179,7 +180,7 @@ def in_water_index(nc):
179180 """
180181 time_deployment_start = np .datetime64 (nc .attrs ['time_deployment_start' ][:- 1 ])
181182 time_deployment_end = np .datetime64 (nc .attrs ['time_deployment_end' ][:- 1 ])
182- TIME = nc ['TIME' ][:]
183+ TIME = nc ['TIME' ]. values
183184 return (TIME >= time_deployment_start ) & (TIME <= time_deployment_end )
184185
185186def in_water (nc ):
@@ -189,7 +190,11 @@ def in_water(nc):
189190 :param nc: xarray dataset
190191 :return: xarray dataset
191192 """
192- return nc .where (in_water_index (nc ), drop = True )
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 )
193198
194199
195200def current_utc_timestamp (format = TIMESTAMP_FORMAT ):
You can’t perform that action at this time.
0 commit comments