Commit cfb2a4e Drew Resnick
committed
1 parent e342906 commit cfb2a4e Copy full SHA for cfb2a4e
File tree 1 file changed +4
-6
lines changed
diagnostics/flow_dep_diag
1 file changed +4
-6
lines changed Original file line number Diff line number Diff line change 12
12
ds = xr .open_dataset (file_path , decode_times = False )
13
13
14
14
#the diagnostic assumes your grid has a longitudinal range -180,180
15
- #Shift your grid from 0,360 using the following lines
15
+ #Shift your grid from 0,360 using the following lines; this will retain the correct
16
+ #coordinates if values are between -180,180
16
17
ds .coords ['lon' ] = (ds .coords ['lon' ] + 180 ) % 360 - 180 #shift the values
17
18
ds = ds .sortby (ds .lon ) #sort them
18
-
19
- #in the case your data is not cropped to a
20
- #specific region, this code can be used to select a subset of data within a lat/lon
21
-
19
+ #cropping the dataset by the bounding box coordinates specified above
22
20
mask_lon = (ds .lon >= wlo ) & (ds .lon <= elo )
23
21
mask_lat = (ds .lat >= sla ) & (ds .lat <= nla )
24
- cropped_ds = ds .where (mask_lon & mask_lat , drop = True )
22
+ cropped_ds = ds .where (mask_lon & mask_lat , drop = True )
25
23
26
24
cropped_ds .to_netcdf (output_path )
You can’t perform that action at this time.
0 commit comments