Skip to content

um_stash_source attribute causes ValueError if not in msi format #4029

@jonseddon

Description

@jonseddon

🐛 Bug Report

If a variable in a netCDF file contains a um_stash_source attribute that is not in MSI format mXXsXXiXXX (for example (28.97/48.0)*m01s34i001) then ValueError is raised when loading.

How To Reproduce

Steps to reproduce the behaviour:

import iris
from netCDF4 import Dataset
from iris.tests.stock import realistic_3d
cube = realistic_3d()
iris.save(cube, 'cube.nc')
rootgrp = Dataset('cube.nc', 'a')
apt = rootgrp.variables['air_potential_temperature']
apt.um_stash_source = '(28.97/48.0)*m01s34i001'
rootgrp.close()
cube = iris.load_cube('cube.nc')

Expected behaviour

ValueError seems excessive here. If the STASH code isn't in the correct format then perhaps a warning and storing the attribute value in cube.attributes would be nicer to users.

Environment

  • OS & Version: RHEL7
  • Iris Version: 3.0.0rc0

(but behaviour is probably OS and version independent)

Additional context

Fix probably needs to go into https://github.com/SciTools/iris/blob/master/lib/iris/fileformats/_pyke_rules/fc_rules_cf.krb#L1014 but I'm not sure how to handle an execption in Pyke myself.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions