xmitgcm
xmitgcm copied to clipboard
Custom Grid Vars & Extra Variables for llcreader
This implements two things:
- Within the core
mds_store: allow a user to add "on-the-fly" grid variables, or really any meta/data pair that does not have a 10 digit iteration number. For example, if we have a filesmooth2Dnorm001.meta/datain our run_directory:
custom_grid_vars = {'smooth3Dnorm001': {
'dims': ['k', 'j', 'i'],
'attrs': {
'standard_name': 'normalization_factor',
'long_name': 'WC01 normalization factor',
}
}
}
ds = open_mdsdataset(run_dir, grid_dir, ..., custom_grid_variables=custom_grid_vars)
- For
llcreader, add this capability and #205 to add extra_variable meta information to an llcmodel, e.g.
fs = LocalFileSystem()
store = llcreader.BaseStore(fs, base_path=data_dir, grid_path=grid_dir)
model = llcreader.LLC90Model(store)
ds = model.get_dataset(varnames=['smooth3Dnorm001'], extra_variables=custom_grid_vars, ...)
@cspencerjones: Hopefully with this PR my comment to #307 makes more sense. You could use this to add your SSU/SSV variables on-the-fly as with the extra_variables capability for mds_store. The only issue is if those SSU/SSV files are on a different grid, things will get more complicated, but if they're on the global grid this should work no problem.
I'll keep this as a draft for now because I need to add tests.
Tests currently fail due to the issue described in #312. They do pass when the pytest fixture scope is set to "function", as described in that issue.