Skip to content

aerocm.climate_models.fair_climate_model

This module contains the FairClimateModel class, which implements a climate model using the FaIR (Finite Amplitude Impulse Response) model.

FairClimateModel

FairClimateModel(start_year, end_year, specie_name, specie_inventory, specie_settings, model_settings)

Bases: ClimateModel

Climate model using FaIR to compute the RF, ERF and temperature increase for a given species and its emission profile, accounting for the background scenario.

Notes

References: - Leach et al. (2021). https://doi.org/10.5194/gmd-14-3007-2021 - Model implementation https://(docs).fairmodel.net/en/latest/

Source code in aerocm/utils/classes.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def __init__(
    self,
    start_year: int,
    end_year: int,
    specie_name: str,
    specie_inventory: list | np.ndarray,
    specie_settings: dict,
    model_settings: dict,
):
    """Initialize the climate model with the provided settings.

    Parameters
    ----------
    start_year : int
        Start year of the simulation.
    end_year : int
        End year of the simulation.
    specie_name : str
        Name of the species.
    specie_inventory : list or np.ndarray
        Emission profile for the species.
    specie_settings : dict
        Dictionary containing species settings.
    model_settings : dict
        Dictionary containing model settings.
    """

    # --- Validate parameters ---
    self.validate_model_settings(model_settings)
    self.validate_specie_settings(specie_name, specie_settings)
    self.validate_inventory(start_year, end_year, specie_inventory)

    # --- Store parameters ---
    self.start_year = start_year
    self.end_year = end_year
    self.specie_name = specie_name
    self.specie_inventory = specie_inventory
    self.specie_settings = specie_settings
    self.model_settings = model_settings

run

run(return_df=False)

Compute the RF, ERF and temperature increase for a given species and its quantities using the FaIR climate model.

Parameters:

Name Type Description Default
return_df bool

If True, returns the results as a pandas DataFrame with years as index. Default is False (returns a dict).

False

Returns:

Name Type Description
output_data dict

Dictionary containing the results of the FaIR climate model.

Source code in aerocm/climate_models/fair_climate_model.py
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
def run(self, return_df: bool = False) -> dict | pd.DataFrame:
    """
    Compute the RF, ERF and temperature increase for a given species and its quantities using the FaIR climate model.

    Parameters
    ----------
    return_df : bool, optional
        If True, returns the results as a pandas DataFrame with years as index. Default is False (returns a dict).

    Returns
    -------
    output_data : dict
        Dictionary containing the results of the FaIR climate model.
    """

    # --- Extract species settings ---
    specie_settings = self.specie_settings
    sensitivity_rf = specie_settings.get(
        "sensitivity_rf", 0.0
    )  # replace 2nd argument with default if needed
    ratio_erf_rf = specie_settings.get("ratio_erf_rf", 1.0)
    efficacy_erf = specie_settings.get("efficacy_erf", 1.0)
    ch4_change_per_species = specie_settings.get(
        "ch4_change_per_species", 0.0
    )  # only for NOx/H2 leakage - CH4 and induced

    # --- Extract simulation settings ---
    start_year = self.start_year
    end_year = self.end_year
    specie_name = self.specie_name
    specie_inventory = self.specie_inventory
    years = list(range(start_year, end_year + 1))

    # --- Extract model settings ---
    model_settings = self.model_settings
    contrails_saturation_factor = model_settings.get(
        "contrails_saturation_factor", 1.0
    )
    background_nox_correction_factor = model_settings.get(
        "background_nox_correction_factor", 0.0
    )
    background_species_quantities = self.get_background_species_quantities(
        model_settings, start_year, end_year
    )

    # --- Prepare inputs depending on species ---
    processed_inventory = None

    if specie_name == "CO2":
        processed_inventory = (
            specie_inventory / 10**12
        )  # Conversion from kgCO2 to GtCO2

    elif specie_name == "Soot - ARI":
        processed_inventory = (
            specie_inventory / 10**9
        )  # Conversion from kgSO2 to MtSO2

    elif specie_name == "Sulfur - ARI":
        processed_inventory = (
            specie_inventory / 10**9
        )  # Conversion from kgBC to MtBC

    elif specie_name == "Contrails":
        contrails_saturation_reference_year = 2018
        years_array = np.array(years)
        idx_ref_contrails = np.where(
            years_array == contrails_saturation_reference_year
        )[0][0]
        inventory_ref = specie_inventory[idx_ref_contrails]
        if (
            inventory_ref == 0
        ):  # in case of pulse emissions etc. emissions/km may be zero
            saturation_inventory = specie_inventory
            inventory_ref = 1.0
        else:
            saturation_inventory = (
                specie_inventory / inventory_ref
            ) ** contrails_saturation_factor
        rf = sensitivity_rf * inventory_ref * saturation_inventory
        erf = rf * ratio_erf_rf
        processed_inventory = erf  # W/m2

    elif (
        specie_name == "H2O"
        or specie_name == "Soot - ACI"
        or specie_name == "Sulfur - ACI"
        or specie_name == "H2 leakage - ST O3"
        or specie_name == "H2 leakage - SWV"
    ):
        rf = sensitivity_rf * specie_inventory
        erf = rf * ratio_erf_rf
        processed_inventory = erf  # W/m2

    elif specie_name == "H2 leakage - CH4 and induced":
        min_year = min(start_year, 1939)
        max_year = max(end_year, 2051)
        tau_reference_year = [min_year, 1940, 1980, 1994, 2004, 2050, max_year]
        tau_reference_values = [11, 11, 10.1, 10, 9.85, 10.25, 10.25]
        tau_function = interp1d(
            tau_reference_year, tau_reference_values, kind="linear"
        )
        tau = tau_function(years)
        ch4_molar_mass = 16.04e-3  # [kg/mol]
        air_molar_mass = 28.97e-3  # [kg/mol]
        atmosphere_total_mass = 5.1352e18  # [kg]
        radiative_efficiency = 3.454545e-4  # radiative efficiency [W/m^2/ppb] with AR6 value (5.7e-4) without indirect effects
        A_CH4_unit = (
            radiative_efficiency
            * 1e9
            * air_molar_mass
            / (ch4_molar_mass * atmosphere_total_mass)
        )  # RF per unit mass increase in atmospheric abundance of CH4 [W/m^2/kg]
        A_CH4 = A_CH4_unit * ch4_change_per_species * specie_inventory
        f1 = 0.5  # Indirect effect on ozone
        f2 = 0.15  # Indirect effect on stratospheric water
        radiative_forcing_from_year = np.zeros(
            (len(specie_inventory), len(specie_inventory))
        )
        # Radiative forcing induced in year j by the species emitted in year i
        for i in range(0, len(specie_inventory)):
            for j in range(0, len(specie_inventory)):
                if i <= j:
                    radiative_forcing_from_year[i, j] = (
                        (1 + f1 + f2) * A_CH4[i] * np.exp(-(j - i) / tau[j])
                    )
        radiative_forcing = np.zeros(len(specie_inventory))
        for k in range(0, len(specie_inventory)):
            radiative_forcing[k] = np.sum(radiative_forcing_from_year[:, k])
        effective_radiative_forcing = radiative_forcing * ratio_erf_rf
        processed_inventory = effective_radiative_forcing  # W/m2

    else:
        nox_background_reference_year = 2018
        nox_background = background_species_quantities["background_NOx"]
        dt_land = self.get_dt_land(
            nox_background, years, nox_background_reference_year
        )
        nox_correction = dt_land * background_nox_correction_factor + 1

        if specie_name == "NOx - ST O3":
            rf = sensitivity_rf * specie_inventory
            erf = rf * ratio_erf_rf
            processed_inventory = erf * nox_correction  # W/m2

        elif specie_name == "NOx - CH4 and induced":
            min_year = min(start_year, 1939)
            max_year = max(end_year, 2051)
            tau_reference_year = [min_year, 1940, 1980, 1994, 2004, 2050, max_year]
            tau_reference_values = [11, 11, 10.1, 10, 9.85, 10.25, 10.25]
            tau_function = interp1d(
                tau_reference_year, tau_reference_values, kind="linear"
            )
            tau = tau_function(years)
            ch4_molar_mass = 16.04e-3  # [kg/mol]
            air_molar_mass = 28.97e-3  # [kg/mol]
            atmosphere_total_mass = 5.1352e18  # [kg]
            radiative_efficiency = 3.454545e-4  # radiative efficiency [W/m^2/ppb] with AR6 value (5.7e-4) without indirect effects
            A_CH4_unit = (
                radiative_efficiency
                * 1e9
                * air_molar_mass
                / (ch4_molar_mass * atmosphere_total_mass)
            )  # RF per unit mass increase in atmospheric abundance of CH4 [W/m^2/kg]
            A_CH4 = A_CH4_unit * ch4_change_per_species * specie_inventory
            f1 = 0.5  # Indirect effect on ozone
            f2 = 0.15  # Indirect effect on stratospheric water
            radiative_forcing_from_year = np.zeros(
                (len(specie_inventory), len(specie_inventory))
            )
            # Radiative forcing induced in year j by the species emitted in year i
            for i in range(0, len(specie_inventory)):
                for j in range(0, len(specie_inventory)):
                    if i <= j:
                        radiative_forcing_from_year[i, j] = (
                            (1 + f1 + f2) * A_CH4[i] * np.exp(-(j - i) / tau[j])
                        )
            radiative_forcing = np.zeros(len(specie_inventory))
            for k in range(0, len(specie_inventory)):
                radiative_forcing[k] = np.sum(radiative_forcing_from_year[:, k])
            effective_radiative_forcing = radiative_forcing * ratio_erf_rf
            processed_inventory = (
                effective_radiative_forcing * nox_correction
            )  # W/m2

    # --- Run FaIR model ---
    fair_runner = FairRunner(start_year, end_year, background_species_quantities)
    results = fair_runner.run(
        specie_name, sensitivity_rf, ratio_erf_rf, efficacy_erf, processed_inventory
    )
    temperature_with_species = results["temperature"]
    effective_radiative_forcing_with_species = results[
        "effective_radiative_forcing"
    ]

    # --- Counterfactual scenario (without the species) ---
    # If background ERF and temperature are provided in model_settings, use them
    if {
        "background_effective_radiative_forcing",
        "background_temperature",
    } <= model_settings.keys():
        temperature_without_species = model_settings["background_temperature"]
        effective_radiative_forcing_without_species = model_settings[
            "background_effective_radiative_forcing"
        ]
    # Else, run FaIR with no additional species
    else:
        results_background = fair_runner.run()  # Run with no additional species
        temperature_without_species = results_background["temperature"]
        effective_radiative_forcing_without_species = results_background[
            "effective_radiative_forcing"
        ]

    # --- Compute RF, ERF and temperature increase due to the species ---
    temperature = temperature_with_species - temperature_without_species

    # For some species, the ERF is directly obtained from the inputs
    if specie_name in [
        "Contrails",
        "NOx - ST O3",
        "NOx - CH4 and induced",
        "H2O",
        "Soot - ACI",
        "Sulfur - ACI",
        "H2 leakage - ST O3",
        "H2 leakage - CH4 and induced",
        "H2 leakage - SWV",
    ]:
        effective_radiative_forcing = processed_inventory.reshape(-1, 1)
    # For other species, the ERF is the difference between the FaIR runs with and without the species
    else:
        effective_radiative_forcing = (
            effective_radiative_forcing_with_species
            - effective_radiative_forcing_without_species
        )

    radiative_forcing = effective_radiative_forcing / ratio_erf_rf

    # --- Return results ---
    output_data = {
        "radiative_forcing": radiative_forcing.flatten(),
        "effective_radiative_forcing": effective_radiative_forcing.flatten(),
        "temperature": temperature.flatten(),
    }
    if return_df:
        output_data = pd.DataFrame(output_data, index=years)
        output_data.index.name = "Year"

    return output_data

get_dt_land staticmethod

get_dt_land(inventory, years, reference_year)

Computes a ratio of emissions growth versus a reference year, used to parametrise

Source code in aerocm/climate_models/fair_climate_model.py
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
@staticmethod
def get_dt_land(inventory, years, reference_year):
    """
    Computes a ratio of emissions growth versus a reference year, used to parametrise

    """
    years_array = np.array(years)
    idx_ref = np.where(years_array == reference_year)[0][0]
    emission_ref = inventory[idx_ref]

    dt_land = (inventory - emission_ref) / emission_ref
    dt_land = np.nan_to_num(
        dt_land, 0.0
    )  # remove NaNs (if no or null background emissions)
    return dt_land

get_background_species_quantities staticmethod

get_background_species_quantities(model_settings=None, start_year=None, end_year=None)

Get the background species quantities from the model settings or from the background scenario.

Parameters:

Name Type Description Default
model_settings dict

Dictionary containing model settings.

None
start_year int

Start year of the simulation.

None
end_year int

End year of the simulation.

None

Returns:

Name Type Description
background_species_quantities dict

Dictionary containing the background species quantities (CO2 and CH4) for each year of the simulation.

Source code in aerocm/climate_models/fair_climate_model.py
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
@staticmethod
def get_background_species_quantities(
    model_settings: dict = None, start_year: int = None, end_year: int = None
) -> dict:
    """
    Get the background species quantities from the model settings or from the background scenario.

    Parameters
    ----------
    model_settings : dict
        Dictionary containing model settings.
    start_year : int
        Start year of the simulation.
    end_year : int
        End year of the simulation.

    Returns
    -------
    background_species_quantities : dict
        Dictionary containing the background species quantities (CO2 and CH4) for each year of the simulation.

    """
    scenario = model_settings.get("background_scenario")

    if "background_species_quantities" in model_settings:
        if scenario:
            warnings.warn(
                f"Both scenario and background species provided in model_settings. "
                f"The background species provided will override scenario '{scenario}'."
            )

        background_species_quantities = model_settings[
            "background_species_quantities"
        ]

    elif scenario:
        background_species_quantities = background_species_quantities_function(
            start_year, end_year, scenario
        )

    else:
        raise ValueError(
            "Either 'background_scenario' or 'background_species_quantities' must be provided in model_settings."
        )

    return background_species_quantities

