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

General small plot improvements and website organisation #801

Merged
merged 16 commits into from
Aug 20, 2024
Merged
93 changes: 80 additions & 13 deletions cset-workflow/extra-meta/colorbar_dict_alphabetical.json
jfrost-mo marked this conversation as resolved.
Show resolved Hide resolved
jfrost-mo marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"air_pressure_at_mean_sea_level": {
"min": 99200,
"max": 102400
"min": 96000,
"max": 104000
},
"atmosphere_mass_content_of_cloud_ice": {
"min": 0.0,
"max": 0.8
"max": 0.5
},
"atmosphere_mass_content_of_water_vapor": {
"min": 0,
Expand All @@ -23,6 +23,10 @@
"min": 0.0,
"max": 2000.0
},
"grid_surface_snow_amount": {
"min": 0.0,
"max": 0.5
},
"ceilometrer_filtered_combined_cloud_amount_maximum_random_overlap": {
"min": 0,
"max": 1,
Expand All @@ -42,25 +46,40 @@
"max": 50.0
},
"dew_point_temperature_at_screen_level": {
"min": 260,
"max": 340,
"min": 250,
"max": 300,
"cmap": "jet"
},
"eastward_wind_at_10m": {
"min": -30.0,
"max": 30.0
"max": 30.0,
"cmap": "RdBu"
},
"eastward_wind": {
"min": -50.0,
"max": 50.0,
"cmap": "RdBu"
},
"northward_wind": {
"min": -50.0,
"max": 50.0,
"cmap": "RdBu"
},
"fog_fraction_at_screen_level": {
"min": 0,
"max": 1,
"cmap": "cubehelix"
"cmap": "viridis"
},
"graupel_water_path": {
"min": 0,
"max": 0.4
"max": 0.5
},
"atmospheric_boundary_layer_thickness": {
"min": 0,
"max": 3000
},
"grid_surface_temperature": {
"min": 250,
"min": 260,
"max": 320,
"cmap": "jet"
},
Expand All @@ -84,28 +103,38 @@
},
"northward_wind_at_10m": {
"min": -30.0,
"max": 30.0
"max": 30.0,
"cmap": "RdBu"
},
"northward_wind_10m": {
"min": -30.0,
"max": 30.0,
"cmap": "RdBu"
},
"radar_reflectivity_at_1km_above_the_surface": {
"min": -50.0,
"max": 50.0
},
"relative_humidity_at_screen_level": {
"min": 30.0,
"max": 110.0,
"max": 105.0,
"cmap": "YlGnBu"
},
"surface_downward_longwave_flux": {
"min": 100,
"max": 450
},
"surface_downward_shortwave_flux": {
"min": 0,
"max": 1400
},
"surface_downward_longwave_flux_radiative_timestep": {
"min": 100,
"max": 450
},
"surface_microphysical_graupelfall_rate": {
"min": 0,
"max": 0.0002
"max": 0.001
},
"surface_microphysical_precipitation_rate": {
"levels": [
Expand Down Expand Up @@ -147,7 +176,7 @@
},
"temperature_at_screen_level": {
"min": 260,
"max": 340,
"max": 320,
jfrost-mo marked this conversation as resolved.
Show resolved Hide resolved
"cmap": "jet"
},
"top_upward_longwave_flux": {
Expand All @@ -167,9 +196,47 @@
"min": 0.0,
"max": 30.0
},
"tropopause_level": {
"min": 30.0,
"max": 70.0
},
"total_lightning_flash_rate": {
"min": 0,
"max": 0.001
},
"air_potential_temperature": {
"min": 230,
"max": 340,
"cmap": "jet"
},
"surface_net_shortwave_flux": {
"min": -100,
"max": 9000
},
"surface_net_longwave_flux": {
"min": -200,
"max": 200,
"cmap": "jet"
},
"toa_upward_longwave_flux": {
"min": 0,
"max": 400
},
"toa_upward_shortwave_flux": {
"min": 0,
"max": 1400
},
"total_ice_water_path": {
"min": 0,
"max": 10
},
"upward_air_velocity": {
"min": -6,
"max": 6,
"cmap":"RdBu"
}




}
18 changes: 15 additions & 3 deletions src/CSET/operators/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def _colorbar_map_levels(varname: str, **kwargs):
try:
vmin, vmax = colorbar[varname]["min"], colorbar[varname]["max"]
logging.debug("From color_bar dictionary: Using min and max")
levels = np.linspace(vmin, vmax, 10)
levels = np.linspace(vmin, vmax, 20)
norm = None
except KeyError:
levels = None
Expand Down Expand Up @@ -243,6 +243,20 @@ def _plot_and_save_contour_plot(
# Add title.
axes.set_title(title, fontsize=16)

# Add watermark with min/max/mean. Currently not user toggable.
# In the bbox dictionary, fc and ec need to be parsed as string hex for grey shade
jfrost-mo marked this conversation as resolved.
Show resolved Hide resolved
axes.annotate(
f"Min: {np.min(cube.data):g} Max: {np.max(cube.data):g} Mean: {np.mean(cube.data):g}",
xy=(1, 0),
xycoords="axes fraction",
xytext=(-5, 5),
textcoords="offset points",
ha="right",
va="bottom",
size=11,
bbox=dict(boxstyle="round", fc="#cccccc", ec="#808080", alpha=0.9),
)

# Add colour bar.
cbar = fig.colorbar(contours)
cbar.set_label(label=f"{cube.name()} ({cube.units})", size=20)
Expand Down Expand Up @@ -614,7 +628,6 @@ def _plot_and_save_postage_stamp_histogram_series(
plt.hist(member_data_1d, density=True, histtype=histtype, stacked=True)
ax = plt.gca()
ax.set_title(f"Member #{member.coord(stamp_coordinate).points[0]}")
ax.set_ylim(0, 1)
ax.set_xlim(vmin, vmax)

# Overall figure title.
Expand All @@ -638,7 +651,6 @@ def _plot_and_save_postage_stamps_in_single_plot_histogram_series(
fig, ax = plt.subplots(figsize=(10, 10), facecolor="w", edgecolor="k")
ax.set_title(title)
ax.set_xlim(vmin, vmax)
ax.set_ylim(0, 1)
ax.set_xlabel(f"{cube.name()} / {cube.units}")
ax.set_ylabel("normalised probability density")
# Loop over all slices along the stamp_coordinate
Expand Down
1 change: 1 addition & 0 deletions src/CSET/recipes/CAPE_ratio_plot.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
category: Diagnostics
title: CAPE ratio plot
description: |
Extracts data required for, and calculates the CAPE ratio diagnostic, plotting on a map.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Profiles
title: Domain mean $VARNAME vertical profile as series
description: Plots a time series of vertical profiles for the domain mean $VARNAME using a `model_level_number` coordinate.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Profiles
title: Domain horizontal mean $VARNAME vertical profile as series
description: Plots a time series of vertical profiles for the domain mean $VARNAME using a log pressure coordinate.

Expand Down
2 changes: 1 addition & 1 deletion src/CSET/recipes/generic_histogram_series.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Histogram
title: $VARNAME $MLEVEL Level Histogram Plot
description: |
Extracts and plots the probability density of $MLEVEL level $VARNAME from a
Expand Down
2 changes: 1 addition & 1 deletion src/CSET/recipes/generic_mlevel_spatial_plot_sequence.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Model Level Spatial
title: $VARNAME $MLEVEL Level Spatial Plot
description: |
Extracts ands plots the $VARNAME from a file at model level $MLEVEL.
Expand Down
2 changes: 1 addition & 1 deletion src/CSET/recipes/generic_plevel_spatial_plot_sequence.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Pressure Level Spatial
title: $VARNAME $PLEVEL Level Spatial Plot
description: |
Extracts ands plots the $PLEVELNAME from a file at pressure level $PLEVEL.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Time Series
title: Domain mean surface $VARNAME time series
description: Plots a time series of the domain mean surface $VARNAME.

Expand Down
2 changes: 1 addition & 1 deletion src/CSET/recipes/generic_surface_histogram_series.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Histogram
title: $VARNAME Surface Level Histogram Plot
description: |
Extracts and plots the probability density of surface `$VARNAME`. It uses
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Time Series
title: Time series of $VARNAME at $LATITUDE_POINT N, $LONGITUDE_POINT E
description: Plots a time series of the surface $VARNAME at a selected gridpoint.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Surface Spatial Plot
title: Surface $VARNAME
description: Extracts and plots the surface $VARNAME from a file.

Expand Down
1 change: 1 addition & 0 deletions src/CSET/recipes/inflow_layer_properties_plot.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
category: Diagnostics
title: Inflow layer properties plot
description: |
Extracts data required for, and calculates the Inflow properties diagnostic, plotting on a spatial map.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Profiles
title: Domain mean $VARNAME vertical profile as series
description: Plots a time series of the vertical profile of domain mean $VARNAME using the full_levels coordinate.

Expand Down
2 changes: 1 addition & 1 deletion src/CSET/recipes/lfric_generic_histogram_series.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Histogram
title: $VARNAME $MLEVEL Level Histogram Plot
description: |
Extracts and plots the probability density of $MLEVEL level $VARNAME from a file at model level $MLEVEL. It uses [`plt.hist`](https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hist.html) to plot the probability density so that the area under the histogram integrates to 1. `stacked` is set to True so the sum of the histograms is normalized to 1. In case of ensemble data choose from postage stamp plot or single plot via the single_plot option in the recipe directly.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Model Level Spatial
title: $VARNAME $MLEVEL Level Spatial Plot
description: |
Extracts and plots the $VARNAME from a file at full level $MLEVEL.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Pressure Level Spatial
title: $VARNAME $PLEVEL Level Spatial Plot
description: |
Extracts and plots the $VARNAME from a file at pressure level $PLEVEL.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Time Series
title: Domain mean surface $VARNAME time series
description: Plots a time series of the domain mean surface $VARNAME.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Surface Spatial Plot
title: Surface $VARNAME
description: Extracts and plots the surface $VARNAME from a file.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Time Series
title: Domain mean time series of $STASH
description: Plots a time series of the domain mean for STASH $STASH.

Expand Down
2 changes: 1 addition & 1 deletion src/CSET/recipes/stash_surface_spatial_plot_sequence.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
category: Quick Look
category: Surface Spatial Plot
title: Spatial plot sequence of $STASH
description: Extracts and plots STASH $STASH from a file.

Expand Down