xmitgcm
xmitgcm copied to clipboard
Surface velocities from ECCO data portal
For a future project, I wanted to use surface velocities from the ECCO data portal (to avoid egress charges). They are available as part of the regional data released here. The data is "shrunk" so it probably makes sense to use existing llcreader code to unshrink it.
I downloaded a single time slice of SSU and SSV and so far my code looks like this:
from xmitgcm import llcreader
from fsspec.implementations.local import LocalFileSystem
fs = LocalFileSystem()
store = llcreader.BaseStore(fs, base_path='/swot/SUM01/spencer/LLCsurf')
model = llcreader.LLC4320Model(store)
ds_faces = model.get_dataset(varnames=['SSU'])
However, xmitgcm isn't aware that SSU is a possible variable name, so I get an error:
KeyError Traceback (most recent call last)
<ipython-input-7-86109449e317> in <module>
----> 1 ds_faces = model.get_dataset(varnames=['SSU'])
~/.conda/envs/pangeo1/lib/python3.9/site-packages/xmitgcm/llcreader/llcmodel.py in get_dataset(self, varnames, iter_start, iter_stop, iter_step, iters, k_levels, k_chunksize, type, read_grid, grid_vars_to_coords)
897
898 # get the data in facet form
--> 899 data_facets = {vname:
900 self._get_facet_data(vname, iters, k_levels, k_chunksize)
901 for vname in varnames}
~/.conda/envs/pangeo1/lib/python3.9/site-packages/xmitgcm/llcreader/llcmodel.py in <dictcomp>(.0)
898 # get the data in facet form
899 data_facets = {vname:
--> 900 self._get_facet_data(vname, iters, k_levels, k_chunksize)
901 for vname in varnames}
902
~/.conda/envs/pangeo1/lib/python3.9/site-packages/xmitgcm/llcreader/llcmodel.py in _get_facet_data(self, varname, iters, klevels, k_chunksize)
741 def _get_facet_data(self, varname, iters, klevels, k_chunksize):
742 # needs facets to be outer index of nested lists
--> 743 dims = _VAR_METADATA[varname]['dims']
744
745 if len(dims)==2:
KeyError: 'SSU'
Would I need to add SSU, SSV etc. to the package as variable names in order to open this data? Or is there something deeper I am missing here?
(this issue is related to #253 I think)
cc @dhruvbalwada
Hey @cspencerjones! Does it work to specify your own inherited llc model on the fly, e.g. like
from xmitgcm import llcreader
class SurfaceLLC4320Model(llcreader.LLC4320Model):
varnames = ["SSU", "SSV"]
If it's truly a regional setup without the 13 faces, then other attributes like nface
may have to change, and it could get hairy (I'm not totally sure ...)
I would recommend browsing through the known models code and trying to find a template to modify.