FairRunner

FairRunner(start_year, end_year, background_species_quantities=None)

Class to run the FaIR climate model for a (single) given species and its emission profile.

Parameters:

Name Type Description Default
start_year int

Start year of the simulation.

required
end_year int

End year of the simulation.

required
background_species_quantities dict

Dictionary containing the background species quantities (CO2 and CH4) for each year of the simulation.

None

Attributes:

Name Type Description
start_year int

Start year of the simulation.

end_year int

End year of the simulation.

background_species_quantities dict

Dictionary containing the background species quantities (CO2 and CH4) for each year of the simulation.

species_list list

List of species included in the simulation.

properties dict

Dictionary containing the properties of each species.

f FAIR

Instance of the FAIR model.

Notes

This class is used internally by the FairClimateModel class, and is not intended to be used directly.

Source code in aerocm/climate_models/fair_climate_model.py
463
464
465
466
467
468
469
470
471
def __init__(
    self, start_year: int, end_year: int, background_species_quantities: dict = None
):
    self.start_year = start_year
    self.end_year = end_year
    self.background_species_quantities = background_species_quantities
    self.species_list = None
    self.properties = None
    self.f = None

run

run(specie_name=None, sensitivity_rf=0.0, ratio_erf_rf=1.0, efficacy_erf=1.0, specie_inventory=None)

Run FaIR climate model previously configured, for a (single) given species and its emission profile.

Parameters:

Name Type Description Default
specie_name str

Name of the species to be studied. If None, run background scenario with no additional species.

None
efficacy_erf int | float

Efficacy of the species for effective radiative forcing (default: 1.0)

1.0
specie_inventory list | ndarray

Array of annual emissions/forcing values for the species.

None

Returns:

Name Type Description
results dict

Dictionary containing the results of the FaIR climate model run for the effective radiative forcing and temperature.

