Skip to content

PP save fails with bounded model_level_number coordinate #3083

@DPeterK

Description

@DPeterK

If you save to PP with a model_level_number coordinate present that includes bounds, the PP saver code fails. This can be easily reproduced by collapsing the model_level_number coordinate in a cube:

cube = iris.load_cube(iris.sample_data_path('uk_hires.pp'), 'air_potential_temperature')
no_vertical = cube.collapsed('model_level_number', iris.analysis.MEAN)
print(no_vertical.coord('model_level_number').bounds)
[[ 1 19]]

iris.save(no_vertical, 'test.pp')
ValueError                                Traceback (most recent call last)
...
/.../iris/lib/iris/fileformats/pp_save_rules.py in _vertical_rules(cube, pp)
    656     # Single depth level (non cross-section).
    657     if (mln_coord is not None and
--> 658             not mln_coord.bounds and
    659             depth_coord is not None and
    660             not depth_coord.bounds):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

The problem code is this logical test in the PP save rules. Looks like the bounds test is not set up to correctly handle arrays.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions