API Reference¶
Generated from the source. For task-oriented documentation see Usage; for provider specifics see Datasets.
Workflow¶
ClimData is the main entry point — an alias for ClimateExtractor. It
composes the configuration, drives each provider, and carries a dataset between
steps.
climdata.utils.wrapper_workflow.ClimateExtractor
¶
Climate data extraction and extreme-index workflow manager.
Provides a high-level API for
- loading/configuring dataset providers via Hydra config
- uploading NetCDF/CSV content into xarray Datasets
- extracting data from supported providers (CMIP, DWD, MSWX, HYRAS, POWER)
- computing extreme indices using configured xclim indices
- converting datasets to long-form DataFrames and saving results
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Hydra configuration object describing dataset, region/time/variables, outputs. |
current_ds |
Dataset
|
The most recently loaded or extracted dataset. |
current_df |
DataFrame
|
The most recently produced long-form DataFrame. |
filename_csv/filename_nc/filename_zarr |
str
|
Generated output filename templates/paths. |
Example
extractor = ClimateExtractor(overrides=['dataset=cmip', 'region=europe']) extractor.extract() idx_ds = extractor.calc_index() df = extractor.to_dataframe(idx_ds) extractor.to_csv(df)
Source code in climdata/utils/wrapper_workflow.py
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 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 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 970 971 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 1067 1068 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 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 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 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 | |
__init__(cfg_name='config', conf_path=None, overrides=None)
¶
Initialize the workflow manager and load configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg_name
|
str
|
Name of the Hydra configuration (default: "config"). |
'config'
|
conf_path
|
str
|
Optional config path override. |
None
|
overrides
|
list[str]
|
Hydra overrides to apply to the configuration. |
None
|
Source code in climdata/utils/wrapper_workflow.py
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 | |
calc_index(ds=None)
¶
Calculate the configured extreme index using xclim indices.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset to operate on. If |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: The computed index as an xarray Dataset (also sets |
Source code in climdata/utils/wrapper_workflow.py
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 | |
close_dask()
¶
Shut down the Dask cluster this extractor started, if any.
Safe to call unconditionally: it is a no-op when no cluster was started. A cluster the extractor merely reused, rather than created, is left running for whoever owns it.
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/utils/wrapper_workflow.py
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 | |
configure_logging(level=logging.INFO, handler=None)
¶
Configure logging for this extractor instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
int
|
Logging level (default: |
INFO
|
handler
|
Handler
|
Handler to add; if |
None
|
Source code in climdata/utils/wrapper_workflow.py
1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 | |
extract()
¶
Extract data from the configured provider using self.cfg.
Uses provider-specific classes (e.g., CMIP, DWD, MSWX, HYRAS, POWER)
to fetch, load and extract datasets. When extraction completes, units are converted to those declared in cfg.varinfo, the dataset is computed, and filenames are generated from the configuration.
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: The extracted and computed dataset (also sets |
Source code in climdata/utils/wrapper_workflow.py
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 970 971 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 | |
get_actions()
¶
Return a dictionary of workflow actions with their outputs and descriptions.
Supports actionsinfo in mapping style or list style and returns a consistent mapping of action name to description/output.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Mapping action name -> {'output': ..., 'description': ...} |
Source code in climdata/utils/wrapper_workflow.py
1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 | |
get_datasets()
¶
Return the list of dataset provider names available in configuration.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: Names of available dataset providers from |
Source code in climdata/utils/wrapper_workflow.py
1715 1716 1717 1718 1719 1720 1721 1722 1723 | |
get_impute_methods()
¶
Return mapping of available imputation methods from config.
Returns:
| Type | Description |
|---|---|
Dict[str, dict]
|
Dict[str, dict]: Mapping of method name -> config (empty dict if none configured). |
Source code in climdata/utils/wrapper_workflow.py
1965 1966 1967 1968 1969 1970 1971 1972 1973 | |
get_indices(variables, require_all=True)
¶
Fetch climate extreme indices from cfg.extinfo that involve the given variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
list[str]
|
Variables to filter indices by (if |
required |
require_all
|
bool
|
If True, return indices that require all provided variables; otherwise return indices if any variable matches. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
Dict[str, dict]
|
Mapping index_name -> index_definition. |
Source code in climdata/utils/wrapper_workflow.py
1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 | |
get_variables(dataset=None)
¶
Return the list of variables available for a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset name to query. Defaults to |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: List of variable names. |
Source code in climdata/utils/wrapper_workflow.py
1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 | |
get_varinfo(var)
¶
Get metadata for a variable from varinfo.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
var
|
str
|
Name of the variable, e.g., 'tas', 'tasmax', 'pr'. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Metadata dictionary containing cf_name, long_name, units, etc. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If varinfo is not loaded or variable not found. |
Source code in climdata/utils/wrapper_workflow.py
1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 | |
impute(ds=None)
¶
Impute missing values using the configured imputation method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset to impute. If None, uses
|
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset | None: The imputed dataset (also sets
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in climdata/utils/wrapper_workflow.py
1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 | |
load_config(overrides=None)
¶
Load and compose the Hydra configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overrides
|
list[str]
|
Hydra overrides to apply when composing the configuration. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
DictConfig |
DictConfig
|
Composed Hydra configuration object stored on |
Source code in climdata/utils/wrapper_workflow.py
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 | |
plot(variable=None, ds=None, **kwargs)
¶
Plot a variable on a Cartopy map with coastlines and country borders.
Thin wrapper around :func:climdata.viz.plot_map operating on
self.current_ds by default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
Variable to plot. Defaults to the sole data variable if the dataset has exactly one. |
None
|
ds
|
Dataset
|
Dataset to plot. If |
None
|
**kwargs
|
Forwarded to :func: |
{}
|
Returns:
| Type | Description |
|---|---|
|
The Cartopy |
Source code in climdata/utils/wrapper_workflow.py
1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 | |
preprocess_aoi(cfg)
¶
Process an 'aoi' specification in the configuration.
Supports GeoJSON strings or dictionaries for FeatureCollection, Feature, or simple geometry objects (Point/Polygon).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration object with optional |
required |
Returns:
| Name | Type | Description |
|---|---|---|
DictConfig |
DictConfig
|
The modified configuration. When a Point is provided, |
Source code in climdata/utils/wrapper_workflow.py
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 | |
provenance_record()
¶
The processing steps recorded so far, oldest first.
Each entry holds step, action, status (completed,
skipped or failed), started/ended UTC timestamps,
duration_s, the parameters that step used, inputs (files
read, with SHA-256), results (files written into a crate) and an
output summary. :meth:to_nc and :meth:to_csv write this list to
the crate's meta.json.
Returns:
| Type | Description |
|---|---|
List[dict]
|
list[dict]: A copy of |
Source code in climdata/utils/wrapper_workflow.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 | |
reproject(ds=None, **overrides)
¶
Reproject / resample the dataset onto the configured target grid.
Reads target_projection and target_resolution from the config, plus
the secondary knobs under regrid. Returns None (leaving the current
dataset untouched) when neither target is configured.
The units of target_resolution must match the axis units of
target_projection: a metric resolution such as "10 km" has no fixed
angular size, so combining it with a geographic CRS raises
:class:~climdata.grid.units.ResolutionCRSMismatch rather than silently
approximating. The check runs before any data is touched.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset to transform. If |
None
|
**overrides
|
Any argument of :func: |
{}
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset | None: The reprojected dataset (also sets |
Dataset
|
and |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
ResolutionCRSMismatch
|
If the resolution units contradict the target CRS. |
Example
extractor = ClimData(overrides=[ "target_projection=EPSG:3035", "target_resolution=10 km", ]) extractor.extract() grid_ds = extractor.reproject()
Source code in climdata/utils/wrapper_workflow.py
1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 | |
run_workflow(overrides=None, actions=None, file=None)
¶
Execute a sequence of workflow actions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
overrides
|
list[str]
|
Hydra overrides to apply (not all actions will use these). |
None
|
actions
|
list[str]
|
Ordered list of actions to perform. Supported actions include: 'upload_netcdf', 'upload_csv', 'extract', 'calc_index', 'impute', 'reproject', 'to_csv', 'to_nc'. 'to_csv' and 'to_nc' write into a FAIR crate unless |
None
|
file
|
str
|
File path used for upload actions when required. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
WorkflowResult |
WorkflowResult
|
Named result container with populated fields for dataframe/dataset/filenames. |
Source code in climdata/utils/wrapper_workflow.py
1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 | |
to_csv(df=None, filename=None, format='default', fair=None)
¶
Save a DataFrame to CSV, by default inside a FAIR crate.
With FAIR output on (the default, output.fair.enabled), the file is
written into a crate folder named after it — out/x.csv becomes
out/x_crate/x.csv — next to meta.json (every processing step,
the configuration, software versions, checksums),
ro-crate-metadata.json and ro-crate-preview.html. The NetCDF
from :meth:to_nc shares the stem, so both go into the same crate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame to save. Defaults to |
None
|
filename
|
str
|
Output filename/directory. Defaults to |
None
|
format
|
str
|
Output format. Options: - 'default': Long-form (single file) - 'simplace': SIMPLACE format (splits by location, tab-separated) - 'monica': MONICA format (splits by location, tab-separated) Defaults to 'default'. |
'default'
|
fair
|
bool
|
Write into a FAIR crate. Defaults to
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path of the written CSV file. For SIMPLACE/MONICA, the base directory. |
str
|
The crate folder, when one is written, is in |
Raises:
| Type | Description |
|---|---|
ValueError
|
If format is not supported or required data is missing. |
Source code in climdata/utils/wrapper_workflow.py
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 1196 1197 1198 1199 1200 | |
to_dataframe(ds=None)
¶
Convert a dataset to a long-form pandas DataFrame.
The output contains columns: time, lat, lon (or latitude/longitude), variable, value, units, source.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset to convert. If |
None
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Long-form DataFrame (also sets |
Source code in climdata/utils/wrapper_workflow.py
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 | |
to_nc(ds=None, filename=None, fair=None)
¶
Save an xarray Dataset to NetCDF, by default inside a FAIR crate.
With FAIR output on (the default, output.fair.enabled), the file is
written into a crate folder named after it:
.. code-block:: text
1 2 3 4 5 | |
meta.json holds every step recorded in :attr:provenance with its
parameters, inputs, timings and output; the configuration the run used;
software versions; and checksums of the data files. Title, creator,
licence and zipping come from output.fair in the configuration.
Notes
- If
dsisNone: savecurrent_ds. - If
filenameisNone: useself.filename_nc. - Creates directories if needed and updates
self.filename_ncandself.current_filename.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset to save. If |
None
|
filename
|
str
|
Output filename. Defaults to |
None
|
fair
|
bool
|
Write into a FAIR crate. Defaults to
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The path of the written NetCDF file. The crate folder, when one |
str
|
is written, is in |
Source code in climdata/utils/wrapper_workflow.py
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 | |
upload_csv(csv_file)
¶
Load a long-form CSV into an xarray.Dataset.
The CSV must contain time and lat/latitude, lon/longitude, variable, value. Units may be supplied in a units column and an optional source column is recognized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
csv_file
|
str
|
Path to the CSV file to load. |
required |
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: The converted dataset (also sets |
Source code in climdata/utils/wrapper_workflow.py
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 | |
upload_netcdf(nc_file)
¶
Load a NetCDF file into an xarray.Dataset and update file metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
nc_file
|
str
|
Path to the NetCDF file to open. |
required |
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: The loaded dataset (also sets |
Source code in climdata/utils/wrapper_workflow.py
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 | |
climdata.utils.wrapper_workflow.WorkflowResult
dataclass
¶
What :meth:ClimateExtractor.run_workflow produces.
Every field but cfg is optional and stays None unless an action in
the sequence populated it, so which attributes are set records which actions
ran. :meth:keys names them.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
The configuration the workflow ran with. |
dataset |
Dataset | None
|
Extracted or uploaded data. |
dataframe |
DataFrame | None
|
Long-form conversion of the dataset. |
filename |
str | None
|
Path written by the last file-writing action. |
index_ds |
Dataset | None
|
Computed extreme index. |
index_filename |
str | None
|
Path of the written index. |
impute_ds |
Dataset | None
|
Gap-filled dataset. |
impute_filename |
str | None
|
Path of the written imputed dataset. |
reprojected_ds |
Dataset | None
|
Regridded dataset. |
reprojected_filename |
str | None
|
Path of the written regridded dataset. |
crate_dir |
str | None
|
FAIR crate folder the last write went into. |
Source code in climdata/utils/wrapper_workflow.py
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 | |
keys()
¶
Name the fields that were actually populated.
Returns:
| Type | Description |
|---|---|
|
list[str]: Attribute names whose value is not |
|
|
a record of which workflow actions produced output. |
Source code in climdata/utils/wrapper_workflow.py
128 129 130 131 132 133 134 135 | |
climdata.utils.config.load_config(config_name='config', overrides=None, verbose=False)
¶
Load Hydra config from ./conf directory.
Uses initialize_config_dir with absolute path to ensure Hydra finds the config.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config_name
|
str
|
Name of the config file (default: "config") |
'config'
|
overrides
|
list[str]
|
Hydra overrides to apply |
None
|
verbose
|
bool
|
Print the loaded config to stdout |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
DictConfig |
Hydra configuration object |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If conf directory cannot be found |
RuntimeError
|
If Hydra initialization or config composition fails |
Source code in climdata/utils/config.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 | |
Discovery¶
Browsing the catalogue without downloading anything.
climdata.explore.list_available_data()
¶
Print a summary table of every dataset in the registry.
One row per provider, with its abbreviation, long name, type, spatial
coverage and native resolution. The abbreviation in the first column is the
key accepted by :func:explore, :func:inspect and the dataset= Hydra
override.
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
The table is written to stdout. |
Example
import climdata as cd cd.list_available_data() # doctest: +SKIP
Source code in climdata/explore/queries.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 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 | |
climdata.explore.explore(dataset)
¶
Print a detailed profile for one dataset.
Covers type, coverage, resolution, frequency, temporal extent and source, followed by the experiments, models and variables the registry knows about. An unknown name prints the list of valid ones rather than raising.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset abbreviation as shown by :func: |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
The profile is written to stdout. |
Example
import climdata as cd cd.explore(dataset="NEXGDDP") # doctest: +SKIP
Source code in climdata/explore/queries.py
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 | |
climdata.explore.find(variable=None, frequency=None, type_filter=None, coverage=None)
¶
Search the registry for datasets matching the given criteria.
Criteria combine with AND: a dataset is listed only if it satisfies every
argument that was supplied. variable requires an exact CF-name match;
the other three match as case-insensitive substrings. Passing no arguments
lists everything.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name that the dataset must provide
(e.g. |
None
|
frequency
|
str
|
Temporal resolution keyword, e.g. |
None
|
type_filter
|
str
|
Dataset type, e.g. |
None
|
coverage
|
str
|
Coverage region, e.g. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
Matches are written to stdout. |
Example
import climdata as cd cd.find(variable="pr", frequency="daily") # doctest: +SKIP cd.find(type_filter="ESM") # doctest: +SKIP
Source code in climdata/explore/queries.py
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 | |
climdata.explore.inspect(dataset, variable)
¶
Print variable-level metadata for one variable of one dataset.
Reports the long name, the unit BASD expects for the variable, and any
conversion note attached to it — the detail that matters before feeding data
to :mod:climdata.sdba, since a unit mismatch there fails silently rather
than loudly. Metadata comes from conf/mappings/parameters.yaml.
Unknown datasets, and variables the dataset does not carry, print the valid alternatives rather than raising.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset abbreviation (e.g. |
required |
variable
|
str
|
CF variable name (e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
The report is written to stdout. |
Example
import climdata as cd cd.inspect("ERA5", variable="tp") # doctest: +SKIP
Source code in climdata/explore/queries.py
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 | |
climdata.explore.list_esm_experiments(dataset)
¶
Print the experiments (scenarios) available for an ESM dataset.
Reads the experiment list straight from the registry, so it costs nothing and
needs no credentials. Non-ESM datasets, and ESM datasets whose experiments
are not declared in the configuration, print a hint pointing at the dataset
class's own get_experiment_ids().
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset abbreviation (e.g. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
The list is written to stdout. |
Example
import climdata as cd cd.list_esm_experiments("CMIP") # doctest: +SKIP
Source code in climdata/explore/queries.py
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 | |
climdata.explore.list_esm_models(dataset, experiment=None)
¶
Print the ESM models available for a dataset, optionally for one experiment.
Unlike :func:list_esm_experiments, this queries the provider's live
catalogue through the dataset class, so it needs network access and can be
slow. Failures at any step — unimportable class, unreachable catalogue,
unknown experiment — are reported and swallowed rather than raised, so an
exploratory call never aborts a session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset abbreviation (e.g. |
required |
experiment
|
str
|
Experiment ID to filter by, e.g.
|
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
The list is written to stdout. |
Example
import climdata as cd cd.list_esm_models("NEXGDDP") # doctest: +SKIP cd.list_esm_models("CMIP", experiment="ssp585") # doctest: +SKIP
Source code in climdata/explore/queries.py
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 | |
climdata.explore.get_registry()
¶
Return the dataset registry for programmatic use.
Returns:
| Type | Description |
|---|---|
dict[str, dict]
|
dict[str, dict]: A shallow copy of :data: |
dict[str, dict]
|
abbreviation. The copy protects the top level only — the per-dataset |
dict[str, dict]
|
metadata dicts are shared, so do not mutate them. |
Example
from climdata.explore import get_registry sorted(get_registry())[:3] # doctest: +SKIP ['AGRI_ISIMIP', 'CMIP', 'CMIP_W5E5']
Source code in climdata/explore/registry.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
climdata.explore.resolve_dataset_key(name)
¶
Resolve a dataset name to its canonical registry key, case-insensitively.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Dataset name in any casing, e.g. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
str | None: The canonical key ( |
Optional[str]
|
matches. Callers report the miss themselves rather than catching an |
Optional[str]
|
exception. |
Example
from climdata.explore import resolve_dataset_key resolve_dataset_key("nexgddp") 'NEXGDDP' resolve_dataset_key("not-a-dataset") is None True
Source code in climdata/explore/registry.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
climdata.explore.DatasetRegistry
¶
A browsable handle on the climdata dataset catalogue.
Wraps the module-level functions of :mod:climdata.explore.queries so the
catalogue can be held in a variable, and adds dict-style lookup for callers
who want the metadata rather than a printed report. Echoing the object at a
REPL prints the summary table.
Attributes:
| Name | Type | Description |
|---|---|---|
keys |
Bound method returning the canonical dataset abbreviations. |
Example
from climdata.explore import DatasetRegistry reg = DatasetRegistry() reg # doctest: +SKIP AVAILABLE CLIMATE DATASETS ... reg.explore("ERA5") # doctest: +SKIP reg["era5"]["resolution"] # dict-style, case-insensitive '0.25°'
Source code in climdata/explore/catalog.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 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 | |
__getitem__(key)
¶
Return the raw metadata dict for one dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Dataset abbreviation, case-insensitive. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
The registry entry, as described in |
dict
|
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If no dataset matches |
Source code in climdata/explore/catalog.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | |
__init__()
¶
Bind the process-wide registry snapshot.
Source code in climdata/explore/catalog.py
35 36 37 | |
__repr__()
¶
Render the catalogue as a summary table.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Abbreviation, long name and type for every dataset. |
Source code in climdata/explore/catalog.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
explore(dataset)
¶
Print a dataset profile. See :func:climdata.explore.explore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset abbreviation, case-insensitive. |
required |
Source code in climdata/explore/catalog.py
69 70 71 72 73 74 75 | |
find(**kwargs)
¶
Search the catalogue. See :func:climdata.explore.find.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any of |
{}
|
Source code in climdata/explore/catalog.py
77 78 79 80 81 82 83 84 | |
inspect(dataset, variable)
¶
Print variable metadata. See :func:climdata.explore.inspect.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
str
|
Dataset abbreviation, case-insensitive. |
required |
variable
|
str
|
CF variable name. |
required |
Source code in climdata/explore/catalog.py
86 87 88 89 90 91 92 93 | |
keys()
¶
Return the canonical dataset abbreviations.
Returns:
| Type | Description |
|---|---|
|
KeysView[str]: The registry keys, e.g. |
Source code in climdata/explore/catalog.py
114 115 116 117 118 119 120 | |
list_available_data()
¶
Print the summary table. See :func:climdata.explore.list_available_data.
Source code in climdata/explore/catalog.py
65 66 67 | |
Providers¶
Each class can be used directly when the workflow wrapper is more than you need.
All follow a fetch → load → extract lifecycle, with the per-provider
deviations noted in each docstring.
Observations, global¶
climdata.datasets.MSWX.MSWXmirror
¶
Download and load MSWX daily data, one variable at a time.
The order of operations is inverted relative to the other providers: call
:meth:extract first to record the region of interest, then
:meth:load, which downloads what is missing and applies the subset
per-file during opening. Loading before extracting works but pulls whole
global frames into the graph.
One call handles one variable, because each variable lives in its own Drive
folder. :class:~climdata.utils.wrapper_workflow.ClimateExtractor loops over
cfg.variables and merges the results.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Hydra configuration. |
variables |
list[str]
|
|
dataset |
Dataset | None
|
The loaded dataset, set by :meth: |
Example
mswx = MSWXmirror(cfg) # doctest: +SKIP mswx.extract(box={"lat_min": 47, "lat_max": 55, # doctest: +SKIP ... "lon_min": 5, "lon_max": 15}) ds = mswx.load("pr") # doctest: +SKIP
Source code in climdata/datasets/MSWX.py
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 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 | |
__init__(cfg)
¶
Bind a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with |
required |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the Google API client libraries are not installed. |
Source code in climdata/datasets/MSWX.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
extract(*, point=None, box=None, shapefile=None, buffer_km=0.0)
¶
Record the region of interest for :meth:load to apply.
Nothing is read here — the instruction is stored and executed per-file
inside :meth:load, which is why this should be called first. The three
modes are mutually exclusive; the first supplied wins, in the order
point, box, shapefile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
tuple[float, float]
|
|
None
|
box
|
dict
|
Bounding box with keys |
None
|
shapefile
|
str | GeoDataFrame
|
Polygon(s) to clip to, as a path or an in-memory frame. |
None
|
buffer_km
|
float
|
For |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
MSWXmirror |
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If none of |
Source code in climdata/datasets/MSWX.py
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 | |
fetch(folder_id, variable)
¶
Download the daily MSWX files for one variable, skipping what exists.
Expands the configured date range into one expected filename per day
(YYYYDDD.nc), checks which are already under
<data_dir>/<DATASET>/<VARIABLE>/, and downloads only the rest — so an
interrupted run resumes rather than restarting. Google credentials are
only required when something is actually missing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_id
|
str
|
Google Drive folder ID for this variable, from
|
required |
variable
|
str
|
CF variable name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
|
list[str]: Basenames now present locally. May be shorter than the |
|
|
requested range if Drive does not hold every day. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If files are missing and no service-account key is configured. |
FileNotFoundError
|
If the configured key file does not exist. |
Source code in climdata/datasets/MSWX.py
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 | |
load(variable)
¶
Download what is missing, then open every daily file as one dataset.
Calls :meth:fetch for this variable, then opens the files with
open_mfdataset, concatenating along time. The per-file
preprocess hook fixes coordinates, applies the subset recorded by
:meth:extract, and renames the MSWX-internal variable to its CF name.
Whether the result is lazy depends on cfg.load.dask.enabled: with a
Dask cluster the dataset stays lazy, without one it is materialised into
memory before returning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name, as declared in |
required |
Returns:
| Type | Description |
|---|---|
|
xr.Dataset: The concatenated dataset, also stored on :attr: |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no files could be found for the variable, or if opening them failed. |
KeyError
|
If the variable has no entry in |
Source code in climdata/datasets/MSWX.py
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 | |
save_csv(filename)
¶
Write the loaded dataset to CSV in long form.
Does nothing if no dataset is loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. The parent directory must exist. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/datasets/MSWX.py
530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 | |
to_zarr(zarr_filename)
¶
Write the loaded dataset to a Zarr store under data/MSWX/.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zarr_filename
|
str
|
Store name, resolved relative to |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
Source code in climdata/datasets/MSWX.py
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 | |
climdata.datasets.ERA5.ERA5Mirror
¶
Build and maintain a local Zarr mirror of ERA5 from the Copernicus CDS.
Unlike the other providers this is a mirroring tool rather than an
extractor: it downloads whole global months and appends them to one Zarr
store per variable, to be read afterwards with xarray.open_zarr. It also
takes a storage path rather than a Hydra config, so it is not driven by
:class:~climdata.utils.wrapper_workflow.ClimateExtractor.
Progress is journalled in a metadata.json beside the stores, so an
interrupted mirror resumes at the first month it has not yet written instead
of re-downloading. Months are fetched concurrently through Dask.
Requires a Copernicus CDS account and a ~/.cdsapirc key file.
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
Directory holding the Zarr stores and |
fs |
AbstractFileSystem
|
Filesystem the stores live on — local by default, but any fsspec target (S3, GCS) works. |
metadata |
dict
|
The journal of downloaded chunks. |
Example
import datetime mirror = ERA5Mirror("./era5") # doctest: +SKIP paths = mirror.download( # doctest: +SKIP ... ["2m_temperature", ("temperature", 500)], ... (datetime.date(2020, 1, 1), datetime.date(2020, 3, 1)), ... )
Source code in climdata/datasets/ERA5.py
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 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 | |
__init__(base_path, fs=None)
¶
Open (or create) a mirror directory and read its journal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_path
|
str
|
Directory for the Zarr stores. Created if absent. |
required |
fs
|
AbstractFileSystem
|
Filesystem to use. Defaults to the local filesystem. |
None
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in climdata/datasets/ERA5.py
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 | |
chunk_exists(variable, year, month, pressure_level)
¶
Test whether a month has already been mirrored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CDS variable name. |
required |
year
|
int
|
Calendar year. |
required |
month
|
int
|
Calendar month, 1-12. |
required |
pressure_level
|
int | None
|
Pressure level in hPa, or |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
|
Source code in climdata/datasets/ERA5.py
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 | |
download(variables, date_range)
¶
Mirror a set of variables over a date range, month by month.
Walks the range one calendar month at a time, skipping months the journal already records and submitting the rest to Dask so several download concurrently. Both endpoints are rounded down to the first of the month, so any month the range touches is fetched whole.
Every resulting store is verified afterwards to have an evenly spaced time axis — the symptom of a download that failed partway through.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
list[str | tuple[str, int]]
|
Variables to mirror. A bare
string requests single-level data; a |
required |
date_range
|
tuple[date, date]
|
Inclusive start and end dates. |
required |
Returns:
| Type | Description |
|---|---|
|
list[str]: Path of the Zarr store for each requested variable. |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If a store ends with an unevenly spaced time axis. Delete that store and re-run — the message names the path. |
Source code in climdata/datasets/ERA5.py
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 | |
download_and_upload_chunk(variable, year, month, pressure_level=None)
¶
Download one month and append it to the variable's Zarr store.
Creates the store on the first month and appends along time
thereafter. Chunking is one timestep by the full global grid, which suits
reading a few dates over a wide area — the common ERA5 access pattern —
rather than long time series at one point.
The journal is updated only after a successful write, so a crash mid-append leaves the month marked as missing and it is retried.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CDS variable name. |
required |
year
|
int
|
Calendar year. |
required |
month
|
int
|
Calendar month, 1-12. |
required |
pressure_level
|
int
|
Pressure level in hPa. |
None
|
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/datasets/ERA5.py
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 | |
download_chunk(variable, year, month, pressure_level=None)
¶
Download one global month of daily-mean ERA5 data.
Requests the CDS daily-statistics product, so what arrives is already aggregated to daily means from 6-hourly steps rather than raw hourly data. The NetCDF lands in a temporary directory and is opened before that directory is removed, so the returned dataset must be consumed or loaded before it goes out of scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CDS variable name, e.g. |
required |
year
|
int
|
Calendar year. |
required |
month
|
int
|
Calendar month, 1-12. |
required |
pressure_level
|
int
|
Pressure level in hPa. |
None
|
Returns:
| Type | Description |
|---|---|
|
xr.Dataset: The downloaded month. |
Raises:
| Type | Description |
|---|---|
Exception
|
Whatever |
Source code in climdata/datasets/ERA5.py
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 | |
get_metadata()
¶
Read the download journal from metadata.json.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
|
|
|
empty journal rather than raising, so a truncated write from an |
||
|
interrupted run costs a re-download rather than a crash. |
Source code in climdata/datasets/ERA5.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
save_metadata()
¶
Write the download journal back to metadata.json.
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/datasets/ERA5.py
116 117 118 119 120 121 122 123 | |
variable_to_zarr_name(variable, pressure_level=None)
¶
Build the Zarr store path for a variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CDS variable name. |
required |
pressure_level
|
int
|
Pressure level in hPa. When given it is folded into the name, so each level gets its own store. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
Path of the form |
|
|
|
Source code in climdata/datasets/ERA5.py
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 | |
climdata.datasets.W5E5.W5E5
¶
Download and assemble W5E5 climate data from the ISIMIP repository.
W5E5 is distributed through ISIMIP3a as observational input data and serves
as the bias-adjustment reference for ISIMIP3b projections — pair it with
:class:~climdata.datasets.CMIP_W5E5.CMIPW5E5 to compare a projection
against the reference it was adjusted to.
The lifecycle is fetch → load → extract. :meth:extract may be
called before :meth:load, in which case the subsetting instructions are
stored and applied as soon as data arrives.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Configuration supplying |
ds |
Dataset | None
|
The loaded dataset, set by :meth: |
client |
ISIMIPClient
|
ISIMIP API client, created in :meth: |
downloaded_files |
list[str]
|
Local paths accumulated by :meth: |
Example
w5e5 = W5E5(cfg) # doctest: +SKIP w5e5.fetch() # doctest: +SKIP w5e5.load() # doctest: +SKIP w5e5.extract(point=(13.4, 52.5)) # doctest: +SKIP
Source code in climdata/datasets/W5E5.py
21 22 23 24 25 26 27 28 29 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 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 | |
__init__(cfg)
¶
Bind a configuration and open an ISIMIP client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with |
required |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in climdata/datasets/W5E5.py
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 | |
extract(*, point=None, box=None, shapefile=None, buffer_km=0.0)
¶
Record a spatial subset, and apply it if data is already loaded.
The instruction is stored rather than executed, so this may be called
before :meth:load; :meth:_apply_extraction runs it once :attr:ds
exists. The three modes are mutually exclusive — the first one supplied
wins, in the order point, box, shapefile. Calling with no
argument clears nothing and does nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
tuple[float, float]
|
|
None
|
box
|
dict
|
Bounding box with keys |
None
|
shapefile
|
str | GeoDataFrame
|
Polygon(s) to clip to, as a path or an in-memory frame. |
None
|
buffer_km
|
float
|
Half-width of a box averaged around |
0.0
|
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/datasets/W5E5.py
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 | |
fetch()
¶
Search ISIMIP and download the W5E5 files covering the request.
Queries the ISIMIP3a obsclim catalogue once per configured variable,
keeps the files whose filename year-range overlaps the requested period
(see :meth:_is_file_in_date_range), and downloads any that are not
already on disk under <data_dir>/<DATASET>/<variable>/.
Per-variable failures are reported and skipped rather than raised, so one
unavailable variable does not abort a multi-variable request — check
:attr:downloaded_files to see what actually arrived.
Returns:
| Name | Type | Description |
|---|---|---|
None |
Paths are appended to :attr: |
Source code in climdata/datasets/W5E5.py
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 | |
load()
¶
Open the downloaded files and merge them into one dataset.
Files are grouped by variable, concatenated along time where a variable spans several decades, merged across variables, and finally clipped to the configured time range.
Returns:
| Name | Type | Description |
|---|---|---|
None |
The dataset is stored on :attr: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
Source code in climdata/datasets/W5E5.py
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 | |
save_csv(filename)
¶
Write the dataset to CSV, creating parent directories.
The frame is written in xarray's wide form — one column per variable,
indexed by the dataset's dimensions — not the long form produced by
:meth:~climdata.utils.wrapper_workflow.ClimateExtractor.to_dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no dataset has been loaded. |
Source code in climdata/datasets/W5E5.py
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 | |
save_netcdf(filename)
¶
Write the dataset to NetCDF, creating parent directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no dataset has been loaded. |
Source code in climdata/datasets/W5E5.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 | |
climdata.datasets.NASAPOWER.POWER
¶
Fetch and assemble a NASA POWER daily time series for one point.
Follows the same fetch → load → extract lifecycle as the gridded
providers, so :class:~climdata.utils.wrapper_workflow.ClimateExtractor can
drive it identically. Because the API is point-based, extract only
narrows the time axis; there is no spatial subsetting to do.
Variable names are translated through cfg.dsinfo.POWER.variables: CF names
(tasmax, pr) on the climdata side, POWER api_id codes
(T2M_MAX, PRECTOTCORR) on the wire.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Hydra configuration supplying |
raw |
dict | None
|
The decoded JSON response, set by :meth: |
ds |
Dataset | None
|
The assembled dataset, set by :meth: |
Source code in climdata/datasets/NASAPOWER.py
20 21 22 23 24 25 26 27 28 29 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 | |
__init__(cfg)
¶
Bind a configuration.
No network call is made here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with |
required |
Source code in climdata/datasets/NASAPOWER.py
39 40 41 42 43 44 45 46 47 48 49 50 51 | |
extract(start=None, end=None)
¶
Narrow the loaded dataset to a time window.
There is no spatial argument: the API already returned exactly one point.
Calling with neither bound is a no-op, which is what lets the generic
workflow invoke extract unconditionally.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
str | datetime
|
Inclusive start of the window.
Open-ended if |
None
|
end
|
str | datetime
|
Inclusive end of the window.
Open-ended if |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
:attr: |
Source code in climdata/datasets/NASAPOWER.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | |
fetch()
¶
Request the daily point series from the POWER API.
Builds a single query for all configured variables over the full
configured date range and stores the decoded JSON on :attr:raw.
Returns:
| Name | Type | Description |
|---|---|---|
None |
The response is stored on :attr: |
Raises:
| Type | Description |
|---|---|
HTTPError
|
If the API returns a non-2xx status — most often an unsupported variable code or an out-of-range date. |
KeyError
|
If a configured variable has no |
Source code in climdata/datasets/NASAPOWER.py
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 | |
load()
¶
Convert the fetched JSON into an :class:xarray.Dataset.
Renames POWER api_id columns back to CF names, parses the
YYYYMMDD keys into a time coordinate, attaches the request's
latitude and longitude as scalar coordinates, and copies long_name
and units from the configuration onto each variable.
POWER encodes gaps as the sentinel -999; those values are passed
through unchanged, so screen for them before computing statistics.
Returns:
| Name | Type | Description |
|---|---|---|
None |
The dataset is stored on :attr: |
Raises:
| Type | Description |
|---|---|
TypeError
|
If :meth: |
KeyError
|
If the response carries no |
Source code in climdata/datasets/NASAPOWER.py
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 | |
save_csv(filename)
¶
Write the loaded dataset to CSV, one row per timestep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. The parent directory must exist. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/datasets/NASAPOWER.py
186 187 188 189 190 191 192 193 194 195 | |
save_netcdf(filename)
¶
Write the loaded dataset to NetCDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. The parent directory must exist. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/datasets/NASAPOWER.py
175 176 177 178 179 180 181 182 183 184 | |
Observations, Germany¶
climdata.datasets.HYRAS.HYRASmirror
¶
Download, open and subset HYRAS grids across both of its file layouts.
Call :meth:extract to record the region of interest, then :meth:load,
which downloads what is missing and applies the subset. Each of the three
subsetting modes takes a different route, chosen for cost:
- point — resolved per file inside
open_mfdataset'spreprocesshook, so only one cell of each file is ever materialised. - box — index bounds computed once from a sample file, then applied to
each file opened individually and concatenated. Files are opened one at a
time rather than through
open_mfdatasetbecause the index bounds must be known before the first file is read. - shapefile — a mask rasterised once, then applied with
where. Unlike the box path this keeps the full grid extent and blanks cells outside the geometry, so the result has the source's spatial shape.
Loading also normalises two unit strings DWD writes in a form xclim does not
accept: pr in "mm" becomes "mm/day", and hurs in
"Percent" becomes "%".
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Hydra configuration. |
variables |
list[str]
|
|
files |
list[str]
|
Local paths resolved by the last :meth: |
dataset |
Dataset | None
|
The loaded dataset, set by :meth: |
Example
hyras = HYRASmirror(cfg) # doctest: +SKIP hyras.extract(box={"lat_min": 47, "lat_max": 55, # doctest: +SKIP ... "lon_min": 6, "lon_max": 15}) ds = hyras.load("pr") # doctest: +SKIP
Source code in climdata/datasets/HYRAS.py
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 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 970 971 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 1067 1068 | |
__init__(cfg)
¶
Bind a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with |
required |
Source code in climdata/datasets/HYRAS.py
557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 | |
extract(*, point=None, box=None, shapefile=None, buffer_km=0.0)
¶
Record the region of interest for :meth:load to apply.
Nothing is read here, and any cached grid indices from a previous call
are discarded. The three modes are mutually exclusive; the first supplied
wins, in the order point, box, shapefile.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
tuple[float, float]
|
|
None
|
box
|
dict
|
Bounding box; all four of |
None
|
shapefile
|
str | GeoDataFrame
|
Polygon(s) to mask to, as a path or an in-memory frame. |
None
|
buffer_km
|
float
|
Dilation applied to |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
HYRASmirror |
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no geometry was given, or if |
Source code in climdata/datasets/HYRAS.py
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 | |
fetch(variable)
¶
Download a variable's files and list the local paths now available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
list[str]: Local paths in chronological order — monthly |
List[str]
|
archives or yearly |
List[str]
|
stored on :attr: |
Source code in climdata/datasets/HYRAS.py
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 | |
load(variable, use_dask=True, chunking=None)
¶
Download what is missing, then open the variable with the subset applied.
Dispatches on file layout first (.tgz archives versus yearly NetCDF)
and then on extraction mode; see the class docstring for why each mode
takes the route it does. Unit strings are normalised and the result is
clipped to the configured time range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name, e.g. |
required |
use_dask
|
bool
|
Whether |
True
|
chunking
|
dict
|
Chunk sizes, e.g. |
None
|
Returns:
| Type | Description |
|---|---|
|
xr.Dataset: The subset dataset, also stored on :attr: |
|
|
Dimensions are |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no files exist for the variable and period. |
Source code in climdata/datasets/HYRAS.py
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 970 971 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 | |
save_csv(filename, df=None)
¶
Write a frame, or the loaded dataset, to CSV.
A gridded HYRAS dataset flattens to one row per cell per timestep, so this can be very large for anything but a point or a small box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. The parent directory must exist. |
required |
df
|
DataFrame
|
Frame to write. Defaults to the loaded
dataset converted with |
None
|
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no frame is given and no dataset is loaded. |
Source code in climdata/datasets/HYRAS.py
1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | |
climdata.datasets.HOSTRADA.HOSTRADAmirror
¶
Download, open and subset HOSTRADA hourly grids.
Follows the same call order as :class:~climdata.datasets.MSWX.MSWXmirror:
:meth:extract records the region of interest, then :meth:load downloads
what is missing and applies the subset per file as it opens.
The grid is projected with 2-D latitude/longitude coordinates, so the subset
is an integer Y/X rectangle rather than a coordinate slice — see the
module docstring for what that implies. Output keeps the projected Y/X
dimensions; pass it through :func:climdata.reproject for a geographic grid.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Hydra configuration. |
variables |
list[str]
|
|
dataset |
Dataset | None
|
The loaded dataset, set by :meth: |
Example
mirror = HOSTRADAmirror(cfg) # doctest: +SKIP mirror.extract(box={"lat_min": 47, "lat_max": 55, # doctest: +SKIP ... "lon_min": 6, "lon_max": 15}) ds = mirror.load("rsds", chunking={"time": "auto"}) # doctest: +SKIP
Source code in climdata/datasets/HOSTRADA.py
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 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 | |
__init__(cfg)
¶
Bind a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with |
required |
Source code in climdata/datasets/HOSTRADA.py
168 169 170 171 172 173 174 175 176 177 178 179 180 | |
extract(*, point=None, box=None, shapefile=None, buffer_km=0.0)
¶
Record the region of interest for :meth:load to apply.
Nothing is read here. The three modes are mutually exclusive; the first
supplied wins, in the order point, box, shapefile. Calling
with no geometry clears any previous request, so the next :meth:load
returns the full German domain.
A shapefile is reduced to its bounding box, not clipped to the
polygon — cells outside the geometry but inside its envelope are kept.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
tuple[float, float]
|
|
None
|
box
|
dict
|
Bounding box with keys |
None
|
shapefile
|
str | GeoDataFrame
|
Geometry whose bounding box is used. |
None
|
buffer_km
|
float
|
Accepted for signature compatibility with the other providers; ignored. |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
HOSTRADAmirror |
'HOSTRADAmirror'
|
|
Source code in climdata/datasets/HOSTRADA.py
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 | |
fetch(variable)
¶
Download the files for a variable and list what is now on disk.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name, e.g. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
list[str]: Sorted local paths covering the configured period. Shorter |
List[str]
|
than the period if the server was missing months. |
Source code in climdata/datasets/HOSTRADA.py
186 187 188 189 190 191 192 193 194 195 196 197 | |
load(variable, chunking=None, use_dask=True)
¶
Download what is missing, then open every monthly file as one dataset.
The Y/X index rectangle is computed once from the first file and
reused for all of them, so the per-file preprocess hook is a cheap
isel rather than a repeated mask evaluation. Files are opened
serially (parallel=False): HOSTRADA's NetCDF-4 files are not reliably
thread-safe to open concurrently. Finally the result is clipped to the
configured time range.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name, e.g. |
required |
chunking
|
dict
|
Chunk sizes applied after opening, e.g.
|
None
|
use_dask
|
bool
|
Whether |
True
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: The concatenated, subset dataset, also stored on |
Dataset
|
|
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If no files exist for the variable and period. |
ValueError
|
If the requested box does not intersect the German domain. |
Source code in climdata/datasets/HOSTRADA.py
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 | |
climdata.datasets.DWD.DWDmirror
¶
Query DWD station observations for one variable at a time.
Unlike the gridded providers there is no fetch/load split:
:meth:extract selects the stations and downloads their records in one
step. One call handles one variable, because DWD groups variables into
datasets (climate_summary, solar, …) with different station lists;
:class:~climdata.utils.wrapper_workflow.ClimateExtractor loops over
cfg.variables and merges the results.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Hydra configuration. |
param_mapping |
DictConfig
|
|
start_date |
str
|
Start of the requested period. |
end_date |
str
|
End of the requested period. |
df |
DataFrame | None
|
Long-form frame, set by :meth: |
dataset |
Dataset | None
|
The extracted dataset, set by :meth: |
Example
dwd = DWDmirror(cfg) # doctest: +SKIP ds = dwd.extract(variable="pr", point=(13.4, 52.5), # doctest: +SKIP ... buffer_km=30)
Source code in climdata/datasets/DWD.py
26 27 28 29 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 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 | |
__init__(cfg)
¶
Bind a configuration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with |
required |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in climdata/datasets/DWD.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
extract(*, variable, point=None, box=None, shapefile=None, buffer_km=25.0)
¶
Select stations by geometry and download their records as a dataset.
Station selection differs by mode. point with buffer_km > 0 takes
every station inside a lat/lon box of that half-width — an approximation,
since a degree of longitude shortens with latitude; buffer_km=0 takes
the single nearest station by planar lat/lon distance. box takes
every station inside it. shapefile takes every station falling
strictly within a geometry, after an optional buffer applied in Web
Mercator.
The returned dataset is indexed by station_id and time, carries a
quality_<variable> companion variable, and has units set from the
configuration so xclim can convert it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name, e.g. |
required |
point
|
tuple[float, float]
|
|
None
|
box
|
dict
|
Bounding box with keys |
None
|
shapefile
|
str | GeoDataFrame
|
Polygon(s) to select within, as a path or an in-memory frame. |
None
|
buffer_km
|
float
|
Half-width for |
25.0
|
Returns:
| Type | Description |
|---|---|
|
xr.Dataset: Observations dimensioned |
|
|
stored on :attr: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If none of |
KeyError
|
If |
Source code in climdata/datasets/DWD.py
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 | |
format(variable, lat_loc, lon_loc)
¶
Collapse the raw frame from :meth:load into one long-form series.
Averages across every selected station per timestamp, producing a single series stamped with the requested coordinates rather than any station's own — so the output describes the location asked about, not the network that answered. The other columns are reduced by mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name to label the rows with. |
required |
lat_loc
|
float
|
Latitude to stamp on every row, in degrees. |
required |
lon_loc
|
float
|
Longitude to stamp on every row, in degrees. |
required |
Returns:
| Type | Description |
|---|---|
|
pd.DataFrame: Columns |
|
|
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If :meth: |
Source code in climdata/datasets/DWD.py
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 | |
get_stations(variable='pr')
¶
Download and cache the station list for a variable's DWD dataset.
Caching is keyed by DWD dataset, not by variable, since several variables share one dataset but different datasets have genuinely different station networks — a cache keyed by variable would hand a solar request the climate-summary stations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name, e.g. |
'pr'
|
Returns:
| Type | Description |
|---|---|
|
pd.DataFrame: Station metadata — |
|
|
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
Source code in climdata/datasets/DWD.py
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 | |
load(variable, lat_loc, lon_loc, buffer_km=50)
¶
Download raw observations from every station within a radius.
A true great-circle radius query, in contrast to :meth:extract, which
approximates with a lat/lon box. The result is the unaggregated long
frame straight from wetterdienst, one row per station, timestamp and
parameter — pass it through :meth:format to collapse it to a single
series.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
CF variable name, e.g. |
required |
lat_loc
|
float
|
Latitude of the search centre, in degrees. |
required |
lon_loc
|
float
|
Longitude of the search centre, in degrees. |
required |
buffer_km
|
float
|
Search radius in kilometres. Defaults to |
50
|
Returns:
| Type | Description |
|---|---|
|
pd.DataFrame: Long-form observations, also stored on :attr: |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
Source code in climdata/datasets/DWD.py
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 | |
save_csv(filename)
¶
Write :attr:df to CSV.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. The parent directory must exist. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
The path written. |
Raises:
| Type | Description |
|---|---|
AttributeError
|
If neither :meth: |
Source code in climdata/datasets/DWD.py
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 | |
Projections¶
climdata.datasets.CMIPCloud.CMIPCloud
¶
Stream CMIP6 model output from the Pangeo cloud catalogue.
Reads analysis-ready Zarr stores from Google Cloud through intake-esm,
so nothing is downloaded up front — only the requested subset is transferred
when the data is finally computed.
The lifecycle is fetch → load → extract, and unlike the
file-based providers the order is strict: :meth:extract needs a loaded
dataset and raises without one.
The catalogue lookups (:meth:open_cmip6_catalog, :meth:get_experiment_ids,
:meth:get_source_ids) are classmethods, so a caller browsing what is
available — a model picker, say — can query them without building an
extraction config first.
Attributes:
| Name | Type | Description |
|---|---|---|
experiment_id |
str
|
CMIP6 experiment, e.g. |
source_id |
str
|
Model name, e.g. |
table_id |
str
|
MIP table setting the frequency, e.g. |
variables |
list[str]
|
Requested CF variable names. |
ds |
Dataset | None
|
The loaded dataset, set by :meth: |
col_subsets |
list
|
Per-variable catalogue subsets, set by :meth: |
Example
cmip = CMIPCloud(cfg) # doctest: +SKIP cmip.fetch() # doctest: +SKIP cmip.load() # doctest: +SKIP ds = cmip.extract(point=(13.4, 52.5)) # doctest: +SKIP
Source code in climdata/datasets/CMIPCloud.py
17 18 19 20 21 22 23 24 25 26 27 28 29 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 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 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 | |
__init__(cfg)
¶
Bind a configuration and validate the requested period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with |
required |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
ValueError
|
If the time range cannot belong to the experiment — see
:meth: |
Source code in climdata/datasets/CMIPCloud.py
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 | |
convert_to_noleap(ds)
¶
Rewrite a CMIP time axis as day-floored pandas timestamps.
CMIP6 models use whichever calendar their modelling centre chose —
noleap, 360_day, proleptic_gregorian — and stamp daily data
at 12:00. Both properties block merging across models and joining against
observations. Converting to pandas.Timestamp at midnight makes the
axes comparable.
This is lossy where the source calendar is not Gregorian: 360-day
timestamps become real dates, which can produce duplicate or missing days
across a long record. It is applied at the end of :meth:extract, once
the data has been subset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset with a CMIP time coordinate. |
required |
Returns:
| Type | Description |
|---|---|
|
xr.Dataset: The dataset with a |
|
|
unchanged if it has no |
Source code in climdata/datasets/CMIPCloud.py
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 | |
extract(*, point=None, box=None, shapefile=None, buffer_km=0.0)
¶
Subset the loaded dataset in time and space.
Always clips to the configured time range first, then applies exactly one
spatial selector. Afterwards the model name is added as a source_id
dimension — so several models can be concatenated — and the time axis is
normalised by :meth:convert_to_noleap.
CMIP6 longitudes run 0-360, so point and box coordinates must be
given in that convention, not as negative western longitudes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
tuple[float, float]
|
|
None
|
box
|
dict
|
Bounding box with keys |
None
|
shapefile
|
str | GeoDataFrame
|
Polygon(s) to clip to, as a path or an in-memory frame. |
None
|
buffer_km
|
float
|
For |
0.0
|
Returns:
| Type | Description |
|---|---|
|
xr.Dataset: The subset, also stored on :attr: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
Source code in climdata/datasets/CMIPCloud.py
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 | |
fetch()
¶
Collect intake catalog subsets for each variable.
Raises:
| Type | Description |
|---|---|
ValueError
|
If the model/experiment/table combination does not
publish every requested variable. Partial coverage is treated
as an error rather than silently dropped, because downstream
extraction indexes the dataset by every name in
|
Source code in climdata/datasets/CMIPCloud.py
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 | |
get_experiment_ids()
classmethod
¶
List the experiments climdata supports, from the live catalogue.
Filtered deliberately to historical plus the canonical sspNNN
scenarios. The raw catalogue carries hundreds of DECK, CFMIP and
diagnostic experiments whose time axes and forcings do not fit the
historical/projection workflow this class is built for.
Returns:
| Type | Description |
|---|---|
|
list[str]: Sorted experiment IDs, e.g. |
|
|
|
Source code in climdata/datasets/CMIPCloud.py
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 | |
get_source_ids(experiment_id, table_id=None, variables=None)
classmethod
¶
List the CMIP6 models available for experiment_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_id
|
CMIP6 experiment, e.g. |
required | |
table_id
|
Restrict to a MIP table, e.g. |
None
|
|
variables
|
Restrict to models that publish all of these
|
None
|
Returns:
| Type | Description |
|---|---|
|
list[str]: Sorted model names. |
Notes
Filtering matters for callers that go on to extract: a model listed
for an experiment does not necessarily publish the requested
variables at the requested frequency, and fetch() would then
fail. Passing the table_id/variables that will be used for
the extraction yields only models that can actually serve it.
Source code in climdata/datasets/CMIPCloud.py
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 | |
get_variables(*, experiment_id, source_id, table_id='day')
¶
List the climdata variables common to every requested model and experiment.
Returns the intersection, not the union: only variables that every
combination of experiment_id and source_id publishes. That is
what a multi-model extraction needs, since one model missing one variable
breaks the merge. The result is further narrowed to the six variables
climdata's downstream index and bias-correction code understands
(tas, tasmin, tasmax, pr, hurs, sfcWind).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_id
|
str | list[str]
|
One experiment or several. |
required |
source_id
|
str | list[str]
|
One model or several. |
required |
table_id
|
str | None
|
MIP table, e.g. |
'day'
|
Returns:
| Type | Description |
|---|---|
|
list[str]: Sorted CF variable names available across all combinations. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no variable is common to every combination — including the case where a model/experiment pair publishes nothing at all. |
Example
CMIPCloud(cfg).get_variables( # doctest: +SKIP ... experiment_id="historical", source_id="GFDL-ESM4") ['hurs', 'pr', 'sfcWind', 'tas', 'tasmax', 'tasmin']
Source code in climdata/datasets/CMIPCloud.py
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 | |
load()
¶
Open the Zarr store behind each catalogue subset and merge them.
Stores are opened lazily over HTTPS, so this is fast and transfers almost
nothing; the data moves when the result is computed. The merge uses
compat="override", taking coordinate values from the first dataset
where models disagree in the last bits of their grid coordinates.
Only the first store per variable is opened, so a variable split across several ensemble members contributes one member.
Returns:
| Type | Description |
|---|---|
|
xr.Dataset | None: The merged dataset, also stored on :attr: |
|
|
|
Source code in climdata/datasets/CMIPCloud.py
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 | |
open_cmip6_catalog(refresh=False)
classmethod
¶
Open the Pangeo CMIP6 ESM datastore, caching it for the process.
The catalogue is a multi-megabyte download taking roughly ten seconds, so the first call pays for it and every later call reuses the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
refresh
|
bool
|
Re-download even if a cached catalogue exists. Use this to pick up newly published models within a long session. |
False
|
Returns:
| Type | Description |
|---|---|
|
intake_esm.esm_datastore: The catalogue, whose |
|
|
frame with one row per published Zarr store. |
Source code in climdata/datasets/CMIPCloud.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
save_csv(filename)
¶
Write the dataset to CSV in long form, doing nothing if none is loaded.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. The parent directory must exist. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/datasets/CMIPCloud.py
622 623 624 625 626 627 628 629 630 631 632 633 634 | |
save_netcdf(filename)
¶
Write the dataset to NetCDF, doing nothing if none is loaded.
Clears the time encoding inherited from the Zarr store first: it names a
calendar that no longer matches the axis rewritten by
:meth:convert_to_noleap, and the NetCDF writer would otherwise fail on
the contradiction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. The parent directory must exist. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/datasets/CMIPCloud.py
539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 | |
save_zarr(store_path)
¶
Write the dataset to a Zarr store, overwriting any existing one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store_path
|
str
|
Destination store path. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Source code in climdata/datasets/CMIPCloud.py
559 560 561 562 563 564 565 566 567 568 569 570 | |
climdata.datasets.NEXGDDP.NEXGDDP
¶
Download and assemble NEX-GDDP-CMIP6 downscaled projections.
Call order matters here: :meth:extract should run before :meth:load, so
the region of interest is known while each global annual file is being
opened. Calling it afterwards still works but materialises whole global
frames first.
Unrecognised models, experiments and variables are warned about rather than
rejected, because NASA adds to the collection faster than the hardcoded
lists here are updated; a genuinely wrong name surfaces as a download
failure in :meth:fetch.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Configuration supplying |
ds |
Dataset | None
|
The loaded dataset, set by :meth: |
experiment_id |
str
|
Experiment, e.g. |
source_id |
str
|
Model, uppercase, e.g. |
member_id |
str
|
Realisation, e.g. |
grid_label |
str
|
Grid label, e.g. |
base_url |
str
|
NASA THREDDS HTTP file server root. |
downloaded_files |
list[str]
|
Local paths accumulated by :meth: |
Example
nex = NEXGDDP(cfg) # doctest: +SKIP nex.get_source_ids()[:3] # doctest: +SKIP ['ACCESS-CM2', 'ACCESS-ESM1-5', 'BCC-CSM2-MR']
Source code in climdata/datasets/NEXGDDP.py
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 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 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 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 970 971 972 973 974 975 976 977 978 979 980 981 982 | |
__init__(cfg)
¶
Initialize NEX-GDDP data accessor.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with required fields: - variables: list of variable names - time_range: dict with start_date and end_date - data_dir: directory to save downloaded files Optional fields: - experiment_id: experiment/scenario (default: 'historical') - source_id: model name (default: 'GFDL-ESM4') - member_id: realization (default: 'r1i1p1f1') |
required |
Source code in climdata/datasets/NEXGDDP.py
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 | |
extract(*, point=None, box=None, shapefile=None, buffer_km=0.0)
¶
Store extraction instructions to be applied during or after load.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
tuple of (lon, lat)
|
Extract data for a specific point location |
None
|
box
|
dict
|
Extract data for a bounding box with keys: lon_min, lon_max, lat_min, lat_max |
None
|
shapefile
|
str or GeoDataFrame
|
Extract data for a shapefile region |
None
|
buffer_km
|
float, default=0.0
|
Buffer distance in kilometers around point (converted to degrees) |
0.0
|
Source code in climdata/datasets/NEXGDDP.py
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 | |
fetch(max_download_workers=8)
¶
Download NEX-GDDP-CMIP6 files from NASA THREDDS server using
dask.delayed for fully parallel file-existence checks and downloads.
Both phases (check + download) use the "threads" scheduler so that
the GIL is released during I/O and multiple HTTP connections run
concurrently without spawning heavyweight processes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_download_workers
|
int, default 8
|
Maximum concurrent HTTP download connections. Keep this ≤ 8 to avoid triggering NASA THREDDS rate- limiting / 503 errors. |
8
|
Source code in climdata/datasets/NEXGDDP.py
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 | |
get_experiment_ids()
¶
Get available NEX-GDDP-CMIP6 experiment IDs.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: List of available experiment IDs |
Source code in climdata/datasets/NEXGDDP.py
382 383 384 385 386 387 388 | |
get_member_ids()
¶
Get available member IDs (realizations) for the current model and experiment by querying the THREDDS server.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: List of available member_ids (e.g., ['r1i1p1f1', 'r2i1p1f1']) |
Source code in climdata/datasets/NEXGDDP.py
410 411 412 413 414 415 416 417 | |
get_source_ids(experiment_id=None)
¶
Get available NEX-GDDP-CMIP6 model (source) IDs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_id
|
str
|
Experiment ID (not used for NEX-GDDP as models are consistent across experiments) |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: List of available model IDs |
Source code in climdata/datasets/NEXGDDP.py
390 391 392 393 394 395 396 397 398 399 400 | |
get_variables()
¶
Get available variables with descriptions.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Dict[str, str]: Dictionary mapping variable names to descriptions |
Source code in climdata/datasets/NEXGDDP.py
402 403 404 405 406 407 408 | |
load()
¶
Load NEX-GDDP files using a ThreadPoolExecutor — one thread per file.
Each thread calls xr.open_dataset(engine="h5netcdf") directly
(no dask graph overhead), applies _extract_preprocess to clip the
global grid (~1440×600) to the target region (~36×32 for Germany),
and loads the result into RAM as plain numpy arrays.
All annual datasets for a variable are then concatenated along time
with xr.concat and merged across variables. The result is a fully
in-memory xarray Dataset — no dask, no lazy evaluation, no scheduler.
This is deliberately not open_mfdataset. Because each file is clipped
to a small region and read immediately into NumPy, there is nothing for a
Dask graph to defer, and building one costs more than it saves:
h5netcdf releases the GIL during reads, so plain threads already run
in parallel, the concatenation is a straight O(n) copy, and no chunk
unification is needed.
The consequence is that the returned dataset is fully in memory. Clip
before loading — see :meth:extract — or a multi-decade global request
will not fit.
Returns:
| Type | Description |
|---|---|
|
xr.Dataset: The merged dataset, also stored on :attr: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
Source code in climdata/datasets/NEXGDDP.py
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 | |
save_csv(filename)
¶
Save the dataset to a CSV file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output filename or path |
required |
Source code in climdata/datasets/NEXGDDP.py
957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 | |
save_netcdf(filename)
¶
Save the dataset to a NetCDF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Output filename or path |
required |
Source code in climdata/datasets/NEXGDDP.py
942 943 944 945 946 947 948 949 950 951 952 953 954 955 | |
to_dataframe()
¶
Convert the dataset to a pandas DataFrame.
Returns:
| Type | Description |
|---|---|
DataFrame
|
pd.DataFrame: Dataset as DataFrame |
Source code in climdata/datasets/NEXGDDP.py
973 974 975 976 977 978 979 980 981 982 | |
climdata.datasets.CMIP_W5E5.CMIPW5E5
¶
Download and assemble ISIMIP3b bias-adjusted CMIP6 projections.
The lifecycle is fetch -> load -> extract. :meth:extract may be
called before :meth:load, in which case the subset is stored and applied as
soon as data arrives.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Configuration supplying |
ds |
Dataset | None
|
The loaded dataset, set by :meth: |
client |
ISIMIPClient
|
ISIMIP API client, created in :meth: |
experiment_id |
str
|
Experiment, e.g. |
source_id |
str
|
Model, lowercase, e.g. |
member_id |
str
|
Realisation, e.g. |
downloaded_files |
list[str]
|
Local paths accumulated by :meth: |
Example
cmip = CMIPW5E5(cfg) # doctest: +SKIP cmip.get_source_ids("ssp585") # doctest: +SKIP ['gfdl-esm4', 'ipsl-cm6a-lr', 'mpi-esm1-2-hr', ...]
Source code in climdata/datasets/CMIP_W5E5.py
28 29 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 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 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 | |
__init__(cfg)
¶
Bind a configuration, open an ISIMIP client and validate the period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with |
required |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
ValueError
|
If the time range cannot belong to the experiment - see
:meth: |
Source code in climdata/datasets/CMIP_W5E5.py
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 | |
extract(*, point=None, box=None, shapefile=None, buffer_km=0.0)
¶
Store extraction instructions to be applied during or after load.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
tuple of (lon, lat)
|
Extract data for a specific point location |
None
|
box
|
dict
|
Extract data for a bounding box with keys: lon_min, lon_max, lat_min, lat_max |
None
|
shapefile
|
str or GeoDataFrame
|
Extract data for a shapefile region |
None
|
buffer_km
|
float, default=0.0
|
Buffer distance in kilometers around point (converted to degrees) |
0.0
|
Source code in climdata/datasets/CMIP_W5E5.py
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 | |
fetch()
¶
Search ISIMIP3b and download the files covering the request.
Queries once per configured variable for the configured model and
experiment, keeps the files whose filename year-range overlaps the period
(see :meth:_is_file_in_date_range), and downloads any not already under
<data_dir>/<DATASET>/<variable>/.
Per-variable failures are reported and skipped rather than raised, so one
unavailable variable does not abort a multi-variable request - check
:attr:downloaded_files to see what actually arrived.
Returns:
| Name | Type | Description |
|---|---|---|
None |
Paths are appended to :attr: |
Source code in climdata/datasets/CMIP_W5E5.py
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 | |
get_experiment_ids()
¶
Get available CMIP6 experiment IDs from ISIMIP repository.
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: List of available experiment IDs (e.g., ['historical', 'ssp126', 'ssp245', 'ssp370', 'ssp585']) |
Source code in climdata/datasets/CMIP_W5E5.py
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 | |
get_source_ids(experiment_id=None)
¶
Get available CMIP6 model (source) IDs for a given experiment from ISIMIP repository.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
experiment_id
|
str
|
CMIP6 experiment ID. If None, uses self.experiment_id |
None
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List[str]: List of available model IDs (e.g., ['gfdl-esm4', 'ipsl-cm6a-lr', 'mpi-esm1-2-hr', 'mri-esm2-0', 'ukesm1-0-ll']) |
Source code in climdata/datasets/CMIP_W5E5.py
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 | |
load()
¶
Open the downloaded files and merge them into one dataset.
Files are grouped by variable, concatenated along time where a variable spans several decades, merged across variables, and clipped to the configured time range.
Returns:
| Name | Type | Description |
|---|---|---|
None |
The dataset is stored on :attr: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
Source code in climdata/datasets/CMIP_W5E5.py
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 | |
save_csv(filename)
¶
Write the dataset to CSV, creating parent directories.
The frame is written in xarray's wide form - one column per variable,
indexed by the dataset's dimensions - not the long form produced by
:meth:~climdata.utils.wrapper_workflow.ClimateExtractor.to_dataframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no dataset has been loaded. |
Source code in climdata/datasets/CMIP_W5E5.py
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 | |
save_netcdf(filename)
¶
Write the dataset to NetCDF, creating parent directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no dataset has been loaded. |
Source code in climdata/datasets/CMIP_W5E5.py
559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 | |
climdata.datasets.AGRI_ISIMIP.AGRI_ISIMIP
¶
Discover, download and subset ISIMIP agricultural model output.
The lifecycle has an extra first step compared to the climate providers:
:meth:query_available_metadata (or :meth:explore, which loops it over
every configured combination) must run before the AVAILABLE_* properties
return anything, because what a given impact model published for a given
forcing and period can only be learned from the API.
After that the usual fetch → load → extract applies. Requests are
described by cfg.query_configs, a list of impact_model /
climate_forcing / period combinations.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Configuration with |
client |
ISIMIPClient
|
ISIMIP API client, created in :meth: |
ds |
Dataset | None
|
The loaded dataset, set by :meth: |
downloaded_files |
list[str]
|
Local paths accumulated by :meth: |
Example
agri = AGRI_ISIMIP(cfg) # doctest: +SKIP agri.query_available_metadata("LPJmL", "gfdl-esm4", "future") sorted(agri.AVAILABLE_CROPS)[:3] # doctest: +SKIP ['mai', 'ri1', 'soy']
Source code in climdata/datasets/AGRI_ISIMIP.py
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 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 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 | |
AVAILABLE_CROPS
property
¶
Crops the API reported for the queried configuration.
Returns:
| Type | Description |
|---|---|
Set[str]
|
set[str]: Crop codes, e.g. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
AVAILABLE_IRRIGATIONS
property
¶
Irrigation regimes the API reported for the queried configuration.
Returns:
| Type | Description |
|---|---|
Set[str]
|
set[str]: Regime codes — typically |
Set[str]
|
and fully irrigated. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
AVAILABLE_SCENARIOS
property
¶
Climate scenarios the API reported for the queried configuration.
Returns:
| Type | Description |
|---|---|
Set[str]
|
set[str]: Scenario names, e.g. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
AVAILABLE_VARIABLES
property
¶
Variables the API reported for the queried configuration.
Returns:
| Type | Description |
|---|---|
Set[str]
|
set[str]: Variable names, e.g. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If :meth: |
__init__(cfg)
¶
Bind a configuration and open an ISIMIP client.
No metadata is queried here; the AVAILABLE_* caches start empty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Configuration with |
required |
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in climdata/datasets/AGRI_ISIMIP.py
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 | |
explore()
¶
Print what ISIMIP holds for every configured query combination.
Runs :meth:query_available_metadata over each entry of
cfg.query_configs and prints the crops, variables, irrigation
regimes and scenarios found. The intended first call on a new
configuration, before committing to a download.
Note that the AVAILABLE_* caches are overwritten by each combination
in turn, so after this they reflect the last one only.
Returns:
| Name | Type | Description |
|---|---|---|
None |
The report is written to stdout. |
Source code in climdata/datasets/AGRI_ISIMIP.py
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 | |
extract(*, point=None, box=None, shapefile=None, buffer_km=0.0)
¶
Specify spatial extraction intent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
point
|
tuple
|
(lon, lat) for point extraction |
None
|
box
|
dict
|
dict(lat_min, lat_max, lon_min, lon_max) for box extraction |
None
|
shapefile
|
str
|
Path to shapefile for shapefile extraction |
None
|
buffer_km
|
float
|
Buffer in km for shapefile extraction |
0.0
|
Source code in climdata/datasets/AGRI_ISIMIP.py
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 | |
fetch(impact_model, climate_forcing, period, crop=None, irrigation=None, variable=None)
¶
Download AGRI-ISIMIP files matching the criteria using isimip_client.download().
Files are stored as::
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
impact_model
|
str
|
Impact model name |
required |
climate_forcing
|
str
|
Climate forcing |
required |
period
|
str
|
Time period |
required |
crop
|
str
|
Specific crop to download |
None
|
irrigation
|
str
|
Specific irrigation type to download |
None
|
variable
|
str
|
Specific variable to download |
None
|
Source code in climdata/datasets/AGRI_ISIMIP.py
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 | |
get_extracted_data()
¶
Extract data based on spatial mode set via extract().
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: Extracted dataset at specified location(s) |
Source code in climdata/datasets/AGRI_ISIMIP.py
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 | |
list_files(impact_model, climate_forcing, period, crop=None, irrigation=None, variable=None)
¶
List available files matching the given criteria.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
impact_model
|
str
|
Impact model name (e.g., 'SIMPLACE-LINTUL5') |
required |
climate_forcing
|
str
|
Climate forcing (e.g., 'mpi-esm1-2-hr') |
required |
period
|
str
|
Time period (e.g., 'historical') |
required |
crop
|
str
|
Filter by crop name |
None
|
irrigation
|
str
|
Filter by irrigation type ('firr' or 'noirr') |
None
|
variable
|
str
|
Filter by variable name |
None
|
Returns:
| Type | Description |
|---|---|
List[Dict]
|
List[Dict]: List of file metadata dictionaries |
Source code in climdata/datasets/AGRI_ISIMIP.py
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 | |
load(file_path, use_dask=True, decode_times=False)
¶
Load a NetCDF file into an xarray Dataset with custom time handling for ISIMIP data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
str
|
Path to the NetCDF file |
required |
use_dask
|
bool
|
Whether to use dask for lazy loading (default: True) |
True
|
decode_times
|
bool
|
Whether to decode times (default: False for ISIMIP data with custom calendars) Set to True if your data uses standard time encoding |
False
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: Loaded xarray dataset with properly decoded time coordinates |
Note
ISIMIP data often uses custom time encoding like "growing seasons since 1601-01-01" with custom calendars. This function automatically detects and converts such times to proper datetime coordinates by: 1. Loading with decode_times=False 2. Parsing the time unit string (e.g., "since 1601-01-01") 3. Interpreting time values as years offset from the reference year 4. Creating proper datetime coordinates
Source code in climdata/datasets/AGRI_ISIMIP.py
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 | |
query_available_metadata(impact_model, climate_forcing, period)
¶
Query ISIMIP API to get all available metadata for a specific configuration. Extracts crops, variables, irrigation types, and scenarios.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
impact_model
|
str
|
Impact model name (e.g., 'SIMPLACE-LINTUL5') |
required |
climate_forcing
|
str
|
Climate forcing/model (e.g., 'mpi-esm1-2-hr') |
required |
period
|
str
|
Time period (e.g., 'historical') |
required |
Raises:
| Type | Description |
|---|---|
Exception
|
If API query fails or no datasets found |
Source code in climdata/datasets/AGRI_ISIMIP.py
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 | |
save_csv(filename)
¶
Write the loaded dataset to CSV, one row per cell per timestep.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. The parent directory must exist. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no dataset has been loaded. |
Source code in climdata/datasets/AGRI_ISIMIP.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 | |
save_netcdf(filename)
¶
Write the loaded dataset to NetCDF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Destination path. The parent directory must exist. |
required |
Returns:
| Type | Description |
|---|---|
|
None |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no dataset has been loaded. |
Source code in climdata/datasets/AGRI_ISIMIP.py
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 | |
Extreme indices¶
Indices are declared in conf/mappings/indices.yaml and evaluated through
xclim.
climdata.extremes.indices.extreme_index
¶
Evaluate a configured extreme index against a loaded dataset.
Attributes:
| Name | Type | Description |
|---|---|---|
cfg |
DictConfig
|
Hydra configuration; |
climate_data |
Dataset
|
Dataset supplying the input variables. Linked intermediate variables are written back into it as they are built. |
Example
indices = extreme_index(cfg, ds) # doctest: +SKIP da = indices.calculate("tx90p") # doctest: +SKIP
Source code in climdata/extremes/indices.py
20 21 22 23 24 25 26 27 28 29 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 | |
__init__(cfg, climate_data)
¶
Bind a configuration and a dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfg
|
DictConfig
|
Hydra configuration containing |
required |
climate_data
|
Dataset
|
Dataset holding the required input variables. |
required |
Source code in climdata/extremes/indices.py
34 35 36 37 38 39 40 41 42 | |
calculate(index)
¶
Compute a single index by name.
Resolution proceeds in three steps:
- Linked variables — each entry under
index_cfg.linkproduces an intermediate DataArray, either by calling an importable function (function_call) or by invoking a method on one input variable (operation). An optionalpostprocessblock may then subset the result. Each is stored back into :attr:climate_dataunder its key so later links and the index itself can reference it. - Argument resolution — any argument written as an OmegaConf-style
reference (
"${...}") is replaced by the matching entry of :attr:climate_data. - Evaluation —
index_cfg.functionis imported and called with the variables listed inindex_cfg.variables(falling back topr).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
str
|
Index name, matching a key of |
required |
Returns:
| Type | Description |
|---|---|
|
xr.DataArray: The computed index, renamed to |
|
|
lazy if the inputs are lazy — call |
Raises:
| Type | Description |
|---|---|
KeyError
|
If |
ValueError
|
If a |
NotImplementedError
|
If a |
Example
indices = extreme_index(cfg, ds) # doctest: +SKIP indices.calculate("tn10p").compute() # doctest: +SKIP
Source code in climdata/extremes/indices.py
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 | |
Grid transformation¶
Reprojection and resampling, plus the resolution/CRS compatibility gate. See the worked example.
climdata.grid.reproject.reproject(obj, target_projection=None, target_resolution=None, *, like=None, method='bilinear', bounds=None, align=True, src_crs=None, x_dim=None, y_dim=None, nodata=np.nan, engine='rasterio', dsinfo_dims=None)
¶
Reproject and/or resample a dataset onto a new grid.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Union[Dataset, DataArray]
|
The :class: |
required |
target_projection
|
Any
|
Destination CRS -- |
None
|
target_resolution
|
Any
|
Destination cell size -- |
None
|
like
|
Optional[Union[Dataset, DataArray]]
|
A template whose grid the output should match exactly. Cannot be
combined with |
None
|
method
|
Union[str, Mapping[str, str]]
|
Resampling method name, or a |
'bilinear'
|
bounds
|
Optional[Sequence[float]]
|
Optional |
None
|
align
|
bool
|
Snap the grid origin to whole multiples of the resolution so that
separately-processed domains stay co-registered. Default |
True
|
src_crs
|
Any
|
Source CRS, when it cannot be inferred from the data. |
None
|
x_dim
|
Optional[str]
|
Source x/longitude dimension name. |
None
|
y_dim
|
Optional[str]
|
Source y/latitude dimension name. |
None
|
nodata
|
Optional[float]
|
Fill value written before warping. Keep the |
nan
|
engine
|
str
|
|
'rasterio'
|
dsinfo_dims
|
Optional[Sequence[str]]
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
Union[Dataset, DataArray]
|
The reprojected object, of the same type as |
Union[Dataset, DataArray]
|
|
Raises:
| Type | Description |
|---|---|
ResolutionCRSMismatch
|
If the resolution units contradict the target CRS. |
ValueError
|
If |
Example
out = reproject(ds, "EPSG:3035", "10 km") # doctest: +SKIP out = reproject(ds, "EPSG:4326", "0.1 deg", # doctest: +SKIP ... method={"pr": "average", "tas": "bilinear"})
Source code in climdata/grid/reproject.py
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 | |
climdata.grid.reproject.resampling_from_name(name)
¶
Look up a :class:rasterio.enums.Resampling member by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
Any
|
A method name such as |
required |
Returns:
| Type | Description |
|---|---|
|
rasterio.enums.Resampling: The matching member. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in climdata/grid/reproject.py
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | |
Resolution parsing¶
climdata.grid.units.parse_resolution(value)
¶
Parse a resolution into canonical units.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
A string ( |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Resolution |
Resolution
|
Linear values in metres, angular values in degrees, bare numbers |
Resolution
|
left alone. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the string cannot be parsed, or if the two components of a tuple are of different kinds. |
TypeError
|
If |
Example
parse_resolution("10 km") Resolution(x=10000.0, y=10000.0, kind='linear', unit='m') parse_resolution("0.1 deg").as_tuple() (0.1, 0.1)
Source code in climdata/grid/units.py
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 | |
climdata.grid.units.resolution_in_crs_units(value, crs, *, latitude=None)
¶
Express a resolution in the axis units of crs, or refuse to.
This is the single enforcement point for the projection/resolution compatibility
rules, so every entry point -- direct call, ClimateExtractor.reproject, a
Hydra override, an LLM tool call -- inherits the check. It runs before any data is
read, so a bad configuration fails immediately rather than after a download.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Anything :func: |
required |
crs
|
Any
|
Anything :func: |
required |
latitude
|
Optional[float]
|
Reference latitude used only to make the error message concrete. |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[float, float]
|
tuple[float, float]: |
Raises:
| Type | Description |
|---|---|
ResolutionCRSMismatch
|
For a linear resolution with a geographic CRS, or an angular resolution with a projected CRS. |
Example
resolution_in_crs_units("10 km", "EPSG:3035") (10000.0, 10000.0) resolution_in_crs_units("10 km", "EPSG:4326") Traceback (most recent call last): ... climdata.grid.units.ResolutionCRSMismatch: ...
Source code in climdata/grid/units.py
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 | |
climdata.grid.units.to_angular(value, latitude)
¶
Convert a linear resolution to degrees at an explicit latitude.
The deliberate escape hatch from :class:ResolutionCRSMismatch, for a caller who
wants the approximation and is prepared to own it. latitude has no default, so
the approximation cannot be made by accident, and there is intentionally no config
flag that reaches this -- a YAML toggle is how such an approximation creeps back
into production runs unnoticed.
The result is exact at latitude and only there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
A linear resolution, e.g. |
required |
latitude
|
float
|
Reference latitude in degrees. Required. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Resolution |
Resolution
|
An angular resolution in degrees. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Example
res = to_angular("10 km", latitude=50.0) round(res.x, 4), round(res.y, 4) (0.1395, 0.0899)
Source code in climdata/grid/units.py
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 | |
climdata.grid.units.Resolution
dataclass
¶
A parsed grid resolution.
Attributes:
| Name | Type | Description |
|---|---|---|
x |
float
|
Magnitude along the x/longitude axis, in :attr: |
y |
float
|
Magnitude along the y/latitude axis, in :attr: |
kind |
str
|
|
unit |
str
|
Canonical unit -- |
Source code in climdata/grid/units.py
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 | |
as_tuple()
¶
Return (x, y) magnitudes.
Source code in climdata/grid/units.py
68 69 70 | |
climdata.grid.units.ResolutionCRSMismatch
¶
Bases: ValueError
target_resolution units are incompatible with target_projection.
Subclasses :class:ValueError so existing except ValueError handlers --
including the LLM execution layer -- keep working.
Source code in climdata/grid/units.py
43 44 45 46 47 48 | |
CRS handling¶
climdata.grid.crs.parse_crs(value)
¶
Coerce value to a :class:pyproj.CRS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
Anything :func: |
required |
Returns:
| Type | Description |
|---|---|
|
pyproj.CRS | None: The parsed CRS. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in climdata/grid/crs.py
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 | |
climdata.grid.crs.crs_axis_unit(crs)
¶
Return the axis unit kind and conversion factor of crs.
The kind is derived from :attr:pyproj.CRS.is_geographic -- never from the
position of an axis. EPSG:4326 lists latitude first, so positional indexing
silently mis-assigns anisotropic resolutions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
crs
|
Anything :func: |
required |
Returns:
| Type | Description |
|---|---|
str
|
tuple[str, float]: |
float
|
or |
Tuple[str, float]
|
factor is |
Tuple[str, float]
|
(US survey foot) it is |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the two horizontal axes carry different units, or if the CRS is neither geographic nor projected. |
Source code in climdata/grid/crs.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 | |
climdata.grid.crs.infer_spatial_dims(obj, x_dim=None, y_dim=None, dsinfo_dims=None)
¶
Infer the horizontal dimension names of obj.
Resolution order: explicit arguments, then whatever rioxarray already knows,
then a table of conventional names, then dsinfo_dims.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
An :class: |
required | |
x_dim
|
Optional[str]
|
Explicit x/longitude dimension name. |
None
|
y_dim
|
Optional[str]
|
Explicit y/latitude dimension name. |
None
|
dsinfo_dims
|
Optional[Sequence[str]]
|
Optional |
None
|
Returns:
| Type | Description |
|---|---|
Tuple[str, str]
|
tuple[str, str]: |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dimensions cannot be determined. |
Source code in climdata/grid/crs.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 | |
climdata.grid.crs.infer_src_crs(obj, default='EPSG:4326')
¶
Infer the CRS of obj, following the conventions found in real files.
Order: an existing rio.crs; dataset-level attributes; a CF grid_mapping
variable, when it survived subsetting; CRS attributes carried on the data variables
themselves (real HYRAS keeps its WKT in esri_pe_string there, and the crs
variable its grid_mapping points at is dropped); a spatial_ref coordinate;
then a geographic heuristic on the coordinate ranges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
An :class: |
required | |
default
|
Any
|
CRS assumed when the coordinates look geographic. Pass |
'EPSG:4326'
|
Returns:
| Type | Description |
|---|---|
|
pyproj.CRS: The inferred CRS. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If no CRS can be determined. |
Source code in climdata/grid/crs.py
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 | |
climdata.grid.crs.normalize_longitude(obj, x_dim)
¶
Roll a 0-360 longitude axis onto -180-180 and re-sort.
CMIP and NEX-GDDP data arrive on 0-360. rasterio will happily warp such an
axis without raising and produce nonsense, so this runs unconditionally for
geographic sources whose longitudes exceed 180.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
An :class: |
required | |
x_dim
|
str
|
Name of the longitude dimension. |
required |
Returns:
| Type | Description |
|---|---|
|
The object with longitudes in -180..180, sorted ascending. Returned |
|
|
unchanged when no rolling is needed. |
Source code in climdata/grid/crs.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
Bias correction and downscaling¶
The ISIMIP3BASD method, wrapped for xarray. See the BCSD guide.
climdata.sdba.BCSD
¶
Complete Bias Correction and Statistical Downscaling (BCSD) workflow.
Combines BiasCorrection and StatisticalDownscaling in a single pipeline following the ISIMIP3BASD methodology.
Passing a list of variables runs the bias-correction stage multivariately (MBCn over the joint distribution, so inter-variable dependence — e.g. the temperature/precipitation correlation — is carried into the corrected fields), then downscales each corrected variable univariately, one at a time. This asymmetry is deliberate: the vendored ISIMIP3BASD downscaling routine is single-variable by construction.
Neither stage guarantees tasmin <= tas <= tasmax (MBCn ends with a
univariate quantile mapping per variable, and downscaling is univariate).
To keep that ordering, correct dtr in place of tasmax and reconcile
the result with :func:climdata.sdba.temperature.enforce_temperature_order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str or list of str
|
Climate variable name(s). A list enables multivariate (MBCn) bias correction across all of them at once. |
required |
bias_correction_kwargs
|
dict
|
Forwarded to BiasCorrection. |
None
|
downscaling_kwargs
|
dict
|
Forwarded to every per-variable
StatisticalDownscaling. Variable-specific bounds and thresholds are
not needed here — they come from
:attr: |
None
|
regridding_method
|
str
|
xESMF method for obs_fine→coarse regridding (default 'conservative'). |
'conservative'
|
regridding_tool
|
str
|
'xesmf' (default) or 'cdo'. |
'xesmf'
|
cdo_method
|
str
|
CDO operator when regridding_tool='cdo'. |
'remapcon'
|
cdo_env
|
str
|
Conda environment with CDO. |
'cdo_stable'
|
weights_dir
|
str
|
Directory to cache regridding weights. |
None
|
Attributes:
| Name | Type | Description |
|---|---|---|
variables |
list of str
|
Every variable this pipeline handles. |
variable |
str or None
|
The single variable, or None for a multivariate pipeline. |
downscalers |
dict
|
Variable name → its StatisticalDownscaling instance. |
downscaling |
StatisticalDownscaling or None
|
The single downscaler, or
None for a multivariate pipeline (use :attr: |
Example
bcsd = BCSD(variable='tas', ... bias_correction_kwargs={'detrend': True}, ... downscaling_kwargs={'n_iterations': 20}) paths = bcsd.run(obs_fine=obs_025deg, ... sim_hist_coarse=gcm_hist_1deg, ... sim_fut_coarse=gcm_fut_1deg)
Multivariate bias correction, univariate downscaling:
bcsd = BCSD(variable=['pr', 'tas', 'tasmax', 'tasmin'], ... bias_correction_kwargs={'n_iterations': 20}) paths = bcsd.run(obs_fine=obs_025deg, ... sim_hist_coarse=gcm_hist_1deg, ... sim_fut_coarse=gcm_fut_1deg) # doctest: +SKIP sorted(paths) # doctest: +SKIP ['pr', 'tas', 'tasmax', 'tasmin']
Source code in climdata/sdba/bcsd.py
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 1067 1068 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 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 | |
__init__(variable, bias_correction_kwargs=None, downscaling_kwargs=None, regridding_method='conservative', regridding_tool='xesmf', cdo_method='remapcon', cdo_env='cdo_stable', weights_dir=None)
¶
Configure the two stages of a BCSD run.
Every argument is documented on the class. The stage objects are built
here, so an invalid bias_correction_kwargs or downscaling_kwargs
is rejected now rather than partway through :meth:run.
Raises:
| Type | Description |
|---|---|
ValueError
|
If no variable, or a duplicated variable, is given. |
ImportError
|
If |
Source code in climdata/sdba/bcsd.py
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 | |
run(obs_fine, sim_hist_coarse, sim_fut_coarse, obs_hist_coarse=None, output_path=None, save_intermediate=False, model=None, scenario=None)
¶
Run the complete BCSD workflow.
Three steps, of which the first is conditional:
- If
obs_hist_coarseis not supplied, regridobs_fineonto the simulation's coarse grid by conservative remapping. - Bias-correct the coarse simulation against the coarse observations using ISIMIP3BASD — jointly over every variable (MBCn) when the pipeline was built with a list.
- Downscale each corrected coarse field onto the fine grid, again with ISIMIP3BASD, writing one NetCDF per variable per year.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs_fine
|
Dataset
|
Historical observations at fine resolution. |
required |
sim_hist_coarse
|
Dataset
|
Historical GCM simulations at coarse resolution. |
required |
sim_fut_coarse
|
Dataset
|
Future GCM simulations at coarse resolution. |
required |
obs_hist_coarse
|
Dataset
|
Historical observations already at coarse resolution. When None, derived automatically via conservative regridding. |
None
|
output_path
|
str or Path
|
Directory for per-year downscaled NetCDF files. Per-year filenames carry the variable name, so all variables of a multivariate run can share one directory. |
None
|
save_intermediate
|
bool
|
Save intermediate bias-corrected output alongside final results. |
False
|
model
|
str
|
Model tag used in output filenames. |
None
|
scenario
|
str
|
Scenario tag used in output filenames. |
None
|
Returns:
| Type | Description |
|---|---|
Union[list, Dict[str, list]]
|
list[Path] for a single-variable pipeline: the downscaled NetCDF |
Union[list, Dict[str, list]]
|
written for each year. dict[str, list[Path]] for a multivariate one: |
Union[list, Dict[str, list]]
|
that same per-year list, keyed by variable. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If any input is missing one of the pipeline's variables. |
Source code in climdata/sdba/bcsd.py
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 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 | |
climdata.sdba.BiasCorrection
¶
Bias correction using ISIMIP3BASD trend-preserving quantile mapping.
Applies bias correction at the coarse GCM resolution before any spatial downscaling. Supports single-variable and multivariate (MBCn) correction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str or list of str
|
Climate variable name(s). When a list is given MBCn is used. |
required |
method
|
str
|
'parametric' (default). |
'parametric'
|
distribution
|
str
|
Parametric distribution override. Defaults come from DEFAULT_CONFIGS. |
None
|
trend_preservation
|
str
|
Override for trend preservation ('additive', 'multiplicative', 'mixed', 'bounded'). |
None
|
detrend
|
bool
|
Detrend before correction. |
False
|
adjust_p_values
|
bool
|
Adjust p-values for perfect match in the reference period. |
False
|
lower_bound, lower_threshold, upper_bound, upper_threshold
|
float
|
Physical bounds / thresholds. |
required |
halfwin_upper_bound_climatology
|
int
|
Half-window for upper bound climatology (0 = disabled). |
0
|
n_processes
|
int
|
Parallel worker count. Defaults to all CPUs. |
None
|
n_quantiles
|
int
|
Quantiles for non-parametric QM (default 50). |
50
|
n_iterations
|
int
|
MBCn iterations (default 20; 0 = univariate, no MBCn). |
20
|
randomization_seed
|
int
|
RNG seed for reproducibility. |
None
|
Example
bc = BiasCorrection(variable='tas', distribution='normal', ... trend_preservation='additive', detrend=True) tas_corrected = bc.correct(obs_hist=obs_ds, sim_hist=gcm_hist_ds, ... sim_fut=gcm_fut_ds)
Source code in climdata/sdba/bcsd.py
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 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 | |
__init__(variable, method='parametric', distribution=None, trend_preservation=None, detrend=False, adjust_p_values=False, lower_bound=None, lower_threshold=None, upper_bound=None, upper_threshold=None, halfwin_upper_bound_climatology=0, n_processes=None, n_quantiles=50, n_iterations=20, randomization_seed=None, **kwargs)
¶
Configure a bias-correction run.
Every argument is documented on the class. Where an argument is left as
None, the per-variable entry in :attr:DEFAULT_CONFIGS supplies the
value, so a bare BiasCorrection("pr") already uses the distribution,
bounds and trend-preservation mode appropriate to precipitation.
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in climdata/sdba/bcsd.py
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 | |
correct(obs_hist, sim_hist, sim_fut, output_path=None, **kwargs)
¶
Apply bias correction to climate model data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs_hist
|
Dataset
|
Historical observations (e.g. 1980–2014). |
required |
sim_hist
|
Dataset
|
Historical model simulations matching the obs_hist period. |
required |
sim_fut
|
Dataset
|
Future model simulations to be corrected. |
required |
output_path
|
str or Path
|
Save the merged result to this NetCDF path. |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: Bias-corrected future simulations. |
Source code in climdata/sdba/bcsd.py
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 | |
correct_one_location(i_loc, space_shape, npy_paths, rotation_matrices=None, step_size=0)
¶
Bias-correct one grid cell via ba.adjust_bias_one_location.
Requires _prepare_ba_state to have been called first (sets vendor globals).
Source code in climdata/sdba/bcsd.py
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 | |
climdata.sdba.StatisticalDownscaling
¶
Statistical downscaling using the ISIMIP3BASD modified MBCn algorithm.
Downscales bias-corrected coarse-resolution data to the fine resolution
of the reference observations, fitting multi-decade windows (window_years)
and writing one file per year. Already-completed years are skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable
|
str
|
Climate variable name. |
required |
n_processes
|
int
|
Parallel worker count. |
None
|
n_iterations
|
int
|
MBCn iterations (default 20). |
20
|
randomization_seed
|
int
|
RNG seed. |
None
|
lower_bound, lower_threshold, upper_bound, upper_threshold
|
float
|
Physical bounds / thresholds (defaults from BiasCorrection.DEFAULT_CONFIGS). |
required |
load_obs_in_memory
|
bool
|
Read |
True
|
window_years
|
int
|
Length of the fitting window (default 30). The years are split into equal chunks of about this length and each chunk is downscaled in one call; output is still one file per year. Short windows (e.g. 1 year) bias pr high and inflate variance. |
30
|
Example
sd = StatisticalDownscaling(variable='tas', n_iterations=20) paths = sd.downscale(obs_fine=obs_fine_ds, sim_coarse=gcm_corrected_ds, ... output_path='./downscaled/', model='ACCESS', scenario='ssp585')
Source code in climdata/sdba/bcsd.py
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 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 970 971 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 | |
__init__(variable, n_processes=None, n_iterations=20, randomization_seed=None, lower_bound=None, lower_threshold=None, upper_bound=None, upper_threshold=None, load_obs_in_memory=True, window_years=30, **kwargs)
¶
Configure a downscaling run.
Every argument is documented on the class. Arguments left as None
fall back to the variable's entry in :attr:DEFAULT_CONFIGS.
Raises:
| Type | Description |
|---|---|
ImportError
|
If |
Source code in climdata/sdba/bcsd.py
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 | |
downscale(obs_fine, sim_coarse, output_path=None, model=None, scenario=None, **kwargs)
¶
Apply statistical downscaling to coarse-resolution data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obs_fine
|
Dataset or DataArray
|
Fine-resolution observations. |
required |
sim_coarse
|
Dataset or DataArray
|
Coarse-resolution bias-corrected simulations. |
required |
output_path
|
str or Path
|
Directory for per-year output NetCDF files. |
None
|
model
|
str
|
Model tag used in output filenames. |
None
|
scenario
|
str
|
Scenario tag used in output filenames. |
None
|
Returns:
| Type | Description |
|---|---|
list
|
list of Path: Per-year NetCDF paths (BCSD_{var}{model}.nc).}_{year |
Source code in climdata/sdba/bcsd.py
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 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 970 971 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 | |
climdata.sdba.regrid_to_coarse(fine_data, coarse_template, method='conservative', regridding_tool='xesmf', cdo_method='remapcon', cdo_env='cdo_stable', weights_dir=None)
¶
Regrid fine-resolution data to coarse resolution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fine_data
|
Dataset
|
Fine-resolution dataset to regrid. |
required |
coarse_template
|
Dataset
|
Coarse-resolution dataset used as the target grid. |
required |
method
|
str
|
xESMF method: 'conservative' (default), 'bilinear', or 'nearest'. |
'conservative'
|
regridding_tool
|
str
|
'xesmf' (default) or 'cdo'. |
'xesmf'
|
cdo_method
|
str
|
CDO operator string when regridding_tool='cdo'. |
'remapcon'
|
cdo_env
|
str
|
Conda environment that has CDO installed. |
'cdo_stable'
|
weights_dir
|
str
|
Directory to cache regridding weight files. |
None
|
Returns:
| Type | Description |
|---|---|
Dataset
|
xr.Dataset: Regridded dataset on the coarse grid. |
Source code in climdata/sdba/bcsd.py
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 | |
climdata.sdba.utils.compute_daily_climatology(data, n_harmonics=3)
¶
Build a smoothed day-of-year climatology.
Groups data by day of year, averages over all years, then applies
:func:smooth_fft along the dayofyear axis. The computation is lazy and
Dask-friendly: chunked inputs stay chunked.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
DataArray
|
Input with a |
required |
n_harmonics
|
int
|
Harmonics retained by :func: |
3
|
Returns:
| Type | Description |
|---|---|
DataArray
|
xr.DataArray: The climatology, with |
Example
clim = compute_daily_climatology(ds.tasmax) # doctest: +SKIP clim.dims # doctest: +SKIP ('dayofyear', 'lat', 'lon')
Source code in climdata/sdba/utils.py
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 | |
climdata.sdba.utils.smooth_fft(x, n_harmonics=3)
¶
Smooth a periodic series by truncating its Fourier spectrum.
All harmonics above n_harmonics are zeroed and the series transformed
back, leaving the annual cycle and its first overtones. The input is treated
as exactly one period, so it is meant for a full day-of-year axis (365 or 366
values), not for an arbitrary time slice.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
ndarray
|
One-dimensional periodic series, e.g. a day-of-year climatology. |
required |
n_harmonics
|
int
|
Number of harmonics to retain. |
3
|
Returns:
| Type | Description |
|---|---|
|
numpy.ndarray: Smoothed series, the same shape and dtype-kind as |
Example
import numpy as np doy = np.arange(365) raw = 10 * np.sin(2 * np.pi * doy / 365) + np.random.default_rng(0).normal(size=365) smooth = smooth_fft(raw, n_harmonics=2) smooth.std() < raw.std() np.True_
Source code in climdata/sdba/utils.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
Imputation¶
climdata.impute.impute_xarray.Imputer
¶
Fill missing values in a (time, lat, lon) dataset, cell by cell.
Reshapes the dataset into one time series per variable and grid cell, runs an imputegap algorithm over the resulting matrix, and reassembles the output. Optional z-score normalisation is applied before imputation and inverted afterwards, which matters for the neural methods and is harmless otherwise.
Attributes:
| Name | Type | Description |
|---|---|---|
ds |
Dataset
|
The input dataset. |
method |
str
|
Algorithm name — |
normalize |
bool
|
Whether series are z-scored before imputation. |
variables |
list[str]
|
Data variables that will be imputed. |
recovered_ds |
Dataset | None
|
Result of the last :meth: |
Example
imputer = Imputer(ds, method="CDRec") # doctest: +SKIP imputer.missing_fraction()["global"] # doctest: +SKIP 0.043 filled = imputer.impute() # doctest: +SKIP
Source code in climdata/impute/impute_xarray.py
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 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 | |
__init__(ds, time_dim='time', lat_dim='lat', lon_dim='lon', method='BRITS', normalize=True)
¶
Bind a dataset and check that the chosen method can actually run.
The PyTorch check happens here rather than at :meth:impute, so a
missing backend is reported before any reshaping work is done.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Dataset
|
Dataset with time, latitude and longitude dimensions. |
required |
time_dim
|
str
|
Name of the time dimension. Defaults to |
'time'
|
lat_dim
|
str
|
Name of the latitude dimension. Defaults to |
'lat'
|
lon_dim
|
str
|
Name of the longitude dimension. Defaults to |
'lon'
|
method
|
str
|
Algorithm to use. Defaults to |
'BRITS'
|
normalize
|
bool
|
Z-score each series before imputing, and invert
afterwards. Defaults to |
True
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If the vendored imputegap is unavailable, or if
|
Source code in climdata/impute/impute_xarray.py
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 | |
impute(epochs=300)
¶
Fill the missing values and return the completed dataset.
Returns a copy unchanged when there is nothing missing, so calling this unconditionally in a workflow is safe and cheap.
Note that every value is reconstructed, not just the gaps: the returned
dataset carries the algorithm's estimate everywhere. Use :meth:metrics
to see how closely it reproduces the values that were present.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
epochs
|
int
|
Training epochs, used only by |
300
|
Returns:
| Type | Description |
|---|---|
|
xr.Dataset: The completed dataset, also stored on |
|
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If :attr: |
Source code in climdata/impute/impute_xarray.py
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 | |
metrics()
¶
Score the reconstruction against the values that were actually present.
Compares imputed against original on the cells that were not missing — the only cells where ground truth exists. This measures how faithfully the algorithm reproduces known data, which is an upper bound on, not a measure of, its accuracy in the gaps. For a real estimate, mask out known values yourself and score the reconstruction there.
Variables with no missing values are omitted entirely.
Returns:
| Type | Description |
|---|---|
|
dict[str, dict]: Per variable, |
|
|
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If :meth: |
Source code in climdata/impute/impute_xarray.py
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 | |
missing_fraction()
¶
Report how much data is missing, per variable and overall.
Returns:
| Type | Description |
|---|---|
|
dict[str, float]: One entry per data variable plus a |
|
|
key. The global figure is the unweighted mean of the per-variable |
|
|
fractions, so variables of different sizes count equally. |
Source code in climdata/impute/impute_xarray.py
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |
summary()
¶
Describe the imputation setup and the gaps it faces.
Returns:
| Name | Type | Description |
|---|---|---|
dict |
|
|
|
and |
||
|
be run. |
Source code in climdata/impute/impute_xarray.py
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | |
Visualisation¶
climdata.viz.plot_map(data, *, variable=None, time=0, reduce=None, ax=None, projection=None, figsize=(10, 5), coastlines=True, borders=True, gridlines=True, land=False, ocean=False, add_colorbar=True, robust=True, cmap=None, title=None, **plot_kwargs)
¶
Plot a 2D geographic field with coastlines and country boundaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
An |
required | |
variable
|
str
|
Variable name when |
None
|
time
|
int | str | datetime
|
Time slice to plot when a |
0
|
reduce
|
str
|
Reduce the time dimension instead of slicing it —
one of |
None
|
ax
|
Existing Cartopy |
None
|
|
projection
|
A |
None
|
|
figsize
|
tuple
|
Figure size when creating a new figure. |
(10, 5)
|
coastlines, borders, gridlines, land, ocean
|
bool
|
Map features to add. |
required |
add_colorbar
|
bool
|
Whether to draw a colorbar. |
True
|
robust
|
bool
|
Use 2nd/98th percentiles for color limits (passed to xarray). |
True
|
cmap
|
str
|
Matplotlib colormap name. |
None
|
title
|
str
|
Axis title. Defaults to the variable name + time. |
None
|
**plot_kwargs
|
Forwarded to |
{}
|
Returns:
| Type | Description |
|---|---|
|
The Cartopy |
Source code in climdata/viz.py
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 | |