Skip to content

Select dimension towards creating transects #224

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

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Dooruk
Copy link
Collaborator

@Dooruk Dooruk commented Apr 3, 2025

I created a way to select slices along the dimension or drop them. This is an intermediate step towards creating transects and I'm very open to suggestions. I'm hoping this might be useful for insitu data visulazions, especially for Tropical arrays.

These dimensions are in tripolar coordinates for SOCA, but I asked xesmf to be added to spack-stack, so we could regrid within EVA in the future. Maybe.

Obviously I only tested selection with only SOCA data but should work for prognostic fv3-jedi vars too? Would require creating cumulative pressure levels (sorry, not an atm. scientist) I suppose.

For instance, to create a vertical transect along the equator:

# Data read
# ---------
datasets:
  - name: experiment
    type: SocaRestart
    soca_filenames: ./MOM6.res.nc
    geometry_file: ./soca_gridspec.nc

    variables: [Temp, Salt]
    coordinate variables: [lon, lat]
    optional variables: [depth]

transforms:
  - transform: select_dimension
    new name: experiment::sel_lat::${variable}
    starting field: experiment::SOCAVars::${variable}
    dimension: lat
    value: 0
    # start value: -5
    # end value: 5
    for:
      variable: [Temp, Salt, depth]

This produces the following. @kevindougherty-noaa this is what I meant in here:

INFO DataCollections:     Data variables:
INFO DataCollections:     SOCAgrid::lon    (lat, lon) float64 12MB -299.7 -299.5 -299.2 ... 60.0 60.0
INFO DataCollections:     SOCAgrid::lat    (lat, lon) float64 12MB -79.81 -79.81 -79.8 ... 64.22 64.11
INFO DataCollections:     SOCAVars::Temp   (lev, lat, lon) float32 467MB nan nan nan ... nan nan nan
INFO DataCollections:     SOCAVars::Salt   (lev, lat, lon) float32 467MB nan nan nan ... nan nan nan
INFO DataCollections:     SOCAVars::depth  (lev, lat, lon) float32 467MB nan nan nan ... nan nan nan
INFO DataCollections:     sel_lat::Temp    (lev, lon) float32 432kB nan nan nan nan ... nan nan nan
INFO DataCollections:     sel_lat::Salt    (lev, lon) float32 432kB nan nan nan nan ... nan nan nan
INFO DataCollections:     sel_lat::depth   (lev, lon) float32 432kB nan nan nan nan ... nan nan nan

Wow, I just realized copilot can be a reviewer now. I'm scared to give it a try 😄

TODO:

  • This probably won't handle 3d vars (i.e., ssh)
  • Deal with grid selection

@Dooruk Dooruk self-assigned this Apr 3, 2025
@Dooruk Dooruk added the enhancement New feature or request label Apr 3, 2025
@Dooruk
Copy link
Collaborator Author

Dooruk commented Apr 3, 2025

FYI @guillaumevernieres in case this is useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant