-
Notifications
You must be signed in to change notification settings - Fork 18
New docs multi-layer plotting example #2434
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
Merged
ukmo-huw-lewis
merged 4 commits into
main
from
2433-add-multi-variable-example-gallery-doc
Aug 28, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
389ea4d
New docs multi-layer plotting example
ukmo-huw-lewis a8b800f
Merge branch 'main' into 2433-add-multi-variable-example-gallery-doc
ukmo-huw-lewis 7f558ae
Merge branch 'main' into 2433-add-multi-variable-example-gallery-doc
ukmo-huw-lewis 93d8b6a
Responded to review comments
ukmo-huw-lewis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
88 changes: 88 additions & 0 deletions
88
docs/source/reference/gallery/examples/spatial/plot_spatial_multi.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| """ | ||
| Overlay plots | ||
| ============= | ||
|
|
||
| Generate spatial map with overlays of multiple 2D fields. | ||
|
ukmo-huw-lewis marked this conversation as resolved.
Outdated
|
||
|
|
||
| .. admonition:: References | ||
|
|
||
| General functionality is provided using the following :doc:`CSET recipes </usage/operator-recipes>`: | ||
|
|
||
| * ``multi_surface_spatial_plot_sequence.yaml`` for 3-layer plots (base layer, masked overlay layer, contour layer) | ||
| * ``multi_overlay_spatial_plot_sequence.yaml`` for base-layer with masked pcolormesh overlay | ||
| * ``multi_contour_spatial_plot_sequence.yaml`` for base-layer with contour overlay | ||
|
|
||
| The following CSET operators are used: | ||
|
|
||
| * :py:mod:`CSET.operators.read.read_cubes` | ||
| * :py:mod:`CSET.operators.filters.generate_mask` | ||
| * :py:mod:`CSET.operators.filters.apply_mask` | ||
| * :py:mod:`CSET.operators.plot.spatial_multi_pcolormesh_plot`. | ||
|
|
||
| Using *cset bake* on the command line | ||
| ------------------------------------- | ||
|
|
||
| * Access recipe file using ``cset cookbook``. | ||
| * Set required recipe inputs on command line. | ||
|
|
||
| Example to generate 3-layer full-domain spatial maps of ``temperature_at_screen_level``, with overlay of ``microphysical_surface_rainfall_rate`` masked to show only values greater than or equal to 0.05, and overlay of contours of ``air_pressure_at_sea_level`` for all output times:: | ||
|
|
||
| cset cookbook multi_surface_spatial_plot_sequence.yaml | ||
| cset -v bake -i "/path/to/input/data" -o "./output_path" \\ | ||
| -r multi_surface_spatial_plot_sequence.yaml \\ | ||
| --VARNAME_BASE="temperature_at_screen_level" \\ | ||
| --VARNAME_OVER="surface_microphysical_rainfall_rate" \\ | ||
| --OVERLAY_MASK_CONDITION="ge" \\ | ||
| --OVERLAY_MASK_VALUE="0.05" \\ | ||
| --VARNAME_CONTOUR="air_pressure_at_mean_sea_level" \\ | ||
| --MODEL_NAME="my_model_label" \\ | ||
| --METHOD="SEQ" \\ | ||
| --SUBAREA_TYPE='None' --SUBAREA_EXTENT='None' --SUBAREA_NAME='None' | ||
|
|
||
| Similar examples can be generated using recipe ``multi_overlay_spatial_plot_sequence.yaml`` for outputs with only ``VARNAME_BASE`` and ``VARNAME_OVER`` shown. | ||
|
|
||
| Alternatively, examples can be generated using recipe ``multi_contour_spatial_plot_sequence.yaml`` for outputs with only ``VARNAME_BASE`` and ``VARNAME_CONTOUR`` shown. | ||
|
|
||
|
|
||
| Configuring the *cset_workflow* | ||
| ------------------------------- | ||
|
|
||
| * Update workflow configuration settings via ``rose edit`` GUI or in ``rose-suite.conf`` file. | ||
| * Complete ``General setup options`` and ``Cycling and Model options`` details - see :doc:`/usage/workflow-configure`. | ||
| * Set required configuration options on ``Diagnostics / Multi-variable plots`` panel | ||
| * A list of different variables can be specified as python lists to generate multiple different output plot combinations using the same workflow run. | ||
| * If all variables are set, 3-layer overlay plots are generated. If either ``OVERLAY`` or ``CONTOUR`` variables are not set, the relevant 2-layer outputs are generated. | ||
|
ukmo-huw-lewis marked this conversation as resolved.
Outdated
|
||
| :: | ||
|
|
||
| SPATIAL_MULTI_VARIABLE = True | ||
| MULTI_BASE_FIELDS = ["temperature_at_screen_level", ...] | ||
| MULTI_OVERLAY_FIELDS = ["surface_microphysical_rainfall_rate", ...] | ||
| MULTI_OVERLAY_MASK_CONDITIONS = ["ge", ...] | ||
| MULTI_OVERLAY_MASK_VALUES = ["0.05", ...] | ||
| MULTI_CONTOUR_FIELDS = ["air_pressure_at_mean_sea_level", ...] | ||
| SPATIAL_MULTI_FIELD_METHOD = "" | ||
|
|
||
|
|
||
| Example python code | ||
| ------------------- | ||
| """ | ||
|
|
||
| from CSET import sample_data_path | ||
| from CSET.operators import plot, read | ||
|
|
||
| # Set path to input data | ||
| filename = sample_data_path("air_temperature_global.nc") | ||
|
|
||
| # Read selected variable(s) of interest | ||
| # Select sub-region to better illustrate output plot | ||
| cube = read.read_cube( | ||
| filename, | ||
| ["temperature_at_screen_level"], | ||
| subarea_type="realworld", | ||
| subarea_extent=[-40.0, 40.0, -120.0, -55.0], | ||
| ) | ||
|
|
||
| # Plot single time using spatial_multi_pcolormesh_plot | ||
| # Here only contours of cube are shown for simplest illustration | ||
| # See operator documentation to generate more complex multi-layer examples | ||
| plot.spatial_multi_pcolormesh_plot(cube, contour_cube=cube) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.