-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Problem opening unstructured grid ocean forecasts with 4D vertical coordinates #2233
Comments
It is not ideal but you can workaround that by dropping the ds = xr.open_dataset(url, drop_variables='siglay') |
@rsignell-usgs -- could you print the Is there some documentation on these new additions to CF conventions that you can point us to? We need to develop a comprehensive strategy towards supporting whatever is in there from xarray. |
We currently enforce the requirement that non-1D variable cannot be assigned in a Dataset with a name that matches one of their dimensions. This is somewhat useful, because it means that It might make sense to relax this requirements part of the eventual "explicit indexes" refactor (#1603). Then the right way to get out an index will simply be |
@rabernat , this unstructured grid model output follows the UGRID Conventions, which layer on top of the CF Conventions. The issue Xarray is having here is with the vertical coordinate however, so this issue could arise with any CF convention model where the vertical stretching function varies over the domain. As requested, here is the ncdump of this URL:
|
Ok I see...the basic problem, as @shoyer says, is that This defines a nice specific problem to solve for the index refactoring. |
In order to maintain a list of currently relevant issues, we mark issues as stale after a period of inactivity If this issue remains relevant, please comment here or remove the |
I had to go around this issue and not use xarray but pandas instead or plain netdcf4 nc = netCDF4.Dataset(input_file) I would love to know if there is a way to do it over xarray since it is so nice to use. |
I've seen this issue come up a few more times recently, so I wanted to ask: in lieu of a "full fix" (a la #2405, with deep data model changes holding up the PR), would there be support for a partial coordinate-renaming-based fix? I'd imagine something like the following: To read in netCDF like the following,
(note the problematic ds = xr.open_dataset("my_problematic_file.nc", rename_vars={'isobaric': 'isobaric_coord'}) thus giving
|
Hi For now, I found a workaround loading and renaming the problematic coordinates with For now, you could try:
Leaving it here in case someone fall into the same problem. |
#2233 (comment) cc @kthyng |
This comment was marked as outdated.
This comment was marked as outdated.
This is the second follow-up item in #6293 I think we could definitely experiment with relaxing this constraint now, although ideally we would continue to check off auditing all of the methods in that long list first. |
I've looked through the github issues associated with the explicit indices, but can't quite tell if I can use them to load FVCOM model output. In any case I just updated and tried without doing anything new and it didn't work:
Same error message as before:
|
Yes it is not yet implemented, still on the todo list (see 2nd item in #6293). |
@benbovy Ah, I see you mean under "Relax all constraints related to “dimension (index) coordinates” in Xarray". Ok, thank you for clarifying that for me! (I wasn't sure what the second item meant in the list of lists.) |
Avoid automatic creating of Index variable when nD variable shares name with one of its dimensions. Closes pydata#2233
* Warn instead of raising for nD index variable Avoid automatic creating of Index variable when nD variable shares name with one of its dimensions. Closes #2233 * fix tests * Remove warning * Add invariants check Co-authored-by: Benoit Bovy <[email protected]> * Add whats-new --------- Co-authored-by: Benoit Bovy <[email protected]>
* Allow creating DataArrays with nD coordinate variables Closes #2233 Closes #8106 * more test more test# make_aggs.bash * Fix test * Apply suggestions from code review Co-authored-by: Michael Niklas <[email protected]> * Update test --------- Co-authored-by: Michael Niklas <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
We can't open the IOOS New England triangular mesh ocean forecasts with Xarray because it doesn't understand their more complex CF vertical coordinate system.
fails with:
If you open this dataset with
nc = netCDF4.Dataset(url)
you can see what the data variables (e.g.temp
) and coordinates (e.g.siglay
) look like:So the
siglay
variable in this dataset specifies the fraction of water column contained in the layer and because this fraction changes over the grid, it has dimensions ofsiglay
andnode
. The variablesiglay
is just one of the variables used in the calculation of this CF-compliant vertical coordinate. The actual vertical coordinate (after computation viaformula_terms
) ends up being 4D.While we understand that there is no way to represent the vertical coordinate with a one-dimensional coordinate that xarray would like, it would be nice if there way to at least load the variable array data like
temp
into xarray. We tried:and we get the same error.
Is there any workaround for this?
The text was updated successfully, but these errors were encountered: