Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions examples/example_model_along_trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

print(ta.versions())

import logging
logging.basicConfig(level=logging.DEBUG)

#%%
# Open drifter dataset from a CSV file
ds = ta.read_csv('bug05_pos.csv.xz',
Expand All @@ -38,11 +35,8 @@
#%%
# Grid the drifter dataset to the timesteps of the model.
times = nk.sel(time=slice('2022-05-10', '2022-05-20')).time.values
print(times, 'Drifter times')
ds = ds.traj.gridtime(times)
print('Dropping na')
ds = ds.dropna('time', how='all')
print('Dropped na')

print(ds)

Expand All @@ -62,9 +56,6 @@
#%%
# Notice that the `lat` and `lon` variables from Norkyst match the original `lat` and `lon` from the dataset.

try:
plt.figure()
temp.plot()
plt.show()
except:
print('Could not plot data')
plt.figure()
temp.plot()
plt.show()
2 changes: 2 additions & 0 deletions trajan/traj1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,8 +322,10 @@ def gridtime(self, times, time_varname=None, round=True):
times = times.to_numpy()

time_varname = self.time_varname if time_varname is None else time_varname
times = times.astype(self.ds[time_varname].dtype) # Make sure we have same dtype for ds and times array

ds = self.ds.copy()

# We fill NaN-values in time coordinate to be able to interpolate
ds[time_varname] = ds[time_varname].interpolate_na(
dim=time_varname, method='linear', fill_value='extrapolate', use_coordinate=False)
Expand Down
Loading