Skip to content

Cube builder cannot create custom vertical coordinate#147

Description

馃悳 Bug Report

When creating a cube with a vertical coordinate, the cube builder cannot handle anything other than 4 levels. This is hard-coded in ants.utils.cube.CubeBuilder.add_model_level_coordinate.

By extension, ants.tests.stock.simple_4d_with_hybrid_height fails when a shape is passed that does not specify 4 vertical levels.

How to reproduce

Step by step guide to reproduce the behaviour:

# use default shape
>>> ants.tests.stock.simple_4d_with_hybrid_height()
<iris 'Cube' of air_temperature / (K) (time: 3; model_level_number: 4; latitude: 5; longitude: 6)>

# try to specify non-default vertical coord, with 5 levels
>>> ants.tests.stock.simple_4d_with_hybrid_height(shape=(3,5,5,6))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File ".../ants/tests/stock.py", line 57, in simple_4d_with_hybrid_height
    builder.add_model_level_coordinate(additional_attributes={"positive": "up"})
  File ".../ants/utils/cube.py", line 238, in add_model_level_coordinate
    self._cube.add_dim_coord(coord, 1)
  File ".../iris/cube.py", line 1409, in add_dim_coord
    self._add_unique_dim_coord(dim_coord, data_dim)
  File ".../iris/cube.py", line 1437, in _add_unique_dim_coord
    raise iris.exceptions.CannotAddError(
iris.exceptions.CannotAddError: Unequal lengths. Cube dimension 1 => 5; coord 'model_level_number' => 4.

Environment

I am using the ANTS 3.1.0 environment.

Version

This bug exists in ANTS 3.1.0 + head of main

Additional Context

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    馃悳 bugBug report for something that isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions