rcaneill / xnemogcm

Interface to open NEMO global circulation model output dataset with xarray and create a xgcm grid.
https://xnemogcm.readthedocs.io/
MIT License
21 stars 10 forks source link

Changed name of dimensions in NEMO4.2 output #34

Closed bguelk closed 1 year ago

bguelk commented 1 year ago

The names of the x and y dimension in the output files from NEMO4.2 have partly changed, e.g. in grid_T.nc (x,y) are now (x_grid_T, y_grid_T). Same applies to output in grid_U.nc and grid_V.nc. Further, a second x and y dimension (x_grid_T_inner, y_grid_T_inner) appears for some fields.

rcaneill commented 1 year ago

I did a try with the tests/CANAL configuration and NEMO 4.2.0, and I don't get the (x_grid_T, y_grid_T) dimensions (it outputs x and y dimensions, as in NEMO 4.0.0) Do you have any non default .xml configuration file?

vopikamm commented 1 year ago

I could reproduce this issue when diagnosing e.g. u_heattr. So I guess this issue would always occur when choosing diagnostics with:

<field id= ...     grid_ref="grid_..._inner" />

This could be solved in a similar fashion as for the vertical dimension. https://github.com/rcaneill/xnemogcm/blob/72d1ca0da2f338663b4009e12cacf4a5c9c348bd/xnemogcm/nemo.py#L80 If you want me to work on it you would need to give write access.

rcaneill commented 1 year ago

So you are proposing to replace:

https://github.com/rcaneill/xnemogcm/blob/72d1ca0da2f338663b4009e12cacf4a5c9c348bd/xnemogcm/nemo.py#L84-L86

by something like?

    x_nme = [i for i in ds.dims.keys() if "x" in i]
    y_nme = [i for i in ds.dims.keys() if "y" in i]
    to_rename.update({x: point.x for x in x_nme}).update({y: point.y for y in y_nme})

This would probably work. The easiest is that @vopikamm you fork xnemogcm, create a new branch on your fork, make the change, and afterward open a pull request. Is it fine for you?

rcaneill commented 1 year ago

(We should also produce test data for this case. I'll simply try to add u_heattr and see if this is sufficient)

vopikamm commented 1 year ago

So you are proposing to replace:

https://github.com/rcaneill/xnemogcm/blob/72d1ca0da2f338663b4009e12cacf4a5c9c348bd/xnemogcm/nemo.py#L84-L86

by something like?

    x_nme = [i for i in ds.dims.keys() if "x" in i]
    y_nme = [i for i in ds.dims.keys() if "y" in i]
    to_rename.update({x: point.x for x in x_nme}).update({y: point.y for y in y_nme})

This would probably work. The easiest is that @vopikamm you fork xnemogcm, create a new branch on your fork, make the change, and afterward open a pull request. Is it fine for you?

One issue I see with this is that it would rename any dimension with an x/y in it (like axis_nbounds). We should also add the _inner dimensions in arakawa_points.py. T.b.h I think this is more an inconsistency in writing netCDF files from the NEMO side: dimension names depending on dimension names of other variables... But I think its quicker to write a small workaround here. I can do it this afternoon.