Skip to content
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

Provide a callback mechanism for non-compliant dataset #63

Open
ocefpaf opened this issue Sep 16, 2015 · 1 comment
Open

Provide a callback mechanism for non-compliant dataset #63

ocefpaf opened this issue Sep 16, 2015 · 1 comment

Comments

@ocefpaf
Copy link
Member

ocefpaf commented Sep 16, 2015

Iris has this nice callback functionality that allow users to "patch" the metadata and force compliance at loading time. Since there are virtually no sgrid compliant data yet I guess that a callback functionality would be a nice addition to pysgrid.

@ayan-usgs The way iris does this is by patching the "future cube" metadata. For example:

def hycom_callback(cube, field, filename):
    """
    Fix non-CF metadata.

    """
    if cube.name() == "Water Surface Elevation"
        cube.standard_name = "sea_surface_elevation"
        return cube

I think that pysgrid can do this at the raw netCDF4-python level by patching the attributes instead. If a non-netCDF sgrid dataset ever exist it will be easier to load it into a netCDF-like object than creating a new object just for that.

@ChrisBarker-NOAA
Copy link
Contributor

I tried this for pyugrid unsuccessfully -- it seems you can't patch attributes on an open file without changing them in the file, which you very well may not want.

and a full callback feature seems like a bloated API to me.

what I've done in pyugrid is to provide a utility that theuser can use to map variable names to roles in the Standard, so it's pretty easy to load a compliant file.

https://github.com/pyugrid/pyugrid/blob/master/pyugrid/grid_io/utils.py

Also, in ugly cases, who knows what may need to be done, so I'd like to be able to load what you can, then let the user write custom code to do the rest by hand with the netcdf file and the SGRid object's API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants