mantle-convection-constrained / terratools

Tools to read, analyse and visualise models written by the TERRA mantle convection code
https://terratools.readthedocs.io/en/latest/
MIT License
6 stars 5 forks source link

Fix reading of NetCDF files with extra variables #81

Closed anowacki closed 1 year ago

anowacki commented 1 year ago

NetCDF files which contain any variables which have unexpected names previously meant that terra_model._field_name_from_variable raised a KeyError. Update the function to return None instead when given a NetCDF variable name which we are not expecting to read.

This was encountered when using convert_files.convert to update old-format NetCDF files without the ncks program, which left old variables in files which are now unexpected.

Although one could argue that requiring files do not have extra, unexpected variables is a good feature of the reader, implementing the behaviour introduced by this commit does mean that old code should be able to continue to read newer file versions which only add new variables.

For all pull requests: