Loading a cube changes the coordinates var_name
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 45/100
Research direction
Start with the reproduction using iris.save and iris.load_cube, then trace how the DimCoord var_name is serialized and restored. Add a regression test covering a coordinate with only a standard_name, and verify that the loaded coordinate retains an unset var_name and matches the original cube.
Written by the indexing model from the issue text.
Description
🐛 Bug Report
Not sure if this is a bug or intentional, or if this has been raised before (I couldn't find a related issue in my search). So my issue is that if you create a cube with a iris.coord.DimCoord (setting only the standard_name of the coordinate) and save it. If you then load the cube, the var_name of the coordinate is then set, meaning that the saved cube no longer matches the loaded one.
How To Reproduce
Here is a small script to reproduce the issue.
from iris.cube import Cube
from iris.coords import DimCoord
import iris
# First create a cube
cube = Cube([0])
cube.add_dim_coord(DimCoord([0],"latitude"), 0)
# Save it to disk
iris.save(cube, "test.nc")
# Load the cube
loaded_cube = iris.load_cube("test.nc")
# Check if the cubes
print("cube==loaded_cube:",cube==loaded_cube)
# Check the coordinate metadata match
print("cube.coord('latitude')==loaded_cube.coord('latitude'):",cube.coord("latitude")==loaded_cube.coord("latitude"))
# Check the coordinate var_name
print("cube.coord('latitude').var_name==loaded_cube.coord('latitude').var_name:",cube.coord("latitude").var_name==loaded_cube.coord("latitude").var_name)
This outputs:
cube==loaded_cube: False
cube.coord('latitude')==loaded_cube.coord('latitude'): False
cube.coord('latitude').var_name==loaded_cube.coord('latitude').var_name: False
Expected behaviour
The cube coordinate var_name is not set for the loaded cube
Environment
- OS & Version: RHEL 9.7
- Iris Version: 3.14.1
- Dominant language
- Python
- Stars
- 724
- Forks
- 317
- Avg merge
- 3d 20h
- Merged PRs (30d)
- 9
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from SciTools/iris
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100