Skip to content

Commit d65f414

Browse files
committed
Add option to set data index in EddyId
1 parent eebbf58 commit d65f414

File tree

4 files changed

+37
-4
lines changed

4 files changed

+37
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [Unreleased]
99

1010
### Added
11+
- Add option to EddyId to select data index like `--indexs time=5 depth=2`
1112
- Add a method to merge several indexs type for eddy obs
1213
- Acces at dataset variable like attribute, and lifetime/age are available for all observations
1314
- Add **EddyInfos** application to get general information about eddies dataset

doc/grid_identification.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ An eddy identification will produce two files in the output directory, one for a
2525

2626
In regional area which are away from the equator, current could be deduce from height, juste write *None None* inplace of *ugos vgos*
2727

28+
In case of **datacube**, you need to specify index for each layer (time, depth, ...) wiht *--indexs* option like:
29+
30+
.. code-block:: bash
31+
32+
EddyId share/nrt_global_allsat_phy_l4_20190223_20190226.nc 20190223 \
33+
adt ugos vgos longitude latitude \
34+
out_directory -v DEBUG --indexs time=0
35+
36+
.. warning::
37+
If no index are specified, you will apply identification only on dataset first layer, which could be
38+
a problem for datacube. Date set in command is used only for output storage.
39+
2840
Python code
2941
***********
3042

examples/10_tracking_diagnostics/pet_groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Groups distribution
3-
==================
3+
===================
44
55
"""
66
import py_eddy_tracker_sample

src/py_eddy_tracker/appli/grid.py

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""
33
All entry point to manipulate grid
44
"""
5+
from argparse import Action
56
from datetime import datetime
67

78
from .. import EddyParser
@@ -47,6 +48,17 @@ def grid_filtering():
4748
h.write(args.filename_out)
4849

4950

51+
class DictAction(Action):
52+
def __call__(self, parser, namespace, values, option_string=None):
53+
indexs = None
54+
if len(values):
55+
indexs = dict()
56+
for value in values:
57+
k, v = value.split("=")
58+
indexs[k] = int(v)
59+
setattr(namespace, self.dest, indexs)
60+
61+
5062
def eddy_id(args=None):
5163
parser = EddyParser("Eddy Identification")
5264
parser.add_argument("filename")
@@ -69,8 +81,14 @@ def eddy_id(args=None):
6981
parser.add_argument("--unregular", action="store_true", help="if grid is unregular")
7082
help = "Output will be wrote in zarr"
7183
parser.add_argument("--zarr", action="store_true", help=help)
84+
help = "Indexs to select grid : --indexs time=2, will select third step along time dimensions"
85+
parser.add_argument(
86+
"--indexs",
87+
nargs="*",
88+
help=help,
89+
action=DictAction,
90+
)
7291
args = parser.parse_args(args) if args else parser.parse_args()
73-
7492
date = datetime.strptime(args.datetime, "%Y%m%d")
7593
kwargs = dict(
7694
step=args.isoline_step,
@@ -90,7 +108,8 @@ def eddy_id(args=None):
90108
unregular=args.unregular,
91109
cut_wavelength=args.cut_wavelength,
92110
filter_order=args.filter_order,
93-
**kwargs
111+
indexs=args.indexs,
112+
**kwargs,
94113
)
95114
out_name = date.strftime("%(path)s/%(sign_type)s_%Y%m%d.nc")
96115
a.write_file(path=args.path_out, filename=out_name, zarr_flag=args.zarr)
@@ -108,10 +127,11 @@ def identification(
108127
unregular=False,
109128
cut_wavelength=500,
110129
filter_order=1,
130+
indexs=None,
111131
**kwargs
112132
):
113133
grid_class = UnRegularGridDataset if unregular else RegularGridDataset
114-
grid = grid_class(filename, lon, lat)
134+
grid = grid_class(filename, lon, lat, indexs=indexs)
115135
if u == "None" and v == "None":
116136
grid.add_uv(h)
117137
u, v = "u", "v"

0 commit comments

Comments
 (0)