Source code in aerocm/climate_models/fair_climate_model.py
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
def run(
    self,
    specie_name: str = None,
    sensitivity_rf: int | float = 0.0,
    ratio_erf_rf: int | float = 1.0,
    efficacy_erf: int | float = 1.0,
    specie_inventory: list | np.ndarray = None,
) -> dict:
    """
    Run FaIR climate model previously configured, for a (single) given species and its emission profile.

    Parameters
    ----------
    specie_name: str, optional
        Name of the species to be studied. If None, run background scenario with no additional species.
    efficacy_erf: int | float, optional
        Efficacy of the species for effective radiative forcing (default: 1.0)
    specie_inventory: list | np.ndarray, optional
        Array of annual emissions/forcing values for the species.

    Returns
    -------
    results : dict
        Dictionary containing the results of the FaIR climate model run for the effective radiative forcing
        and temperature.
    """
    # --- Setup model for fresh start ---
    self._setup_model()

    # --- Prepare inputs ---
    f = self.f
    species_list = self.species_list
    properties = self.properties
    if specie_name not in species_list + [
        None
    ]:  # None is allowed for run with only background species
        warnings.warn(
            f"Species '{specie_name}' not recognized and won't have any effect. Available species: {species_list}"
        )

    if specie_name == "Soot - ARI":
        erf_ari_soot = (
            sensitivity_rf * ratio_erf_rf * 10**9
        )  # W/m² per MtSO2/yr, conversion from W/m² per kgSO2/yr
        fill(
            f.species_configs["erfari_radiative_efficiency"],
            erf_ari_soot,
            specie="Soot - ARI",
        )
        fill(f.species_configs["aci_shape"], 0.0, specie="Soot - ARI")

    if specie_name == "Sulfur - ARI":
        erf_ari_sulfur = (
            sensitivity_rf * ratio_erf_rf * 10**9
        )  # W/m² per MtSO2/yr, conversion from W/m² per kgSO2/yr
        fill(
            f.species_configs["erfari_radiative_efficiency"],
            erf_ari_sulfur,
            specie="Sulfur - ARI",
        )
        fill(f.species_configs["aci_shape"], 0.0, specie="Sulfur - ARI")

    # --- Set efficacy erf for current species ---
    if specie_name in species_list:
        fill(
            f.species_configs["forcing_efficacy"], efficacy_erf, specie=specie_name
        )

    # --- Set emissions/forcing inputs for current species ---
    # - special case for CO2: adds to background CO2 -
    if specie_name == "CO2":
        total_CO2 = f.emissions.loc[
            dict(specie="CO2", config=f.configs[0], scenario=f.scenarios[0])
        ].data  # background CO2 emissions
        total_CO2 += specie_inventory[1:]  # add aviation CO2 emissions
        fill(
            f.emissions,
            total_CO2,
            specie="CO2",
            config=f.configs[0],
            scenario=f.scenarios[0],
        )

    # - Species not recognized -
    elif specie_name not in species_list:
        pass  # species not recognized, do nothing

    # - Species using forcing as input instead of emissions -
    elif properties[specie_name]["input_mode"] == "forcing":
        fill(
            f.forcing,
            specie_inventory,
            specie=specie_name,
            config=f.configs[0],
            scenario=f.scenarios[0],
        )

    # - Species using emissions as input -
    else:
        fill(
            f.emissions,
            specie_inventory[1:],
            specie=specie_name,
            config=f.configs[0],
            scenario=f.scenarios[0],
        )

    # --- Initialise state variables to zero ---
    initialise(f.forcing, 0)
    initialise(f.temperature, 0)
    initialise(f.cumulative_emissions, 0)
    initialise(f.airborne_emissions, 0)

    # --- Run model ---
    f.run(progress=False)

    # --- Results ---
    results = {
        "effective_radiative_forcing": f.forcing_sum.loc[
            dict(config=f.configs[0])
        ].data,
        "temperature": f.temperature.loc[dict(config=f.configs[0], layer=0)].data,
    }

    return results

initialise_emissions_and_forcing

initialise_emissions_and_forcing()

Initialise all emissions and forcing to zero for all species.

Source code in aerocm/climate_models/fair_climate_model.py
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
def initialise_emissions_and_forcing(self):
    """
    Initialise all emissions and forcing to zero for all species.
    """
    f = self.f
    for specie in self.species_list:
        if self.properties[specie]["input_mode"] == "forcing":
            fill(
                f.forcing,
                0,
                specie=specie,
                config=f.configs[0],
                scenario=f.scenarios[0],
            )
        else:
            fill(
                f.emissions,
                0,
                specie=specie,
                config=f.configs[0],
                scenario=f.scenarios[0],
            )

background_species_quantities_function

background_species_quantities_function(start_year, end_year, scenario=None)

Get background species quantities (CO2 and CH4) from RCP or SSP scenarios.

Parameters:

Name Type Description Default
start_year int

Start year of the simulation.

required
end_year int

End year of the simulation. Background scenario to be used ('RCP26', 'RCP45', 'RCP60', 'RCP85', 'SSP119', 'SSP126', 'SSP245', 'SSP370', 'SSP434', 'SSP460', 'SSP534-over', 'SSP585'). Select None to set background species to zero.

required

Returns:

Name Type Description
background_species_quantities dict

Dictionary containing the background species quantities (CO2, CH4, NOx) for each year of the simulation.

Example
>>> from aerocm.climate_models.fair_climate_model import background_species_quantities_function
>>> background_species_quantities = background_species_quantities_function(2020, 2050, 'RCP45')
Source code in aerocm/climate_models/fair_climate_model.py
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
def background_species_quantities_function(
    start_year: int, end_year: int, scenario: str = None
) -> dict:
    """
    Get background species quantities (CO2 and CH4) from RCP or SSP scenarios.

    Parameters
    ----------
    start_year : int
        Start year of the simulation.
    end_year : int
        End year of the simulation.
        Background scenario to be used ('RCP26', 'RCP45', 'RCP60', 'RCP85', 'SSP119', 'SSP126', 'SSP245', 'SSP370', 'SSP434', 'SSP460', 'SSP534-over', 'SSP585'). Select None to set background species to zero.

    Returns
    -------
    background_species_quantities : dict
        Dictionary containing the background species quantities (CO2, CH4, NOx) for each year of the simulation.

    Example
    -------
    ```python
    >>> from aerocm.climate_models.fair_climate_model import background_species_quantities_function
    >>> background_species_quantities = background_species_quantities_function(2020, 2050, 'RCP45')
    ```
    """

    # --- Validate inputs ---
    if start_year < BACKGROUND_SCENARIO_START_YEAR:
        raise ValueError(f"start_year must be >= {BACKGROUND_SCENARIO_START_YEAR}")

    # --- Initialise variables ---
    background_species_quantities = {
        "background_CO2": np.zeros(end_year - start_year + 1),
        "background_CH4": np.zeros(end_year - start_year + 1),
        "background_NOx": np.zeros(end_year - start_year + 1),
    }

    background_scenario_data_path = None

    # --- Read data ---
    if scenario == "SSP119":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "SSP119.csv"
        )
    elif scenario == "SSP126":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "SSP126.csv"
        )
    elif scenario == "SSP245":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "SSP245.csv"
        )
    elif scenario == "SSP370":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "SSP370.csv"
        )
    elif scenario == "SSP434":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "SSP434.csv"
        )
    elif scenario == "SSP460":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "SSP460.csv"
        )
    elif scenario == "SSP534-over":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "SSP534-over.csv"
        )
    elif scenario == "SSP585":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "SSP585.csv"
        )
    elif scenario == "RCP26":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "RCP26.csv"
        )
    elif scenario == "RCP45":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "RCP45.csv"
        )
    elif scenario == "RCP60":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "RCP60.csv"
        )
    elif scenario == "RCP85":
        background_scenario_data_path = pth.join(
            background_scenarios.__path__[0], "RCP85.csv"
        )
    else:
        warnings.warn(
            "Scenario not recognised (available: SSP119, SSP126, SSP245, SSP370, SSP434, SSP460, SSP534-over, SSP585, RCP26, RCP45, RCP60, RCP85)"
        )

    background_scenario_data_df = pd.read_csv(background_scenario_data_path)

    # World CO2
    background_species_quantities["background_CO2"] = (
        background_scenario_data_df["CO2"][
            start_year
            - BACKGROUND_SCENARIO_START_YEAR : end_year
            - BACKGROUND_SCENARIO_START_YEAR
            + 1
        ].values
    ) / 1000  # Unit: GtCO2

    # World CH4
    background_species_quantities["background_CH4"] = background_scenario_data_df[
        "CH4"
    ][
        start_year
        - BACKGROUND_SCENARIO_START_YEAR : end_year
        - BACKGROUND_SCENARIO_START_YEAR
        + 1
    ].values  # Unit: MtCH4

    # Background NOx
    background_species_quantities["background_NOx"] = background_scenario_data_df[
        "NOx"
    ][
        start_year
        - BACKGROUND_SCENARIO_START_YEAR : end_year
        - BACKGROUND_SCENARIO_START_YEAR
        + 1
    ].values  # Unit: MtNOx

    if end_year > BACKGROUND_SCENARIO_END_YEAR:
        # World CO2
        constant_co2 = (background_scenario_data_df["CO2"].values[-1]) * np.ones(
            end_year - BACKGROUND_SCENARIO_END_YEAR
        )
        background_species_quantities["background_CO2"] = np.concatenate(
            (background_species_quantities["background_CO2"], constant_co2)
        )

        # World CH4
        constant_ch4 = (background_scenario_data_df["CH4"].values[-1]) * np.ones(
            end_year - BACKGROUND_SCENARIO_END_YEAR
        )
        background_species_quantities["background_CH4"] = np.concatenate(
            (background_species_quantities["background_CH4"], constant_ch4)
        )

        # Background NOx
        constant_nox = (background_scenario_data_df["NOx"].values[-1]) * np.ones(
            end_year - BACKGROUND_SCENARIO_END_YEAR
        )
        background_species_quantities["background_NOx"] = np.concatenate(
            (background_species_quantities["background_NOx"], constant_nox)
        )

        # Warning
        warnings.warn(
            f"Background scenario'{scenario}' has no emission data after 2500. "
            f"Constant emissions were considered for after 2500."
        )

    return background_species_quantities