Skip to content
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

Align Coordinate Data for Multiple Variables #1599

Open
kgoebber opened this issue Dec 5, 2020 · 3 comments
Open

Align Coordinate Data for Multiple Variables #1599

kgoebber opened this issue Dec 5, 2020 · 3 comments
Labels
Area: Xarray Pertains to xarray integration Type: Feature New functionality
Milestone

Comments

@kgoebber
Copy link
Collaborator

kgoebber commented Dec 5, 2020

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.

@kgoebber kgoebber added the Type: Feature New functionality label Dec 5, 2020
@dopplershift dopplershift added the Area: Xarray Pertains to xarray integration label Dec 5, 2020
@dopplershift dopplershift added this to the 1.1 milestone Dec 5, 2020
@dopplershift dopplershift modified the milestones: 1.1.0, 1.2.0 Aug 2, 2021
@dopplershift dopplershift modified the milestones: 1.2.0, 1.3.0 Oct 8, 2021
@jthielen
Copy link
Collaborator

jthielen commented Feb 9, 2022

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.

@kgoebber
Copy link
Collaborator Author

kgoebber commented Feb 9, 2022

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.

@dopplershift dopplershift modified the milestones: 1.3.0, May 2022 Apr 6, 2022
@dopplershift dopplershift modified the milestones: May 2022, July 2022 Jun 1, 2022
@dopplershift dopplershift modified the milestones: 1.4.1, April 2023 Mar 16, 2023
@dcherian
Copy link

dcherian commented Jun 6, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Xarray Pertains to xarray integration Type: Feature New functionality
Projects
Status: No status
Development

No branches or pull requests

4 participants