Skip to content

E3SM results visualization #843

Closed
Closed

Description

@evasinha-pnnl

Proposed new feature or change:

I would like to plot E3SM, eam.h0 output files that are at ne30np4.pg2. As a first step, I am trying to read the grid file:

import uxarray as ux

grid_path = file_path + 'ne30pg2_scrip_c20191218.nc'

uxgrid = ux.open_grid(grid_path)
print(uxgrid)
print(uxgrid.node_lon)

However as shown in the outputs below the lon values being read are all zero:

<uxarray.Grid>
Original Grid Type: Scrip
Grid Dimensions:
  * n_node: 21727
  * n_face: 21600
  * n_max_face_nodes: 4
  * n_nodes_per_face: (21600,)
Grid Coordinates (Spherical):
  * node_lon: (21727,)
  * node_lat: (21727,)
  * face_lon: (21600,)
  * face_lat: (21600,)
Grid Coordinates (Cartesian):
Grid Connectivity Variables:
  * face_node_connectivity: (21600, 4)
Grid Descriptor Variables:

<xarray.DataArray 'node_lon' (n_node: 21727)>
array([0., 0., 0., ..., 0., 0., 0.])
Dimensions without coordinates: n_node

Can you provide a simple example of plotting E3SM unstructured outputs?

Activity

  1. added
    new feature
    on Jul 8, 2024
  2. rljacob commented on Jul 8, 2024

    @rljacob
    Member
  3. philipc2 commented on Jul 8, 2024

    @philipc2
    Member

    Hi @evasinha

    The minimal example you provided looks correct to me. The reason the node_lon appears to be all zeros is because it is only printing a handfull of the values for the repr.

    image

    I'd suggest taking a look at our User Guide section on Plotting

    @rytam2 is also working on an E3SM visualuzation notebook in #836

  4. evasinha-pnnl commented on Jul 8, 2024

    @evasinha-pnnl
    Author

    Thanks @philipc2

    When I try to generate a plot using uxarray it show up as blank:

    import uxarray as ux
    import matplotlib.pyplot as plt
    
    grid_path = file_path + 'ne30pg2_scrip_c20191218.nc'
    fname = '20240703_SSP245_ZATM_BGC_ne30pg2_f09_oEC60to30v3.eam.h0.2075-06.nc'
    
    uxds = ux.open_dataset(grid_path, fname)
    
    uxds['SFCO2'][0].plot()
    plt.savefig('SFCO2.png')
    

    Is it possible that there are some issues rendering the image and if so how can those be resolved?

  5. philipc2 commented on Jul 8, 2024

    @philipc2
    Member

    @evasinha

    Here's a slightly modified example that works for me. Our plotting API is written using HoloViews, so I needed to make a few modifications to the code you provided.

    import uxarray as ux
    import holoviews as hv
    hv.extension('matplotlib')
    
    grid_path = "/Users/philipc/Downloads/ne30pg2_scrip_c20191218.nc"
    data_path = "/Users/philipc/Downloads/20240703_SSP245_ZATM_BGC_ne30pg2_f09_oEC60to30v3.eam.h0.2075-06.nc"
    
    uxds = ux.open_dataset(grid_path, data_path)
    
    # generate and store a plot as a variable
    out = uxds['SFCO2'][0].plot(backend='matplotlib', 
                                fig_size=350,
                                pixel_ratio=4.0)
    
    # safe plot as a PNG
    hv.save(out, 'SFCO2.png', fmt='png')
    image
  6. evasinha-pnnl commented on Jul 8, 2024

    @evasinha-pnnl
    Author

    @philipc2 Thank you very much for the modified working example. The modified script worked effortlessly for me as well.

  7. moved this from 📚 Backlog to ✅ Done in UXarray Developmenton Jul 8, 2024
  8. whannah1 commented on Jul 8, 2024

    @whannah1

    @philipc2 is there a similar example that also specifies a map projection?

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

    new feature

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions