ECCO-GROUP / ECCOv4-py

A Python library with routines that support the loading, analysis, and plotting fields of the ECCO Version 4 Ocean and Sea-Ice State Estimate. The ecco_v4_py library builds on several valuable tools such as xmitgcm, gcm, xarray, and dask.
MIT License
31 stars 31 forks source link

Errors thrown when 'tile' dim is named 'face' by xmitgcm.open_mdsdataset #127

Closed ds4g15 closed 2 years ago

ds4g15 commented 3 years ago

Hi all, I'm not sure whether to raise this with ECCOv4-py or xmitgcm but when opening an MDS dataset (produced by re-running ECCOv4r4) with xmitgcm, the dimension tile which ECCOv4-py is looking for in many of its functions is named face, resulting in a range of errors. I have a clunky way around using xarray's rename function but I thought I'd bring this compatibility clash up in case somebody wanted to put something more permanent in the module to handle this. If this is more an issue for xmitgcm then apologies, I can take it over there instead. Thanks!

timothyas commented 3 years ago

Hey @ds4g15! 👋

Yeah I think ECCOv4py decided to use tile rather than face because the matlab package gcmfaces uses face to mean multiple faces stuck together (LLC stuff)... Unfortunately the rename is the best way around it in my opinion.

You can also use load_ecco_vars_from_mds which takes care of this (by doing the same thing), with the downside being that the input argument notation is a bit cumbersome, it differs from xmitgcm, and note that it does not actually do any loading despite the name.

ifenty commented 2 years ago

Hi Dafydd @ds4g15

In case you didn't already see it, in the routine Tim mentions: _load_ecco_vars_frommds, the following lines rename the dimension face (from xmitgcm) to tile:

https://github.com/ECCO-GROUP/ECCOv4-py/blob/88a4ee402e0f50671b5b059b2679664069581bc4/ecco_v4_py/read_bin_llc.py#L232-L235

My original intention was for face to refer to the model's separate-but-connected subdomains (following the MITgcm exch2 package convention) and for tile to refer to the evenly-sized arrays that we divide the face arrays into ( following the convention of the MITgcm docs). See, for example,

https://github.com/MITgcm/MITgcm/blob/448d225072cf8aa5e45b6d274f6b15e079823f28/pkg/exch2/W2_EXCH2_PARAMS.h#L79-L82

C     facet_link  :: Face-Edge connectivity map:
C       facet_link(i,j)=XX.1 : face(j)-edge(i) (i=1,2,3,4 <==> N,S,E,W)
C       is connected to Northern edge of face "XX" ; similarly,
C       = XX.2 : to Southern.E, XX.3 = Eastern.E, XX.4 = Western.E of face "XX".

And figure 3 of the exch2 docs.

Maybe that naming convention was a mistake. Besides this hiccup with xmitgcm, have you found the different dimension name issue to cause any problems with packages other than ecco_v4_py?

One solution may be to add an optional argument to xmitgcm use allow a different name for this dimension with the default being 'face'?

-Ian