Skip to content

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.

2 participants