-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MeshCoord
constructor always uses metadata of node coordinate regardless of location
#4860
Comments
@schlunma Thanks for taking the time to report this, much appreciated! I'm particularly excited simply because it means that you're using our experimental We're mostly all busy this week attending SciPy 2022 (13-15 July), but we'll get back to you asap 👍 I'll class this issue as a |
Thanks @Bill, that's great! Yes, I've used it quite extensively in the last couple of weeks (also in combination with iris-esmf-regrid), and I'm really happy with it 👍 Thanks for all the great work on this 🚀 |
Well, it kind-of is intended this way, but we can be open to persuasion ... However, I guess it is at least arguable that we should be requiring the location + noords coordinates two to have equivalent or compatible metadata , which we could test for -- e.g. what if the face_coords had different units to the node_coords? It may also be worth considering that MeshCoords don't actually add anything to the cube.location + cube.mesh information : They are a bridging concept providing unstructured coordinate info in a form more like the structured equivalents. What do you think will be useful ? Just great to hear that you're using this, though 🚀 ! |
Thanks for these insights @pp-mo, I can definitely understand the reasoning behind this! However, I still think this is confusing and can be wrong in some (unrealistic, but not completely impossible) cases. ExampleConsider the data below where the node metadata is very different to the face metadata (even the units differ!). Netcdf file with unstructured gridnetcdf cube {
dimensions:
Mesh2d_node = 10242 ;
Mesh2d_face = 20480 ;
bnds_3 = 3 ;
Mesh_2d_face_N_nodes = 3 ;
variables:
int Mesh_2d ;
Mesh_2d:cf_role = "mesh_topology" ;
Mesh_2d:topology_dimension = 2 ;
Mesh_2d:Conventions = "UGRID-1.0" ;
Mesh_2d:node_coordinates = "nlon nlat" ;
Mesh_2d:face_coordinates = "flon flat" ;
Mesh_2d:face_node_connectivity = "mesh2d_face" ;
double nlon(Mesh2d_node) ;
nlon:units = "rad" ;
nlon:standard_name = "grid_longitude" ;
nlon:long_name = "node longitude" ;
double nlat(Mesh2d_node) ;
nlat:units = "rad" ;
nlat:standard_name = "grid_latitude" ;
nlat:long_name = "node latitude" ;
double flon(Mesh2d_face) ;
flon:bounds = "flon_bnds" ;
flon:units = "degrees_east" ;
flon:standard_name = "longitude" ;
flon:long_name = "face longitude" ;
double flon_bnds(Mesh2d_face, bnds_3) ;
double flat(Mesh2d_face) ;
flat:bounds = "flat_bnds" ;
flat:units = "degrees_north" ;
flat:standard_name = "latitude" ;
flat:long_name = "face latitude" ;
double flat_bnds(Mesh2d_face, bnds_3) ;
int mesh2d_face(Mesh2d_face, Mesh_2d_face_N_nodes) ;
mesh2d_face:cf_role = "face_node_connectivity" ;
mesh2d_face:start_index = 1 ;
int64 tas(Mesh2d_face) ;
tas:standard_name = "air_temperature" ;
tas:long_name = "Near-surface air temperature" ;
tas:units = "K" ;
tas:mesh = "Mesh_2d" ;
tas:location = "face" ;
// global attributes:
:Conventions = "CF-1.7" ;
} Loading this cube gives this: air_temperature / (K) (-- : 20480)
Mesh coordinates:
grid_latitude x
grid_longitude x
Attributes:
Conventions 'CF-1.7' The first thing you notice is that somehow the coordinates describing the faces have the name MeshCoord : grid_latitude / (rad)
mesh: <Mesh: 'Mesh_2d'>
location: 'face'
points: [ 52.61807547, 53.87577873, ..., -46.82864641, -44.85063277]
bounds: [
[ 0.92919108, 0.92919108, 0.89622949],
[ 0.92919108, 0.96233691, 0.92919108],
...,
[-0.8285508 , -0.82920591, -0.79519872],
[-0.79519872, -0.76070502, -0.79398573]]
shape: (20480,) bounds(20480, 3)
dtype: float64
standard_name: 'grid_latitude'
long_name: 'node latitude'
axis: 'y' You clearly see that the IdeasOne possible idea on how to deal with this could be:
One additional thought I have here is that it might be reasonable to perform theses checks already when creating the mesh. That way problems arise very early. Let me know what you think 🚀 |
Could someone with the necessary permissions add the ESMValTool label to this? Thanks!! 👍 |
Hi @schlunma . I think that pinning down all these decisions may be a bit tricky. |
Hi @pp-mo, thanks, that sounds great! I will be travelling this week and next week, so I might be slow to respond, but I will definitely try to test it before the workshop👍 |
The
MeshCoord
constructor always uses the metadata (standard_name
,long_name
,units
, etc.) of the node coordinate, regardless of thelocation
that is specified:iris/lib/iris/experimental/ugrid/mesh.py
Lines 2845 to 2853 in 2cbaec7
That feels really weird to me and can lead to unexpected behavior. For example, if you compare the original face coordinate that is used to construct a
Mesh
and compare it to the output ofMesh.to_MeshCoord
you get different results:Here, the metadata of
face_lat
andmesh_face_lat
differ since the metadata offace_lat
andnode_lat
differ.I am not sure if this is an intended feature or not, so please feel free to just close this if this is intentional.
Cheers 👍
Iris version:
3.2.1.post0
The text was updated successfully, but these errors were encountered: