Skip to content

Use grid_var_names everywhere #363

Closed

Description

@kjnam

Use grid_var_names everywhere
UXARRY uses grid_var_names to map mesh topology variable names, but it is not used for all variables currently. For example, Mesh2_edge_nodes is not referred to through grid_var_names. Not using mapped names becomes an issue when a dataset uses a different topology information variable name from default Mesh2.

Describe the solution you'd like
Use grid_var_names for all topology variables.

Activity

  1. added
    new feature
    on Jun 29, 2023
  2. philipc2 commented on Jun 29, 2023

    @philipc2
    Member

    Hi @kjnam

    I'll look into this! We've been thinking of a refactor to how we internally use grid_var_names, since there are quite a few inconsistencies throughout our usages.

    Can you explain the issue that you encountered a bit more in detail? Specifically, were you using our access attributes (uxds.uxgrid.Mesh2_edge_nodes) or directly accessing the internal dataset (uxds.uxgrid._ds).

  3. self-assigned this
    on Jun 29, 2023
  4. kjnam commented on Jun 29, 2023

    @kjnam
    ContributorAuthor

    @philipc2 A main issue with this in my case is slicing (or sel with xarray). Since there could be two different names for same topology variables and dimensions, slicing becomes a headache.

  5. philipc2 commented on Jun 29, 2023

    @philipc2
    Member

    @kjnam

    I can see where that would cause issues.

    For the case of a UGRID dataset (which I believe you are referring to), If the inputted dataset has variable names that aren't the ones that we use (i.e. Instead of Mesh2_edge_nodes it may simply be mesh_edge_nodes), there would be inconsitensties between the variable names (especially if we construct a new one internally)

    This could cause some headaches when working with UxDataArray or UxDataset for the case where where the variable names are not matched.

    I'll give this a look through and get a fix out soon! Thank you for bringing this to light!

  6. kjnam commented on Jun 29, 2023

    @kjnam
    ContributorAuthor

    @philipc2 Thanks for taking care of it. That is exactly the case. You described it much better than I did. 👍
    This issue breaks my use cases, and I do not see a simple way to correct it on my side.

  7. rajeeja commented on Jun 29, 2023

    @rajeeja
    Contributor

    @philipc2 Thanks for taking care of it. That is exactly the case. You described it much better than I did. 👍 This issue breaks my use cases, and I do not see a simple way to correct it on my side.

    We should get all grid_var_names in our dictionary.

    @kjnam It'd be good if you shared a mesh with mesh_edge_nodes etc. for var name.

  8. kjnam commented on Jun 29, 2023

    @kjnam
    ContributorAuthor

    @rljacob I will concoct and upload a small example file.
    For now, I am renaming items in my dataset to go around the issue.

  9. philipc2 commented on Jun 30, 2023

    @philipc2
    Member

    Here's my proposed solution:

    Retire grid_var_names for Indexing, Standardize Variable/Dimension Names across Grid, UxDataset, and UxDataArray

    The grid_var_names dictionary only serves a purpose for UGRID datasets, mapping our internal names (which follows the naming in the UGRID examples under the documentation) to the original names in the inputted dataset.

    To avoid any inconstancies with naming, at the data loading step (open_grid or open_dataset), the variable and dimension names will be standardized to the convention that we have already been employing as seen below:

    image

    Having standardized names in our Grid means that we should also parse over the data file in our UxDataset to adjust the names to match our conventions.

  10. kjnam commented on Jun 30, 2023

    @kjnam
    ContributorAuthor

    @philipc2 Thanks for your suggestion. It is what I just did for my use case as a temporary measure, and I agree it is a reasonable option. Converting (or standardizing) names would certainly make the matter simple inside of uxarray, though it means that we are losing a bit of the original UGRID information.
    Keeping the original information in post-processed outputs may matter in some cases. (I certainly need to keep it, at least for now.) Uxarray does not (or does not need to) have writing IO functions implemented yet, as far as I know, and it is probably not a concern for now.
    Maybe uxarray can store the original name of a UGRID so that it can be recovered when the grid data is written (or accessed) to comply with the UGRID convention in outputs. This is like the current approach without mapping names internally.

  11. erogluorhan commented on Jul 11, 2023

    @erogluorhan
    Member

    @philipc2 Thanks for your suggestion. It is what I just did for my use case as a temporary measure, and I agree it is a reasonable option. Converting (or standardizing) names would certainly make the matter simple inside of uxarray, though it means that we are losing a bit of the original UGRID information. Keeping the original information in post-processed outputs may matter in some cases. (I certainly need to keep it, at least for now.)

    I agree with this. In case user just reads in and then writes out an UGRID file with custom variable names, preserving those nomes in the output would be favorable. So, instead of retiring grid_var_names, we can consider making it internal API and use only for UGRID case internally.

    Uxarray does not (or does not need to) have writing IO functions implemented yet, as far as I know, and it is probably not a concern for now. Maybe uxarray can store the original name of a UGRID so that it can be recovered when the grid data is written (or accessed) to comply with the UGRID convention in outputs. This is like the current approach without mapping names internally.

    We have encode_as where the user can generate a Xarray dataset in the desired grid type out of their UXarray dataset.
    We thought encoding instead of writing out to file would work better as Xarray has already functions like to_netcdf that supports writing to file. Thoughts?

  12. kjnam commented on Jul 11, 2023

    @kjnam
    ContributorAuthor

    @erogluorhan Sounds good to me.

  13. self-assigned this
    on Jul 18, 2023
  14. moved this from 📝 To Do to 🏗 In progress in UXarray Developmenton Aug 21, 2023
  15. added this to the Grid Topology milestone on Aug 23, 2023
  16. moved this from 🏗 In progress to ✅ Done in UXarray Developmenton Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

new feature

Type

No type

Fields

Priority

None yet

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions