-
Notifications
You must be signed in to change notification settings - Fork 15
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
added TELEMAC support and tests #91
Conversation
I forgot the |
ok ready for review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, kudos. Just some minor stuff are needed
@@ -74,7 +74,7 @@ def open_dataset( | |||
import xarray as xr | |||
|
|||
default_kwargs: dict[str, T.Any] = dict( | |||
mask_and_scale=True, | |||
# mask_and_scale=True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why comment out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good question, I forgot to mention this:
mask_and_scale
is an argument that is not available in the xarray-selafin backend but that seems to exists for all other formats (zarr, grib, netcdf). I don't know how to solve this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mask_and_scale
is about applying the add_offset
and the scale_factor
. It's a netcdf thing, but xarray also applies it to zarr. I don't know if it makes sense in selafin, but even if it doesn't, I would add it as a do-nothing argument. Either that or I would add a **kwargs
so that it can be consumed without throwing an exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean directly in xarray-selafin
, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the docs a **kwargs
is not allowed:
https://docs.xarray.dev/en/stable/internals/how-to-add-new-backend.html#open-dataset
Furthermore, mask_and_scale
may not be supported by all backends: https://docs.xarray.dev/en/stable/generated/xarray.open_dataset.html
Therefore, I guess it's OK to remove it. That being said, if the selafin files can be quantized it might make sense to add support for mask_and_scale in xarray-selafin
but that's a different issue.
|
||
# TELEMAC output uses one-based indices for `face_nodes` | ||
# Let's ensure that we use zero-based indices everywhere. | ||
ds[CONNECTIVITY] = ((FACE_DIM, VERTICE_DIM), ds.attrs['ikle2'] - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is most probably xarray-selafin related, but why is ikle2
an attribute and not a variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Luc actually shifted ikle2
and ikle3
from coordinates to attributes because it removed useless dimensions.
Here's the commit.
We might want to move them back in the variables at some point I agree.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't call the connectivity useless. Furthermore, it might be that serializing attributes needs more space compared to data variables (lack of compression etc). Haven't tested it though.
Can you please test |
Please update the README, too. |
sorry my bad. I though dropping elements crossing IDL was integrated in the mesh = api.open_dataset('meshes/global-v0.2.slf')
mesh_ = thalassa.utils.drop_elements_crossing_idl(mesh)
map = thalassa.plot(mesh_.isel(time=0), variable = 'B', show_mesh = True) did it |
No it isn't. it has to be done manually. we could add a boolean param for it though. E.g. thalassa.open_dataset("/path/to/netcdf", drop_idl=True) but that should be discussed in a different issue. |
I had a second look BTW. I am starting to think that we should remove the
So if a user wants to open a selafin file he should just make sure that both
and then use: import thalassa
ds = thalassa.open_dataset("/path/to/foo.slf", engine="selafin") and things should just work. That being said, we should still keep it as a dev dependency because we want to use it for our tests. |
These need to be updated, too:
And if there is a publicly available selafin file, we could add it here, too: https://thalassa.readthedocs.io/en/latest/installation.html |
added the following components for normalisation:
is_telemac
()normalize_telemac
infer_format
()NORMALIZE_DISPATCHER
Which should address the normalisation for TELEMAC format discussed in #90
I might have added too many elements:
xarray-selafin
to support directly.slf
file formatsIf it too much for one PR, let me know, I'll drop these last changes