Skip to content

Commit dac0782

Browse files
- pet_storage complements (AntSimi#67)
- orthograph in __init__ - no capitals field_table to get same field name as in .nc
1 parent 267aec5 commit dac0782

File tree

3 files changed

+38
-33
lines changed

3 files changed

+38
-33
lines changed

examples/01_general_things/pet_storage.py

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
55
General information about eddies storage.
66
7-
All eddies files have same structure with more or less field and a way of ordering.
7+
All files have the same structure, with more or less fields and possible different order.
88
99
There are 3 class of files:
1010
11-
- Eddies collections which contains a list of eddies without link between observations
12-
- Track eddies collections which manage eddies when there are merged in trajectory
13-
(track field allow to separate each track)
14-
- Network eddies collections which manage eddies when there are merged in network
15-
(track/segment field allow to separate observations)
11+
- **Eddies collections** : contain a list of eddies without link between them
12+
- **Track eddies collections** : manage eddies associated in trajectories, the ```track``` field allows to separate each trajectory
13+
- **Network eddies collections** : manage eddies associated in networks, the ```track``` and ```segment``` fields allow to separate observations
1614
"""
1715

1816
import py_eddy_tracker_sample
@@ -23,7 +21,7 @@
2321
from py_eddy_tracker.observations.tracking import TrackEddiesObservations
2422

2523
# %%
26-
# Eddies could be store in 2 formats with same structures:
24+
# Eddies can be stored in 2 formats with the same structure:
2725
#
2826
# - zarr (https://zarr.readthedocs.io/en/stable/), which allow efficiency in IO,...
2927
# - NetCDF4 (https://unidata.github.io/netcdf4-python/), well-known format
@@ -32,16 +30,20 @@
3230
# array field like contour/profile are 2D column.
3331

3432
# %%
35-
# Eddies files (zarr or netcdf) could be loaded with `load_file` method:
33+
# Eddies files (zarr or netcdf) could be loaded with ```load_file``` method:
3634
eddies_collections = EddiesObservations.load_file(get_path("Cyclonic_20160515.nc"))
3735
eddies_collections.field_table()
3836
# offset and scale_factor are used only when data is stored in zarr or netCDF4
3937

4038
# %%
4139
# Field access
4240
# ------------
41+
# To access the total field, here ```amplitude```
4342
eddies_collections.amplitude
4443

44+
# To access only a specific part of the field
45+
eddies_collections.amplitude[4:15]
46+
4547
# %%
4648
# Data matrix is a numpy ndarray
4749
eddies_collections.obs
@@ -52,35 +54,34 @@
5254
# %%
5355
# Contour storage
5456
# ---------------
55-
# Contour are stored to fixed size for all, contour are resample with an algorithm before to be store in object
56-
57+
# All contours are stored on the same number of points, and are resampled if needed with an algorithm to be stored as objects
5758

5859
# %%
59-
# Tracks
60-
# ------
61-
# Tracks add several field like:
60+
# Trajectories
61+
# ------------
62+
# Tracks eddies collections add several fields :
6263
#
63-
# - track : ID which allow to identify path
64-
# - observation_flag : True if it's an observation to filled a missing detection
65-
# - observation_number : Age of eddies
66-
# - cost_association : result of cost function which allow to associate the observation with eddy path
64+
# - **track** : Trajectory number
65+
# - **observation_flag** : Flag indicating if the value is interpolated between two observations or not (0: observed eddy, 1: interpolated eddy)"
66+
# - **observation_number** : Eddy temporal index in a trajectory, days starting at the eddy first detection
67+
# - **cost_association** : result of the cost function to associate the eddy with the next observation
6768
eddies_tracks = TrackEddiesObservations.load_file(
6869
py_eddy_tracker_sample.get_path("eddies_med_adt_allsat_dt2018/Cyclonic.zarr")
6970
)
70-
# In this example some field are removed like effective_contour_longitude, ... in order to save time for doc building
71+
# In this example some fields are removed (effective_contour_longitude,...) in order to save time for doc building
7172
eddies_tracks.field_table()
7273

7374
# %%
74-
# Network
75-
# -------
76-
# Network files use some specific field:
75+
# Networks
76+
# --------
77+
# Network files use some specific fields :
7778
#
78-
# - track : ID of network (ID 0 are for lonely eddies/trash)
79-
# - segment : ID of path in network (from 0 to N)
80-
# - previous_obs : Index of the previous observation in the full dataset, if -1 there are no previous observation
81-
# - next_obs : Index of the next observation in the full dataset, if -1 there are no next observation
82-
# - previous_cost : Result of cost_function (1 good <> 0 bad) with previous observation
83-
# - next_cost : Result of cost_function (1 good <> 0 bad) with next observation
79+
# - track : ID of network (ID 0 correspond to lonely eddies)
80+
# - segment : ID of a segment within a network (from 1 to N)
81+
# - previous_obs : Index of the previous observation in the full dataset, if -1 there are no previous observation (the segment starts)
82+
# - next_obs : Index of the next observation in the full dataset, if -1 there are no next observation (the segment ends)
83+
# - previous_cost : Result of the cost function (1 is a good association, 0 is bad) with previous observation
84+
# - next_cost : Result of the cost function (1 is a good association, 0 is bad) with next observation
8485
eddies_network = NetworkObservations.load_file(
8586
get_remote_sample(
8687
"eddies_med_adt_allsat_dt2018_err70_filt500_order1/Anticyclonic_network.nc"
@@ -103,3 +104,7 @@
103104
]
104105
]
105106
)
107+
108+
# %%
109+
# Networks are ordered by increasing network number (`track`), then increasing segment number, then increasing time
110+

src/py_eddy_tracker/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def parse_args(self, *args, **kwargs):
474474
nc_attr=dict(
475475
long_name="number of points for effective contour",
476476
units="ordinal",
477-
description="Number of point for effective contour before resampling",
477+
description="Number of points for effective contour before resampling",
478478
),
479479
),
480480
contour_lon_s=dict(
@@ -516,9 +516,9 @@ def parse_args(self, *args, **kwargs):
516516
nc_type="u2",
517517
nc_dims=("obs",),
518518
nc_attr=dict(
519-
long_name="number of point for speed contour",
519+
long_name="number of points for speed contour",
520520
units="ordinal",
521-
description="Number of point for speed contour before resampling",
521+
description="Number of points for speed contour before resampling",
522522
),
523523
),
524524
shape_error_e=dict(

src/py_eddy_tracker/observations/observation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,16 +283,16 @@ def box_display(value):
283283

284284
def field_table(self):
285285
"""
286-
Produce description table of field available in this object
286+
Produce description table of the fields available in this object
287287
"""
288-
rows = [("Name(Unit)", "Long name", "Scale factor", "Offset")]
288+
rows = [("Name (Unit)", "Long name", "Scale factor", "Offset")]
289289
names = list(self.obs.dtype.names)
290290
names.sort()
291291
for field in names:
292292
infos = VAR_DESCR[field]
293293
rows.append(
294294
(
295-
f"{infos.get('nc_name', field).capitalize()} ({infos['nc_attr'].get('units', '')})",
295+
f"{infos.get('nc_name', field)} ({infos['nc_attr'].get('units', '')})",
296296
infos["nc_attr"].get("long_name", "").capitalize(),
297297
infos.get("scale_factor", ""),
298298
infos.get("add_offset", ""),

0 commit comments

Comments
 (0)