ghg_forcing_for_cmip.plotting#
Plotting functions for tutorials in documentation
Functions:
| Name | Description |
|---|---|
plot_average_hemisphere |
Plot global, monthly average separate for hemispheres |
plot_collocated_rmse |
Plot rmse for collocated data for GB vs. EO data |
plot_coverage |
Plot GHG observations on world map |
plot_future_predictions |
Plot observed, fitted, and predicted data |
plot_global_hemisphere |
Plot global average of GHG |
plot_global_hemisphere_coverage |
Plot global, monthly-avg. ghg concentration |
plot_gridsizes |
Plot earth gridding |
plot_hemisphere |
Plot observed and predicted data aggregated over different hemispheres |
plot_locations |
Plot future years |
plot_map |
Plot world map with observation stations |
plot_monthly_average |
Plot global, monthly average of GHG concentration |
plot_prophet_components |
Plot trend and seasonality components from Prophet models. |
plot_average_hemisphere #
Plot global, monthly average separate for hemispheres
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d_colloc
|
DataFrame
|
dataframe including grouping variable with hemisphere levels (Northern, Southern, Tropics) whereby Northern: >30°, Southern: < -30°, and Tropics: <30°, >-30° |
required |
gas
|
str
|
either "co2" or "ch4" |
required |
Source code in src/ghg_forcing_for_cmip/plotting.py
plot_collocated_rmse #
Plot rmse for collocated data for GB vs. EO data
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d_colloc_co2
|
DataFrame
|
collocated data for co2 |
required |
d_colloc_ch4
|
DataFrame
|
collocated data for ch4 |
required |
measure
|
str
|
either "rmse" or "dcor" |
required |
Returns:
| Type | Description |
|---|---|
Any
|
axs of matplotlib.pyplot |
Source code in src/ghg_forcing_for_cmip/plotting.py
plot_coverage #
plot_coverage(
df: DataFrame,
year: int,
grid_size: int,
gas: str,
unit: str,
ms: int = 10,
lw: float = 0.5,
vmin: Optional[float] = None,
vmax: Optional[float] = None,
xlim: Optional[list[float]] = None,
ylim: Optional[list[float]] = None,
) -> Any
Plot GHG observations on world map
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
dataset including ghg data |
required |
year
|
int
|
year for which data should be visualized |
required |
grid_size
|
int
|
size of single grid cells |
required |
gas
|
str
|
name of greenhouse gas |
required |
unit
|
str
|
unit of greenhouse gas |
required |
ms
|
int
|
marker size, by default 10 |
10
|
lw
|
float
|
red border used to visualize observed data, by default 0.5 |
0.5
|
vmin
|
Optional[float]
|
minimum scale value for legend,
if |
None
|
vmax
|
Optional[float]
|
maximum scale value for legend,
if |
None
|
xlim
|
Optional[list[float]]
|
range of x-axis that should be visualized, can be used to "zoom" into the map |
None
|
ylim
|
Optional[list[float]]
|
range of y-axis that should be visualized, can be used to "zoom" into the map |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
fig, axs |
Source code in src/ghg_forcing_for_cmip/plotting.py
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 | |
plot_future_predictions #
plot_future_predictions(
df_observed: DataFrame,
df_coverage: DataFrame,
df_future_years: DataFrame,
min_year: int,
split_value: int,
figsize: tuple[int],
gas: str,
unit: str,
day: int = 15,
quantiles: tuple[float, float] = (0.025, 0.975),
) -> Any
Plot observed, fitted, and predicted data
Monthly aggregated across hemispheres and for the global mean.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_observed
|
DataFrame
|
observed GHG data |
required |
df_coverage
|
DataFrame
|
predicted data within observed year range showing full coverage |
required |
df_future_years
|
DataFrame
|
predicted data for future years |
required |
min_year
|
int
|
minimum year for truncating the x-axis |
required |
split_value
|
int
|
value used to differentiate between southern, northern hemisphere, and tropics |
required |
figsize
|
tuple[int]
|
size of plot |
required |
gas
|
str
|
name of GHG |
required |
unit
|
str
|
unit of GHG |
required |
day
|
int
|
day used for creating a date variable |
15
|
quantiles
|
tuple[float, float]
|
quantiles used for uncertainty shading |
(0.025, 0.975)
|
Returns:
| Type | Description |
|---|---|
Any
|
fig, axs |
Source code in src/ghg_forcing_for_cmip/plotting.py
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 | |
plot_global_hemisphere #
plot_global_hemisphere(
df: DataFrame,
gas: str,
unit: str,
figsize: Optional[tuple[int, int]] = None,
) -> Any
Plot global average of GHG
grouped by northern, southern hemispheres and tropics
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
dataframe |
required |
gas
|
str
|
name of greenhouse gas |
required |
unit
|
str
|
unit of greenhouse gas |
required |
figsize
|
Optional[tuple[int, int]]
|
size of figure |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
fig, axs |
Source code in src/ghg_forcing_for_cmip/plotting.py
plot_global_hemisphere_coverage #
plot_global_hemisphere_coverage(
df_collocated: DataFrame,
df_coverage: DataFrame,
gas: str,
unit: str,
split_value: int,
figsize: Optional[tuple[int, int]] = None,
quantiles: tuple[float, float] = (0.025, 0.975),
) -> Any
Plot global, monthly-avg. ghg concentration
Plotting for different hemispheres and compared to observed data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_collocated
|
DataFrame
|
collocated dataframe including observed data (i.e., gb_value) |
required |
df_coverage
|
DataFrame
|
gap filled dataframe including predicted data that covers full spatio-temporal range |
required |
gas
|
str
|
name of greenhouse gas |
required |
unit
|
str
|
unit of greenhouse gas |
required |
split_value
|
int
|
splitting value used to differentiate between northern, southern hemisphere and tropics |
required |
figsize
|
Optional[tuple[int, int]]
|
size of figure |
None
|
quantiles
|
tuple[float, float]
|
quantiles used for uncertainty shading |
(0.025, 0.975)
|
Returns:
| Type | Description |
|---|---|
Any
|
fig, axs |
Source code in src/ghg_forcing_for_cmip/plotting.py
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 | |
plot_gridsizes #
Plot earth gridding
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
raw ground-based data frame |
required |
grid_size
|
int
|
size of grid cell; should be CONFIG.GRID_CELL_SIZE |
required |
subset
|
bool
|
if true shows only Europe if false shows Earth |
required |
Returns:
| Type | Description |
|---|---|
Any
|
fig, axs from plot |
Source code in src/ghg_forcing_for_cmip/plotting.py
1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 | |
plot_hemisphere #
plot_hemisphere(
df_pred: DataFrame,
df_obs: DataFrame,
gas: str,
unit: str,
year_min: int,
split_value: int,
figsize: tuple[int],
day: int = 15,
) -> Any
Plot observed and predicted data aggregated over different hemispheres
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_pred
|
DataFrame
|
predicted data, spanning full coverage |
required |
df_obs
|
DataFrame
|
observed ground-based data |
required |
gas
|
str
|
name of greenhouse gas |
required |
unit
|
str
|
unit of greenhouse gas measurement |
required |
year_min
|
int
|
minimum year used for showing x-range |
required |
split_value
|
int
|
value used to differentiate between northern, southern hemisphere and tropics |
required |
figsize
|
tuple[int]
|
plot size |
required |
day
|
int
|
day used for constructing date variable |
15
|
Returns:
| Type | Description |
|---|---|
Any
|
fig, axs |
Source code in src/ghg_forcing_for_cmip/plotting.py
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 | |
plot_locations #
plot_locations(
df_observed: DataFrame,
df_fitted: DataFrame,
year_min: int,
figsize: tuple[int],
gas: str,
unit: str,
locations: DataFrame,
df_predicted: Optional[DataFrame] = None,
day: int = 15,
quantiles: tuple[float, float] = (0.025, 0.975),
) -> Any
Plot future years
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df_observed
|
DataFrame
|
observed data set |
required |
df_fitted
|
DataFrame
|
fitted data to observed data |
required |
year_min
|
int
|
minimum year used for truncating the x-axis |
required |
figsize
|
tuple[int]
|
size of figure |
required |
gas
|
str
|
name of greenhouse gas |
required |
unit
|
str
|
unit of greenhouse gas |
required |
locations
|
DataFrame
|
selected locations to plot |
required |
df_predicted
|
Optional[DataFrame]
|
predict future data |
None
|
day
|
int
|
day used for creating a date variable, default is 15 |
15
|
quantiles
|
tuple[float, float]
|
quantiles used for uncertainty shading |
(0.025, 0.975)
|
Returns:
| Type | Description |
|---|---|
Any
|
fig, axs |
Source code in src/ghg_forcing_for_cmip/plotting.py
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 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 | |
plot_map #
plot_map(
d: DataFrame,
title: str,
axs: Any,
lon_value: str = "longitude",
lat_value: str = "latitude",
marker: str = "x",
markersize: int = 20,
figsize: tuple[int, int] = (8, 3),
) -> Any
Plot world map with observation stations
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
DataFrame
|
dataframe with ghg concentrations and lat, lon information |
required |
title
|
str
|
title of the plot |
required |
axs
|
Any
|
axes of matplotlib |
required |
lon_value
|
str
|
name of longitudinal variable (column) |
'longitude'
|
lat_value
|
str
|
name of latitudinal variable (column) |
'latitude'
|
marker
|
str
|
shape of plot markers |
'x'
|
markersize
|
int
|
size of plot markers |
20
|
figsize
|
tuple[int, int]
|
size of world map |
(8, 3)
|
Returns:
| Type | Description |
|---|---|
Any
|
axes from matplotlib pyplot |
Source code in src/ghg_forcing_for_cmip/plotting.py
plot_monthly_average #
plot_monthly_average(
d: DataFrame,
gas: str,
axs: Any,
label_eo: str = "satellite",
label_gb: str = "ground_based",
) -> Any
Plot global, monthly average of GHG concentration
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
d
|
DataFrame
|
dataframe with raw data |
required |
gas
|
str
|
either "ch4" or "co2" |
required |
axs
|
Any
|
axis of plt.subplots object |
required |
label_eo
|
str
|
legend in plot for earth observations, by default "satellite" |
'satellite'
|
label_gb
|
str
|
legend in plot for ground-based data, by default "ground_based" |
'ground_based'
|
Returns:
| Type | Description |
|---|---|
Any
|
axis object from matplotlib.pyplot |
Source code in src/ghg_forcing_for_cmip/plotting.py
plot_prophet_components #
plot_prophet_components(
components: dict[str, DataFrame],
gas: str,
unit: str,
x_years: tuple[int, int],
figsize: Optional[tuple[int, int]] = None,
) -> Any
Plot trend and seasonality components from Prophet models.
Creates a figure with two rows: trend components (top) and seasonality components (bottom), with separate panels for each region (Southern, Tropical, Northern).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
components
|
dict[str, DataFrame]
|
Dictionary with keys 'southern', 'tropical', 'northern', each containing a DataFrame with columns 'ds', 'trend', 'yearly'. |
required |
gas
|
str
|
Name of greenhouse gas (e.g., 'co2', 'ch4'). |
required |
unit
|
str
|
Unit of measurement (e.g., 'ppm', 'ppb'). |
required |
x_years
|
tuple[int, int]
|
Tuple of start and end years for the x-axis. |
required |
figsize
|
Optional[tuple[int, int]]
|
Size of the figure. If None, uses (12, 8). |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
fig, axs tuple from matplotlib. |
Source code in src/ghg_forcing_for_cmip/plotting.py
972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 | |