From d945100d10a3d7830624ecd58b051429f8479f11 Mon Sep 17 00:00:00 2001 From: Nils Brueggemann <nils.brueggemann@mpimet.mpg.de> Date: Wed, 12 Mar 2025 16:03:54 +0100 Subject: [PATCH] pyic_view: Allow option to specify a directory for grid files. --- scripts/pyic_view.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scripts/pyic_view.py b/scripts/pyic_view.py index fff946b..3785dc5 100755 --- a/scripts/pyic_view.py +++ b/scripts/pyic_view.py @@ -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, ) -- GitLab