DocOtak / gsw-xarray

Wrapper for gsw that will add CF attributes to xarray.DataArray outputs
https://gsw-xarray.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
23 stars 3 forks source link

Error when using gsw modules #5

Closed rcaneill closed 2 years ago

rcaneill commented 2 years ago

See #4

Comment on the test test_func_standard_module: it fails. This means that gsw can only be used when importing function from gsw, and not from the modules (like from gsw.density import sigma0). This is a problem... I do not know how to solve it (I am not used to using the __dir__ and __getattr__).

DocOtak commented 2 years ago

Oh! I haven't used those "grouped" modules for a very long time... will need to look into how to solve this.

DocOtak commented 2 years ago

Looks like the only reliable/non "hack" way is by just replicating the submodule structure of the upstream gsw library. That is the files like density.py need to actually exist.

The docs for GSW-Python state:

When importing functions in a module or script, however, it is safer to import them directly from the gsw namespace; it is more concise and future-proof; the organization of the subpackages is subject to change.

So we should indeed discourage this type of usage, but upstream compat is more important for this project.