psy-view icon indicating copy to clipboard operation
psy-view copied to clipboard

deal with netcdf file not well described

Open lj-mu opened this issue 10 months ago • 0 comments

Really nice software!

I just wonder if psy-view could support some wired netcdf files, for example:

netcdf omega3 { dimensions: i = 9011 ; j = 8939 ; k = 6 ; variables: float momVort3(k, j, i) ; momVort3:long_name = "3rd component (vertical) of Vorticity" ; momVort3:units = "s^-1" ; momVort3:grid_loc = "3220" ;

// global attributes: :CDI = "Climate Data Interface version 2.4.4 (https://mpimet.mpg.de/cdi)" ; :Conventions = "none" ;

where, the coordinate is not provided in details.

When I open this nc file using psy-view, I got below error:

Traceback (most recent call last): File "/Users/miniconda3/bin/psy-view", line 11, in sys.exit(main()) ^^^^^^ File "/Users/miniconda3/lib/python3.11/site-packages/psy_view/init.py", line 161, in main start_app(ds, args.name, args.plotmethod, args.preset) File "/Users/miniconda3/lib/python3.11/site-packages/psy_view/init.py", line 73, in start_app ds_widget = DatasetWidgetStandAlone(ds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/miniconda3/lib/python3.11/site-packages/psy_view/ds_widget.py", line 340, in init self.refresh() File "/Users/miniconda3/lib/python3.11/site-packages/psy_view/ds_widget.py", line 1588, in refresh valid_variables = self.plotmethod_widget.valid_variables(self.ds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/miniconda3/lib/python3.11/site-packages/psy_view/plotmethods.py", line 825, in valid_variables xc_dims = set(ds[self.combo_xcoord.currentText()].dims) ~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/miniconda3/lib/python3.11/site-packages/xarray/core/dataset.py", line 1547, in getitem raise KeyError( KeyError: "No variable named ''. Variables on the dataset include ['momVort3']"

It seems that psy-view is not able to deal with such exception. Could you add such feature? as for high-resolution model results, not always coordinates info are provided. Thanks!

lj-mu avatar Jan 07 '25 16:01 lj-mu