Skip to main content
Ctrl+K
IMPROVER  documentation - Home IMPROVER  documentation - Home

About IMPROVER

  • What is IMPROVER?

Examples

  • Examples
    • Using example data: Threshold realizations to get probabilities
    • Simple example: Threshold realizations to get probabilities
    • Using example data: Cluster and match ensemble realizations
  • Adding Examples to the Gallery

Developer Guide

  • Code style guide
  • Definition of done
  • Guidance for reviewing code
  • How to implement a command line utility
  • Running at your site
  • Dependencies
  • Ticket creation and definition of ready
  • Making a new release

Metadata Guide

  • Introduction
  • Principles
  • Probability Distribution
  • Statistical Processing
  • Developer guide to working with metadata
  • Reference

The Code

  • The Code
    • improver.api package
    • improver.blending package
      • improver.blending.blend_across_adjacent_points module
      • improver.blending.calculate_weights_and_blend module
      • improver.blending.spatial_weights module
      • improver.blending.utilities module
      • improver.blending.weighted_blend module
      • improver.blending.weights module
    • improver.calibration package
      • improver.calibration.beta_recalibration module
      • improver.calibration.dataframe_utilities module
      • improver.calibration.dz_rescaling module
      • improver.calibration.emos_calibration module
      • improver.calibration.load_and_apply_quantile_regression_random_forest module
      • improver.calibration.load_and_train_quantile_regression_random_forest module
      • improver.calibration.quantile_mapping module
      • improver.calibration.quantile_regression_random_forest module
      • improver.calibration.rainforest_calibration module
      • improver.calibration.reliability_calibration module
      • improver.calibration.samos_calibration module
      • improver.calibration.simple_bias_correction module
      • improver.calibration.stochastic_noise module
      • improver.calibration.utilities module
    • improver.categorical package
      • improver.categorical.decision_tree module
      • improver.categorical.modal_code module
      • improver.categorical.subperiod_selector module
      • improver.categorical.utilities module
    • improver.cli package
      • improver.cli.__main__ module
      • improver.cli.aggregate_reliability_tables module
      • improver.cli.apply_beta_recalibration module
      • improver.cli.apply_bias_correction module
      • improver.cli.apply_dz_rescaling module
      • improver.cli.apply_emos_coefficients module
      • improver.cli.apply_height_adjustment module
      • improver.cli.apply_lapse_rate module
      • improver.cli.apply_mask module
      • improver.cli.apply_night_mask module
      • improver.cli.apply_quantile_regression_random_forest module
      • improver.cli.apply_rainforests_calibration module
      • improver.cli.apply_reliability_calibration module
      • improver.cli.apply_samos_coefficients module
      • improver.cli.between_thresholds module
      • improver.cli.blend_adjacent_points module
      • improver.cli.blend_cycles_and_realizations module
      • improver.cli.blend_with_vicinity_and_rename module
      • improver.cli.calculate_forecast_bias module
      • improver.cli.categorical module
      • improver.cli.categorical_modes module
      • improver.cli.clip module
      • improver.cli.cloud_condensation_level module
      • improver.cli.cloud_top_temperature module
      • improver.cli.collapse_realizations module
      • improver.cli.combine module
      • improver.cli.compare module
      • improver.cli.construct_reliability_tables module
      • improver.cli.convection_ratio module
      • improver.cli.copy_metadata module
      • improver.cli.create_grid_with_halo module
      • improver.cli.cubelist_extract module
      • improver.cli.deterministic_realization_selector module
      • improver.cli.duration_subdivision module
      • improver.cli.enforce_consistent_forecasts module
      • improver.cli.estimate_dz_rescaling module
      • improver.cli.estimate_emos_coefficients module
      • improver.cli.estimate_emos_coefficients_from_table module
      • improver.cli.estimate_samos_coefficients module
      • improver.cli.estimate_samos_coefficients_from_table module
      • improver.cli.estimate_samos_gams module
      • improver.cli.estimate_samos_gams_from_table module
      • improver.cli.expand_realization_dimension module
      • improver.cli.expected_value module
      • improver.cli.extend_radar_mask module
      • improver.cli.extract module
      • improver.cli.extract_from_table module
      • improver.cli.feels_like_temp module
      • improver.cli.field_texture module
      • improver.cli.fill_radar_holes module
      • improver.cli.forecast_trajectory_gap_filler module
      • improver.cli.freezing_rain module
      • improver.cli.generate_clearsky_solar_radiation module
      • improver.cli.generate_landmask_ancillary module
      • improver.cli.generate_metadata_cube module
      • improver.cli.generate_orographic_smoothing_coefficients module
      • improver.cli.generate_percentiles module
      • improver.cli.generate_realizations module
      • improver.cli.generate_solar_time module
      • improver.cli.generate_topography_bands_mask module
      • improver.cli.generate_topography_bands_weights module
      • improver.cli.gradient_between_adjacent_grid_squares module
      • improver.cli.gradient_between_vertical_levels module
      • improver.cli.hail_fraction module
      • improver.cli.hail_size module
      • improver.cli.height_of_max_vertical_velocity module
      • improver.cli.integrate_time_bounds module
      • improver.cli.interpolate_using_difference module
      • improver.cli.interpret_metadata module
      • improver.cli.lightning_from_cape_and_precip module
      • improver.cli.lightning_multivariate_probability_usaf2024 module
      • improver.cli.manipulate_reliability_table module
      • improver.cli.max_in_height module
      • improver.cli.max_in_time_window module
      • improver.cli.merge module
      • improver.cli.nbhood module
      • improver.cli.nbhood_iterate_with_mask module
      • improver.cli.nbhood_land_and_sea module
      • improver.cli.neighbour_finding module
      • improver.cli.normalise_to_reference module
      • improver.cli.nowcast_accumulate module
      • improver.cli.nowcast_extrapolate module
      • improver.cli.nowcast_optical_flow module
      • improver.cli.nowcast_optical_flow_from_winds module
      • improver.cli.orographic_enhancement module
      • improver.cli.phase_change_level module
      • improver.cli.phase_mask module
      • improver.cli.phase_probability module
      • improver.cli.precipitation_duration module
      • improver.cli.quantile_mapping module
      • improver.cli.realization_cluster_and_match module
      • improver.cli.realization_selection module
      • improver.cli.recursive_filter module
      • improver.cli.regrid module
      • improver.cli.relabel_to_period module
      • improver.cli.remake_as_shower_condition module
      • improver.cli.resolve_wind_components module
      • improver.cli.shower_condition_probability module
      • improver.cli.sleet_probability module
      • improver.cli.snow_fraction module
      • improver.cli.snow_splitter module
      • improver.cli.spot_extract module
      • improver.cli.standardise module
      • improver.cli.stochastic_noise module
      • improver.cli.subperiod_selector module
      • improver.cli.temp_lapse_rate module
      • improver.cli.temporal_interpolate module
      • improver.cli.threshold module
      • improver.cli.threshold_interpolation module
      • improver.cli.time_lagged_ensembles module
      • improver.cli.train_quantile_regression_random_forest module
      • improver.cli.uv_index module
      • improver.cli.vertical_updraught module
      • improver.cli.vicinity module
      • improver.cli.visibility_combine_cloud_base module
      • improver.cli.weather_symbol_modes module
      • improver.cli.weighted_blending module
      • improver.cli.wet_bulb_freezing_level module
      • improver.cli.wet_bulb_temperature module
      • improver.cli.wet_bulb_temperature_integral module
      • improver.cli.wind_direction module
      • improver.cli.wind_downscaling module
      • improver.cli.wind_gust_diagnostic module
    • improver.clustering package
      • improver.clustering.clustering module
      • improver.clustering.realization_clustering module
    • improver.developer_tools package
      • improver.developer_tools.metadata_interpreter module
    • improver.ensemble_copula_coupling package
      • improver.ensemble_copula_coupling._scipy_continuous_distns module
      • improver.ensemble_copula_coupling.constants module
      • improver.ensemble_copula_coupling.ensemble_copula_coupling module
      • improver.ensemble_copula_coupling.numba_utilities module
      • improver.ensemble_copula_coupling.utilities module
    • improver.fire_weather package
      • improver.fire_weather.build_up_index module
      • improver.fire_weather.drought_code module
      • improver.fire_weather.duff_moisture_code module
      • improver.fire_weather.fine_fuel_moisture_code module
      • improver.fire_weather.fire_severity_index module
      • improver.fire_weather.fire_weather_index module
      • improver.fire_weather.initial_spread_index module
    • improver.generate_ancillaries package
      • improver.generate_ancillaries.generate_ancillary module
      • improver.generate_ancillaries.generate_derived_solar_fields module
      • improver.generate_ancillaries.generate_distance_to_feature module
      • improver.generate_ancillaries.generate_miscellaneous_ancillaries module
      • improver.generate_ancillaries.generate_orographic_smoothing_coefficients module
      • improver.generate_ancillaries.generate_svp_derivative_table module
      • improver.generate_ancillaries.generate_svp_table module
      • improver.generate_ancillaries.generate_topographic_zone_weights module
    • improver.metadata package
      • improver.metadata.constants package
        • improver.metadata.constants.attributes module
        • improver.metadata.constants.mo_attributes module
        • improver.metadata.constants.time_types module
      • improver.metadata.amend module
      • improver.metadata.check_datatypes module
      • improver.metadata.forecast_times module
      • improver.metadata.probabilistic module
      • improver.metadata.utilities module
    • improver.nbhood package
      • improver.nbhood.nbhood module
      • improver.nbhood.recursive_filter module
      • improver.nbhood.use_nbhood module
    • improver.nowcasting package
      • improver.nowcasting.accumulation module
      • improver.nowcasting.forecasting module
      • improver.nowcasting.lightning module
      • improver.nowcasting.optical_flow module
      • improver.nowcasting.pysteps_advection module
      • improver.nowcasting.utilities module
    • improver.pollen package
      • improver.pollen.daily_concentration module
      • improver.pollen.hourly_concentration module
      • improver.pollen.pollen_index_for_period module
      • improver.pollen.pollen_maximum_index_for_period module
      • improver.pollen.utilities module
    • improver.precipitation package
      • improver.precipitation.calculate_sleet_prob module
      • improver.precipitation.convection module
      • improver.precipitation.freezing_rain module
      • improver.precipitation.hail_fraction module
      • improver.precipitation.precipitation_duration module
      • improver.precipitation.shower_condition_probability module
      • improver.precipitation.snow_fraction module
      • improver.precipitation.snow_probability_at_surface module
      • improver.precipitation.snow_splitter module
      • improver.precipitation.utilities module
    • improver.psychrometric_calculations package
      • improver.psychrometric_calculations.cloud_condensation_level module
      • improver.psychrometric_calculations.cloud_top_temperature module
      • improver.psychrometric_calculations.condensation_trails module
      • improver.psychrometric_calculations.hail_size module
      • improver.psychrometric_calculations.precip_phase_probability module
      • improver.psychrometric_calculations.precipitable_water module
      • improver.psychrometric_calculations.psychrometric_calculations module
      • improver.psychrometric_calculations.significant_phase_mask module
      • improver.psychrometric_calculations.temperature_saturated_air_parcel module
      • improver.psychrometric_calculations.wet_bulb_temperature module
    • improver.regrid package
      • improver.regrid.bilinear module
      • improver.regrid.grid module
      • improver.regrid.idw module
      • improver.regrid.landsea module
      • improver.regrid.landsea2 module
      • improver.regrid.nearest module
    • improver.spotdata package
      • improver.spotdata.apply_lapse_rate module
      • improver.spotdata.build_spotdata_cube module
      • improver.spotdata.height_adjustment module
      • improver.spotdata.neighbour_finding module
      • improver.spotdata.spot_extraction module
      • improver.spotdata.spot_manipulation module
      • improver.spotdata.utilities module
    • improver.standard_geopotential_height package
      • improver.standard_geopotential_height.standard_geopotential_height module
    • improver.synthetic_data package
      • improver.synthetic_data.generate_metadata module
      • improver.synthetic_data.set_up_test_cubes module
      • improver.synthetic_data.utilities module
    • improver.temperature package
      • improver.temperature.feels_like_temperature module
      • improver.temperature.lapse_rate module
      • improver.temperature.layer_mean_temperature module
      • improver.temperature.virtual_temperature module
    • improver.utilities package
      • improver.utilities.cli_utilities module
      • improver.utilities.common_input_handle module
      • improver.utilities.compare module
      • improver.utilities.complex_conversion module
      • improver.utilities.copy_metadata module
      • improver.utilities.cube_checker module
      • improver.utilities.cube_constraints module
      • improver.utilities.cube_extraction module
      • improver.utilities.cube_manipulation module
      • improver.utilities.deterministic_realization_selector module
      • improver.utilities.expand_realization_dimension module
      • improver.utilities.extract_from_table module
      • improver.utilities.flatten module
      • improver.utilities.forecast_reference_enforcement module
      • improver.utilities.generalized_additive_models module
      • improver.utilities.gradient_between_vertical_levels module
      • improver.utilities.indexing_operations module
      • improver.utilities.interpolation module
      • improver.utilities.load module
      • improver.utilities.mask module
      • improver.utilities.masking module
      • improver.utilities.mathematical_operations module
      • improver.utilities.neighbourhood_tools module
      • improver.utilities.pad_spatial module
      • improver.utilities.probability_manipulation module
      • improver.utilities.redirect_stdout module
      • improver.utilities.rescale module
      • improver.utilities.round module
      • improver.utilities.save module
      • improver.utilities.solar module
      • improver.utilities.spatial module
      • improver.utilities.statistical module
      • improver.utilities.temporal module
      • improver.utilities.temporal_interpolation module
      • improver.utilities.textural module
      • improver.utilities.threshold_interpolation module
      • improver.utilities.time_lagging module
    • improver.visibility package
      • improver.visibility.visibility_combine_cloud_base module
    • improver.wind_calculations package
      • improver.wind_calculations.vertical_updraught module
      • improver.wind_calculations.wind_components module
      • improver.wind_calculations.wind_direction module
      • improver.wind_calculations.wind_downscaling module
      • improver.wind_calculations.wind_gust_diagnostic module
    • improver.between_thresholds module
    • improver.constants module
    • improver.cube_combiner module
    • improver.expected_value module
    • improver.grids module
    • improver.lightning module
    • improver.memprofile module
    • improver.orographic_enhancement module
    • improver.percentile module
    • improver.profile module
    • improver.standardise module
    • improver.threshold module
    • improver.uv_index module
  • Repository
  • Suggest edit
  • Open issue
  • .rst

Adding Examples to the Gallery

Contents

  • Adding a New Example
  • Using Real Data in Examples
  • Managing Dependencies for Examples

Adding Examples to the Gallery#

This guide explains how to add new examples to the IMPROVER examples gallery.

Adding a New Example#

To add a new example to this gallery:

  1. Create a Python file in the doc/source/examples/ directory with a descriptive name.

  2. Follow the format of existing examples like thresholding_simple_example.py:

    • Start with a docstring (triple quotes) containing a title with equals signs above and below

    • Add a description of what the example demonstrates

    • Include author and license information

    • Use # %% to separate code cells

    • Add comments or section headers (using # %% followed by description lines) to explain each step

  3. Alternatively, you can create a Jupyter notebook and convert it to a Sphinx-Gallery compatible Python file using jupytext:

    jupytext --to py:percent --opt notebook_metadata_filter='-all' your_notebook.ipynb
    
  4. Sphinx-Gallery will automatically:

    • Generate a thumbnail from the first figure

    • Convert the script to a reStructuredText page

    • Add it to this gallery

    • Create a downloadable Jupyter notebook version

  5. Build the documentation to see your example in the gallery.

Using Real Data in Examples#

If you want to create examples that use real data files:

  1. Add the data files to the improver_example_data repository.

  2. Create a branch in the improver_example_data repository with your data files.

  3. When creating a pull request in this repository (improver), note the PR number (e.g., 123). Create a branch in improver_example_data with the same number as the PR number (e.g., branch named 123). This ensures that the documentation build for the pull request preview can access the correct version of the example data.

    Alternatively, for local development, you can create matching branch names in both repositories instead of using PR numbers.

  4. In your example script, use the example_data_path() function to reference the data files:

    from improver import example_data_path
    
    data_file = example_data_path("subdirectory", "filename.nc")
    
  5. When both pull requests are merged, the documentation will automatically use the example data from the master branch of improver_example_data.

Managing Dependencies for Examples#

Examples require appropriate Python packages to be available in multiple environments. If your example requires additional modules that are not part of the standard IMPROVER dependencies:

  1. For ReadTheDocs builds: Check if the required module is listed in doc/rtd_environment.yml. If missing, add it to the dependencies: section. This file specifies the conda environment used when building the documentation on ReadTheDocs.

  2. For GitHub Actions CI checks: Examples are also run as part of the continuous integration checks using the test environments defined in the envs/ directory (e.g., envs/environment_a.yml, envs/environment_b.yml). Unless the required module is available in all of these test environments, some GitHub Actions checks will fail.

  3. If a required module is not available in all environments and cannot be added to them, you can make your example skip gracefully by checking for the module’s availability at the start of the script:

    try:
        import required_module
    except ImportError:
        import sys
        sys.exit(0)  # Exit cleanly for sphinx-gallery
    

    This allows sphinx-gallery to skip the example without failing the documentation build or GitHub Actions checks.

previous

Using example data: Cluster and match ensemble realizations

next

Code style guide

Contents
  • Adding a New Example
  • Using Real Data in Examples
  • Managing Dependencies for Examples

This Page

  • Show Source

By Met Office

© Copyright - British Crown copyright. The Met Office.