ACCESS-NRI / um2nc-standalone

Standalone um2nc/um2netcdf to unify development efforts in a single repository.
0 stars 0 forks source link

Feature Requirement: remove unreliable cell methods #3

Open truth-quark opened 2 weeks ago

truth-quark commented 2 weeks ago

um2nc needs to process UM files which include unreliable/incorrect cell methods.

Rationale/background: the iris library is a generic tool for opening/working with earth science data. As a more general library, it lacks some features to handle complexity within the UM file format. The tool doesn't know how to properly handle cell methods, which are sub-cell pre-processing operations: https://github.com/SciTools/iris/blob/main/lib/iris/coords.py#L2903. um2nc needs to perform custom formatting to ensure NetCDF data is written out correctly.

MartinDix commented 2 weeks ago
import iris
pr = iris.load_cube('/g/data/tm70/esm15_testing/sample_output/aiihca.paa1jan', 'rainfall_flux')
print(pr)
rainfall_flux / (kg m-2 s-1)        (latitude: 145; longitude: 192)
    Dimension coordinates:
        latitude                             x               -
        longitude                            -               x
    Scalar coordinates:
        forecast_period             372.0 hours, bound=(0.0, 744.0) hours
        forecast_reference_time     0101-01-01 00:00:00
        time                        0101-01-16 12:00:00, bound=(0101-01-01 00:00:00, 0101-02-01 00:00:00)
    Cell methods:
        0                           time: mean (interval: 1 hour)
    Attributes:
        STASH                       m01s05i214
        source                      'Data from Met Office Unified Model'
        um_version                  '7.3'

The pa files have monthly mean data (as shown by the time bounds). However iris has given an incorrect cell method (sets 1 hour for any averaging period). Although it would be possible to work out the correct interval from the time bounds, the CMIP6 data specification didn't require it, so it's simplest to just drop the interval.