gcages.ar6.infilling#
Infilling part of the AR6 workflow
Classes:
| Name | Description |
|---|---|
AR6Infiller |
Infiller that follows the same logic as was used in AR6 |
Functions:
| Name | Description |
|---|---|
do_ar6_like_infilling |
Do infilling like it was done in AR6 |
get_ar6_full_historical_emissions |
Get the full AR6 historical emissions |
get_ar6_infiller |
Get an infiller following the logic used in AR6 |
infill_scenario |
Infill a single scenario |
load_massaged_ar6_infilling_db |
Load the infilling database that was used in AR6 |
AR6Infiller #
Infiller that follows the same logic as was used in AR6
If you want exactly the same behaviour as in AR6,
initialise using from_ar6_config
Methods:
| Name | Description |
|---|---|
__call__ |
Infill |
from_ar6_config |
Initialise from the config used in AR6 |
Attributes:
| Name | Type | Description |
|---|---|---|
harmonisation_year |
int | None
|
Year in which the data was harmonised |
historical_emissions |
DataFrame | None
|
Historical emissions used for harmonisation |
infillers |
Mapping[str, Callable[[DataFrame], DataFrame]]
|
Functions to use for infilling each variable. |
n_processes |
int | None
|
Number of processes to use for parallel processing. |
progress |
bool
|
Should progress bars be shown for each operation? |
run_checks |
bool
|
If |
Source code in src/gcages/ar6/infilling.py
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 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 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | |
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 infilled data is also 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 infilled data is also harmonised.
infillers
instance-attribute
#
Functions to use for infilling each variable.
The keys define the variable that can be infilled. The variables define the function which, given inputs with the expected lead variables, returns the infilled timeseries.
n_processes
class-attribute
instance-attribute
#
n_processes: int | None = None
Number of processes to use for parallel processing.
Set to None to process in serial.
progress
class-attribute
instance-attribute
#
progress: bool = True
Should progress bars be shown for each operation?
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__ #
Infill
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
in_emissions
|
DataFrame
|
Emissions to infill |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Infilled emissions |
Source code in src/gcages/ar6/infilling.py
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 | |
from_ar6_config
classmethod
#
from_ar6_config(
ar6_infilling_db_file: Path,
ar6_infilling_db_cfcs_file: Path,
variables_to_infill: Iterable[str] | None = None,
run_checks: bool = True,
historical_emissions: DataFrame | None = None,
harmonisation_year: int | None = None,
progress: bool = True,
n_processes: int | None = None,
) -> AR6Infiller
Initialise from the config used in AR6
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ar6_infilling_db_file
|
Path
|
File containing the AR6 infilling database This is for all emissions except CFCs. |
required |
ar6_infilling_db_cfcs_file
|
Path
|
File containing the AR6 infilling database for CFCs |
required |
variables_to_infill
|
Iterable[str] | None
|
Variables to infill. If not supplied, we use the default set from AR6. |
None
|
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
|
historical_emissions
|
DataFrame | None
|
Historical emissions used for harmonisation Only required if |
None
|
harmonisation_year
|
int | None
|
Year in which the data was harmonised Only required if |
None
|
progress
|
bool
|
Should a progress bar be shown for each operation? |
True
|
n_processes
|
int | None
|
Number of processes to use for parallel processing. Set to |
None
|
Returns:
| Type | Description |
|---|---|
AR6Infiller
|
Initialised harmoniser |
Source code in src/gcages/ar6/infilling.py
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 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 | |
do_ar6_like_infilling #
do_ar6_like_infilling(
indf: DataFrame,
follower: str,
lead_options: tuple[tuple[str, ...], ...],
db_file: Path,
cruncher: _DatabaseCruncher,
cfcs: bool,
) -> DataFrame
Do infilling like it was done in AR6
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indf
|
DataFrame
|
Emissions scenario to infill |
required |
follower
|
str
|
Variable to infill |
required |
lead_options
|
tuple[tuple[str, ...], ...]
|
Options to try as the lead variable |
required |
db_file
|
Path
|
File from which to load the infilling database |
required |
cruncher
|
_DatabaseCruncher
|
Cruncher to use for deriving the relationship between |
required |
cfcs
|
bool
|
Should we load the CFC infilling database? |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Infilled timeseries |
Source code in src/gcages/ar6/infilling.py
get_ar6_full_historical_emissions
cached
#
Get the full AR6 historical emissions
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
Path
|
Filepath from which to load the emissions |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Historical emissions as used in AR6 |
Raises:
| Type | Description |
|---|---|
AssertionError
|
|
Source code in src/gcages/ar6/infilling.py
get_ar6_infiller
cached
#
get_ar6_infiller(
follower: str,
lead: tuple[str, ...],
db_file: Path,
cruncher: _DatabaseCruncher,
cfcs: bool,
) -> Callable[[DataFrame], DataFrame]
Get an infiller following the logic used in AR6
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
follower
|
str
|
Variable to infill |
required |
lead
|
tuple[str, ...]
|
Lead variable(s) for the infilling |
required |
db_file
|
Path
|
File from which to load the infilling database |
required |
cruncher
|
_DatabaseCruncher
|
Cruncher to use for deriving the relationship between |
required |
cfcs
|
bool
|
Should we load the CFC infilling database? |
required |
Returns:
| Type | Description |
|---|---|
Callable[[DataFrame], DataFrame]
|
Infilled timeseries |
Source code in src/gcages/ar6/infilling.py
infill_scenario #
infill_scenario(
indf: DataFrame,
infillers: Mapping[
str, Callable[[DataFrame], DataFrame]
],
) -> DataFrame
Infill a single scenario
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indf
|
DataFrame
|
Scenario to harmonise |
required |
infillers
|
Mapping[str, Callable[[DataFrame], DataFrame]]
|
Functions to use for infilling each variable. The keys define the variable that can be infilled. The variables define the function which, given inputs with the expected lead variables, returns the infilled time series. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Infilled scenario |
Source code in src/gcages/ar6/infilling.py
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 | |
load_massaged_ar6_infilling_db
cached
#
Load the infilling database that was used in AR6
The data is massaged to what is expected by our infilling, it isn't the raw data (at least not raw metadata).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
Path
|
Filepath from which to load the infilling database |
required |
cfcs
|
bool
|
If |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
Infilling database used in AR6 |
Raises:
| Type | Description |
|---|---|
AssertionError
|
|
Source code in src/gcages/ar6/infilling.py
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 | |