DamienIrving / climate-analysis

Code used for the analysis and visualisation of climate data during my PhD
MIT License
40 stars 19 forks source link

iris standard names #30

Open DamienIrving opened 8 years ago

DamienIrving commented 8 years ago

When reading/writing an iris cube, you must use a CF compliant standard name.

To get around this problem when writing cubes to file, you can add your preferred standard name to the list iris stores:

iris.std_names.STD_NAMES[standard_name] = {'canonical_units': units}

When reading cubes you can simply pass it the long_name instead (which it tries if the standard_name fails), which might involve a try / except block that catches the ConstraintMismatchError. Interestingly, when iris loads the file the resulting cube will not have a "standard_name = your_variable" attribute. The loaded cubes will instead have an attribute "invalid_standard_name = your_variable".