Skip to content

Commit 0ba3db4

Browse files
committed
Add option to subset, and modify adress of framework
1 parent 15126c3 commit 0ba3db4

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

src/py_eddy_tracker/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,17 @@ def parse_args(self, *args, **kwargs):
332332
description='Eddy identification number',
333333
)
334334
),
335+
sub_track=dict(
336+
attr_name=None,
337+
nc_name='sub_track',
338+
nc_type='uint32',
339+
nc_dims=('obs',),
340+
nc_attr=dict(
341+
longname='segment_number',
342+
units='ordinal',
343+
description='segment number inside a group',
344+
)
345+
),
335346
n=dict(
336347
attr_name=None,
337348
nc_name='observation_number',

src/py_eddy_tracker/observations/observation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ def write_netcdf(self, path="./", filename="%(path)s/%(sign_type)s.nc"):
843843
def set_global_attr_netcdf(self, h_nc):
844844
h_nc.Metadata_Conventions = "Unidata Dataset Discovery v1.0"
845845
h_nc.comment = "Surface product; mesoscale eddies"
846-
h_nc.framework_used = "https://bitbucket.org/emason/py-eddy-tracker"
846+
h_nc.framework_used = "https://github.com/AntSimi/py-eddy-tracker"
847847
h_nc.standard_name_vocabulary = (
848848
"NetCDF Climate and Forecast (CF) Metadata Convention Standard Name Table"
849849
)

src/py_eddy_tracker/observations/tracking.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
2929
"""
3030
from numpy import empty, arange, where, unique, \
31-
interp, ones, bool_, zeros
31+
interp, ones, bool_, zeros, array
3232
from .. import VAR_DESCR_inv
3333
import logging
3434
from datetime import datetime, timedelta
@@ -111,7 +111,7 @@ def set_global_attr_netcdf(self, h_nc):
111111
h_nc.title = 'Cyclonic' if self.sign_type == -1 else 'Anticyclonic'
112112
h_nc.Metadata_Conventions = 'Unidata Dataset Discovery v1.0'
113113
h_nc.comment = 'Surface product; mesoscale eddies'
114-
h_nc.framework_used = 'https://bitbucket.org/emason/py-eddy-tracker'
114+
h_nc.framework_used = 'https://github.com/AntSimi/py-eddy-tracker'
115115
h_nc.standard_name_vocabulary = 'NetCDF Climate and Forecast (CF) Metadata Convention Standard Name Table'
116116
h_nc.date_created = datetime.now().strftime('%Y-%m-%dT%H:%M:%SZ')
117117
t = h_nc.variables[VAR_DESCR_inv['j1']]
@@ -194,6 +194,10 @@ def nb_obs_by_track(self):
194194
self.compute_index()
195195
return self.__obs_by_track
196196

197+
def extract_ids(self, tracks):
198+
mask = self.get_mask_from_id(array(tracks))
199+
return self.__extract_with_mask(mask)
200+
197201
def __extract_with_mask(self, mask, full_path=False, remove_incomplete=False, compress_id=False):
198202
"""
199203
Extract a subset of observations

src/scripts/EddySubSetter

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,16 @@ def id_parser():
2222
metavar=('llcrnrlon', 'llcrnrlat', 'urcrnrlon', 'urcrnrlat'),
2323
help='Coordinates of bounding to extract'
2424
)
25+
parser.add_argument('-i', '--ids', nargs='+', type=int, help='List of tracks which will be extract')
2526
return parser
2627

2728

2829
if __name__ == '__main__':
2930
args = id_parser().parse_args()
3031

3132
dataset = TrackEddiesObservations.load_from_netcdf(args.filename, raw_data=True)
33+
if args.ids is not None:
34+
dataset = dataset.extract_ids(args.ids)
3235
if args.period is not None:
3336
dataset = dataset.extract_with_period(args.period, full_path=args.full_path,
3437
remove_incomplete=args.remove_incomplete)

0 commit comments

Comments
 (0)