Skip to content
Snippets Groups Projects
Commit 6369ba88 authored by tomrink's avatar tomrink
Browse files

snapshot...

parent 47341a5a
No related branches found
No related tags found
No related merge requests found
......@@ -76,21 +76,31 @@ def get_bounding_gfs_files(timestamp):
return fList[iL], ftimes[iL], fList[iR], ftimes[iR]
def get_horz_layer(xr_dataset, fld_name, press, lon_lo, lon_hi, lat_lo, lat_hi):
def get_horz_layer(xr_dataset, fld_name, press, lon_range=None, lat_range=None):
plevs = xr_dataset['pressure levels']
p_idx = value_to_index(plevs.values, press)
fld = xr_dataset[fld_name]
if lon360:
if lon_lo < 0:
lon_lo += 360
if lon_hi < 0:
lon_hi += 360
x_lo = value_to_index(lon_coords, lon_lo)
x_hi = value_to_index(lon_coords, lon_hi)
y_lo = value_to_index(lat_coords, lat_lo)
y_hi = value_to_index(lat_coords, lat_hi)
p_idx = value_to_index(plevs.values, press)
x_lo = 0
x_hi = xr_dataset.fakeDim2.shape[0]
y_lo = 0
y_hi = xr_dataset.fakeDim1.shape[0]
if lon_range is not None:
lon_lo = lon_range[0]
lon_hi = lon_range[1]
lat_lo = lat_range[0]
lat_hi = lat_range[1]
if lon360:
if lon_lo < 0:
lon_lo += 360
if lon_hi < 0:
lon_hi += 360
x_lo = value_to_index(lon_coords, lon_lo)
x_hi = value_to_index(lon_coords, lon_hi)
y_lo = value_to_index(lat_coords, lat_lo)
y_hi = value_to_index(lat_coords, lat_hi)
sub_fld = fld[y_lo:y_hi, x_lo:x_hi, p_idx]
sub_fld = sub_fld.expand_dims('channel')
......@@ -100,21 +110,31 @@ def get_horz_layer(xr_dataset, fld_name, press, lon_lo, lon_hi, lat_lo, lat_hi):
return sub_fld
def get_horz_layer_s(xr_dataset, fld_names, press, lon_lo=None, lon_hi=None, lat_lo=None, lat_hi=None):
def get_horz_layer_s(xr_dataset, fld_names, press, lon_range=None, lat_range=None):
plevs = xr_dataset['pressure levels']
if lon360:
if lon_lo < 0:
lon_lo += 360
if lon_hi < 0:
lon_hi += 360
x_lo = value_to_index(lon_coords, lon_lo)
x_hi = value_to_index(lon_coords, lon_hi)
y_lo = value_to_index(lat_coords, lat_lo)
y_hi = value_to_index(lat_coords, lat_hi)
p_idx = value_to_index(plevs.values, press)
x_lo = 0
x_hi = xr_dataset.fakeDim2.shape[0]
y_lo = 0
y_hi = xr_dataset.fakeDim1.shape[0]
if lon_range is not None:
lon_lo = lon_range[0]
lon_hi = lon_range[1]
lat_lo = lat_range[0]
lat_hi = lat_range[1]
if lon360:
if lon_lo < 0:
lon_lo += 360
if lon_hi < 0:
lon_hi += 360
x_lo = value_to_index(lon_coords, lon_lo)
x_hi = value_to_index(lon_coords, lon_hi)
y_lo = value_to_index(lat_coords, lat_lo)
y_hi = value_to_index(lat_coords, lat_hi)
sub_fld_s = []
for fld_name in fld_names:
fld = xr_dataset[fld_name]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment