@@ -11,7 +11,7 @@ logger = logging.getLogger("pet")
1111
1212
1313def id_parser ():
14- parser = EddyParser ('Eddy Identification ' )
14+ parser = EddyParser ('Eddy Subsetter ' )
1515 parser .add_argument ('filename' )
1616 parser .add_argument ('filename_out' )
1717
@@ -30,11 +30,17 @@ def id_parser():
3030 metavar = ('llcrnrlon' , 'llcrnrlat' , 'urcrnrlon' , 'urcrnrlat' ),
3131 help = 'Coordinates of bounding to extract'
3232 )
33+ group .add_argument ('--direction' , choices = ['E' , 'W' , 'S' , 'N' ],
34+ help = 'Select only track which have an end point which go in this direction' )
35+ group .add_argument ('--minimal_degrees_displacement_in_direction' , type = float ,
36+ help = 'Minimal displacement in direction specified in --directio options' )
37+ group .add_argument ('--select_first_observation_in_box' , type = float ,
38+ help = 'Select only the first obs in each box for each tracks, value specified must be resolution' )
3339 group .add_argument ('--remove_var' , nargs = '+' , type = str , help = 'remove all listed variable' )
3440 group .add_argument ('--include_var' , nargs = '+' , type = str , help = 'use only listed variable, remove_var will be ignored' )
3541 group .add_argument ('-i' , '--ids' , nargs = '+' , type = int , help = 'List of tracks which will be extract' )
3642
37- group = parser .add_argument_group ('Extraction options' )
43+ group = parser .add_argument_group ('General options' )
3844 group .add_argument ('--sort_time' , action = 'store_true' , help = 'sort all observation with time' )
3945
4046 parser .add_argument ('-n' , '--no_raw_mode' , action = 'store_true' ,
@@ -78,6 +84,18 @@ if __name__ == '__main__':
7884 remove_incomplete = args .remove_incomplete ,
7985 reject_virtual = args .reject_virtual )
8086
87+ # Select only track which go in the direction specified
88+ if args .direction :
89+ if args .minimal_degrees_displacement_in_direction :
90+ dataset = dataset .extract_in_direction (
91+ args .direction ,
92+ value = args .minimal_degrees_displacement_in_direction )
93+ else :
94+ dataset = dataset .extract_in_direction (args .direction )
95+
96+ if args .select_first_observation_in_box :
97+ dataset = dataset .extract_first_obs_in_box (res = args .select_first_observation_in_box )
98+
8199 if args .sort_time :
82100 logger .debug ('start sorting ...' )
83101 dataset .obs .sort (order = ['time' , 'lon' , 'lat' ])
0 commit comments