@@ -5,7 +5,7 @@ Subset eddy Dataset
5
5
"""
6
6
from py_eddy_tracker import EddyParser
7
7
from py_eddy_tracker .observations .tracking import TrackEddiesObservations
8
- from os . path import basename , dirname
8
+ import logging
9
9
10
10
11
11
def id_parser ():
@@ -14,6 +14,8 @@ def id_parser():
14
14
parser .add_argument ('filename_out' )
15
15
parser .add_argument ('-p' , '--period' , nargs = 2 , type = int ,
16
16
help = 'Start day and end day, if it s negative value we will add to day min and add to day max, if 0 it s not use' )
17
+ parser .add_argument ('-l' , '--length' , nargs = 2 , type = int ,
18
+ help = 'Minimal and maximal quantity of observation for one track, ones bounds could be negative, it will be not use' )
17
19
parser .add_argument ('-f' , '--full_path' , action = 'store_true' ,
18
20
help = 'Extract path, if one obs or more are selected' )
19
21
parser .add_argument ('-d' , '--remove_incomplete' , action = 'store_true' ,
@@ -34,12 +36,20 @@ if __name__ == '__main__':
34
36
# Original dataset
35
37
dataset = TrackEddiesObservations .load_from_netcdf (args .filename , raw_data = False if args .no_raw_mode else True )
36
38
39
+ # Select with id
37
40
if args .ids is not None :
38
41
dataset = dataset .extract_ids (args .ids )
42
+
43
+ # Select with length
44
+ if args .length is not None :
45
+ dataset = dataset .extract_with_length (args .length )
46
+
47
+ # Select with a start date and end date
39
48
if args .period is not None :
40
49
dataset = dataset .extract_with_period (args .period , full_path = args .full_path ,
41
50
remove_incomplete = args .remove_incomplete )
42
51
52
+ # Select track which go through an area
43
53
if args .area is not None :
44
54
area = dict (llcrnrlon = args .area [0 ],
45
55
llcrnrlat = args .area [1 ],
@@ -49,5 +59,8 @@ if __name__ == '__main__':
49
59
dataset = dataset .extract_with_area (area , full_path = args .full_path ,
50
60
remove_incomplete = args .remove_incomplete )
51
61
52
- if len (dataset ) != 0 :
62
+ # if no data, no output will be written
63
+ if len (dataset ) == 0 :
64
+ logging .warning ("No data are selected, out file couldn't be create" )
65
+ else :
53
66
dataset .write_netcdf (filename = args .filename_out )
0 commit comments