Skip to content

Commit 6c5311d

Browse files
committed
Removing some unused imports, and cleaning some gallery scripts
1 parent 9d2ad76 commit 6c5311d

10 files changed

Lines changed: 7 additions & 25 deletions

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@ pip install trajan
2626
TrajAn exposes a `.traj` accessor on xarray Datasets:
2727

2828
```python
29-
import lzma
3029
import xarray as xr
3130
import trajan as ta
3231

3332
# Open a CF-trajectory dataset (e.g. from drifting buoys)
34-
with lzma.open("barents.nc.xz") as f:
35-
ds = xr.open_dataset(f)
36-
ds.load()
33+
ds = xr.open_dataset('barents.nc')
3734

3835
# Basic map plot — geographic projection is chosen automatically
3936
ds.traj.plot()

examples/data_dir/test.nc

0 Bytes
Binary file not shown.

examples/example_animation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
``.show()`` to display interactively or ``.save()`` to write a file.
88
"""
99
import logging
10-
import lzma
1110
import numpy as np
1211
import xarray as xr
1312
import coloredlogs

examples/example_concat.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,8 @@
33
==============================
44
"""
55
import numpy as np
6-
import lzma
76
import matplotlib.pyplot as plt
8-
import cartopy.crs as ccrs
97
import xarray as xr
10-
import pandas as pd
118
import trajan as ta
129

1310
#%%

examples/example_drifter_csv.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Read a position log from a CSV file and convert it to a CF-compatible dataset
33
=============================================================================
44
"""
5-
import pandas as pd
65
import trajan as ta
76
import matplotlib.pyplot as plt
87

@@ -14,4 +13,3 @@
1413
ds.traj.plot(color=None, label=ds.trajectory.values)
1514
plt.legend()
1615
plt.show()
17-

examples/example_drifters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
============================
44
"""
55
import numpy as np
6-
import lzma
76
import matplotlib.pyplot as plt
87
import cartopy.crs as ccrs
98
import xarray as xr

examples/example_nc_particles.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,21 @@
1616
ds = xr.open_dataset(ta.DATA_DIR + 'gnome_nc_particles.nc')
1717
print(ds)
1818

19-
print(ds.traj)
20-
2119
#%%
22-
# Basic plot
23-
ds.traj.plot(land='mask')
20+
# Displaying what is detected by TrajAn
21+
print(ds.traj)
2422

2523
#%%
26-
# Convert from Ragged to Orthogonal
27-
ds_ortho = ds.traj.gridtime('1h')
24+
# Plotting
2825

29-
#%%
30-
# Plotting a mean trajectory
26+
ds.traj.plot(land='mask') # plotting all trajectories
27+
ds_ortho = ds.traj.gridtime('1h') # convert from Ragged to Orthogonal
3128
ds_ortho.mean('trajectory').traj.plot(color='r', label='Mean trajectory')
32-
33-
#%%
3429
# Plotting initial and final element locations, and a convex hull
3530
ds_ortho.isel(time=0).traj.plot.scatter(color='k', s=80, zorder=100, label='Initial positions')
3631
ds_ortho.isel(time=-1).traj.plot.scatter(color='b', s=80, zorder=100, label='Final positions')
3732
ds_ortho.isel(time=-1).traj.plot.convex_hull(color='g', label='Convex hull of final positions')
3833
#ds_ortho.isel(time=10).traj.plot.convex_hull(color='y', label='Convex hull after 10 hours')
39-
4034
plt.legend()
4135
plt.title('Sample trajectory dataset from nc_particles repository')
4236
plt.show()

examples/example_opendrift.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Analysing output from OpenDrift
33
===============================
44
"""
5-
import lzma
65
import matplotlib.pyplot as plt
76
import xarray as xr
87
import trajan as ta

tests/test_seltime.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import xarray as xr
33
import pandas as pd
44
import numpy as np
5-
import matplotlib.pyplot as plt
65

76

87
def test_seltime(barents):

trajan/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ def trajectory_dict_to_dataset(trajectory_dict,
251251
else:
252252
variable_attributes[var] = {}
253253
time = np.empty((num_drifters, num_times), dtype='datetime64[s]')
254-
time[:] = np.datetime64('nat')
254+
time[:] = np.datetime64('NaT', 's')
255255

256256
# Fill arrays with data from dictionaries
257257
for drifter_num, (drifter_name,

0 commit comments

Comments
 (0)