File tree Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Expand file tree Collapse file tree 3 files changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -227,6 +227,7 @@ def main(args):
227
227
args .infiles ,
228
228
args .var ,
229
229
time_bounds = args .adjustment_tbounds ,
230
+ isel_hour = args .isel_hour ,
230
231
input_units = args .input_units ,
231
232
output_units = args .output_units ,
232
233
use_cftime = False ,
@@ -288,6 +289,12 @@ def main(args):
288
289
289
290
parser .add_argument ("--input_units" , type = str , default = None , help = "input data units" )
290
291
parser .add_argument ("--output_units" , type = str , default = None , help = "output data units" )
292
+ parser .add_argument (
293
+ "--isel_hour" ,
294
+ type = int ,
295
+ default = None ,
296
+ help = "select a single hour from the infiles"
297
+ )
291
298
parser .add_argument (
292
299
"--adjustment_tbounds" ,
293
300
type = str ,
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ def main(args):
125
125
args .hist_files ,
126
126
args .hist_var ,
127
127
time_bounds = args .hist_time_bounds ,
128
+ isel_hour = args .isel_hour ,
128
129
input_units = args .input_hist_units ,
129
130
output_units = args .output_units ,
130
131
valid_min = args .valid_min ,
@@ -135,6 +136,7 @@ def main(args):
135
136
args .ref_files ,
136
137
args .ref_var ,
137
138
time_bounds = args .ref_time_bounds ,
139
+ isel_hour = args .isel_hour ,
138
140
lat_bounds = args .lat_bounds ,
139
141
lon_bounds = args .lon_bounds ,
140
142
input_units = args .input_ref_units ,
@@ -196,6 +198,12 @@ def main(args):
196
198
required = True ,
197
199
help = "reference data files"
198
200
)
201
+ parser .add_argument (
202
+ "--isel_hour" ,
203
+ type = int ,
204
+ default = None ,
205
+ help = "select a single hour from the input files"
206
+ )
199
207
parser .add_argument (
200
208
"--hist_time_bounds" ,
201
209
type = str ,
Original file line number Diff line number Diff line change @@ -204,6 +204,7 @@ def read_data(
204
204
time_bounds = None ,
205
205
lat_bounds = None ,
206
206
lon_bounds = None ,
207
+ isel_hour = None ,
207
208
input_units = None ,
208
209
output_units = None ,
209
210
lon_chunk_size = None ,
@@ -225,6 +226,8 @@ def read_data(
225
226
Rename var to value of rename_var
226
227
time_bounds : list, optional
227
228
Time period to extract from infiles [YYYY-MM-DD, YYYY-MM-DD]
229
+ isel_hour : int, optional
230
+ Select a single hour from the infiles
228
231
lat_bnds : list, optional
229
232
Latitude bounds: [south bound, north bound]
230
233
lon_bnds : list, optional
@@ -278,7 +281,11 @@ def read_data(
278
281
279
282
if time_bounds :
280
283
start_date , end_date = time_bounds
281
- ds = ds .sel ({'time' : slice (start_date , end_date )})
284
+ ds = ds .sel ({'time' : slice (start_date , end_date )})
285
+
286
+ if type (isel_hour ) == int :
287
+ ds = ds .isel (time = (ds .time .dt .hour == isel_hour ))
288
+
282
289
if lat_bounds :
283
290
ds = subset_lat (ds , lat_bounds )
284
291
if lon_bounds :
You can’t perform that action at this time.
0 commit comments