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

Add more plotting features #5

Open
wants to merge 6 commits into
base: DTC_MPAS
Choose a base branch
from

Conversation

mkavulich
Copy link

Synopsis

Adding new options for plotting. All of these sit under the plot: section of the config file.

  # vmin, vmax:
  # By default the color range will be scaled to the max/min values of the plotted data. To use a custom range,
  # set vmin and/or vmax
  vmin: null
  vmax: null

  # Settings for plotting political boundaries. To disable political boundaries, specify "boundaries:" with no options
  boundaries:
    detail: 0

  # Settings for plotting coastlines. To disable coastlines, specify "coastlines:" with no options
  coastlines:
    # Scale is the resolution of the plotted boundary dataset. Options are 110m, 50m, and 10m.
    scale: '10m'
    # Most standard Matplotlib arguments for shapes will work here, but I haven't figured out good documentation on which.
    # The ones listed here work, but likely a lot more customization can happen here.
    color: 'black'
    linewidth: 0.5
    facecolor: 'none'

Here is an example plot produced with the following settings on Hera:

data:
  filename: /scratch1/BMC/hmtb/kavulich/MPAS/plotting_scripts/debby/history.2024-08-08_12.00.00.nc
  var:
    - qv
  lev:
    - 15
plot:
  filename: 'boundary_tests/cropped_{fnme}_{var}_{lev}_counties.png'
  title: 'Plot of {varln}, for MPAS forecast, {date} {time}'
  latrange:
    - 20
    - 40
  lonrange:
    - -100
    - -60
  boundaries:
    detail: 2
  colorbar:
    orientation: vertical
    label: 'Units: {units}'
  vmin: 0
  colormap: "viridis"
  coastlines:
    color: 'black'
    scale: '50m'
  dpi: 300
  figheight: 4
  figwidth: 8

Screenshot 2024-12-19 at 2 41 24 PM

Type

  • Enhancement (adds new functionality)

Impact

  • This is a non-breaking change (existing functionality continues to work as expected)

Checklist

  • I have added myself and any co-authors to the PR's Assignees list.
  • I have reviewed the documentation and have made any updates necessitated by this change.

Copy link

@willmayfield willmayfield left a comment

Choose a reason for hiding this comment

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

Great work Mike! Tested this and got plots.

A couple of notes:

  1. I plotted data from diag files. For the gridfile I first tried the "static.nc" file, which I believe should contain all the necessary grid information. However, I got an error at the point when the script tried to open the gridfile. I think the relevant part of the error may be indicating that it fails trying to attach a time to this data? "ValueError: Failed to decode variable 'Time': unable to decode time units 'seconds since 0000-01-01 00:00:00' with 'the default calendar'. Try opening your dataset with decode_times=False or installing cftime if it is not installed."

I then used the "init.nc" file instead and it succeeded. I assume a "history" file would also suffice. So this isn't necessarily a problem, maybe just something to note in the comments that serve as documentation. I did not try the actual grid.nc kind of file.

  1. I used the globbing ability when loading filenames to get a collection of forecast hours for plotting. I ended up needing to put '{date}-{time}' as part of the output filename so it didn't keep overwriting the same png file for each input file. Do you have any wuick ideas for how to handle plotting a series of forecast hours this way? As in, can the filename be "foo_{var}_lev{lev}_fhr{fhr}.png" with a reasonable configurability? It's ok to have the full datetime string for now, but it might be nice to simplify those filenames so they don't have to be "global_test1_t2m_lev0_2023-09-15_00:00:00.png".

Approving! Feel free to merge as-is or with any quick changes related to these comments.

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.

2 participants