gcages.cmip7_scenariomip#
CMIP7 ScenarioMIP components
Modules:
| Name | Description |
|---|---|
gridding_emissions |
Handling of gridding emissions |
harmonisation |
Harmonisation helpers for the CMIP7 ScenarioMIP workflow |
infilling |
Infilling configuration and related things for the CMIP7 ScenarioMIP workflow |
post_processing |
Post-processing in line the CMIP7 ScenarioMIP workflow |
pre_processing |
Pre-processing part of the workflow |
scm_running |
SCM-running configuration and related things for the updated workflow |
Classes:
| Name | Description |
|---|---|
CMIP7ScenarioMIPInfiller |
Infiller that follows the same logic as was used in CMIP7 ScenarioMIP |
CMIP7ScenarioMIPPostProcessor |
CMIP7 ScenarioMIP fast-track post-processor |
CMIP7ScenarioMIPPreProcessingResult |
Result of pre-processing with CMIP7ScenarioMIPPreProcessor |
CMIP7ScenarioMIPPreProcessor |
Pre-processor for CMIP7's ScenarioMIP |
CMIP7ScenarioMIPSCMRunner |
Simple climate model runner |
ReaggregatorBasic |
Reaggregator that follows this module's logic |
ReaggregatorLike |
Interface that can be used for re-aggregation |
Functions:
| Name | Description |
|---|---|
create_cmip7_scenariomip_global_harmoniser |
Create an Aneris harmoniser configured for CMIP7 ScenarioMIP global emissions. |
CMIP7ScenarioMIPInfiller #
Infiller that follows the same logic as was used in CMIP7 ScenarioMIP
If you want exactly the same behaviour as in CMIP7 ScenarioMIP,
initialise using from_cmip7_scenariomip_config
Methods:
| Name | Description |
|---|---|
__call__ |
Create an a infilled df for CMIP7 ScenarioMIP's simple climate model run. |
from_cmip7_scenariomip_config |
Initialise from the config used in AR6 |
Attributes:
| Name | Type | Description |
|---|---|---|
cmip7_ghg_inversions |
DataFrame
|
Green house gasses inversion data frame. |
harmonisation_year |
int
|
Year in which the data was harmonised |
historical_emissions |
DataFrame
|
Historical emissions used for harmonisation |
infilling_db |
DataFrame
|
Infilling leaders data base for each variable. |
pre_industrial_year |
int
|
Pre-Industrial year |
run_checks |
bool
|
If |
ur |
UnitRegistry | None
|
UnitRegistry |
Source code in src/gcages/cmip7_scenariomip/infilling.py
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 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 869 870 871 872 873 874 875 876 877 878 879 | |
cmip7_ghg_inversions
instance-attribute
#
cmip7_ghg_inversions: DataFrame
Green house gasses inversion data frame.
harmonisation_year
class-attribute
instance-attribute
#
harmonisation_year: int = 2023
Year in which the data was harmonised
historical_emissions
instance-attribute
#
historical_emissions: DataFrame
Historical emissions used for harmonisation
infilling_db
instance-attribute
#
infilling_db: DataFrame
Infilling leaders data base for each variable.
pre_industrial_year
class-attribute
instance-attribute
#
pre_industrial_year: int = 1750
Pre-Industrial year
run_checks
class-attribute
instance-attribute
#
run_checks: bool = True
If True, run checks on both input and output data
If you are sure about your workflow, you can disable the checks to speed things up (but we don't recommend this unless you really are confident about what you're doing).
__call__ #
Create an a infilled df for CMIP7 ScenarioMIP's simple climate model run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_emissions
|
DataFrame
|
Emissions to infill |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Infilled emissions DataFrame |
Source code in src/gcages/cmip7_scenariomip/infilling.py
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | |
from_cmip7_scenariomip_config
classmethod
#
from_cmip7_scenariomip_config(
cmip7_scenariomip_infilling_leader_emissions_file: Path,
cmip7_ghg_inversions_file: Path,
cmip7_scenariomip_global_historical_emissions_file: Path,
ur: UnitRegistry | None = None,
run_checks: bool = True,
) -> CMIP7ScenarioMIPInfiller
Initialise from the config used in AR6
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmip7_scenariomip_infilling_leader_emissions_file
|
Path
|
File containing the infilling leaders database This is for all emissions except GHGs. |
required |
cmip7_ghg_inversions_file
|
Path
|
File containing the infilling database for GHGs inversions |
required |
cmip7_scenariomip_global_historical_emissions_file
|
Path
|
File containing the historical emissions used for harmonisation |
required |
run_checks
|
bool
|
Should checks of the input and output data be performed? If this is turned off, things are faster, but error messages are much less clear if things go wrong. |
True
|
Returns:
| Type | Description |
|---|---|
CMIP7ScenarioMIPInfiller
|
Initialised CMIP7ScenarioMIPInfiller |
Source code in src/gcages/cmip7_scenariomip/infilling.py
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 869 870 871 872 873 874 875 876 877 878 879 | |
CMIP7ScenarioMIPPostProcessor #
CMIP7 ScenarioMIP fast-track post-processor
Methods:
| Name | Description |
|---|---|
__call__ |
Do the post-processing |
from_cmip7_scenariomip_config |
Initialise from the config used in CMIP7 ScenarioMIP |
Attributes:
| Name | Type | Description |
|---|---|---|
exceedance_global_warming_levels |
tuple[float, ...]
|
Global-warming levels against which to calculate exceedance probabilities |
gsat_assessment_median |
float
|
Median of the GSAT assessment |
gsat_assessment_pre_industrial_period |
tuple[int, ...]
|
Pre-industrial time period used for the GSAT assessment |
gsat_assessment_time_period |
tuple[int, ...]
|
Time period over which the GSAT assessment applies |
gsat_in_line_with_assessment_variable_name |
str
|
The name of the GSAT variable once its been aligned with the assessment |
gsat_variable_name |
str
|
The name of the GSAT variable |
n_processes |
int
|
Number of processes to use for parallel processing. |
percentiles_to_calculate |
tuple[float, ...]
|
Percentiles to calculate and include in the output |
run_checks |
bool
|
If |
Source code in src/gcages/cmip7_scenariomip/post_processing.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 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 94 95 96 97 98 99 100 101 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 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 | |
exceedance_global_warming_levels
class-attribute
instance-attribute
#
Global-warming levels against which to calculate exceedance probabilities
gsat_assessment_median
instance-attribute
#
gsat_assessment_median: float
Median of the GSAT assessment
gsat_assessment_pre_industrial_period
instance-attribute
#
Pre-industrial time period used for the GSAT assessment
gsat_assessment_time_period
instance-attribute
#
Time period over which the GSAT assessment applies
gsat_in_line_with_assessment_variable_name
instance-attribute
#
gsat_in_line_with_assessment_variable_name: str
The name of the GSAT variable once its been aligned with the assessment
n_processes
class-attribute
instance-attribute
#
Number of processes to use for parallel processing.
Set to 1 to process in serial.
percentiles_to_calculate
class-attribute
instance-attribute
#
Percentiles to calculate and include in the output
run_checks
class-attribute
instance-attribute
#
run_checks: bool = True
If True, run checks on both input and output data
If you are sure about your workflow, you can disable the checks to speed things up (but we don't recommend this unless you really are confident about what you're doing).
__call__ #
__call__(in_df: DataFrame) -> PostProcessingResult
Do the post-processing
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_df
|
DataFrame
|
Data to post-process |
required |
Returns:
| Type | Description |
|---|---|
PostProcessingResult
|
Post-processed results |
Source code in src/gcages/cmip7_scenariomip/post_processing.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 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 224 225 226 | |
from_cmip7_scenariomip_config
classmethod
#
from_cmip7_scenariomip_config() -> (
CMIP7ScenarioMIPPostProcessor
)
Initialise from the config used in CMIP7 ScenarioMIP
Returns:
| Type | Description |
|---|---|
CMIP7ScenarioMIPPostProcessor
|
Initialised post-processor |
Source code in src/gcages/cmip7_scenariomip/post_processing.py
CMIP7ScenarioMIPPreProcessingResult #
Result of pre-processing with CMIP7ScenarioMIPPreProcessor
This has more components than normal, because we need to support both the 'normal' global path and harmonising at the region-sector level.
Attributes:
| Name | Type | Description |
|---|---|---|
assumed_zero_emissions |
DataFrame | None
|
Emissions that were asssumed to be zero during the processing |
global_workflow_emissions |
DataFrame
|
Emissions that can be used with the 'normal' global workflow |
global_workflow_emissions_raw_names |
DataFrame
|
Emissions consistent with those that can be used with the 'normal' global workflow |
gridding_workflow_emissions |
DataFrame
|
Emissions that can be used with the gridding workflow |
Source code in src/gcages/cmip7_scenariomip/pre_processing/pre_processor.py
assumed_zero_emissions
instance-attribute
#
assumed_zero_emissions: DataFrame | None
Emissions that were asssumed to be zero during the processing
global_workflow_emissions
instance-attribute
#
global_workflow_emissions: DataFrame
Emissions that can be used with the 'normal' global workflow
global_workflow_emissions_raw_names
instance-attribute
#
global_workflow_emissions_raw_names: DataFrame
Emissions consistent with those that can be used with the 'normal' global workflow
The difference is that these are reported with CMIP7 ScenarioMIP naming, which isn't compatible with our SCM runners (for example), so is probably not what you want to use, but perhaps helpful for plotting and direct comparisons.
CMIP7ScenarioMIPPreProcessor #
Pre-processor for CMIP7's ScenarioMIP
For more details of the logic, see gcages.cmip7_scenariomip.pre_processing.
Methods:
| Name | Description |
|---|---|
__call__ |
Pre-process |
Attributes:
| Name | Type | Description |
|---|---|---|
co2_biosphere_sectors |
tuple[str, ...]
|
Gridding sectors that are assumed to come from the biosphere CO2 reservoir |
co2_fossil_sectors |
tuple[str, ...]
|
Gridding sectors that are assumed to come from the fossil CO2 reservoir |
co2_name |
str
|
Name used for CO2 in variable names |
level_separator |
str
|
The separator between levels in variable names |
n_processes |
int | None
|
Number of processes to use for parallel processing. |
progress |
bool
|
Should progress bars be shown? |
reaggregator |
ReaggregatorLike | None
|
Re-aggregator to use when converting raw data to gridding sectors |
run_checks |
bool
|
If |
table |
str
|
The value used for the top level of variable names |
world_gridding_sectors |
tuple[str, ...]
|
Sectors that are only used for gridding at the world (i.e. regional sum) level |
Source code in src/gcages/cmip7_scenariomip/pre_processing/pre_processor.py
491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 | |
co2_biosphere_sectors
class-attribute
instance-attribute
#
co2_biosphere_sectors: tuple[str, ...] = (
CO2_BIOSPHERE_SECTORS_GRIDDING
)
Gridding sectors that are assumed to come from the biosphere CO2 reservoir
co2_fossil_sectors
class-attribute
instance-attribute
#
co2_fossil_sectors: tuple[str, ...] = (
CO2_FOSSIL_SECTORS_GRIDDING
)
Gridding sectors that are assumed to come from the fossil CO2 reservoir
co2_name
class-attribute
instance-attribute
#
co2_name: str = 'CO2'
Name used for CO2 in variable names
level_separator
class-attribute
instance-attribute
#
level_separator: str = '|'
The separator between levels in variable names
n_processes
class-attribute
instance-attribute
#
Number of processes to use for parallel processing.
Set to None to process in serial.
reaggregator
class-attribute
instance-attribute
#
reaggregator: ReaggregatorLike | None = None
Re-aggregator to use when converting raw data to gridding sectors
If not supplied, we guess the re-aggregator during processing
run_checks
class-attribute
instance-attribute
#
run_checks: bool = True
If True, run checks on both input and output data
If you are sure about your workflow, you can disable the checks to speed things up (but we don't recommend this unless you really are confident about what you're doing).
table
class-attribute
instance-attribute
#
table: str = 'Emissions'
The value used for the top level of variable names
world_gridding_sectors
class-attribute
instance-attribute
#
Sectors that are only used for gridding at the world (i.e. regional sum) level
__call__ #
__call__(
in_emissions: DataFrame,
) -> CMIP7ScenarioMIPPreProcessingResult
Pre-process
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_emissions
|
DataFrame
|
Emissions to pre-process |
required |
Returns:
| Type | Description |
|---|---|
CMIP7ScenarioMIPPreProcessingResult
|
Pre-processed emissions |
Source code in src/gcages/cmip7_scenariomip/pre_processing/pre_processor.py
CMIP7ScenarioMIPSCMRunner #
Simple climate model runner
It follows the same logic as was used in CMIP7 SCENARIOMIP
If you want exactly the same behaviour as in CMIP7 SCENARIOMIP
initialise using from_cmip7_scenariomip_config
Methods:
| Name | Description |
|---|---|
__call__ |
Run the simple climate model |
from_cmip7_scenariomip_config |
Initialise from the config used in CMIP7 ScenarioMIP |
Attributes:
| Name | Type | Description |
|---|---|---|
batch_size_scenarios |
int | None
|
The number of scenarios to run at a time |
climate_models_cfgs |
dict[str, list[dict[str, Any]]]
|
Climate models to run and the configuration to use with them |
db |
OpenSCMDB | None
|
Database in which to store the output of the runs |
harmonisation_year |
int | None
|
Year in which the data was harmonised |
historical_emissions |
DataFrame | None
|
Historical emissions used for harmonisation |
n_processes |
int | None
|
Number of processes to use for parallel processing. |
output_variables |
tuple[str, ...]
|
Variables to include in the output |
progress |
bool
|
Should progress bars be shown for each operation? |
res_column_type |
type
|
Type to cast the result's column type to |
run_checks |
bool
|
If |
verbose |
bool
|
Should verbose messages be printed? |
Source code in src/gcages/cmip7_scenariomip/scm_running.py
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 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 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | |
batch_size_scenarios
class-attribute
instance-attribute
#
batch_size_scenarios: int | None = None
The number of scenarios to run at a time
Smaller batch sizes use less memory, but take longer overall (all else being equal).
If not supplied, all scenarios are run simultaneously.
climate_models_cfgs
class-attribute
instance-attribute
#
climate_models_cfgs: dict[str, list[dict[str, Any]]] = (
field(
repr=lambda x: join(
f"{climate_model}: {len(cfgs)} configurations"
for (climate_model, cfgs) in items()
)
)
)
Climate models to run and the configuration to use with them
db
class-attribute
instance-attribute
#
db: OpenSCMDB | None = None
Database in which to store the output of the runs
If not supplied, output of the runs is not stored.
harmonisation_year
class-attribute
instance-attribute
#
harmonisation_year: int | None = None
Year in which the data was harmonised
Only required if run_checks is True to check
that the data to run is harmonised.
historical_emissions
class-attribute
instance-attribute
#
historical_emissions: DataFrame | None = None
Historical emissions used for harmonisation
Only required if run_checks is True to check
that the data to run is harmonised.
n_processes
class-attribute
instance-attribute
#
Number of processes to use for parallel processing.
Set to None to process in serial.
output_variables
instance-attribute
#
Variables to include in the output
progress
class-attribute
instance-attribute
#
progress: bool = True
Should progress bars be shown for each operation?
res_column_type
class-attribute
instance-attribute
#
Type to cast the result's column type to
run_checks
class-attribute
instance-attribute
#
run_checks: bool = True
If True, run checks on both input and output data
If you are sure about your workflow, you can disable the checks to speed things up (but we don't recommend this unless you really are confident about what you're doing).
verbose
class-attribute
instance-attribute
#
verbose: bool = True
Should verbose messages be printed?
This is a temporary hack while we think about how to handle logging
__call__ #
Run the simple climate model
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_emissions
|
DataFrame
|
Emissions to run |
required |
force_rerun
|
bool
|
Force scenarios to re-run (i.e. disable caching). |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Raw results from the simple climate model |
Source code in src/gcages/cmip7_scenariomip/scm_running.py
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 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 | |
from_cmip7_scenariomip_config
classmethod
#
from_cmip7_scenariomip_config(
magicc_exe_path: Path,
magicc_prob_distribution_path: Path,
output_variables: tuple[
str, ...
] = SCM_OUTPUT_VARIABLES_DEFAULT,
batch_size_scenarios: int | None = None,
db: OpenSCMDB | None = None,
historical_emissions_path: Path | None = None,
harmonisation_year: int = 2023,
verbose: bool = True,
run_checks: bool = True,
progress: bool = True,
n_processes: int | None = cpu_count(),
) -> CMIP7ScenarioMIPSCMRunner
Initialise from the config used in CMIP7 ScenarioMIP
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
magicc_exe_path
|
Path
|
Path to the MAGICC executable to use. This should be a MAGICC v7.6.0a3 executable. |
required |
magicc_prob_distribution_path
|
Path
|
Path to the MAGICC probabilistic distribution. This should be the CMIP7 ScenarioMIP probabilistic distribution. |
required |
output_variables
|
tuple[str, ...]
|
Variables to include in the output |
SCM_OUTPUT_VARIABLES_DEFAULT
|
batch_size_scenarios
|
int | None
|
The number of scenarios to run at a time |
None
|
db
|
OpenSCMDB | None
|
Database to use for storing results. If not supplied, raw outputs are not stored. |
None
|
historical_emissions_path
|
Path | None
|
Historical emissions used for harmonisation Only required if |
None
|
harmonisation_year
|
int
|
Year in which the data was harmonised Only required if |
2023
|
verbose
|
bool
|
Should verbose messages be printed? This is a temporary hack while we think about how to handle logging |
True
|
run_checks
|
bool
|
Should checks of the input and output data be performed? If this is turned off, things are faster, but error messages are much less clear if things go wrong. |
True
|
progress
|
bool
|
Should progress bars be shown for each operation? |
True
|
n_processes
|
int | None
|
Number of processes to use for parallel processing. Set to |
cpu_count()
|
Returns:
| Type | Description |
|---|---|
CMIP7ScenarioMIPSCMRunner
|
Initialised SCM runner |
Source code in src/gcages/cmip7_scenariomip/scm_running.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | |
ReaggregatorBasic #
Reaggregator that follows this module's logic
Methods:
| Name | Description |
|---|---|
assert_has_all_required_timeseries |
Assert that the data has all the required timeseries |
assert_is_internally_consistent |
Assert that the data is internally consistent |
default_tols_internal_consistency |
Get default tolerances for internal consistency checks |
get_internal_consistency_checking_index |
Get the index which selects only data relevant for checking internal consistency |
to_complete |
Convert the raw data to complete data |
to_gridding_sectors |
Re-aggregate data to the sectors used for gridding |
Attributes:
| Name | Type | Description |
|---|---|---|
internal_consistency_tolerances |
Mapping[str, Mapping[str, float]] | Mapping[str, Mapping[str, PINT_SCALAR]]
|
Tolerances to apply when checking the internal consistency of the data |
model_regions |
tuple[str, ...]
|
Model regions to use while reaggregating |
region_level |
str
|
Region level in the data index |
unit_level |
str
|
Unit level in the data index |
variable_level |
str
|
Variable level in the data index |
world_region |
str
|
The value used when the data represents the sum over all regions |
Source code in src/gcages/cmip7_scenariomip/pre_processing/reaggregation/basic.py
1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 | |
internal_consistency_tolerances
class-attribute
instance-attribute
#
internal_consistency_tolerances: (
Mapping[str, Mapping[str, float]]
| Mapping[str, Mapping[str, PINT_SCALAR]]
) = field()
Tolerances to apply when checking the internal consistency of the data
model_regions
instance-attribute
#
Model regions to use while reaggregating
region_level
class-attribute
instance-attribute
#
region_level: str = 'region'
Region level in the data index
unit_level
class-attribute
instance-attribute
#
unit_level: str = 'unit'
Unit level in the data index
variable_level
class-attribute
instance-attribute
#
variable_level: str = 'variable'
Variable level in the data index
world_region
class-attribute
instance-attribute
#
world_region: str = 'World'
The value used when the data represents the sum over all regions
(Having a value for this is odd, there should really just be no region level when data is the sum, but this is the data format used so we have to follow this convention.)
assert_has_all_required_timeseries #
assert_has_all_required_timeseries(indf: DataFrame) -> None
Assert that the data has all the required timeseries
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indf
|
DataFrame
|
Data to check |
required |
Raises:
| Type | Description |
|---|---|
NotCompleteError
|
|
Source code in src/gcages/cmip7_scenariomip/pre_processing/reaggregation/basic.py
assert_is_internally_consistent #
assert_is_internally_consistent(indf: DataFrame) -> None
Assert that the data is internally consistent
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indf
|
DataFrame
|
Data to check |
required |
Raises:
| Type | Description |
|---|---|
InternalConsistencyError
|
The data is not internally consistent |
Source code in src/gcages/cmip7_scenariomip/pre_processing/reaggregation/basic.py
default_tols_internal_consistency #
default_tols_internal_consistency() -> (
Mapping[str, Mapping[str, float]]
| Mapping[str, Mapping[str, PINT_SCALAR]]
)
Get default tolerances for internal consistency checks
Source code in src/gcages/cmip7_scenariomip/pre_processing/reaggregation/basic.py
get_internal_consistency_checking_index #
get_internal_consistency_checking_index() -> MultiIndex
Get the index which selects only data relevant for checking internal consistency
Returns:
| Type | Description |
|---|---|
MultiIndex
|
Internal consistency checking index |
Source code in src/gcages/cmip7_scenariomip/pre_processing/reaggregation/basic.py
to_complete #
to_complete(raw: DataFrame) -> ToCompleteResult
Convert the raw data to complete data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
DataFrame
|
Raw data |
required |
Returns:
| Type | Description |
|---|---|
ToCompleteResult
|
To complete result |
Source code in src/gcages/cmip7_scenariomip/pre_processing/reaggregation/basic.py
to_gridding_sectors #
Re-aggregate data to the sectors used for gridding
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indf
|
DataFrame
|
Data to re-aggregate |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Data re-aggregated to the gridding sectors |
Source code in src/gcages/cmip7_scenariomip/pre_processing/reaggregation/basic.py
ReaggregatorLike #
Bases: Protocol
Interface that can be used for re-aggregation
Methods:
| Name | Description |
|---|---|
assert_has_all_required_timeseries |
Assert that the data has all the required timeseries |
assert_is_internally_consistent |
Assert that the data is internally consistent |
get_internal_consistency_checking_index |
Get the index which selects only data relevant for checking internal consistency |
to_complete |
Convert the raw data to complete data |
to_gridding_sectors |
Re-aggregate data to the sectors used for gridding |
Attributes:
| Name | Type | Description |
|---|---|---|
model_regions |
tuple[str, ...]
|
Model regions to use while reaggregating |
region_level |
str
|
Region level in the data index |
unit_level |
str
|
Unit level in the data index |
variable_level |
str
|
Variable level in the data index |
world_region |
str
|
The value used when the data represents the sum over all regions |
Source code in src/gcages/cmip7_scenariomip/pre_processing/pre_processor.py
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 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
model_regions
instance-attribute
#
Model regions to use while reaggregating
world_region
instance-attribute
#
world_region: str
The value used when the data represents the sum over all regions
(Having a value for this is odd, there should really just be no region level when data is the sum, but this is the data format used so we have to follow this convention.)
assert_has_all_required_timeseries #
assert_has_all_required_timeseries(indf: DataFrame) -> None
Assert that the data has all the required timeseries
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indf
|
DataFrame
|
Data to check |
required |
Raises:
| Type | Description |
|---|---|
NotCompleteError
|
|
Source code in src/gcages/cmip7_scenariomip/pre_processing/pre_processor.py
assert_is_internally_consistent #
assert_is_internally_consistent(indf: DataFrame) -> None
Assert that the data is internally consistent
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indf
|
DataFrame
|
Data to check |
required |
Raises:
| Type | Description |
|---|---|
InternalConsistencyError
|
The data is not internally consistent |
Source code in src/gcages/cmip7_scenariomip/pre_processing/pre_processor.py
get_internal_consistency_checking_index #
get_internal_consistency_checking_index() -> MultiIndex
Get the index which selects only data relevant for checking internal consistency
Returns:
| Type | Description |
|---|---|
MultiIndex
|
Internal consistency checking index |
Source code in src/gcages/cmip7_scenariomip/pre_processing/pre_processor.py
to_complete #
to_complete(raw: DataFrame) -> ToCompleteResult
Convert the raw data to complete data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw
|
DataFrame
|
Raw data |
required |
Returns:
| Type | Description |
|---|---|
ToCompleteResult
|
To complete result |
Source code in src/gcages/cmip7_scenariomip/pre_processing/pre_processor.py
to_gridding_sectors #
create_cmip7_scenariomip_global_harmoniser #
create_cmip7_scenariomip_global_harmoniser(
cmip7_scenariomip_global_historical_emissions_file: Path,
aneris_global_overrides_file: Path,
run_checks: bool = True,
progress: bool = True,
n_processes: int | None = cpu_count(),
) -> AnerisHarmoniser
Create an Aneris harmoniser configured for CMIP7 ScenarioMIP global emissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmip7_scenariomip_global_historical_emissions_file
|
Path
|
File containing CMIP7 ScenarioMIP historical emissions. |
required |
aneris_global_overrides_file
|
Path
|
File containing aneris overrides for the global workflow. |
required |
run_checks
|
bool
|
Should checks of input and output data be performed? |
True
|
progress
|
bool
|
Should progress bars be shown? |
True
|
n_processes
|
int | None
|
Number of processes to use for parallel processing. |
cpu_count()
|
Returns:
| Type | Description |
|---|---|
AnerisHarmoniser
|
Harmoniser that will behave in line with CMIP7 ScenarioMIP's global workflow |
Source code in src/gcages/cmip7_scenariomip/harmonisation.py
98 99 100 101 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 | |