Skip to content
Snippets Groups Projects
Commit d945100d authored by Nils Brüggemann's avatar Nils Brüggemann
Browse files

pyic_view: Allow option to specify a directory for grid files.

parent 32653a0d
No related branches found
No related tags found
No related merge requests found
Pipeline #99654 passed
......@@ -106,7 +106,7 @@ def str_to_array(string):
# return fpath_ckdtree
def get_data(ds, var_name, it, iz, res, lon_reg, lat_reg, do_chunking=True):
def get_data(ds, var_name, it, iz, res, lon_reg, lat_reg, path_grid, do_chunking=True):
isel_dict = dict(time=it)
if ds[var_name].ndim==3:
depth_name = pyic.identify_depth_name(ds[var_name])
......@@ -124,7 +124,9 @@ def get_data(ds, var_name, it, iz, res, lon_reg, lat_reg, do_chunking=True):
if do_chunking:
da = da.chunk(**chunks)
dai = pyic.interp_to_rectgrid_xr(
da.isel(**isel_dict), res=res,
da.isel(**isel_dict),
path_grid=path_grid,
res=res,
lon_reg=lon_reg, lat_reg=lat_reg,
verbose=False,
mask_out_of_range=False,
......@@ -475,6 +477,7 @@ class view(object):
self.dai = get_data(
self.ds, self.var_name, self.it, self.iz,
self.res, self.lon_reg, self.lat_reg,
self.path_grid,
do_chunking=self.do_chunking,
)
self.Lon, self.Lat = np.meshgrid(self.dai.lon.data, self.dai.lat.data)
......@@ -636,6 +639,7 @@ class view(object):
self.dai = get_data(
self.ds, self.var_name, self.it, self.iz,
self.res, self.lon_reg, self.lat_reg,
self.path_grid,
do_chunking=self.do_chunking,
)
self.Lon, self.Lat = np.meshgrid(self.dai.lon, self.dai.lat)
......@@ -798,6 +802,9 @@ def main():
Open zarr archive:
pyic_view icon_zarr_archive.zarr
Specify path_grid:
pyic_view icon_data_20000101T*.nc --path_grid=~/work/icon/grids
Argument list:
--------------
"""
......@@ -810,6 +817,8 @@ def main():
help='Path to ICON data file.')
parser.add_argument('--size', type=float, default=1.0,
help='Factor that determines the figure size')
parser.add_argument('--path_grid', type=str, default='auto',
help='Path for grid information. Expects as subdirecotry the directory grid_name/ckdtree/rectgrids. Defaults to \'auto\' which means that ')
iopts = parser.parse_args()
#flist = glob.glob(iopts.fpath_data)
......@@ -817,9 +826,8 @@ def main():
flist.sort()
# Initial plot
path_grid = 'auto'
View = view(flist,
path_grid=path_grid,
path_grid=iopts.path_grid,
fig_size_fac=iopts.size,
)
......
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