You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When loading a polar stereographic netCDF file, Iris correctly interprets the "standard_parallel" attribute of the polar stereographic grid mapping variable, storing this in the "true_scale_lat" attribute of the PolarStereographic coordinate system (line 456 of iris/fileformats/_nc_load_rules/helpers.py).
This looks to be a defect in line 2150 of iris/fileformats/netcdf/saver.py, which reads:
cf_var_grid.true_scale_lat = cs.true_scale_lat
Where I would have expected:
cf_var_grid.standard_parallel = cs.true_scale_lat
The consequence is that the netCDF written by Iris is not CF-compliant, and cannot even be read back correctly by Iris due to the lack of the required "standard_parallel" or "scale_factor_at_projection_origin" grid mapping attributes, meaning that the cube ends up lacking horizontal coordinates or a coordinate system.
Happy to provide example data file and code to reproduce the bug, or any other information that might be useful.
Environment
Iris Version: 3.3 or later (i.e. one with polar stereographic support)
The text was updated successfully, but these errors were encountered:
Thanks @TonyP-BAS
I don't know how it slipped through exactly, but clearly you are right.
From the recently-added coverage scan, these lines are not exercised by any tests whatever, so no wonder.
( I would link, but it seems the CodeCov site is currently down ☹️ )
Do you feel able to submit a PR for this yourself ?
I think the code change is probably just as simple as you suggest, but we should definitely add a test.
The simplest I can think of is an integration test to check that Iris can save and re-load one of these and retrieve a coord-system with all the same parameters.
Obviously, it's a shame that tests don't exist for other coord-system types ... but I don't think there is any obligation to fix that here+now.
🐛 Bug Report
When loading a polar stereographic netCDF file, Iris correctly interprets the "standard_parallel" attribute of the polar stereographic grid mapping variable, storing this in the "true_scale_lat" attribute of the PolarStereographic coordinate system (line 456 of iris/fileformats/_nc_load_rules/helpers.py).
But when saving such a cube to netCDF, Iris writes this value to an attribute of the grid mapping variable called "true_scale_lat", not "standard_parallel", as required by the CF convention (https://cfconventions.org/Data/cf-conventions/cf-conventions-1.10/cf-conventions.html#polar-stereographic).
This looks to be a defect in line 2150 of iris/fileformats/netcdf/saver.py, which reads:
Where I would have expected:
The consequence is that the netCDF written by Iris is not CF-compliant, and cannot even be read back correctly by Iris due to the lack of the required "standard_parallel" or "scale_factor_at_projection_origin" grid mapping attributes, meaning that the cube ends up lacking horizontal coordinates or a coordinate system.
Happy to provide example data file and code to reproduce the bug, or any other information that might be useful.
Environment
The text was updated successfully, but these errors were encountered: