.. _boxplots: Boxplots Diagnostic =================== Description ----------- The **Boxplots** diagnostic computes and visualizes boxplots of spatial field means from climate model datasets, for one or multiple variables, over a specified time period. The diagnostic is designed with a class that analyzes a single model and generates the NetCDF files with the field means, and another class that produces the plots. Classes ------- There is one class for the analysis and one for the plotting: * **Boxplots**: retrieves the data and prepares it for plotting (e.g., regridding, unit conversion). It also handles the computation of field means, which are saved as class attributes and as NetCDF files. * **PlotBoxplots**: provides methods for plotting the boxplots of the field means computed by the Boxplots class. File structure -------------- * The diagnostic is located in the ``aqua/diagnostics/boxplots`` directory, which contains both the source code and the command line interface (CLI) script. * A template configuration file is available at ``aqua/diagnostics/templates/diagnostics/config-boxplots.yaml`` * Notebooks are available in the ``notebooks/diagnostics/boxplots`` directory and contain examples of how to use the diagnostic. Input variables and datasets ---------------------------- The diagnostic can be used with any dataset that contains spatial fields. Multimodel datasets can be analyzed, and the diagnostic can be configured to compare against multiple reference datasets. Some of the variables that are typically used in this diagnostic are: * ``tnlwrf`` (top net longwave radiation flux) * ``tnswrf`` (top net shortwave radiation flux) * ``slhtf`` (surface latent heat flux) * ``ishf`` (instantaneous surface sensible heat flux) The diagnostic is designed to work with data from the Low Resolution Archive (LRA), generated by the Data Reduction OPerator (DROP) of the AQUA project, which provides monthly data at a 1x1 degree resolution. .. note:: All analyzed variables should share the same units to ensure meaningful comparisons; otherwise, the diagnostic will raise an error. Basic usage ----------- The basic usage of this diagnostic is explained with a working example in the notebook. The basic structure of the analysis is the following: .. code-block:: python from aqua.diagnostics import Boxplots, PlotBoxplots variables = ['-tnlwrf', 'tnswrf'] boxplots = Boxplots(model='IFS-NEMO', exp='historical-1990', source='lra-r100-monthly') boxplots.run(var=variables) boxplots_era5 = Boxplots(model='ERA5', exp='era5', source='monthly') boxplots_era5.run(var=variables) boxplots_ceres = Boxplots(model='CERES', exp='ebaf-toa41', source='monthly', regrid='r100') boxplots_ceres.run(var=variables) datasets = boxplots.fldmeans datasets_ref = [boxplots_ceres.fldmeans, boxplots_era5.fldmeans] plot = PlotBoxplots(diagnostic='radiation') plot.plot_boxplots(data=datasets, data_ref=datasets_ref, var=variables) .. note:: Start/end dates and reference datasets can be customized. If not specified otherwise, plots will be saved in PNG and PDF format in the current working directory. CLI usage --------- The diagnostic can be run from the command line interface (CLI) by running the following command: .. code-block:: bash cd $AQUA/aqua/diagnostics/boxplots python cli_boxplots.py --config Additionally, the CLI can be run with the following optional arguments: - ``--config``, ``-c``: Path to the configuration file. - ``--nworkers``, ``-n``: Number of workers to use for parallel processing. - ``--cluster``: Cluster to use for parallel processing. By default, a local cluster is used. - ``--loglevel``, ``-l``: Logging level. Default is ``WARNING``. - ``--catalog``: Catalog to use for the analysis. Can be defined in the config file. - ``--model``: Model to analyse. Can be defined in the config file. - ``--exp``: Experiment to analyse. Can be defined in the config file. - ``--source``: Source to analyse. Can be defined in the config file. - ``--outputdir``: Output directory for the plots. - ``--startdate``: Start date for the analysis. - ``--enddate``: End date for the analysis. Configuration file structure ---------------------------- The configuration file is a YAML file that contains the details on the dataset to analyse or use as reference, the output directory and the diagnostic settings. Most of the settings are common to all the diagnostics (see :ref:`diagnostics-configuration-files`). Here we describe only the specific settings for the boxplots diagnostic. * ``boxplots``: a block (nested in the ``diagnostics`` block) containing options for the Boxplots diagnostic. Variable-specific parameters override the defaults. * ``run``: enable/disable the diagnostic. * ``diagnostic_name``: name of the diagnostic. ``boxplots`` by default, but can be changed when the boxplots CLI is invoked within another ``recipe`` diagnostic, as is currently done for ``Radiation``. * ``variables``: list of variables to analyse. .. code-block:: yaml diagnostics: boxplots: run: true diagnostic_name: 'radiation_toa' variables: ['-tnlwrf', 'tnswrf'] - vars: ['-tnlwrf', 'tnswrf'] add_mean_line: true anomalies: true ref_number: 0 # use ERA5 as reference for anomalies Output ------ The diagnostic produces a single plot: * A boxplot showing the distribution of the field means for each variable across the specified models and reference datasets. If reference datasets are provided and the ``anomalies`` option is set to ``True``, the boxplot will show anomalies with respect to the mean of the selected reference dataset. With the ``add_mean_line`` option set to ``True``, dashed lines indicating the absolute mean values will be added to the boxplots. Plots are saved in both PDF and PNG format. Observations ------------ This diagnostic can be applied to different variables and datasets, although it is currently used primarily for radiation analyses. The default reference datasets are: * ERA5 reanalysis for atmospheric variables * CERES EBAF for radiation variables at top of atmosphere Details are available on the `CERES website `_. Custom reference datasets can be configured in the configuration file. Example plots ------------- All plots can be reproduced using the notebooks in the ``notebooks`` directory on LUMI HPC. .. figure:: figures/radiation_boxplot.png :align: center :width: 100% Box plot showing the globally averaged incoming and outgoing TOA radiation of IFS-NEMO historical-1990 with respect to ERA5 and CERES climatologies. .. figure:: figures/radiation_boxplot_anomalies.png :align: center :width: 100% Box plot showing the anomalies of the globally averaged incoming and outgoing TOA radiation of IFS-NEMO historical-1990 with respect to the ERA5 climatology. The dashed lines indicate the absolute mean values. Available demo notebooks ------------------------ Notebooks are stored in ``notebooks/diagnostics/boxplots``: * `boxplots.ipynb `_ Authors and contributors ------------------------ This diagnostic is maintained by Silvia Caprioli (`@silviacaprioli `_, `silvia.caprioli@polito.it `_). Contributions are welcome — please open an issue or a pull request. For questions or suggestions, contact the AQUA team or the maintainers. Detailed API ------------ This section provides a detailed reference for the Application Programming Interface (API) of the ``Boxplots`` diagnostic, produced from the diagnostic function docstrings. .. automodule:: aqua.diagnostics.boxplots :members: :undoc-members: :show-inheritance: