Skip to content

Conversation

@kevindougherty-noaa
Copy link
Contributor

Description

This PR adds the ability to plot contour and filled contour plots from EMCPy's plotting capabilities. The appropriate driver scripts and configuration yamls have been created.

Dependencies

None.

Impact

Please list the other repositories (if any) that this PR will require changes in (example below):

None.

Copy link
Contributor

@EdwardSafford-NOAA EdwardSafford-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this looks good. I had some questions which are mostly cut and paste issues I think.

Copy link
Collaborator

@CoryMartin-NOAA CoryMartin-NOAA left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't tested but additions look good, can you add some example plots to the PR so we know it works?

@kevindougherty-noaa
Copy link
Contributor Author

Here is a sample image from some of the SOCA data that is available in the tests for the map contour:
image

@CoryMartin-NOAA
Copy link
Collaborator

Looks good, will merge once we have another +1 review

Copy link
Collaborator

@Dooruk Dooruk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @kevindougherty-noaa, looks good. We are in the process of switching to spack 1.9, I will test creating a vertical transect with the SOCA output once we are done with that.

@Dooruk Dooruk linked an issue Feb 10, 2025 that may be closed by this pull request
@CoryMartin-NOAA CoryMartin-NOAA merged commit f2e3242 into develop Feb 10, 2025
5 checks passed
@CoryMartin-NOAA CoryMartin-NOAA deleted the feature/add_contour_plotting branch February 10, 2025 15:29
@Dooruk
Copy link
Collaborator

Dooruk commented Feb 20, 2025

I tried this but wasn't able to run it, perhaps my configuration is wrong?:

graphics:

  plotting_backend: Emcpy
  figure_list:
# Map plots
# --------

  - batch figure:
      variables: [ave_ssh]
    figure:
      figure size: [20,10]
      layout: [1,1]
      title: 'SOCA'
      output name: soca_ave_ssh.png
    plots:
      - mapping:
          projection: plcarr
          domain: global
        add_map_features: ['coastline']
        add_colorbar:
          label: ave_ssh
        add_grid:
        layers:
        - type: FilledContourPlot
          x:
            variable: sst_only::SOCAgrid::lon
          y:
            variable: sst_only::SOCAgrid::lat
          z:
            variable: sst_only::SOCAVars::ave_ssh
           
           

First I get the following error:

src/eva/plotting/batch/emcpy/diagnostics/emcpy_filled_contour_plot.py", line 36, in configure_plot
self.plotobj = emcpy.plots.plots.FilledContourPlot(self.xdata, self.ydata, self.z)
^^^^^^
AttributeError: 'EmcpyFilledContourPlot' object has no attribute 'z'

If I change emcpy_filled_contour_plot.py

        # Create declarative plotting FilledContourPlot object
        # ----------------------------------------------------
        self.plotobj = emcpy.plots.plots.FilledContourPlot(self.xdata, self.ydata, self.z)

to

        # Create declarative plotting FilledContourPlot object
        # ----------------------------------------------------
        self.plotobj = emcpy.plots.plots.FilledContourPlot(self.xdata, self.ydata, self.zdata)

I get

spack-stack/scu17/spack-stack-1.9.0/envs/ue-intel-2021.10.0/install/intel/2021.10.0/py-matplotlib-3.7.4-xf2yck4/lib/python3.11/site-packages/matplotlib/contour.py", line 1475, in _check_xyz
raise TypeError(f"Input z must be 2D, not {z.ndim}D")
TypeError: Input z must be 2D, not 1D

I tried turning if the flatten method didn't help either so I declare defeat. Would it be possible to add a test config and input file?

Reading part is fine:

INFO DataCollections: ////////////////////////////////////////////////////////////////////////////////
INFO DataCollections:
INFO DataCollections: Raw xarray display of the ssh_only collection:
INFO DataCollections:
INFO DataCollections: <xarray.Dataset> Size: 37MB
INFO DataCollections: Dimensions: (lon: 1080, lat: 1440)
INFO DataCollections: Dimensions without coordinates: lon, lat
INFO DataCollections: Data variables:
INFO DataCollections: SOCAgrid::lon (lon, lat) float64 12MB -299.7 -299.5 ... 60.0 60.0
INFO DataCollections: SOCAgrid::lat (lon, lat) float64 12MB -79.81 -79.81 ... 64.22 64.11
INFO DataCollections: SOCAVars::ave_ssh (lon, lat) float64 12MB 0.0 0.0 0.0 0.0 ... 0.0 0.0 0.0

@CoryMartin-NOAA
Copy link
Collaborator

@kevindougherty-noaa any chance you have the YAML that made that figure?

@kevindougherty-noaa
Copy link
Contributor Author

@CoryMartin-NOAA I will take a look at this.

CoryMartin-NOAA added a commit that referenced this pull request Apr 10, 2025
## Description

This PR looks to add a missing need for Filled Contour Map plots and
Gridded plots. Specifically attempting to solve the following issue:
[here](#216 (comment))

## Dependencies

Waiting on the following PRs:
- [x] waiting on
[NOAA-EMC/emcpy/pull/145](NOAA-EMC/emcpy#145)

---------

Co-authored-by: Cory Martin <cory.r.martin@noaa.gov>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Contour Plots

5 participants