Skip to content

Handling of writing files with degree units #82

@znichollscr

Description

@znichollscr

The motivation

If you want to write files which have "degrees" units, input4mips-validation doesn't work in all cases. Specifically, any units like "degrees_north", "degrees_n", "degrees_east" will end up as "degrees" in the written file. The underlying cause is iris' units' sanitisation (SciTools/iris#6216), which makes sense for iris but isn't what we want here. The reason we hit this is that we go via iris to write netCDF files.

The proposed solution

One of two options:

Option 1: an automatic workaround, which puts the units back to what they were before writing the netCDF file to disk. Iris seems to be ok with updating units directly (via e.g. cube.units = "string"), even if the units aren't officially supported by udunits (like "degrees_south").

Option 2: raise a warning if we notice that the units have changed. The warning could suggest to users to either a) change their units or b) use the pattern of getting the cubes, then updating the cubes themselves, then writing (which is what I did for the MAC files, see

# Fix up some bugs from iris' conversion
).

Alternatives

Additional context

Re-riting of MAC files: https://github.com/climate-resource/input4mips_validation/blob/9f3462c77ebce974e2df02fbe5e45cf4f064c07a/scripts/add-input4mips-info-to-mac.py

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureRelated to a (new) feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions