NOC-MSM / pyBDY

pyBDY: a Python based regional NEMO model configuration toolbox.
GNU General Public License v3.0
7 stars 7 forks source link

Using NCML reader with short netcdf variables (enhanced = 'none') #36

Closed thopri closed 4 years ago

thopri commented 4 years ago

Issue with reading ncml file comprising of CMEMS data, if the underlying netcdf has short variables. This results in a int array being passed and PyNEMO crashing.

It is unclear if PyJinius and java are reading in enhanced mode, this is documented as being enabled by default and should be able to read the short variable format automatically (use scale factor, offset etc).

This can be explicitly defined in the ncml file, but the fix for the moment is to explicitly define the array as float when it is converted from JavaArray to numpy array. (NCML.py line 229)

jdha commented 4 years ago

For ref:

The preferred way to open a NetcdfFile is through the NetcdfDataset.openFile factory method...

When you want the Netcdf-Java library to deal with missing values and scale/offset unpacking, and to identify Coordinate Systems, you should use the NetcdfDataset.openDataset factory call ...

PyNEMO currently uses NetcdfDataset.openFile - so we should be ok