aerocm.climate_models.aviation_climate_simulation¶
Main interface to run climate simulations for aviation emissions using different climate models.
AviationClimateSimulation ¶
AviationClimateSimulation(climate_model, start_year, end_year, species_inventory, species_settings=None, model_settings=None)
Class to run a climate simulation for aviation emissions using a specified climate model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
climate_model
|
str | ClimateModel | Callable
|
The climate model to use. Can be a registered name ('IPCC', 'GWP*', 'LWE', 'FaIR'), a subclass of ClimateModel, or a callable function |
required |
start_year
|
int
|
The starting year of the simulation. |
required |
end_year
|
int
|
The ending year of the simulation. |
required |
species_inventory
|
dict
|
A dictionary where keys are species names and values are arrays of emissions over time. |
required |
species_settings
|
dict
|
A dictionary where keys are species names and values are dictionaries of settings for each species. |
None
|
model_settings
|
dict
|
A dictionary of settings for the climate model. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
available_climate_models |
list
|
List of registered climate model names. |
Example
>>> import numpy as np
>>> from aerocm.climate_models.aviation_climate_simulation import AviationClimateSimulation
>>> from aerocm.utils.functions import plot_simulation_results
>>> start_year = 2020
>>> end_year = 2050
>>> climate_model = "GWP*"
>>> species_inventory = {
... "CO2": np.random.rand(end_year - start_year + 1) * 1e9, # in kg
... "Contrails": np.random.rand(end_year - start_year + 1) * 1e9, # in km
... "NOx - ST O3 increase": np.random.rand(end_year - start_year + 1) * 1e6, # in kg
... "NOx - CH4 decrease and induced": np.random.rand(end_year - start_year + 1) * 1e6, # in kg
... "H2O": np.random.rand(end_year - start_year + 1) * 1e6, # in kg
... "Soot": np.random.rand(end_year - start_year + 1) * 1e6, # in kg
... "Sulfur": np.random.rand(end_year - start_year + 1) * 1e6, # in kg
... }
>>> species_settings = {
... "CO2": {"ratio_erf_rf": 1.0},
... "Contrails": {"sensitivity_rf": 2.23e-12, "ratio_erf_rf": 0.42, "efficacy_erf": 1.0},
... "NOx - ST O3 increase": {"sensitivity_rf": 7.6e-12, "ratio_erf_rf": 1.37, "efficacy_erf": 1.0},
... "NOx - CH4 decrease and induced": {"sensitivity_rf": -6.1e-12, "ratio_erf_rf": 1.18, "efficacy_erf": 1.0},
... "H2O": {"sensitivity_rf": 5.2e-15, "ratio_erf_rf": 1.0, "efficacy_erf": 1.0},
... "Soot": {"sensitivity_rf": 1.0e-10, "ratio_erf_rf": 1.0, "efficacy_erf": 1.0},
... "Sulfur": {"sensitivity_rf": -2.0e-11, "ratio_erf_rf": 1.0, "efficacy_erf": 1.0},
... }
>>> model_settings = {"tcre": 0.00045}
>>> results = AviationClimateSimulation(
... climate_model,
... start_year,
... end_year,
... species_inventory,
... species_settings,
... model_settings
... ).run(return_xr=True)
>>> plot_simulation_results(results, data_var="temperature_change", species=["CO2", "Non-CO2"], stacked=True)
Source code in aerocm/climate_models/aviation_climate_simulation.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
run ¶
run(return_xr=False)
Run the climate simulation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
return_xr
|
bool
|
If True, return results as an xarray Dataset. Default is False (returns a dictionary). |
False
|
Returns:
| Type | Description |
|---|---|
dict or Dataset
|
Results of the climate simulation. |
Source code in aerocm/climate_models/aviation_climate_simulation.py
102 103 104 105 106 107 108 109 110 111 112 113 114 115 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 | |
validate_model ¶
validate_model()
Validate the climate model provided. Specifically, check if it's a registered name, a subclass of ClimateModel, or a callable function.
Source code in aerocm/climate_models/aviation_climate_simulation.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
to_xarray ¶
to_xarray(data, timesteps)
Convert results dictionary to xarray Dataset
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict
|
dictionary with species as keys and another dictionary as values, where the inner dictionary has variable names (e.g. 'rf, 'erf') as keys and arrays as values |
required |
timesteps
|
list
|
Years corresponding to the data arrays |
required |
Source code in aerocm/climate_models/aviation_climate_simulation.py
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 | |
add_default_species_settings ¶
add_default_species_settings(climate_model, species_settings=None)
Complete the species settings with default values from the climate model for the ones that are not provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
climate_model
|
ClimateModel
|
The climate model class containing available species settings and their default values. |
required |
species_settings
|
dict
|
The dictionary of species settings provided by the user. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
dict
|
Updated species settings dictionary with default values filled in. |
Source code in aerocm/climate_models/aviation_climate_simulation.py
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 | |
add_default_model_settings ¶
add_default_model_settings(climate_model, model_settings)
Complete the model settings with default values from the climate model for the ones that are not provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
climate_model
|
ClimateModel
|
The climate model class containing available model settings and their default values. |
required |
model_settings
|
dict
|
The dictionary of model settings provided by the user. Defaults to None. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Updated model settings dictionary with default values filled in. |
Source code in aerocm/climate_models/aviation_climate_simulation.py
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 | |