diff --git a/doc/sphinx/source/recipes/recipe_monitor.rst b/doc/sphinx/source/recipes/recipe_monitor.rst index ac12fc1d1d..87ac9d0b17 100644 --- a/doc/sphinx/source/recipes/recipe_monitor.rst +++ b/doc/sphinx/source/recipes/recipe_monitor.rst @@ -211,15 +211,16 @@ Zonal mean profile of ta including a reference dataset. 1D profile of ta including a reference dataset. -.. _fig_hovmoeller_z_vs_time_with_ref: -.. figure:: /recipes/figures/monitor/hovmoeller_z_vs_time_with_ref.png +.. _fig_variable_vs_lat_with_ref: +.. figure:: /recipes/figures/monitor/variable_vs_lat_with_ref.png :align: center :width: 14cm -Hovmoeller plot (pressure vs time) of ta including a reference dataset. -.. _fig_variable_vs_lat_with_ref: -.. figure:: /recipes/figures/monitor/variable_vs_lat_with_ref.png +Zonal mean pr including a reference dataset. + +.. _fig_hovmoeller_z_vs_time_with_ref: +.. figure:: /recipes/figures/monitor/hovmoeller_z_vs_time_with_ref.png :align: center :width: 14cm -1D profile of pr over latitude. +Hovmoeller plot (pressure vs time) of ta including a reference dataset. diff --git a/esmvaltool/diag_scripts/monitor/multi_datasets.py b/esmvaltool/diag_scripts/monitor/multi_datasets.py index 2def700fc4..4a364e8c89 100644 --- a/esmvaltool/diag_scripts/monitor/multi_datasets.py +++ b/esmvaltool/diag_scripts/monitor/multi_datasets.py @@ -31,22 +31,7 @@ datasets need to be given on the same horizontal and vertical grid (you can use the preprocessors :func:`esmvalcore.preprocessor.regrid` and :func:`esmvalcore.preprocessor.extract_levels` for this). Input data - needs to be 2D with dimensions `latitude`, `height`/`air_pressure`. -<<<<<<< HEAD - - Hovmoeller altitude vs time (plot type ``hovmoeller_z_vs_time``): - for each variable and dataset, an individual profile is plotted. If a - reference dataset is defined, also include this dataset and a bias plot - into the figure. Note that if a reference dataset is defined, all input - datasets need to be given on the same horizontal and vertical grid (you - can use the preprocessors :func:`esmvalcore.preprocessor.regrid` and - :func:`esmvalcore.preprocessor.extract_levels` for this). Input data - needs to be 2D with dimensions `time`, `height`/`air_pressure`. -======= ->>>>>>> origin/main - - Variable vs. latitude plot (plot type ``variable_vs_lat``): - for each variable separately, all datasets are plotted in one - single figure. Input data needs to be 1D with single - dimension `latitude`. + needs to be 2D with dimensions `latitude`, `altitude`/`air_pressure`. .. warning:: @@ -57,7 +42,19 @@ - 1D profiles (plot type ``1d_profile``): for each variable separately, all datasets are plotted in one single figure. Input data needs to be 1D with - single dimension `height` / `air_pressure` + single dimension `altitude` / `air_pressure` + - Variable vs. latitude plot (plot type ``variable_vs_lat``): + for each variable separately, all datasets are plotted in one + single figure. Input data needs to be 1D with single + dimension `latitude`. + - Hovmoeller Z vs time (plot type ``hovmoeller_z_vs_time``): for each + variable and dataset, an individual profile is plotted. If a reference + dataset is defined, also include this dataset and a bias plot into the + figure. Note that if a reference dataset is defined, all input datasets + need to be given on the same horizontal and vertical grid (you can use + the preprocessors :func:`esmvalcore.preprocessor.regrid` and + :func:`esmvalcore.preprocessor.extract_levels` for this). Input data + needs to be 2D with dimensions `time`, `altitude`/`air_pressure`. Author ------ @@ -81,7 +78,7 @@ plots: dict, optional Plot types plotted by this diagnostic (see list above). Dictionary keys must be ``timeseries``, ``annual_cycle``, ``map``, ``zonal_mean_profile``, - ``1d_profile`` or ``hovmoeller_z_vs_time``. + ``1d_profile``, ``variable_vs_lat``, or ``hovmoeller_z_vs_time``. Dictionary values are dictionaries used as options for the corresponding plot. The allowed options for the different plot types are given below. plot_filename: str, optional @@ -138,9 +135,9 @@ to something like ``ambiguous_project``. Examples: ``title: 'Awesome Plot of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. time_format: str, optional (default: None) - :func:`~datetime.strftime` format string that is used to format the time - axis using :class:`matplotlib.dates.DateFormatter`. If ``None``, use the - default formatting imposed by the iris plotting function. + :func:`~datetime.datetime.strftime` format string that is used to format + the time axis using :class:`matplotlib.dates.DateFormatter`. If ``None``, + use the default formatting imposed by the iris plotting function. Configuration options for plot type ``annual_cycle`` ---------------------------------------------------- @@ -292,7 +289,7 @@ plot_func: str, optional (default: 'contourf') Plot function used to plot the profiles. Must be a function of :mod:`iris.plot` that supports plotting of 2D cubes with coordinates - latitude and height/air_pressure. + latitude and altitude/air_pressure. plot_kwargs: dict, optional Optional keyword arguments for the plot function defined by ``plot_func``. Dictionary keys are elements identified by ``facet_used_for_labels`` or @@ -334,6 +331,75 @@ coordinates. Can be adjusted to avoid overlap with the figure. Only relevant if ``show_stats: true``. +Configuration options for plot type ``1d_profile`` +-------------------------------------------------- +aspect_ratio: float, optional (default: 1.5) + Aspect ratio of the plot. The default value results in a slender upright + plot. +gridline_kwargs: dict, optional + Optional keyword arguments for grid lines. By default, ``color: lightgrey, + alpha: 0.5`` are used. Use ``gridline_kwargs: false`` to not show grid + lines. +legend_kwargs: dict, optional + Optional keyword arguments for :func:`matplotlib.pyplot.legend`. Use + ``legend_kwargs: false`` to not show legends. +log_x: bool, optional (default: False) + Use logarithmic X-axis. Note that for the logarithmic x axis tickmarks are + set so that minor tickmarks show up. Setting of individual tickmarks by + pyplot_kwargs is not recommended in this case. +log_y: bool, optional (default: True) + Use logarithmic Y-axis. +plot_kwargs: dict, optional + Optional keyword arguments for :func:`iris.plot.plot`. Dictionary keys are + elements identified by ``facet_used_for_labels`` or ``default``, e.g., + ``CMIP6`` if ``facet_used_for_labels: project`` or ``historical`` if + ``facet_used_for_labels: exp``. Dictionary values are dictionaries used as + keyword arguments for :func:`iris.plot.plot`. String arguments can include + facets in curly brackets which will be derived from the corresponding + dataset, e.g., ``{project}``, ``{short_name}``, ``{exp}``. Examples: + ``default: {linestyle: '-', label: '{project}'}, CMIP6: {color: red, + linestyle: '--'}, OBS: {color: black}``. +pyplot_kwargs: dict, optional + Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys + are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as + single argument for these functions. String arguments can include facets in + curly brackets which will be derived from the datasets plotted in the + corresponding plot, e.g., ``{short_name}``, ``{exp}``. Facets like + ``{project}`` that vary between the different datasets will be transformed + to something like ``ambiguous_project``. Examples: ``title: 'Awesome Plot + of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. +show_y_minor_ticklabels: bool, optional (default: False) + Show tick labels for the minor ticks on the Y axis. + +Configuration options for plot type ``variable_vs_lat`` +------------------------------------------------------- +gridline_kwargs: dict, optional + Optional keyword arguments for grid lines. By default, ``color: lightgrey, + alpha: 0.5`` are used. Use ``gridline_kwargs: false`` to not show grid + lines. +legend_kwargs: dict, optional + Optional keyword arguments for :func:`matplotlib.pyplot.legend`. Use + ``legend_kwargs: false`` to not show legends. +plot_kwargs: dict, optional + Optional keyword arguments for :func:`iris.plot.plot`. Dictionary keys are + elements identified by ``facet_used_for_labels`` or ``default``, e.g., + ``CMIP6`` if ``facet_used_for_labels: project`` or ``historical`` if + ``facet_used_for_labels: exp``. Dictionary values are dictionaries used as + keyword arguments for :func:`iris.plot.plot`. String arguments can include + facets in curly brackets which will be derived from the corresponding + dataset, e.g., ``{project}``, ``{short_name}``, ``{exp}``. Examples: + ``default: {linestyle: '-', label: '{project}'}, CMIP6: {color: red, + linestyle: '--'}, OBS: {color: black}``. +pyplot_kwargs: dict, optional + Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys + are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as + single argument for these functions. String arguments can include facets in + curly brackets which will be derived from the datasets plotted in the + corresponding plot, e.g., ``{short_name}``, ``{exp}``. Facets like + ``{project}`` that vary between the different datasets will be transformed + to something like ``ambiguous_project``. Examples: ``title: 'Awesome Plot + of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + Configuration options for plot type ``hovmoeller_z_vs_time`` ------------------------------------------------------------ cbar_label: str, optional (default: '{short_name} [{units}]') @@ -370,7 +436,7 @@ plot_func: str, optional (default: 'contourf') Plot function used to plot the profiles. Must be a function of :mod:`iris.plot` that supports plotting of 2D cubes with coordinates - latitude and height/air_pressure. + latitude and altitude/air_pressure. plot_kwargs: dict, optional Optional keyword arguments for the plot function defined by ``plot_func``. Dictionary keys are elements identified by ``facet_used_for_labels`` or @@ -412,78 +478,9 @@ coordinates. Can be adjusted to avoid overlap with the figure. Only relevant if ``show_stats: true``. time_format: str, optional (default: None) - :func:`~datetime.strftime` format string that is used to format the time - axis using :class:`matplotlib.dates.DateFormatter`. If ``None``, use the - default formatting imposed by the iris plotting function. - -Configuration options for plot type ``1d_profile`` --------------------------------------------------- -aspect_ratio: float, optional (default: 1.5) - Aspect ratio of the plot. The default value results in a slender upright - plot. -gridline_kwargs: dict, optional - Optional keyword arguments for grid lines. By default, ``color: lightgrey, - alpha: 0.5`` are used. Use ``gridline_kwargs: false`` to not show grid - lines. -legend_kwargs: dict, optional - Optional keyword arguments for :func:`matplotlib.pyplot.legend`. Use - ``legend_kwargs: false`` to not show legends. -log_x: bool, optional (default: False) - Use logarithmic X-axis. Note that for the logarithmic x axis tickmarks are - set so that minor tickmarks show up. Setting of individual tickmarks by - pyplot_kwargs is not recommended in this case. -log_y: bool, optional (default: True) - Use logarithmic Y-axis. -plot_kwargs: dict, optional - Optional keyword arguments for :func:`iris.plot.plot`. Dictionary keys are - elements identified by ``facet_used_for_labels`` or ``default``, e.g., - ``CMIP6`` if ``facet_used_for_labels: project`` or ``historical`` if - ``facet_used_for_labels: exp``. Dictionary values are dictionaries used as - keyword arguments for :func:`iris.plot.plot`. String arguments can include - facets in curly brackets which will be derived from the corresponding - dataset, e.g., ``{project}``, ``{short_name}``, ``{exp}``. Examples: - ``default: {linestyle: '-', label: '{project}'}, CMIP6: {color: red, - linestyle: '--'}, OBS: {color: black}``. -pyplot_kwargs: dict, optional - Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys - are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the datasets plotted in the - corresponding plot, e.g., ``{short_name}``, ``{exp}``. Facets like - ``{project}`` that vary between the different datasets will be transformed - to something like ``ambiguous_project``. Examples: ``title: 'Awesome Plot - of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. -show_y_minor_ticklabels: bool, optional (default: False) - Show tick labels for the minor ticks on the Y axis. - -Configuration options for plot type ``variable_vs_lat`` -------------------------------------------------------- -gridline_kwargs: dict, optional - Optional keyword arguments for grid lines. By default, ``color: lightgrey, - alpha: 0.5`` are used. Use ``gridline_kwargs: false`` to not show grid - lines. -legend_kwargs: dict, optional - Optional keyword arguments for :func:`matplotlib.pyplot.legend`. Use - ``legend_kwargs: false`` to not show legends. -plot_kwargs: dict, optional - Optional keyword arguments for :func:`iris.plot.plot`. Dictionary keys are - elements identified by ``facet_used_for_labels`` or ``default``, e.g., - ``CMIP6`` if ``facet_used_for_labels: project`` or ``historical`` if - ``facet_used_for_labels: exp``. Dictionary values are dictionaries used as - keyword arguments for :func:`iris.plot.plot`. String arguments can include - facets in curly brackets which will be derived from the corresponding - dataset, e.g., ``{project}``, ``{short_name}``, ``{exp}``. Examples: - ``default: {linestyle: '-', label: '{project}'}, CMIP6: {color: red, - linestyle: '--'}, OBS: {color: black}``. -pyplot_kwargs: dict, optional - Optional calls to functions of :mod:`matplotlib.pyplot`. Dictionary keys - are functions of :mod:`matplotlib.pyplot`. Dictionary values are used as - single argument for these functions. String arguments can include facets in - curly brackets which will be derived from the datasets plotted in the - corresponding plot, e.g., ``{short_name}``, ``{exp}``. Facets like - ``{project}`` that vary between the different datasets will be transformed - to something like ``ambiguous_project``. Examples: ``title: 'Awesome Plot - of {long_name}'``, ``xlabel: '{short_name}'``, ``xlim: [0, 5]``. + :func:`~datetime.datetime.strftime` format string that is used to format + the time axis using :class:`matplotlib.dates.DateFormatter`. If ``None``, + use the default formatting imposed by the iris plotting function. .. hint:: @@ -757,10 +754,10 @@ def _add_stats(self, plot_type, axes, dim_coords, dataset, # Different options for the different plots types fontsize = 6.0 y_pos = 0.95 - if plot_type == 'map': - x_pos_bias = self.plots[plot_type]['x_pos_stats_bias'] - x_pos = self.plots[plot_type]['x_pos_stats_avg'] - elif plot_type in ['zonal_mean_profile', 'hovmoeller_z_vs_time']: + if all([ + 'x_pos_stats_avg' in self.plots[plot_type], + 'x_pos_stats_bias' in self.plots[plot_type], + ]): x_pos_bias = self.plots[plot_type]['x_pos_stats_bias'] x_pos = self.plots[plot_type]['x_pos_stats_avg'] else: @@ -1295,14 +1292,14 @@ def _plot_hovmoeller_z_vs_time_without_ref(self, plot_func, dataset): axes = fig.add_subplot() plot_kwargs = self._get_plot_kwargs(plot_type, dataset) plot_kwargs['axes'] = axes - plot_zonal_mean_profile = plot_func(cube, **plot_kwargs) + plot_hovmoeller = plot_func(cube, **plot_kwargs) # Print statistics if desired self._add_stats(plot_type, axes, dim_coords_dat, dataset) # Setup colorbar fontsize = self.plots[plot_type]['fontsize'] - colorbar = fig.colorbar(plot_zonal_mean_profile, + colorbar = fig.colorbar(plot_hovmoeller, ax=axes, **self._get_cbar_kwargs(plot_type)) colorbar.set_label(self._get_cbar_label(plot_type, dataset), @@ -2126,8 +2123,8 @@ def compute(self): self.create_map_plot(datasets) self.create_zonal_mean_profile_plot(datasets) self.create_1d_profile_plot(datasets) - self.create_hovmoeller_z_vs_time_plot(datasets) self.create_variable_vs_lat_plot(datasets) + self.create_hovmoeller_z_vs_time_plot(datasets) def main(): diff --git a/esmvaltool/recipes/monitor/recipe_monitor_with_refs.yml b/esmvaltool/recipes/monitor/recipe_monitor_with_refs.yml index 7deae3f5f2..a93a627274 100644 --- a/esmvaltool/recipes/monitor/recipe_monitor_with_refs.yml +++ b/esmvaltool/recipes/monitor/recipe_monitor_with_refs.yml @@ -14,13 +14,8 @@ documentation: datasets: # Note: plot_label currently only used by diagnostic plot_multiple_annual_cycles -<<<<<<< HEAD - - {project: CMIP6, dataset: MPI-ESM1-2-HR, exp: historical, ensemble: r1i1p1f1, grid: gn, plot_label: 'MPI-ESM1-2-HR historical'} - - {project: CMIP6, dataset: MPI-ESM1-2-LR, exp: historical, ensemble: r1i1p1f1, grid: gn, plot_label: 'MPI-ESM1-2-LR MPI historical', reference_for_monitor_diags: true} -======= - - {project: CMIP6, dataset: EC-Earth3, exp: historical, ensemble: r1i1p1f1, grid: gr, plot_label: 'EC-Earth3 historical'} - - {project: CMIP6, dataset: CanESM5, exp: historical, ensemble: r1i1p1f1, grid: gn, plot_label: 'Reference (CanESM5 historical)', reference_for_monitor_diags: true} ->>>>>>> origin/main + - {project: CMIP6, dataset: MPI-ESM1-2-HR, exp: historical, ensemble: r1i1p1f1, grid: gn, plot_label: 'MPI-ESM1-2-HR historical'} + - {project: CMIP6, dataset: MPI-ESM1-2-LR, exp: historical, ensemble: r1i1p1f1, grid: gn, plot_label: 'Reference (MPI-ESM1-2-LR historical)', reference_for_monitor_diags: true} preprocessors: @@ -71,36 +66,27 @@ preprocessors: scheme: linear coordinate: air_pressure -<<<<<<< HEAD - global_mean_pressure: + var_vs_lat: + climate_statistics: + operator: mean + regrid: + target_grid: 2x2 + scheme: linear + zonal_statistics: + operator: mean + + global_mean_extract_levels: custom_order: true extract_levels: levels: {cmor_table: CMIP6, coordinate: plev39} scheme: linear coordinate: air_pressure -======= - var_vs_lat: - climate_statistics: - operator: mean ->>>>>>> origin/main regrid: target_grid: 2x2 - scheme: - reference: esmf_regrid.schemes:ESMFAreaWeighted -<<<<<<< HEAD + scheme: linear area_statistics: operator: mean - var_vs_lat: - climate_statistics: - operator: mean - zonal_statistics: - operator: mean -======= - zonal_statistics: - operator: mean - ->>>>>>> origin/main diagnostics: @@ -121,9 +107,9 @@ diagnostics: annual_mean_kwargs: linestyle: '--' plot_kwargs: - EC-Earth3: # = dataset since 'facet_used_for_labels' is 'dataset' by default + MPI-ESM1-2-HR: # = dataset since 'facet_used_for_labels' is 'dataset' by default color: C0 - CanESM5: + MPI-ESM1-2-LR: color: black plot_multiple_annual_cycles: @@ -142,9 +128,9 @@ diagnostics: legend_kwargs: loc: upper right plot_kwargs: - 'EC-Earth3 historical': # = plot_label since 'facet_used_for_labels: plot_label' + 'MPI-ESM1-2-HR historical': # = plot_label since 'facet_used_for_labels: plot_label' color: C0 - 'Reference (CanESM5 historical)': + 'Reference (MPI-ESM1-2-LR historical)': color: black pyplot_kwargs: title: Near-Surface Air Temperature on Northern Hemisphere @@ -198,26 +184,25 @@ diagnostics: plots: 1d_profile: plot_kwargs: - EC-Earth3: # = dataset since 'facet_used_for_labels' is 'dataset' by default + MPI-ESM1-2-HR: # = dataset since 'facet_used_for_labels' is 'dataset' by default color: C0 - CanESM5: + MPI-ESM1-2-LR: color: black pressure_vs_time_with_ref: description: Plot hovmoeller z vs time including reference datasets. variables: ta: - preprocessor: global_mean_pressure + preprocessor: global_mean_extract_levels mip: Amon - timerange: '2000/2014' + timerange: '2000/2004' scripts: plot: + <<: *plot_multi_dataset_default script: monitor/multi_datasets.py - plot_folder: '{plot_dir}' - plot_filename: '{plot_type}_{real_name}_{dataset}_{mip}' plots: hovmoeller_z_vs_time: - plot_func: 'contourf' + plot_func: contourf common_cbar: true time_format: '%Y-%m' log_y: true @@ -231,6 +216,7 @@ diagnostics: timerange: '20000101/20030101' scripts: plot: + <<: *plot_multi_dataset_default script: monitor/multi_datasets.py plots: variable_vs_lat: