gcages.cmip7_scenariomip.infilling#
Infilling configuration and related things for the CMIP7 ScenarioMIP workflow
Classes:
| Name | Description |
|---|---|
CMIP7ScenarioMIPInfiller |
Infiller that follows the same logic as was used in CMIP7 ScenarioMIP |
Functions:
| Name | Description |
|---|---|
get_complete |
Get a complete set of timeseries |
get_direct_copy_infiller |
Get an infiller which just copies the timeseries from another scenario |
get_direct_scaling_infiller |
Get an infiller which just scales one set of emissions to create the next set |
get_pre_industrial_aware_direct_scaling_infiller |
Build pre-industrial-aware direct scaling infillers for follower/leader pairs. |
get_silicone_based_infiller |
Get an infiller based on silicone |
infill |
Infill an emissions scenario using the provided infillers. |
load_cmip7_scenariomip_ghg_inversions |
Load |
load_cmip7_scenariomip_infilling_db |
Load infilling database for CMIP7 ScenarioMIP harmonisation. |
Attributes:
| Name | Type | Description |
|---|---|---|
COMPLETE_EMISSIONS_INPUT_VARIABLES_GCAGES |
Complete set of input emissions using gcages' naming |
|
complete_index_gcages_names |
Complete index using gcages' names |
COMPLETE_EMISSIONS_INPUT_VARIABLES_GCAGES
module-attribute
#
COMPLETE_EMISSIONS_INPUT_VARIABLES_GCAGES = [
"Emissions|CO2|Biosphere",
"Emissions|CO2|Fossil",
"Emissions|BC",
"Emissions|CH4",
"Emissions|CO",
"Emissions|N2O",
"Emissions|NH3",
"Emissions|NMVOC",
"Emissions|NOx",
"Emissions|OC",
"Emissions|SOx",
"Emissions|C2F6",
"Emissions|C6F14",
"Emissions|CF4",
"Emissions|SF6",
"Emissions|HFC125",
"Emissions|HFC134a",
"Emissions|HFC143a",
"Emissions|HFC227ea",
"Emissions|HFC23",
"Emissions|HFC245fa",
"Emissions|HFC32",
"Emissions|HFC4310mee",
"Emissions|CCl4",
"Emissions|CFC11",
"Emissions|CFC113",
"Emissions|CFC114",
"Emissions|CFC115",
"Emissions|CFC12",
"Emissions|CH3CCl3",
"Emissions|HCFC141b",
"Emissions|HCFC142b",
"Emissions|HCFC22",
"Emissions|Halon1202",
"Emissions|Halon1211",
"Emissions|Halon1301",
"Emissions|Halon2402",
"Emissions|C3F8",
"Emissions|C4F10",
"Emissions|C5F12",
"Emissions|C7F16",
"Emissions|C8F18",
"Emissions|cC4F8",
"Emissions|SO2F2",
"Emissions|HFC236fa",
"Emissions|HFC152a",
"Emissions|HFC365mfc",
"Emissions|CH2Cl2",
"Emissions|CHCl3",
"Emissions|CH3Br",
"Emissions|CH3Cl",
"Emissions|NF3",
]
Complete set of input emissions using gcages' naming
complete_index_gcages_names
module-attribute
#
complete_index_gcages_names = from_product(
[COMPLETE_EMISSIONS_INPUT_VARIABLES_GCAGES, ["World"]],
names=["variable", "region"],
)
Complete index using gcages' names
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 | |
get_complete #
Get a complete set of timeseries
This is just a convenience function to help deal with the fact
that infill can return None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indf
|
DataFrame
|
Input data |
required |
infilled
|
DataFrame | None
|
Results of infilling using infill |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Complete data i.e. the combination of |
Source code in src/gcages/cmip7_scenariomip/infilling.py
get_direct_copy_infiller #
Get an infiller which just copies the timeseries from another scenario
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
Variable to infill |
required |
copy_from
|
DataFrame
|
Scenario to copy from |
required |
Returns:
| Type | Description |
|---|---|
Callable[[DataFrame], DataFrame]
|
Infiller which can infill data for |
Source code in src/gcages/cmip7_scenariomip/infilling.py
get_direct_scaling_infiller #
get_direct_scaling_infiller(
leader: str,
follower: str,
scaling_factor: float,
l_0: float,
f_0: float,
f_unit: str,
calculation_year: int,
f_calculation_year: int,
) -> Callable[[DataFrame], DataFrame]
Get an infiller which just scales one set of emissions to create the next set
This is basically silicone's constant ratio infiller with smarter handling of pre-industrial levels.
Source code in src/gcages/cmip7_scenariomip/infilling.py
get_pre_industrial_aware_direct_scaling_infiller #
get_pre_industrial_aware_direct_scaling_infiller(
*,
historical_emissions: DataFrame,
cmip7_ghg_inversions_reporting_names: DataFrame,
scaling_leaders: dict[str, str],
harmonisation_year: int = 2023,
pre_industrial_year: int = 1750,
) -> dict[str, Any]
Build pre-industrial-aware direct scaling infillers for follower/leader pairs.
This constructs scaling factors that preserve both pre-industrial baselines and harmonisation-year values when scaling follower emissions based on leader emissions.
The scaling preserves two key properties::
f_future(l_harmonisation) = f_harmonisation
f_future(l_pre_industrial) = f_pre_industrial
with linear interpolation between these anchor points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
historical_emissions
|
DataFrame
|
Historical emissions data with MultiIndex including 'variable' level. Must contain harmonisation-year values for all leader/follower variables. |
required |
cmip7_ghg_inversions_reporting_names
|
DataFrame
|
CMIP7 GHG inversion data with pre-industrial (PI) year values. Must contain PI-year values for all leader/follower variables. |
required |
scaling_leaders
|
dict[str, str]
|
Mapping of follower variable names to leader variable names. |
required |
harmonisation_year
|
int
|
Primary harmonisation reference year |
2023
|
pre_industrial_year
|
int
|
Pre-industrial reference year |
1750
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Mapping of follower variable into direct scaling infiller callable. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If multiple units found for a variable, no valid harmonisation year data, or scaling factor computation yields NaN. |
Source code in src/gcages/cmip7_scenariomip/infilling.py
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 | |
get_silicone_based_infiller #
get_silicone_based_infiller(
infilling_db: DataFrame,
follower_variable: str,
lead_variables: list[str],
silicone_db_cruncher: _DatabaseCruncher,
derive_relationship_kwargs: dict[str, Any]
| None = None,
) -> Callable[[DataFrame], DataFrame]
Get an infiller based on silicone
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
infilling_db
|
DataFrame
|
Infilling database |
required |
follower_variable
|
str
|
The variable to infill |
required |
lead_variables
|
list[str]
|
The variables used to infill |
required |
silicone_db_cruncher
|
_DatabaseCruncher
|
Silicone cruncher to use |
required |
derive_relationship_kwargs
|
dict[str, Any] | None
|
Passed to |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[DataFrame], DataFrame]
|
Function which can be used to infill |
Source code in src/gcages/cmip7_scenariomip/infilling.py
infill #
infill(
indf: DataFrame,
infillers: Mapping[
str, Callable[[DataFrame], DataFrame]
],
) -> DataFrame | None
Infill an emissions scenario using the provided infillers.
Parameters#
indf Emissions scenario to infill
infillers Infillers to use
Each key is the gas the infiller can infill.
Each value is the function which does the infilling.
Returns#
: Infilled timeseries.
If nothing was infilled, `None` is returned
Source code in src/gcages/cmip7_scenariomip/infilling.py
load_cmip7_scenariomip_ghg_inversions #
Load
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
Path
|
Path from which to load the file |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Green house gases inversion data frame |
Source code in src/gcages/cmip7_scenariomip/infilling.py
load_cmip7_scenariomip_infilling_db #
Load infilling database for CMIP7 ScenarioMIP harmonisation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
Path
|
Path from which to load the file |
required |
check_hash
|
bool
|
Check file hash |
True
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
Infilled emissions |
Raises:
| Type | Description |
|---|---|
AssertionError
|
We expect to be reading the file from https://zenodo.org/records/17844114/files/infiling-db_202512021030_202512071232_202511040855_202511040855.csv?download=1 |