gcages.scm_running#
General simple climate model (SCM) running tools
Modules:
| Name | Description |
|---|---|
magicc |
General tools for running MAGICC |
Functions:
| Name | Description |
|---|---|
convert_openscm_runner_output_names_to_magicc_output_names |
Get output names for the call to MAGICC |
get_scenarios_to_run_after_checking_cache |
Get the scenarios to run after checking the database cache |
run_batch |
Run a batch of scenarios |
run_scms |
Run simple climate models (SCMs) |
convert_openscm_runner_output_names_to_magicc_output_names #
convert_openscm_runner_output_names_to_magicc_output_names(
openscm_runner_names: Iterable[str],
) -> tuple[str, ...]
Get output names for the call to MAGICC
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
openscm_runner_names
|
Iterable[str]
|
OpenSCM-Runner output names |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
MAGICC output names |
Source code in src/gcages/scm_running/__init__.py
get_scenarios_to_run_after_checking_cache #
get_scenarios_to_run_after_checking_cache(
scenarios: DataFrame,
climate_model: str,
db: OpenSCMDB,
scenario_group_levels: list[str],
climate_model_level: str,
verbose: bool,
) -> DataFrame | None
Get the scenarios to run after checking the database cache
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenarios
|
DataFrame
|
Full set of scenarios |
required |
climate_model
|
str
|
Climate model we are going to run with |
required |
db
|
OpenSCMDB
|
Database in which results are being stored |
required |
scenario_group_levels
|
list[str]
|
Index levels which define scenario groups Typically something like ["model", "scenario"] |
required |
climate_model_level
|
str
|
Climate model level in the database's metadata This level should store information about the climate model used to run the scenario. |
required |
verbose
|
bool
|
If we skip running scenarios, should we print a message showing which ones |
required |
Returns:
| Type | Description |
|---|---|
DataFrame | None
|
Scenarios to run If all scenarios have already been run for |
Source code in src/gcages/scm_running/__init__.py
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 | |
run_batch #
run_batch(
batch: DataFrame,
climate_models_cfgs: dict[str, list[dict[str, Any]]],
output_variables: tuple[str, ...],
) -> DataFrame
Run a batch of scenarios
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
batch
|
DataFrame
|
Batch to run |
required |
climate_models_cfgs
|
dict[str, list[dict[str, Any]]]
|
Climate model to run and its configuration Passed to [openscm_runner.run.run] |
required |
output_variables
|
tuple[str, ...]
|
Output variables to retrieve from the climate model Passed to [openscm_runner.run.run] |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Results of running the batch |
Source code in src/gcages/scm_running/__init__.py
run_scms #
run_scms(
scenarios: DataFrame,
climate_models_cfgs: dict[str, list[dict[str, Any]]],
output_variables: tuple[str, ...],
scenario_group_levels: list[str],
n_processes: int,
db: OpenSCMDB | None = None,
db_climate_model_level: str = "climate_model",
verbose: bool = True,
progress: bool = True,
batch_size_scenarios: int | None = None,
force_rerun: bool = False,
) -> DataFrame | None
Run simple climate models (SCMs)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenarios
|
DataFrame
|
Scenarios to run |
required |
climate_models_cfgs
|
dict[str, list[dict[str, Any]]]
|
Climate model to run and its configuration Passed to [openscm_runner.run.run] |
required |
output_variables
|
tuple[str, ...]
|
Output variables to retrieve from the climate model Passed to [openscm_runner.run.run] |
required |
scenario_group_levels
|
list[str]
|
Index levels which define scenario groups Typically something like ["model", "scenario"] |
required |
n_processes
|
int
|
Number of parallel processes to use while running |
required |
db
|
OpenSCMDB | None
|
Database in which to save the results If not provided, results are not saved along the way |
None
|
db_climate_model_level
|
str
|
Climate model level in the database's metadata This level should store information about the climate model used to run the scenario. |
'climate_model'
|
verbose
|
bool
|
If we skip running scenarios because they have already been run, should we print a message showing which ones? |
True
|
progress
|
bool
|
Should progress bar(s) be displayed? |
True
|
batch_size_scenarios
|
int | None
|
How many scenarios should be run in a single batch? Running more scenarios at once is faster, but it runs the risk of running out of memory. |
None
|
force_rerun
|
bool
|
Should we force the scenarios to be re-run, even if they are already in |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame | None
|
Results of running the SCM If |
Source code in src/gcages/scm_running/__init__.py
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 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 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 | |