diff --git a/lib/iris/fileformats/pp_rules.py b/lib/iris/fileformats/pp_rules.py index c3fd1246a3..38ebdf3e43 100644 --- a/lib/iris/fileformats/pp_rules.py +++ b/lib/iris/fileformats/pp_rules.py @@ -42,13 +42,21 @@ def convert(f): cell_methods = [] dim_coords_and_dims = [] aux_coords_and_dims = [] + + class DimCoordParams(namedtuple('DimThing', ['points', 'standard_name', 'long_name', 'var_name', 'units', 'bounds', 'attributes', 'coord_system', 'circular'])): + pass + class Date2NumParams(namedtuple('Date2NumParams', ['unit', 'calendar', 'date'])): + pass + class UnitParams(namedtuple('UnitParams', ['name', 'calendar'])): + def __new__(cls, name, calendar=None): + return super(UnitParams, cls).__new__(cls, name, calendar) if \ (f.lbtim.ia == 0) and \ (f.lbtim.ib == 0) and \ (f.lbtim.ic in [1, 2, 3]) and \ (len(f.lbcode) != 5 or (len(f.lbcode) == 5 and f.lbcode.ix not in [20, 21, 22, 23] and f.lbcode.iy not in [20, 21, 22, 23])): - aux_coords_and_dims.append((DimCoord(f.time_unit('hours').date2num(f.t1), standard_name='time', units=f.time_unit('hours')), None)) + aux_coords_and_dims.append((DimCoordParams(Date2NumParams("hours", f.calendar, f.t1), standard_name='time', units=UnitParams('hours')), None)) if \ (f.lbtim.ia == 0) and \ diff --git a/lib/iris/fileformats/rules.py b/lib/iris/fileformats/rules.py index 41e7c5e972..81809d4113 100644 --- a/lib/iris/fileformats/rules.py +++ b/lib/iris/fileformats/rules.py @@ -783,8 +783,8 @@ def load_cubes(filenames, user_callback, loader): for filename in filenames: for field in loader.field_generator(filename, **loader.field_generator_kwargs): - # Convert the field to a Cube. - cube, factories, references = _make_cube(field, loader.converter) + # Convert the field to Cube creation params. + cube_params, factories, references = _make_cube(field, loader.converter) # Run any custom user-provided rules. if loader.legacy_custom_rules: