Skip to content

deal with netcdf file not well described #68

Open
@lj-mu

Description

@lj-mu

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions