Skip to content

NetCDF reader: refactored reading of auxiliary pressure data

Christoph Fischer requested to merge devel_issue_220 into master

Fixes #220 (closed)

Reading 3-D model level data with auxiliary pressure fields already works quite nicely for GRIB files. For NetCDF files however, it is still a bit unintuitive and often not clear to the user what went wrong. If the pressure field could not be found, fields are just loaded as a 2-D field, which does not make sense at all. Also, the current code is a bit hacky, since it does lots of tests already while reading files, while the pressure field searched for might be in a different file.

Reading auxiliary NetCDF files now works as followed (2 steps):

  • Read all grids first: If the grid is 3-D, but not a hybrid grid or a pressure grid, assume it to be a 3-D grid on model levels, therefore of type AUXILIARY_PRESSURE_3D. So no consistency checks are done while scanning the files yet, since the pressure variable might be in a different file.
  • After scanning all files, the auxiliary pressure variable is searched: The user can type it in the user interface, or if they do not, we try to find it automatically: Scan the 3-D fields for a field with a pressure unit. Use one if we find one, but also print a warning informing the user.
  • Do the consistency checks for all variables of type AUXILIARY_PRESSURE_3D .

The method getVerticalCoordinateAuxiliaryPressure() was used previously to find the 3-D pressure grid and do consistency checks. However, if the pressure field has not been parsed yet (might be in a different file), it just assumes that it is consistent, which makes this method kinda obsolete. Now, these checks got removed (similar methods for other grid types also do not do consistency checks here) and it just checks for a vertical dimension of a supported type. The consistency checks are done after reading all files.

Can be tested using the data in /.../: Either with the aux.nc file containing 3-D data on model levels; or the two other files where the aux pressure field is in a separate file. Also try to (faulty) specify a wrong (or none) auxiliary pressure field name in the load dataset dialog.

Edited by Marc R.

Merge request reports