Skip to content

Commit 7d69d00

Browse files
committed
Fix some remaining bugs in previous commit
1 parent 67cb477 commit 7d69d00

5 files changed

Lines changed: 7 additions & 10 deletions

File tree

examples/data_dir/test.nc

0 Bytes
Binary file not shown.

examples/example_concentration.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
import numpy as np
66
import matplotlib.pyplot as plt
77
import xarray as xr
8-
import trajan as _
8+
import trajan as ta
99

1010
#%%
1111
# Demonstrating calculation and plotting of gridded concentrations
1212

1313
#%%
1414
# Importing a trajectory dataset from an oil drift simulation (OpenOil)
15-
ds = xr.open_dataset('opv2025_subset.nc')
15+
ds = xr.open_dataset(ta.DATA_DIR + 'opv2025_subset.nc')
1616

1717
#%%
1818
# Make a grid covering this dataset with a horizontal resolution of 200m

examples/example_drifters.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@
129129
# **Speed filter** — positions from which the speed to the next observation
130130
# exceeds a given threshold (here 3 m/s) are masked. We reload the original
131131
# (uncleaned) dataset to illustrate the effect.
132-
with lzma.open('barents.nc.xz') as barents:
133-
ds_raw = xr.open_dataset(barents)
134-
ds_raw.load()
135-
132+
ds_raw = xr.open_dataset(ta.DATA_DIR + 'barents.nc')
136133
ds_speed = ds_raw.traj.filter(method='speed', max_speed=3.)
137134

138135
#%%

trajan/traj/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,12 @@ def assign_cf_attrs(self,
633633
'time_coverage_start':
634634
pd.to_datetime(
635635
np.nanmin(ds[self.time_varname].values[ds[
636-
self.time_varname].values != np.datetime64('NaT', 'ns')])).
636+
self.time_varname].values != np.datetime64('NaT', 's')])).
637637
isoformat() if self.ds.sizes[self.obs_dim] > 0 else np.nan,
638638
'time_coverage_end':
639639
pd.to_datetime(
640640
np.nanmax(ds[self.time_varname].values[ds[
641-
self.time_varname].values != np.datetime64('NaT', 'ns')])
641+
self.time_varname].values != np.datetime64('NaT', 's')])
642642
).isoformat() if self.ds.sizes[self.obs_dim] > 0 else np.nan,
643643
})
644644

trajan/traj/ragged.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def from_contiguous(ds, trajectory_dim, obs_dim, time_varname,
100100
# the time var (special case as it is of a different type)
101101

102102
array_time = np.full((nbr_trajectories, longest_trajectory),
103-
np.datetime64('NaT', 'ns'),
103+
np.datetime64('NaT', 's'),
104104
dtype='datetime64[ns]')
105105

106106
start_index = 0
@@ -389,7 +389,7 @@ def insert_nan_where(self, condition):
389389
s = np.split(olddata, insert_indices)
390390

391391
if np.issubdtype(var.dtype, np.datetime64):
392-
na = np.atleast_1d(np.datetime64('NaT', 'ns'))
392+
na = np.atleast_1d(np.datetime64('NaT', 's'))
393393
else:
394394
na = np.atleast_1d(np.nan)
395395
newdata = np.concatenate(

0 commit comments

Comments
 (0)