How to change the time coordinate..

75 views
Skip to first unread message

Raghavendra S. Mupparthy

unread,
Jul 24, 2020, 10:04:31 AM7/24/20
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
Hello All,

I have an ancillary file created by regridding the data to a higher resolution (n2048e) from the original source (at n1024e). I have created this using ANTS (which makes use of Iris). Now when I regrid, the time dimension is messed up.

Original n1024e cube:
>>> print(orig_cubes)
0: mass_fraction_of_ozone_in_air / (1) (time: 12; model_level_number: 70; latitude: 1536; longitude: 1)
>>> print(orig_cubes[0])
mass_fraction_of_ozone_in_air / (1) (time: 12; model_level_number: 70; latitude: 1536; longitude: 1)
     Dimension coordinates:
          time                           x                       -             -                -
          model_level_number             -                       x             -                -
          latitude                       -                       -             x                -
          longitude                      -                       -             -                x
     Auxiliary coordinates:
          level_height                   -                       x             -                -
          sigma                          -                       x             -                -
     Attributes:
          STASH: m01s00i060
          grid_staggering: 6
          source: Data from Met Office Unified Model
          um_version: 7.9
     Cell methods:
          mean: time
          mean: longitude
>>>
>>> print(orig_cubes[0].coord('time'))
DimCoord([-001-01-16 00:00:00, -001-02-15 00:00:00, -001-03-15 00:00:00,
       -001-04-14 00:00:00, -001-05-14 00:00:00, -001-06-13 00:00:00,
       -001-07-13 00:00:00, -001-08-12 00:00:00, -001-09-11 00:00:00,
       -001-10-11 00:00:00, -001-11-10 00:00:00, -001-12-10 00:00:00], standard_name='time', calendar='gregorian')
>>>

But the regridded cube's time coordinate has changed
>>> print(cubes[0])
mass_fraction_of_ozone_in_air / (1) (time: 12; model_level_number: 70; latitude: 3072; longitude: 1)
     Dimension coordinates:
          time                           x                       -             -                -
          model_level_number             -                       x             -                -
          latitude                       -                       -             x                -
          longitude                      -                       -             -                x
     Auxiliary coordinates:
          level_height                   -                       x             -                -
          sigma                          -                       x             -                -
     Attributes:
          STASH: m01s00i060
          grid_staggering: 6
          source: Data from Met Office Unified Model
          um_version: 7.9
     Cell methods:
          mean: time
          mean: longitude
>>> print(cubes[0].coord('time'))
DimCoord([-001-01-16 00:00:00, -001-02-15 00:00:00, -001-03-16 00:00:00,
       -001-04-15 00:00:00, -001-05-15 00:00:00, -001-06-14 00:00:00,
       -001-07-14 00:00:00, -001-08-13 00:00:00, -001-09-12 00:00:00,
       -001-10-12 00:00:00, -001-11-11 00:00:00, -001-12-11 00:00:00], standard_name='time', calendar='gregorian')
>>>

As can be seen from the above, the time info is all shifted after February. This in turn causes UM to generate 'RCF_ANCIL_ATMOS' error (Error message: replanca_rcf_replanca: Error in first validity time given in ancillary file).

I would like to make the regridded cube's time coordinate to match the original (n1024e) cube. How to go about it?

Regards
Raghu 

RuthC

unread,
Aug 19, 2020, 4:33:48 AM8/19/20
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
Does replace_coord do what you need?  E.g.

cubes[0].replace_coord(orig_cubes[0].coord('time'))

Ruth

Raghavendra S. Mupparthy

unread,
Sep 17, 2020, 3:03:17 PM9/17/20
to SciTools (iris, cartopy, cf_units, etc.) - https://github.com/scitools
Thanks Ruth! Let me try that!
Reply all
Reply to author
Forward
0 new messages