Skip to content

Align Coordinate Data for Multiple Variables #1599

Open

Description

@kgoebber

There are a number of calculations (e.g., isentropic_interpolation, potential_vorticity_baroclinic) that require multiple variables to have the same number of vertical levels. Unfortunately, there are a number of methods to obtain gridded data that don't automatically return base state variables (e.g., 'Geopotential_height_isobaric', 'u-component_of_the_wind_isobaric', 'v-component_of_the_wind_isobaric', 'Temperature_isobaric', 'Relative_humidity_isobaric') with the same coordinates, specifically in there vertical. One could end up with at least two, if not three different vertical coordinates because one or more variables are missing values at very low pressure values (very high up in the atmosphere, commonly above 100-hPa level). It would be nice to have in MetPy a way to unify these variables to their common subset of values in the vertical and assign a common vertical name.

I imagine a xarray Dataset going in that contains the variables needing to be unified, which will have multiple vertical coordinates (e.g., 'isobaric', 'isobaric3', 'isobaric5', etc.) and out comes a xarray Dataset with all of the same variables subset to the common levels that are available for all of the variables with a single common vertical coordinate name across all of the variables (e.g., 'isobaric_unified'). This output would then be the input for the specific MetPy calculations (as mentioned above). Another alternative would be to build this functionality into a decorator for those functions so the end user wouldn't have to specifically worry about that, but I'm not sold on that idea.

Activity

  1. added
    Type: Feature
    on Dec 5, 2020
  2. added
    Area: Xarray
    on Dec 5, 2020
  3. added this to the 1.1 milestone on Dec 5, 2020
  4. modified the milestones: 1.1.0, 1.2.0 on Aug 2, 2021
  5. modified the milestones: 1.2.0, 1.3.0 on Oct 8, 2021
  6. jthielen commented on Feb 9, 2022

    @jthielen
    Collaborator

    The title for this "Align coordinate data for multiple variables" is rather broad, but based on the description, is the specific feature of interest just vertical alignment, namely subsetting data to the vertical levels where coordinate values match across multiple variables? If so, I think this would be a good fit for a Dataset accessor method. It may also motivate a basic form of vertical coordinate subtype identification (e.g., isobaric vs. height vs. isentropic vs. sigma/hybrid-sigma) so we can partition variables properly into where we want them to overlap vs. not (unless we always want the user to specify which variables to align rather than automatically choosing them).

    I'd concur with avoiding building this in to a decorator that's automatically applied...I think this would mean having levels disappear without explanation, which seems like poor user-side behavior.

  7. kgoebber commented on Feb 9, 2022

    @kgoebber
    CollaboratorAuthor

    Yes, the intent was the vertical alignment of multiple variables. This would be most helpful when doing isentropic or vertical cross section analysis where you need the same number of vertical levels to do the interpolation. I don't know the current status, but I was commonly not getting the same number of vertical levels between temperature and moisture when I would pull a dataset from NOMADS - that was the original impetus for this functionality since you would have to do this alignment manually in that instance.

  8. modified the milestones: 1.3.0, May 2022 on Apr 6, 2022
  9. modified the milestones: 1.4.1, April 2023 on Mar 16, 2023
  10. dcherian commented on Jun 6, 2023

    @dcherian

    We could add cf_xarray.align to parallel xarray.align.

    xarray.align only supports an opt-out exclude kwarg, but for these purposes it seems like we'd want an opt-in include kwarg, so that we only aligned along specific user-specified dimensions (so cfxr.align(..., include="vertical")) Or perhaps cfxr.align_along_dims(..., dims="vertical")

    xref xarray-contrib/cf-xarray#449

  11. modified the milestones: 1.7.0, 1.8.0 on Jan 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: XarrayType: Feature

    Type

    No type

    Projects

    • Status
      No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions