UgridDataset#
Top-level container for UGRID NetCDF mesh data. Provides the user-facing API for reading, writing, inspecting, and operating on unstructured mesh data.
UgridDataset is a thin, GIS-aware facade: its public methods delegate the heavy lifting to the
sibling modules of the subpackage (spatial ops, interpolation, I/O, plotting):
flowchart LR
U["UgridDataset"]
U -->|"clip · subset_by_bounds"| SP["spatial.clip_mesh<br/>spatial.subset_by_bounds"]
U -->|"to_dataset"| IN["interpolation.mesh_to_grid"]
U -->|"read_file · to_file"| IO["io.parse_ugrid_topology<br/>io.write_ugrid_topology"]
U -->|"plot · plot_outline"| PL["plot.plot_mesh_data<br/>plot.plot_mesh_outline"]
U -->|"metadata"| MD["UgridMetadata"]
See the subpackage overview for how UgridDataset composes Mesh2d, Connectivity, and
MeshVariable.
pyramids.netcdf.ugrid.UgridDataset
#
Bases: _UgridFacades
Container for UGRID NetCDF mesh data.
Combines mesh topology, data variables, and global attributes into a single object with GIS-aware operations. Does NOT inherit from Dataset or RasterBase — the raster paradigm does not apply to unstructured meshes.
Attributes:
| Name | Type | Description |
|---|---|---|
_mesh |
Mesh2d topology instance. |
|
_data_variables |
Mapping of variable name to MeshVariable. |
|
_global_attributes |
File-level NetCDF attributes. |
|
_topology_info |
Parsed UGRID topology metadata. |
|
_crs_wkt |
CRS in WKT format. |
|
_file_name |
Source file path, if read from disk. |
Source code in src/pyramids/netcdf/ugrid/dataset.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 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 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 | |
mesh
property
#
The mesh topology.
mesh_name
property
#
Name of the mesh topology variable.
data_variable_names
property
#
Names of all data variables.
crs
property
#
CRS as a pyproj.CRS object, or None. Cached after first access.
epsg
property
#
EPSG code of the CRS, or None.
crs_wkt
property
#
The mesh CRS as WKT, or None when there is none that parses.
Gated on a successful parse rather than returning _crs_wkt verbatim.
_crs_wkt is copied straight out of the file and :attr:crs tolerates
an unparseable one on purpose, swallowing the error and reporting no
CRS. Handing the raw string to a caller would move that parse out from
under the handler, so a malformed WKT would start raising downstream
instead of being reported as "no CRS" here.
bounds
property
#
Mesh bounding box as (xmin, ymin, xmax, ymax).
global_attributes
property
#
File-level NetCDF attributes.
n_node
property
#
Number of mesh nodes.
n_face
property
#
Number of mesh faces.
n_edge
property
#
Number of mesh edges.
data_vars
property
#
A copy of the {name: variable} mapping.
A fresh dict, so mutating it never changes the dataset — variable edits go through
:meth:with_variable / :meth:drop_variables / :meth:rename_variable, which each
return a new dataset.
metadata
property
#
Full metadata summary for this dataset.
time_values
property
#
Parsed time coordinate values from the first temporal variable.
Returns None if no variables have a time dimension.
volume_topology
property
#
The ragged (per-column) vertical layering, or None for a uniform / 2-D mesh.
Present only for a genuinely 3-D mesh whose columns carry different layer counts
(issue #1330): it maps each face to its slice of the flat volume axis that a
location="volume" variable is indexed through. None means the dense
(layer, element) path applies — the uniform-layer behaviour is unchanged.
n_volume
property
#
The total number of volumes, or None when the mesh has no volume topology.
The flat volume-axis length of a ragged 3-D mesh (the sum of every column's layer
count). None for a 2-D or uniform-layer mesh, where :attr:n_layers applies
instead.
n_layers
property
#
The number of layers, or None when no variable is layered.
A 3-D mesh output puts some variables on the n layer centres and others on the
n + 1 layer interfaces, so two counts differing by one is normal rather than a
contradiction; this reports n, the layer count proper. Any other disagreement is
a real inconsistency and raises. :meth:isel_layer is unaffected either way — it
indexes each variable on its own layer axis.
Reporting n means the n + 1 is not visible here, so a caller iterating
range(n_layers) over an interface variable would skip its last interface. Read
:attr:n_layer_interfaces for that count rather than inferring it: it answers None
unless a variable really sits on the interfaces.
For a ragged 3-D mesh (:attr:volume_topology set) there is no single layer count:
this reports the maximum over the columns — the number of layer slots — so
range(n_layers) covers the deepest column, and :meth:isel_layer makes the absent
shallow-column layers explicit (NaN) rather than padding them silently.
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The layer-centre count (the max, for a ragged mesh), or |
int | None
|
no variable is layered. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The layered variables carry counts that are not a layer-centre / layer-interface pair. |
n_layer_interfaces
property
#
The number of layer interfaces, or None when nothing sits on them.
The companion to :attr:n_layers. A 3-D output's vertical velocities and fluxes live on
the n + 1 interfaces between the n layer centres, and n_layers deliberately
reports the centre count -- so this is where the other half of the pair is readable.
It is not simply n_layers + 1, which is always computable: that would assert
that something in the dataset is interface-located. Only a variable actually carrying
that count makes it true, so a centres-only dataset answers None.
Returns:
| Type | Description |
|---|---|
int | None
|
int | None: The layer-interface count, or |
int | None
|
every layered variable sits on the centres. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The layered variables carry counts that are not a layer-centre /
layer-interface pair -- the same guard :attr: |
layer_values
property
#
The layer coordinate values, when a layered variable carries them.
Read from a layered variable's layer_values attribute. The UGRID reader does not
populate that attribute -- as with :attr:time_values, the coordinate is supplied by
whoever builds or transforms the dataset -- so this is normally None for a mesh
read straight from a file, and :meth:sel_layer then selects by layer position.
connected_components()
#
Label the mesh's connected face components.
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: One component label per face. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
exterior_edges()
#
The indices of the edges on the mesh boundary.
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: Boundary edge indices. |
exterior_faces()
#
The indices of the faces touching the mesh boundary.
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: Boundary face indices. |
bounding_polygon()
#
The mesh footprint as one dissolved polygon, holes preserved.
Returns:
| Type | Description |
|---|---|
Any
|
shapely.geometry.base.BaseGeometry: The (multi)polygon of the mesh outline. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
circumcenters()
#
The circumcentre of every face (triangular meshes only).
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: |
Raises:
| Type | Description |
|---|---|
ValueError
|
The mesh is not triangular. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
voronoi()
#
The Voronoi tesselation of the mesh nodes (the mesh dual).
Returns:
| Type | Description |
|---|---|
Any
|
scipy.spatial.Voronoi: The tesselation. |
sparse_adjacency(kind='face')
#
The mesh adjacency as a sparse matrix.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kind
|
str
|
|
'face'
|
Returns:
| Type | Description |
|---|---|
Any
|
scipy.sparse.csr_matrix: The symmetric adjacency. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
binary_dilation(variable_name=None, *, iterations=1, border_value=False, fixed=None)
#
Grow a boolean face mask over its neighbours.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str | None
|
The boolean face variable to dilate, or |
None
|
iterations
|
int
|
How many times to grow. Defaults to 1. |
1
|
border_value
|
bool
|
What lies outside the mesh. Defaults to False. |
False
|
fixed
|
ndarray | None
|
A boolean per-face mask of the cells the result must preserve, whatever the
dilation would do to them — scipy's |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
Any
|
A new dataset with the dilated mask. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
binary_erosion(variable_name=None, *, iterations=1, border_value=False, fixed=None)
#
Shrink a boolean face mask away from its boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str | None
|
The boolean face variable to erode, or |
None
|
iterations
|
int
|
How many times to shrink. Defaults to 1. |
1
|
border_value
|
bool
|
What lies outside the mesh. Defaults to False, which erodes the boundary; pass True to erode only the interior. |
False
|
fixed
|
ndarray | None
|
A boolean per-face mask of the cells the result must preserve, whatever the
erosion would do to them — scipy's |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
Any
|
A new dataset with the eroded mask. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
to_location(location, variable_name=None)
#
Remap a variable onto another facet of the mesh.
Averages the values of the contributing elements, so a face field asked for on the nodes becomes each node's mean of the faces around it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
str
|
The facet to remap onto — |
required |
variable_name
|
str | None
|
The variable to remap, or |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
Any
|
A new dataset whose variable sits on |
Raises:
| Type | Description |
|---|---|
ValueError
|
An unknown |
Source code in src/pyramids/netcdf/ugrid/_facades.py
fill_na_spatial(variable_name=None, *, max_distance=None)
#
Fill each gap from the nearest valid element in space.
Where :meth:interpolate_na fills along time, this fills across the mesh: a gap takes
the value of the closest element that has one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str | None
|
The variable to fill, or |
None
|
max_distance
|
float | None
|
Leave a gap unfilled when no valid element is this close. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
Any
|
A new dataset with the gaps filled. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
laplace_interpolate(variable_name=None, *, use_weights=True, direct_solve=False)
#
Fill the interior gaps by solving Laplace's equation over the mesh.
The valid values are the boundary condition and each gap becomes the smooth solution between them — a better hole-filler than nearest when the field varies smoothly.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str | None
|
The variable to fill, or |
None
|
use_weights
|
bool
|
Weight the graph Laplacian by inverse distance. Defaults to True. |
True
|
direct_solve
|
bool
|
Solve directly rather than iteratively. Defaults to False. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
Any
|
A new dataset with the interior gaps filled. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
polygonize(variable_name=None, *, decimals=None)
#
Dissolve adjacent faces of equal value into polygons.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str | None
|
The face variable to dissolve by, or |
None
|
decimals
|
int | None
|
Round to this many decimals before grouping, for approximate equality. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
geopandas.GeoDataFrame: One row per merged region, with its value and geometry. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
sample_line(line, variable_name=None)
#
Sample a variable along a line, ordered by distance along it.
One sample per crossing, at the midpoint of each part of the line-face intersection.
A line that leaves a face and re-enters it is sampled once per entry, so
face_indices can repeat -- see :func:pyramids.netcdf.ugrid.vector_ops.sample_line.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
line
|
Any
|
A shapely |
required |
variable_name
|
str | None
|
The variable to sample, or |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
Any
|
|
Any
|
along-line order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/pyramids/netcdf/ugrid/_facades.py
burn(geometry, value, *, name='burned', fill=float('nan'), all_touched=True)
#
Burn vector geometry onto the faces as a new variable.
The mesh analogue of rasterising a vector layer: every face the geometry covers takes
value, the rest take fill.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
geometry
|
Any
|
A shapely geometry, GeoDataFrame, FeatureCollection, or iterable of them. |
required |
value
|
float
|
The value burned into the covered faces. |
required |
name
|
str
|
The new variable's name. Defaults to |
'burned'
|
fill
|
float
|
The value for the faces the geometry misses. Defaults to NaN. |
float('nan')
|
all_touched
|
bool
|
Burn every face the geometry touches, rather than only those whose centroid falls inside. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
Any
|
A new dataset carrying the burned variable. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
rasterize_like(reference, variable_name=None, *, method='nearest', nodata=-9999.0, max_distance=None)
#
Interpolate a variable onto an existing raster's grid.
Where :meth:to_dataset builds its own grid from a cell size, this snaps to the
geotransform, shape and CRS of a raster you already have, so the result is
co-registered with it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
Any
|
The raster whose grid to match (a pyramids |
required |
variable_name
|
str | None
|
The variable to interpolate, or |
None
|
method
|
str
|
|
'nearest'
|
nodata
|
float
|
The value for cells the mesh does not cover. |
-9999.0
|
max_distance
|
float | None
|
How far a |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Dataset |
Any
|
A raster on |
Raises:
| Type | Description |
|---|---|
ValueError
|
An unknown |
Source code in src/pyramids/netcdf/ugrid/_facades.py
interp_time(new_times, *, method='linear', bounds='nan')
#
Interpolate every temporal variable onto new time coordinates.
Distinct from :meth:interpolate_na, which fills gaps on the existing axis: this
relabels the axis, resampling the series onto the times you ask for.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_times
|
Any
|
The time coordinates to interpolate onto. |
required |
method
|
str
|
|
'linear'
|
bounds
|
str
|
What a label outside the existing axis answers -- |
'nan'
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
Any
|
A new dataset on the requested time coordinates. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension; |
Source code in src/pyramids/netcdf/ugrid/_facades.py
regrid(target, *, method='overlap', variable_name=None)
#
Regrid a variable onto another mesh.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
Any
|
The destination |
required |
method
|
str
|
|
'overlap'
|
variable_name
|
str | None
|
The variable to regrid, or |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
Any
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
An unknown |
Source code in src/pyramids/netcdf/ugrid/_facades.py
to_xarray()
#
Hand the mesh and its variables to xarray, in the UGRID-CF encoding.
xarray is a peer dependency, imported only here (as the raster
:meth:pyramids.netcdf.NetCDF.to_xarray does), so nothing here imports it at module
scope. Note the parent pyramids.netcdf package does currently pull xarray and dask
at import time for unrelated reasons, so that cost is not avoided in practice yet.
Returns:
| Type | Description |
|---|---|
Any
|
xarray.Dataset: The mesh's UGRID-CF variables plus the data variables. |
Raises:
| Type | Description |
|---|---|
OptionalPackageDoesNotExist
|
xarray is not installed. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
to_zarr(store, **kwargs)
#
Write the mesh and its variables to a zarr store, through xarray.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
Any
|
The zarr store (a path or a mapping). |
required |
**kwargs
|
Any
|
Passed to |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
The value |
Raises:
| Type | Description |
|---|---|
OptionalPackageDoesNotExist
|
xarray or zarr is not installed. |
Source code in src/pyramids/netcdf/ugrid/_facades.py
__init__(mesh, data_variables, global_attributes, topology_info=None, crs_wkt=None, file_name=None, volume_topology=None)
#
Assemble a dataset from an already-built mesh and its variables.
The low-level constructor. Prefer :meth:read_file for a file, :meth:from_arrays
for raw arrays, or one of the from_* bridges -- each of those builds the mesh and
the metadata record and then calls this. It is also what every derivation
(:meth:isel, :meth:reduce, :meth:copy, ...) calls through type(self)(...),
which is how a subclass survives them.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mesh
|
Mesh2d
|
The topology the variables sit on. |
required |
data_variables
|
dict[str, MeshVariable]
|
Mapping of variable name to :class: |
required |
global_attributes
|
dict[str, Any]
|
The file-level attributes, e.g. |
required |
topology_info
|
MeshTopologyInfo | None
|
The record of the on-disk variable names and the declared
topology dimension. |
None
|
crs_wkt
|
str | None
|
WKT of the mesh CRS. |
None
|
file_name
|
str | None
|
The path this dataset was read from, carried through derivations so a
:meth: |
None
|
volume_topology
|
VolumeTopology | None
|
The ragged (per-column) vertical layering for a genuinely 3-D
mesh — the map from faces to the flat |
None
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
read_file(path, mesh_name=None, driver=None, lazy=True)
classmethod
#
Open a mesh file.
UGRID NetCDF is read here. Any other format — 2DM, Selafin, DFSU, XMDF, … — is read by a
third-party driver registered into the pyramids.mesh_drivers entry-point group. A
non-NetCDF suffix is dispatched by detection; a NetCDF suffix is read by the built-in
reader first, and only a file that opens but carries no UGRID topology falls back to a
driver claiming that suffix. Either way a successful UGRID read triggers no driver
discovery, so a .nc read still pays nothing.
Resolution order:
drivergiven — that driver, or an error. Never falls back.- A
/vsipath or a NetCDF suffix — the built-in UGRID reader. If a NetCDF-suffixed file opens but declares no UGRID topology, a registered driver claiming that suffix is tried before giving up, so 3Di, TUFLOW FV and other NetCDF-based formats are reachable; discovery runs only after the built-in read has already failed. - Otherwise a registered driver claiming the suffix whose
can_openaccepts the file. - Nothing claimed it — the built-in reader anyway, so a NetCDF file under an unusual suffix still opens exactly as it always did.
- That failed too — :class:
UnsupportedMeshFormatError, naming what is installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the file. A GDAL virtual-filesystem path
( |
required |
mesh_name
|
str | None
|
Which topology to read, for a file declaring more than one (see
:meth: |
None
|
driver
|
str | None
|
Name of a registered mesh driver to use, bypassing detection — the
name a plugin declares, not a GDAL driver short name. |
None
|
lazy
|
bool
|
Defer reading variable values until first access. Forwarded to the driver,
which honours it when it declares |
True
|
Returns:
| Type | Description |
|---|---|
UgridDataset
|
UgridDataset instance. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist. |
DriverNotExistError
|
If |
UnsupportedMeshFormatError
|
If no installed driver reads the file, and the built-in UGRID reader cannot either. |
IsADirectoryError
|
The path is a directory that no driver claims. |
TypeError
|
|
RuntimeError
|
GDAL cannot open a file that reached the built-in reader by its
own suffix. A file whose suffix no driver claimed is reported as
:class: |
ValueError
|
If no UGRID topology is found in the file, or |
Source code in src/pyramids/netcdf/ugrid/dataset.py
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 | |
get_data(variable_name)
#
Get a data variable by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
Name of the data variable. |
required |
Returns:
| Type | Description |
|---|---|
MeshVariable
|
MeshVariable instance. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the variable name is not found. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
__getitem__(key)
#
Get a data variable by name using bracket notation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The variable name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
MeshVariable |
MeshVariable
|
The variable. |
Raises:
| Type | Description |
|---|---|
KeyError
|
No variable is named |
Source code in src/pyramids/netcdf/ugrid/dataset.py
__contains__(key)
#
Whether key names a data variable of this dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The variable name to test. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True when the dataset carries a variable of that name. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
__len__()
#
The number of data variables.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
How many data variables the dataset carries. Note this counts variables, |
int
|
not elements -- :attr: |
|
int
|
sizes. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
__iter__()
#
Iterate over the data variable names.
Returns:
| Type | Description |
|---|---|
Any
|
Iterator[str]: The variable names, in insertion order -- so |
Any
|
and |
Source code in src/pyramids/netcdf/ugrid/dataset.py
keys()
#
The data variable names (read-only mapping surface).
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: The names, in insertion order. A list rather than a view, so it does |
list[str]
|
not track later edits -- every variable edit returns a new dataset anyway. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
values()
#
The data variables (read-only mapping surface).
Returns:
| Type | Description |
|---|---|
list[MeshVariable]
|
list[MeshVariable]: The variables, in the same order as :meth: |
list[MeshVariable]
|
variables themselves are not copied, so reading |
list[MeshVariable]
|
lazy loader. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
items()
#
The (name, variable) pairs (read-only mapping surface).
Returns:
| Type | Description |
|---|---|
list[tuple[str, MeshVariable]]
|
list[tuple[str, MeshVariable]]: One pair per variable, in insertion order. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
get(key, default=None)
#
The variable key, or default when it is absent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The variable name to look up. |
required |
default
|
Any
|
What to answer when no variable is named |
None
|
Returns:
| Type | Description |
|---|---|
MeshVariable | Any
|
MeshVariable | Any: The variable, or |
Source code in src/pyramids/netcdf/ugrid/dataset.py
with_variable(name, data, *, location='face', nodata=None)
#
Return a new dataset with name added or replaced.
UGRID derivations are immutable — unlike NetCDF.set_variable this does not mutate
in place but returns a fresh dataset. A 2-D data array is treated as temporal
(leading axis = time); a 1-D array is a static per-element variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Variable name to add or replace. |
required |
data
|
ndarray
|
The values; |
required |
location
|
str
|
Mesh location — |
'face'
|
nodata
|
float | None
|
Optional no-data value for the new variable. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset carrying the variable. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
drop_variables(names)
#
Return a new dataset without the named variable(s).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
names
|
str | list[str]
|
A variable name, or a list of them, to drop. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset without those variables. |
Raises:
| Type | Description |
|---|---|
KeyError
|
A named variable is not present. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
rename_variable(old, new)
#
Return a new dataset with variable old renamed to new.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old
|
str
|
The current variable name. |
required |
new
|
str
|
The new name. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with the variable renamed. |
Raises:
| Type | Description |
|---|---|
KeyError
|
|
ValueError
|
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
to_dataset(variable_name, cell_size, method='nearest', bounds=None, epsg=None, nodata=-9999.0)
#
Convert a mesh variable to a regular-grid Dataset.
Interpolates mesh data onto a regular grid and returns a standard pyramids Dataset. This is the bridge between unstructured (UGRID) and structured (raster) worlds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
Name of the data variable to rasterize. |
required |
cell_size
|
float
|
Target grid cell size in coordinate units. |
required |
method
|
str
|
Interpolation method ("nearest" or "linear"). |
'nearest'
|
bounds
|
tuple[float, float, float, float] | None
|
Target (xmin, ymin, xmax, ymax). Defaults to mesh bounds. |
None
|
epsg
|
int | None
|
Target EPSG code. Defaults to mesh CRS. |
None
|
nodata
|
float
|
No-data value for the output raster. |
-9999.0
|
Returns:
| Type | Description |
|---|---|
Dataset
|
pyramids Dataset with the interpolated data. |
Raises:
| Type | Description |
|---|---|
KeyError
|
No variable is named |
ValueError
|
The variable exists but holds no data (nothing was loaded and it carries no lazy loader), so there is nothing to interpolate. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
crop(mask=None, touch=True, *, bbox=None, epsg=None)
#
Crop the mesh to a polygon mask or a bbox — the unstructured-mesh analogue of crop.
The mesh equivalent of :meth:pyramids.dataset.Dataset.crop / :meth:NetCDF.crop. Rather
than warping a raster, it selects the faces that fall inside the region (renumbering the
node connectivity for the resulting sub-mesh) and keeps the data on the surviving elements.
Delegates to :meth:clip for a polygon and :meth:subset_by_bounds for a bbox; this method
exists so the spatial-subset call is named crop across the raster and mesh classes alike.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
Polygon mask — a shapely geometry, |
None
|
touch
|
bool
|
Applies only to a polygon |
True
|
bbox
|
tuple or list of 4 floats, keyword-only
|
|
None
|
epsg
|
(int, keyword - only)
|
CRS of |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new sub-mesh — faces inside the region, connectivity renumbered, and data variables subset to the surviving elements. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If both |
TypeError
|
If neither |
Examples:
- Crop a mesh to a polygon (faces intersecting it survive):
- Crop to a bounding box in the mesh's own CRS:
See Also
clip: Polygon-mask subsetting that crop delegates to when mask is given.
subset_by_bounds: Bounding-box subsetting that crop delegates to when bbox is
given.
pyramids.dataset.Dataset.crop: The raster equivalent on a gridded dataset.
Source code in src/pyramids/netcdf/ugrid/dataset.py
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 | |
clip(mask, touch=True)
#
Clip the mesh to a polygon mask.
Selects faces that intersect (touch=True) or are fully contained within (touch=False) the mask polygon.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mask
|
Any
|
Polygon mask (GeoDataFrame, FeatureCollection, or Shapely geometry). |
required |
touch
|
bool
|
If True, include faces touching the boundary. |
True
|
Returns:
| Type | Description |
|---|---|
UgridDataset
|
New UgridDataset with clipped mesh and data. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
subset_by_bounds(xmin, ymin, xmax, ymax)
#
Subset mesh to faces within a bounding box.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xmin
|
float
|
Minimum x-coordinate. |
required |
ymin
|
float
|
Minimum y-coordinate. |
required |
xmax
|
float
|
Maximum x-coordinate. |
required |
ymax
|
float
|
Maximum y-coordinate. |
required |
Returns:
| Type | Description |
|---|---|
UgridDataset
|
New UgridDataset with subset mesh and data. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
to_crs(to_epsg)
#
Reproject all node coordinates to a new CRS.
Uses pyproj.Transformer to reproject node coordinates. Face/edge center coordinates are recomputed after reprojection. Data values are preserved — only coordinates change.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
to_epsg
|
int
|
Target EPSG code. |
required |
Returns:
| Type | Description |
|---|---|
UgridDataset
|
New UgridDataset with reprojected coordinates. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The mesh declares neither an EPSG code nor a WKT, so there is no source CRS to reproject from. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
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 | |
sel_time(index)
#
Select a single time step from all temporal variables.
Non-temporal variables are kept unchanged.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
Time step index. |
required |
Returns:
| Type | Description |
|---|---|
UgridDataset
|
New UgridDataset with single time step data. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
sel_time_range(start, stop)
#
Select a time range from all temporal variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
int
|
Start index (inclusive). |
required |
stop
|
int
|
Stop index (exclusive). |
required |
Returns:
| Type | Description |
|---|---|
UgridDataset
|
New UgridDataset with the selected time range. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
attach_data(path, driver=None, lazy=True)
#
Attach a results-only file's variables to this mesh.
Some formats carry values but no topology — an SMS .dat, an XMDF, an XDMF — and must
be paired with a mesh read from elsewhere. Those drivers declare needs_mesh, and
:meth:read_file refuses them, pointing here.
>>> mesh = UgridDataset.read_file("domain.2dm") # doctest: +SKIP
>>> result = mesh.attach_data("velocity.dat") # doctest: +SKIP
The driver returns only the variables it read; this method merges them onto the dataset. That division is deliberate — it makes a name the dataset already defines an unambiguous collision, and means a driver cannot drop the dataset's own variables by rebuilding the mapping.
The driver checks the file's declared element count against this mesh. That check is the only safeguard there is: a bare results file carries nothing identifying the mesh it belongs to, so attaching it to the wrong one would otherwise produce a plausible and entirely wrong dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
The results file to read. |
required |
driver
|
str | None
|
Name of a registered driver to use, bypassing detection. |
None
|
lazy
|
bool
|
Defer reading variable values until first access. Defaults to True. |
True
|
Returns:
| Type | Description |
|---|---|
UgridDataset
|
A new dataset carrying this mesh plus the attached variables. This dataset is |
UgridDataset
|
unchanged. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the results file does not exist. |
DriverNotExistError
|
If |
UnsupportedMeshFormatError
|
If no installed driver can attach this file, the
named driver does not declare |
ValueError
|
If the driver returns a variable whose name this dataset already uses, or reports an element-count mismatch against this mesh. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
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 | |
to_file(path, driver=None, **options)
#
Write the dataset to a file.
Writes UGRID-compliant NetCDF by default: a topology variable, node coordinates, connectivity arrays, face/edge centres, data variables, and global attributes following the UGRID convention.
With driver, writes through a registered third-party driver instead — 2DM, Selafin,
PLY and others are writable. The output format is never inferred from the suffix, so
to_file("mesh.slf") still writes NetCDF; name the driver to change that.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Output file path. |
required |
driver
|
str | None
|
Name of a registered mesh driver to write with, as declared by the
plugin providing it (see :func: |
None
|
**options
|
Any
|
Format-specific settings for the driver, passed through uninterpreted
(for example Selafin endianness, or PLY ascii versus binary). The built-in
writer takes none, so passing any without a |
{}
|
Raises:
| Type | Description |
|---|---|
DriverNotExistError
|
If |
UnsupportedMeshFormatError
|
If the named driver cannot write a mesh. |
TypeError
|
If |
Source code in src/pyramids/netcdf/ugrid/dataset.py
to_geodataframe(variable_name=None, location='face')
#
Convert mesh to a GeoDataFrame.
For faces: each row is a Polygon with data columns. For nodes: each row is a Point. For edges: each row is a LineString.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str | None
|
Optional data variable to include as a column. |
None
|
location
|
str
|
Mesh location ("face", "node", or "edge"). |
'face'
|
Returns:
| Type | Description |
|---|---|
GeoDataFrame
|
geopandas GeoDataFrame. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
to_feature_collection(variable_name=None, location='face')
#
Convert mesh to a pyramids FeatureCollection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str | None
|
Optional data variable to include. |
None
|
location
|
str
|
Mesh location ("face", "node", or "edge"). |
'face'
|
Returns:
| Type | Description |
|---|---|
FeatureCollection
|
pyramids FeatureCollection. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
from_arrays(node_x, node_y, face_node_connectivity, data=None, data_locations=None, epsg=4326, mesh_name=DEFAULT_MESH_NAME)
classmethod
#
Create a UgridDataset programmatically from arrays.
Plural because an unstructured mesh is not one array: the topology
needs node coordinates and a face-node connectivity table before any
data can be attached. It therefore takes a flat epsg rather than the
:class:~pyramids.base.georeference.GeoReference the gridded
constructors take — a mesh carries its own coordinates, so there is no
affine transform to describe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_x
|
ndarray
|
Node x-coordinates. |
required |
node_y
|
ndarray
|
Node y-coordinates. |
required |
face_node_connectivity
|
ndarray
|
(n_faces, max_nodes) array of node indices. Use -1 as fill value for mixed meshes. |
required |
data
|
dict[str, ndarray] | None
|
Optional dict mapping variable name to data array. |
None
|
data_locations
|
dict[str, str] | None
|
Optional dict mapping variable name to location ("face", "node", "edge"). Defaults to "face". |
None
|
epsg
|
int
|
EPSG code for the CRS. |
4326
|
mesh_name
|
str
|
Name for the topology variable. |
DEFAULT_MESH_NAME
|
Returns:
| Type | Description |
|---|---|
UgridDataset
|
UgridDataset instance. |
Examples:
- Build the smallest possible mesh — two triangles — and inspect
its topology:
>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> mesh = UgridDataset.from_arrays( ... node_x=np.array([0.0, 1.0, 1.0, 0.0]), ... node_y=np.array([0.0, 0.0, 1.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... ) >>> (mesh.n_node, mesh.n_face) (4, 2) >>> mesh.bounds (0.0, 0.0, 1.0, 1.0) - Attach a per-face variable and read it back:
>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> mesh = UgridDataset.from_arrays( ... node_x=np.array([0.0, 1.0, 1.0, 0.0]), ... node_y=np.array([0.0, 0.0, 1.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... data={"depth": np.array([1.5, 2.5])}, ... ) >>> mesh.data_variable_names ['depth'] >>> mesh["depth"].location 'face' >>> mesh["depth"].data.tolist() [1.5, 2.5]
Source code in src/pyramids/netcdf/ugrid/dataset.py
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 | |
from_structured(dataset, band_names=None, mesh_name=DEFAULT_MESH_NAME)
classmethod
#
Build a mesh from a raster, one quad face per cell.
The bridge from the structured world: each cell becomes a quad over the corner lattice (shared corners deduplicated) and each band becomes a per-face variable, so a raster can be fed to the mesh operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
Any
|
The source raster (a pyramids |
required |
band_names
|
list[str] | None
|
Names for the per-face variables, one per band. Defaults to
|
None
|
mesh_name
|
str
|
The topology name to stamp. Defaults to the package default. |
DEFAULT_MESH_NAME
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
The quad mesh carrying the band values. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
from_geodataframe(gdf, mesh_name=DEFAULT_MESH_NAME)
classmethod
#
Build a mesh from polygon geometries, one face per polygon.
Vertices are deduplicated into the node set and each ring is oriented counter-clockwise; the frame's attribute columns become per-face variables.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gdf
|
Any
|
A GeoDataFrame of polygons. Its |
required |
mesh_name
|
str
|
The topology name to stamp. Defaults to the package default. |
DEFAULT_MESH_NAME
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
The mesh built from the polygons. |
Raises:
| Type | Description |
|---|---|
ValueError
|
The frame declares no CRS, so the mesh would carry no georeferencing. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
from_xarray(ds)
classmethod
#
Read a mesh back from an xarray.Dataset in the UGRID-CF encoding.
The inverse of :meth:to_xarray. xarray is a peer dependency, imported only inside
the bridge, so nothing in this module imports it at module scope.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ds
|
Any
|
The |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
The reconstructed mesh and variables. |
Raises:
| Type | Description |
|---|---|
OptionalPackageDoesNotExist
|
xarray is not installed. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
from_zarr(store, **kwargs)
classmethod
#
Read a mesh from a zarr store written by :meth:to_zarr.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
Any
|
The zarr store (a path or a mapping). |
required |
**kwargs
|
Any
|
Passed to |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
The reconstructed mesh and variables. |
Raises:
| Type | Description |
|---|---|
OptionalPackageDoesNotExist
|
xarray or zarr is not installed. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
mesh_names(path, driver=None)
staticmethod
#
The names of every topology a file declares.
A mesh file may carry several topologies; :meth:read_file takes the first unless told
otherwise, so this is how a caller discovers what else is in there.
Dispatch mirrors :meth:read_file exactly, including the short-circuit that keeps a
NetCDF suffix from triggering driver discovery. Every driver is asked, not only those
declaring multi_mesh: a single-mesh format answers with a one-item list, which is
the right answer rather than an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the file. |
required |
driver
|
str | None
|
Name of a registered driver to ask, bypassing detection. |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
list[str]: One name per declared topology, in file order. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The file does not exist. |
DriverNotExistError
|
|
UnsupportedMeshFormatError
|
No installed driver claims the suffix and the built-in reader cannot open it either, or a driver failed or returned something other than a list of topology names. |
IsADirectoryError
|
The path is a directory that no driver claims. |
RuntimeError
|
GDAL cannot open a file that reached the built-in reader by its own suffix. GDAL exceptions are enabled package-wide, so the open failure surfaces as GDAL's own error. |
ValueError
|
The file declares no UGRID topology. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
read_all(path, driver=None, lazy=True)
classmethod
#
Read every topology in a file, one dataset each.
:meth:read_file answers a single mesh (the first, or the one named). This answers
all of them, so nothing in a multi-mesh file is silently dropped. Dispatch follows
:meth:mesh_names and :meth:read_file, so a third-party format works here too.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Path to the file. |
required |
driver
|
str | None
|
Name of a registered mesh driver to use, bypassing detection.
|
None
|
lazy
|
bool
|
Defer reading variable values until first access. Forwarded to a driver,
which may honour an eager read; the built-in UGRID reader has no eager mode, so
|
True
|
Returns:
| Type | Description |
|---|---|
dict[str, UgridDataset]
|
dict[str, UgridDataset]: Each topology name mapped to its dataset. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
The file does not exist. |
DriverNotExistError
|
|
UnsupportedMeshFormatError
|
No installed driver reads the file and the built-in
reader cannot either — raised from :meth: |
IsADirectoryError
|
The path is a directory that no driver claims. |
RuntimeError
|
GDAL cannot open a file that reached the built-in reader by its own suffix. GDAL exceptions are enabled package-wide, so the open failure surfaces as GDAL's own error. |
TypeError
|
|
ValueError
|
The file declares no UGRID topology. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
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 | |
isel_layer(index)
#
Select along the layer axis by position.
A layered variable — (layer, element), or (time, layer, element) — is indexed
on its layer axis. An integer collapses that axis (the variable loses its layer
dimension); a slice or sequence keeps it, trimmed. Variables with no layer axis are
carried through untouched, as the time selectors carry static variables.
For a ragged 3-D mesh (:attr:volume_topology set) a location="volume"
variable has no rectangular layer axis to index; the selection is per column instead.
index must be an int k: each column yields its k-th layer where it has
one, and a column shallower than k + 1 layers yields NaN — the absent layers are
made explicit, never padded silently. The volume variable becomes a plain
location="face" field; other variables carry through as on the uniform path.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int | slice | list[int] | ndarray
|
An |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with the layer selection applied. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a layer dimension, or a non- |
Source code in src/pyramids/netcdf/ugrid/dataset.py
sel_layer(value)
#
Select along the layer axis by coordinate value.
Matches value against :attr:layer_values, falling back to layer positions when
no layer coordinate is present -- which is the usual case, since the reader does not
populate layer_values (see :attr:layer_values). So on a mesh read from a file,
sel_layer(1) selects layer position 1.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Any
|
The layer coordinate value to select. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with that layer selected. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No layer dimension, or the value is not among the layer coordinates. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
collapse_layer(layer, *, location='face')
#
Collapse a ragged 3-D mesh's volume variables to a 2-D field (issue #1330).
The explicit 2-D collapse of a ragged mesh: each column's layer-th value becomes a
plain (n_face,) (or (time, n_face)) face field, absent layers NaN. It is
:meth:isel_layer under a name that says "give me a 2-D slice", so a caller can ask for
the surface/bed layer as a flat field without reaching for the per-column internals.
(Named collapse_layer rather than to_location because the latter already moves a
variable between mesh locations by graph interpolation — a different operation.)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer
|
int
|
The 0-based layer position to take from each column. |
required |
location
|
str
|
The target mesh location. Only |
'face'
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset whose volume variables are 2-D face fields. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
to_dataframe(variables=None, *, dropna=False)
#
A tidy frame of the mesh values, one row per element (and step).
The mesh counterpart of :meth:pyramids.netcdf.NetCDF.to_dataframe, in the tidy
shape rather than the raster (y, x) MultiIndex one: an unstructured element has no
row/column address, so each row carries the element index, its centroid coordinates,
the time step where the variable has one, and the value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
Sequence[str] | None
|
Which data variables to include. |
None
|
dropna
|
bool
|
Drop rows whose value is no-data. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: Columns |
DataFrame
|
|
DataFrame
|
|
DataFrame
|
|
DataFrame
|
the step coordinate, or None for a static one. |
Raises:
| Type | Description |
|---|---|
KeyError
|
A requested variable is not a data variable of this dataset. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
copy()
#
An independent deep copy of this dataset.
Every variable's values are copied, so writing into the copy never shows in the
original — the counterpart of :meth:pyramids.netcdf.NetCDF.copy.
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
The copy. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
from_bytes(data, *, suffix='.nc')
classmethod
#
Read a UGRID mesh from an in-memory buffer.
Writes data into GDAL's in-memory filesystem and reads it as a file, mirroring
:meth:pyramids.netcdf.NetCDF.from_bytes — for a mesh fetched over the network or
held in a database blob. The values are materialised before the buffer is unlinked, so
the result does not depend on it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
bytes
|
The bytes of a UGRID NetCDF file. |
required |
suffix
|
str
|
The extension to present to GDAL. Defaults to |
'.nc'
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
The mesh read from the buffer. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
GDAL cannot read the buffer at all. It is written to |
ValueError
|
The buffer reads as a file but declares no UGRID topology. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
info(buf=None, drivers=False)
#
Print a summary of the mesh, its variables and its attributes.
The mesh counterpart of :meth:pyramids.netcdf.NetCDF.info: one readable block naming
the topology, the element counts, the CRS, and every data variable with its location,
dtype and shape.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buf
|
Any
|
Where to write. Defaults to |
None
|
drivers
|
bool
|
Also list the mesh file-format drivers available in this interpreter — the built-in UGRID reader plus any installed plugin. Off by default because resolving them walks every installed distribution, which a summary of one dataset should not pay for. |
False
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
set_global_attribute(name, value)
#
Return a new dataset carrying one more global attribute.
A UGRID derivation is immutable here (as :meth:with_variable is), so this answers a
new dataset rather than writing in place; :meth:to_file then persists the attributes
through the shared CF writer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The attribute name. |
required |
value
|
Any
|
The attribute value. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset whose global attributes include |
Source code in src/pyramids/netcdf/ugrid/dataset.py
delete_global_attribute(name)
#
Return a new dataset without the global attribute name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The attribute to drop. Dropping an absent attribute is not an error,
mirroring the raster |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset without that attribute. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
active_mask(variable_name)
#
The variable's per-element active (wet/dry) mask, or None when it has none.
The first-class companion of the data (issue #1331): True marks an active/wet
element, False a dry one, kept separate from nodata/NaN so a consumer can tell
a dry element from a missing value. The mask is element-indexed — (n_element,)
when it is static or (n_time, n_element) when it varies per step — and is returned
as read, never applied to the values. Use :meth:masked_values to get the values with
it applied.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
Name of the data variable. |
required |
Returns:
| Type | Description |
|---|---|
NDArray | None
|
np.ndarray | None: The boolean mask, or |
Raises:
| Type | Description |
|---|---|
KeyError
|
|
Examples:
- A variable with a mask reports it; one without answers
None:>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> ds = UgridDataset.from_arrays( ... node_x=np.array([0.0, 1.0, 1.0, 0.0]), ... node_y=np.array([0.0, 0.0, 1.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... data={"depth": np.array([2.0, 4.0])}, ... ) >>> ds["depth"].active = np.array([True, False]) >>> ds.active_mask("depth").tolist() [True, False] >>> ds.active_mask("depth") is not None True
Source code in src/pyramids/netcdf/ugrid/dataset.py
masked_values(variable_name)
#
The variable's values with both nodata and the active mask blanked to NaN.
The opt-in counterpart of a bare .data read (issue #1331): dry elements (where
:meth:active_mask is False) become NaN on top of the usual nodata blanking,
so a caller that wants "treat dry as missing" gets it explicitly — the values are
never masked by default. Keeps the variable's full shape (every time step and layer),
unlike the single-step :meth:sample / :meth:weighted path. When the variable has no
mask the result is just the nodata-blanked values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
Name of the data variable. |
required |
Returns:
| Type | Description |
|---|---|
NDArray
|
np.ndarray: The float64 values, dry and missing elements alike as NaN. |
Raises:
| Type | Description |
|---|---|
KeyError
|
|
ValueError
|
The variable has no loaded data. |
Examples:
- Dry elements become NaN, so a mean over the wet cells is straightforward:
>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> ds = UgridDataset.from_arrays( ... node_x=np.array([0.0, 1.0, 1.0, 0.0]), ... node_y=np.array([0.0, 0.0, 1.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... data={"depth": np.array([2.0, 4.0])}, ... ) >>> ds["depth"].active = np.array([True, False]) >>> ds.masked_values("depth").tolist() [2.0, nan] >>> float(np.nanmean(ds.masked_values("depth"))) 2.0
Source code in src/pyramids/netcdf/ugrid/dataset.py
summary(variables=None, *, metrics=DEFAULT_METRICS, skipna=True, ddof=0)
#
A per-variable summary table over the whole mesh.
The mesh counterpart of :meth:pyramids.netcdf.NetCDF.summary, built on the same shared
assembly (:func:pyramids.base._summary.variable_summary) so the two classes answer in an
identical shape. Each variable is reduced over all of its samples — every element and,
for a temporal variable, every step — with the declared no-data value left out.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
Sequence[str] | None
|
Which data variables to summarise, in output-row order. |
None
|
metrics
|
Sequence[str]
|
Which statistics to report, in column order. Defaults to
|
DEFAULT_METRICS
|
skipna
|
bool
|
Leave no-data out of the statistics (the default) or let it propagate. |
True
|
ddof
|
int
|
Delta degrees of freedom for |
0
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: One row per variable (index name |
DataFrame
|
metric. |
DataFrame
|
element yields NaN statistics and a |
Raises:
| Type | Description |
|---|---|
KeyError
|
A requested variable is not a data variable of this dataset. |
TypeError
|
A requested variable is non-numeric. |
ValueError
|
A requested variable has no loaded data, or an unknown metric. |
Examples:
- Per-variable summary of a two-triangle mesh:
>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> mesh = UgridDataset.from_arrays( ... node_x=np.array([0.0, 1.0, 1.0, 0.0]), ... node_y=np.array([0.0, 0.0, 1.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... data={"depth": np.array([2.0, 4.0])}, ... ) >>> mesh.summary().loc["depth", ["count", "min", "max", "mean"]].tolist() [2.0, 2.0, 4.0, 3.0]
Source code in src/pyramids/netcdf/ugrid/dataset.py
2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 | |
sample(variable_name, x, y, *, method='contains', time_index=0)
#
Sample a mesh variable at point locations.
The mesh counterpart of :meth:pyramids.dataset.Dataset.sample. Where the raster
version inverts an affine geotransform to find the pixel under each point, a mesh
resolves the point to an element through :class:MeshSpatialIndex: a face-located
variable by which face contains the point (method="contains") or the nearest
face centroid (method="nearest"); a node-located variable by nearest node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
Name of the data variable. |
required |
x
|
float | ndarray
|
Query x-coordinate(s), in the mesh CRS. |
required |
y
|
float | ndarray
|
Query y-coordinate(s), in the mesh CRS. |
required |
method
|
str
|
|
'contains'
|
time_index
|
int
|
Step for a temporal variable. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
NDArray
|
numpy.ndarray: One value per query point; NaN where a |
NDArray
|
falls outside every face. |
Raises:
| Type | Description |
|---|---|
ValueError
|
An unknown |
Source code in src/pyramids/netcdf/ugrid/dataset.py
3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 | |
weighted(variable_name, *, how='mean', time_index=0, q=None)
#
Area-weighted statistic of a face variable over the mesh.
An irregular mesh has faces of different sizes, so the meaningful aggregate weights
each face by its area. Delegates to the shared
:func:pyramids.base._reductions.weighted_statistic with :attr:Mesh2d.face_areas
as the weights — the same kernel the raster weighted reduction uses.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
Name of a face-located data variable. |
required |
how
|
str
|
One of |
'mean'
|
time_index
|
int
|
Step for a temporal variable. Defaults to 0. |
0
|
q
|
float | None
|
The quantile in |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The area-weighted statistic over all faces. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Examples:
- Area-weighted mean: the larger face (area 4, value 10) outweighs the
smaller (area 2, value 20), pulling the mean below the unweighted 15.0:
>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> mesh = UgridDataset.from_arrays( ... node_x=np.array([0.0, 4.0, 4.0, 0.0]), ... node_y=np.array([0.0, 0.0, 2.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... data={"v": np.array([10.0, 20.0])}, ... ) >>> round(mesh.weighted("v"), 3) 13.333 - The area-weighted quantile clamps to the data range at the extremes:
>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> mesh = UgridDataset.from_arrays( ... node_x=np.array([0.0, 4.0, 4.0, 0.0]), ... node_y=np.array([0.0, 0.0, 2.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... data={"v": np.array([10.0, 20.0])}, ... ) >>> mesh.weighted("v", how="quantile", q=0.0) 10.0 >>> mesh.weighted("v", how="quantile", q=1.0) 20.0
Source code in src/pyramids/netcdf/ugrid/dataset.py
3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 | |
zonal_stats(zones, *, variable_name, stats=('mean',), weighted=True, time_index=0)
#
Aggregate a face variable within polygons, weighted by face area.
The mesh counterpart of :func:pyramids.dataset.ops._zonal.zonal_stats. Each face
is assigned to the zone whose polygon contains its centroid (the mesh analogue of a
raster pixel's cell centre), then the shared
:func:pyramids.base._reductions.reduce_by_label reduces the face values per zone.
With weighted (the default) the averaging statistics (mean / std /
var) are area-weighted, so a zone's mean is area-exact — a capability the raster
path does not yet have. sum is always the plain Σ value (never an area integral),
and count / min / max are weight-invariant.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zones
|
Any
|
Polygons, as a :class: |
required |
variable_name
|
str
|
Name of a face-located data variable. |
required |
stats
|
tuple[str, ...]
|
Statistics per zone, any of |
('mean',)
|
weighted
|
bool
|
Area-weight the averaging statistics ( |
True
|
time_index
|
int
|
Step for a temporal variable. Defaults to 0. |
0
|
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: Indexed like |
DataFrame
|
containing no face centroid is NaN ( |
Raises:
| Type | Description |
|---|---|
ValueError
|
The variable is not face-located, or the zones' CRS disagrees with the mesh CRS. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 | |
reduce(how, *, skipna=True, q=None, groupby=None)
#
Reduce the time dimension of every temporal variable, whole or in groups.
The mesh counterpart of :meth:pyramids.netcdf.NetCDF.reduce over time. Each
temporal variable is reduced along its time axis through the shared
:func:pyramids.base._reductions.reduce_axis — the very kernel the raster reductions
use. Non-temporal variables are kept unchanged.
Without groupby the whole axis collapses to one statistic and the variable becomes
static. With groupby each group is reduced on its own slab and the results are
stacked back along the time axis, so the variable stays temporal with one step per
group — the same shape contract the raster grouped reduce has. For a (4, 2)
variable over four monthly steps, reduce("mean") answers shape (2,) with
has_time False, while reduce("mean", groupby="MS") answers shape (2, 2)
with has_time still True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
how
|
str
|
One of |
required |
skipna
|
bool
|
Skip the declared no-data value and NaN. Defaults to True. |
True
|
q
|
float | None
|
The quantile for |
None
|
groupby
|
Any
|
Reduce within groups of steps instead of over the whole axis. Two
spellings, matching the raster grouped reduce: a sequence of per-step
labels the same length as the time axis (grouped in first-appearance order,
so the caller controls the order), or a pandas offset alias ( |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset. Without |
UgridDataset
|
collapsed over time into a static per-element variable; with |
|
UgridDataset
|
keeps its time dimension, at one step per group. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Examples:
- Mean over two time steps of a per-face variable:
>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> mesh = UgridDataset.from_arrays( ... node_x=np.array([0.0, 1.0, 1.0, 0.0]), ... node_y=np.array([0.0, 0.0, 1.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... data={"d": np.array([[1.0, 2.0], [3.0, 4.0]])}, ... data_locations={"d": "face"}, ... ) >>> mesh["d"].has_time True >>> reduced = mesh.reduce("mean") >>> reduced["d"].data.tolist() [2.0, 3.0] >>> reduced["d"].has_time False
Source code in src/pyramids/netcdf/ugrid/dataset.py
3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 | |
resample(freq, how='mean', *, skipna=True, q=None)
#
Bin the time axis by a calendar frequency and reduce each bin.
Sugar over reduce(how, groupby=freq): the mesh counterpart of the raster
resample. The time coordinates must be date-like, since the bins come from a pandas
offset alias ("1MS", "YS", "7D", …). The time dimension is kept, one step
per non-empty bin, stamped with pandas' own label for that bin — which is the bin's
start for a start-anchored alias and its end for an end-anchored one. Over steps in
January, February and March 2020, "MS" labels the bins 01-01 / 02-01 / 03-01 while
"ME" labels them 01-31 / 02-29 / 03-31, and "W" labels each week by its Sunday.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
freq
|
str
|
A pandas offset alias naming the bin width. |
required |
how
|
str
|
The statistic each bin is reduced with. Defaults to |
'mean'
|
skipna
|
bool
|
Skip the declared no-data value and NaN. Defaults to True. |
True
|
q
|
float | None
|
The quantile, required when |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with one time step per bin. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension, the coordinates are not date-like,
or |
Source code in src/pyramids/netcdf/ugrid/dataset.py
mean(*, skipna=True)
#
Mean over time of every temporal variable (thin wrapper over :meth:reduce).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skipna
|
bool
|
Skip the declared no-data value and NaN. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset; each temporal variable collapsed to its time mean. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
sum(*, skipna=True)
#
Sum over time of every temporal variable (thin wrapper over :meth:reduce).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skipna
|
bool
|
Skip the declared no-data value and NaN. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset; each temporal variable collapsed to its time sum. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
min(*, skipna=True)
#
Minimum over time of every temporal variable (thin wrapper over :meth:reduce).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skipna
|
bool
|
Skip the declared no-data value and NaN. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset; each temporal variable collapsed to its time minimum. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
max(*, skipna=True)
#
Maximum over time of every temporal variable (thin wrapper over :meth:reduce).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skipna
|
bool
|
Skip the declared no-data value and NaN. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset; each temporal variable collapsed to its time maximum. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
std(*, skipna=True)
#
Std-dev over time of every temporal variable (thin wrapper over :meth:reduce).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skipna
|
bool
|
Skip the declared no-data value and NaN. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset; each temporal variable collapsed to its time std. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
var(*, skipna=True)
#
Variance over time of every temporal variable (thin wrapper over :meth:reduce).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skipna
|
bool
|
Skip the declared no-data value and NaN. Defaults to True. |
True
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset; each temporal variable collapsed to its time variance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
cumsum()
#
Cumulative sum along time for every temporal variable.
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset in which each temporal variable holds the running |
UgridDataset
|
sum of its steps along the time axis; static variables are unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension, or a temporal variable has no loaded data. |
Examples:
- Running sum over three time steps of a per-face variable:
>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> mesh = UgridDataset.from_arrays( ... node_x=np.array([0.0, 1.0, 1.0, 0.0]), ... node_y=np.array([0.0, 0.0, 1.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... data={"d": np.array([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])}, ... data_locations={"d": "face"}, ... ) >>> mesh.cumsum()["d"].data.tolist() [[1.0, 2.0], [4.0, 6.0], [9.0, 12.0]]
Source code in src/pyramids/netcdf/ugrid/dataset.py
cumprod()
#
Cumulative product along time for every temporal variable.
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset in which each temporal variable holds the running |
UgridDataset
|
product of its steps along the time axis; static variables are unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension, or a temporal variable has no loaded data. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
shift(periods=1)
#
Shift each temporal variable periods steps along time, vacated steps NaN.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
periods
|
int
|
Steps to shift; negative shifts towards the start. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with each temporal variable shifted along time, the |
UgridDataset
|
vacated steps filled with NaN; static variables are unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension, or a temporal variable has no loaded data. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
ffill(*, limit=None, dim=None)
#
Forward-fill gaps along time from the last valid step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int | None
|
Maximum consecutive gaps one valid step may fill, or |
None
|
dim
|
str | None
|
The dimension to fill along. A mesh fills along |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with each temporal variable's gaps carried forward |
UgridDataset
|
from the previous valid step; static variables are unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
bfill(*, limit=None, dim=None)
#
Back-fill gaps along time from the next valid step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
limit
|
int | None
|
Maximum consecutive gaps one valid step may fill, or |
None
|
dim
|
str | None
|
The dimension to fill along. A mesh fills along |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with each temporal variable's gaps carried backward |
UgridDataset
|
from the next valid step; static variables are unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
interpolate_na(*, method='linear', limit=None, use_coordinate=True, dim=None)
#
Fill each interior time gap by interpolating between the steps on either side.
Distance is measured along the time coordinate by default, so unevenly spaced steps
weight their neighbours accordingly; pass use_coordinate=False to measure by step
position instead. A leading or trailing gap has only one neighbour and is left alone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
method
|
str
|
One of |
'linear'
|
limit
|
int | None
|
Maximum consecutive gaps a run may fill, or |
None
|
use_coordinate
|
bool
|
Measure distance along the time coordinate rather than by step
position. With time values |
True
|
dim
|
str | None
|
The dimension to interpolate along. A mesh interpolates along |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with each temporal variable's interior gaps |
UgridDataset
|
interpolated along time; static variables are unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
rolling(window, how='mean', *, center=False, min_periods=None, q=None, dim=None)
#
Rolling-window reduction along time for every temporal variable.
Each time step becomes a statistic of the window of steps it owns (ending at it, or
centred on it), cut where the window runs off the axis. Gaps are skipped; a step whose
window holds fewer than min_periods valid cells is NaN. The time dimension keeps
its length.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
int
|
Steps per window. |
required |
how
|
str
|
The reduction over each window ( |
'mean'
|
center
|
bool
|
Centre each window on its step rather than ending at it. Defaults to False. |
False
|
min_periods
|
int | None
|
Valid cells a window needs before its step holds a value. |
None
|
q
|
float | None
|
The quantile in |
None
|
dim
|
str | None
|
The dimension to roll along. A mesh rolls along |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with each temporal variable replaced by its rolling |
UgridDataset
|
statistic along time; static variables are unchanged. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 | |
isel(time=None, *, element=None)
#
Select by position along the time axis, the element axis, or both.
The mesh counterpart of :meth:pyramids.netcdf.NetCDF.isel. Over time an integer
selects a single step and collapses the time dimension (the variables become static);
a slice or sequence keeps the time dimension, trimmed to the chosen steps. Over
element the selection is a topology change: the chosen faces are kept and the mesh
is renumbered around them (as :meth:clip does), so the result is a smaller mesh.
Giving both applies the element selection first, then the time selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
int | slice | list[int] | ndarray | None
|
An |
None
|
element
|
int | slice | list[int] | ndarray | None
|
An |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with the selection applied. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Neither |
IndexError
|
A face index is out of range for this mesh. |
Examples:
- Keep one face, renumbering the mesh around it:
>>> import numpy as np >>> from pyramids.netcdf.ugrid import UgridDataset >>> mesh = UgridDataset.from_arrays( ... node_x=np.array([0.0, 1.0, 1.0, 0.0]), ... node_y=np.array([0.0, 0.0, 1.0, 1.0]), ... face_node_connectivity=np.array([[0, 1, 2], [0, 2, 3]]), ... data={"depth": np.array([2.0, 4.0])}, ... ) >>> one = mesh.isel(element=0) >>> one.n_face, one.n_node (1, 3) >>> one["depth"].data.tolist() [2.0]
Source code in src/pyramids/netcdf/ugrid/dataset.py
3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 | |
head(n=5)
#
Keep the first n time steps (fewer if the axis is shorter).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of leading steps to keep. Defaults to 5. |
5
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset trimmed to the first |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
tail(n=5)
#
Keep the last n time steps (fewer if the axis is shorter).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
Number of trailing steps to keep. Defaults to 5. |
5
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset trimmed to the last |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
thin(step)
#
Keep every step-th time step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
int
|
Stride; must be >= 1. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset keeping every |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
drop_isel(indices)
#
Drop the time steps at indices by position, keeping the rest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
int | list[int] | ndarray
|
A step position, or a sequence of them, to drop (negative indices count from the end). |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset without the dropped steps. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
squeeze()
#
Drop the time dimension when it has length 1; otherwise return unchanged.
Mirrors :meth:pyramids.netcdf.NetCDF.squeeze for the time axis: a single-step
temporal variable becomes static, a multi-step one is left alone.
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with single-step temporal variables collapsed to |
UgridDataset
|
static, or |
Raises:
| Type | Description |
|---|---|
ValueError
|
A single-step temporal variable has no loaded data. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
diff(n=1)
#
Discrete difference along time (out[i] = x[i] - x[i-1]), n times.
The time dimension shortens by n; a time_values coordinate, if present, drops
its first n entries to stay aligned with the result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n
|
int
|
The number of successive differences. Defaults to 1. |
1
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with each temporal variable differenced along time |
UgridDataset
|
(its time axis shorter by |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension, or a temporal variable has no loaded data. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
argmin()
#
The time-step position of each element's minimum.
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
Static |
UgridDataset
|
declaring |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
argmax()
#
The time-step position of each element's maximum.
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
Static |
UgridDataset
|
declaring |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
idxmin()
#
The time coordinate of each element's minimum.
Where :meth:argmin answers a step position, this answers the value of the time
coordinate at that step, so it needs numeric time coordinates.
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
Static |
UgridDataset
|
minimum, NaN where an element has no valid step. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension, or the time coordinates are
date-like rather than numeric (use |
Source code in src/pyramids/netcdf/ugrid/dataset.py
idxmax()
#
The time coordinate of each element's maximum.
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
Static |
UgridDataset
|
maximum, NaN where an element has no valid step. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension, or the time coordinates are
date-like rather than numeric (use |
Source code in src/pyramids/netcdf/ugrid/dataset.py
sel(time=None, *, method=None, tolerance=None)
#
Select time steps by coordinate value, exactly or by nearest.
The mesh counterpart of :meth:pyramids.netcdf.NetCDF.sel over time. A scalar selects
one step and collapses the time dimension; a sequence keeps it. Values are matched
against the dataset's :attr:time_values (which fall back to step positions when the
file carries no explicit time coordinate). method="nearest" snaps each value to the
closest coordinate instead of requiring an exact hit, and tolerance caps how far it
may snap — the same contract the raster sel uses, including raising KeyError (not
ValueError) when a snap would exceed tolerance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
time
|
Any
|
A coordinate value, or a sequence of them. |
None
|
method
|
str | None
|
|
None
|
tolerance
|
float | None
|
The furthest a |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with the selected steps. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No time dimension; an unknown |
KeyError
|
A |
Source code in src/pyramids/netcdf/ugrid/dataset.py
drop_sel(values)
#
Drop the time steps whose coordinate is in values, keeping the rest.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
values
|
Any
|
A coordinate value, or a sequence of them, to drop. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset without the steps whose coordinate is in |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
sortby()
#
Sort the time steps by their coordinate value (stable).
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with steps ordered by ascending time coordinate. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
drop_duplicates()
#
Keep the first step of each distinct time coordinate value.
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with duplicate-coordinate steps removed, first kept. |
Raises:
| Type | Description |
|---|---|
ValueError
|
No variable has a time dimension. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
dropna(how='any', thresh=None, *, dim=None)
#
Drop time steps that do not hold enough valid cells.
A step is kept only when every temporal variable meets the threshold at that
step, so the variables stay time-aligned. how="any" requires every cell of a
variable to be valid (a single gap drops the step); how="all" requires at least
one; thresh overrides how with an explicit valid-cell count per variable.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
how
|
str
|
|
'any'
|
thresh
|
int | None
|
Explicit minimum valid-cell count per variable, overriding |
None
|
dim
|
str | None
|
The dimension to drop along. A mesh drops along |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset with the surviving steps. |
Raises:
| Type | Description |
|---|---|
ValueError
|
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
concat(others)
#
Concatenate same-topology datasets along time.
The mesh counterpart of :meth:pyramids.netcdf.NetCDF.concat. Every dataset must sit
on the same mesh. Each temporal variable's data is concatenated along its time axis
(and its time_values coordinate, when present); a static variable is taken from
self unchanged. The variable set must match across datasets.
A per-step active mask (:attr:MeshVariable.active of shape (n_time, n_element))
is dropped on concatenation — the parts' masks are not joined along time, and the
concatenated time length no longer matches self's mask, so the implicit carry
discards it (issue #1331). A static (n_element,) mask survives, since it applies
to every step. Re-attach a per-step mask after concatenating if you need one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
others
|
UgridDataset | list[UgridDataset]
|
One dataset, or a list of them, to append after |
required |
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset spanning the concatenated time axis. |
Raises:
| Type | Description |
|---|---|
AlignmentError
|
A dataset sits on a different mesh. Note this is not a
|
ValueError
|
A dataset carries a different variable set, or a variable has no loaded data. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
merge(others, *, compat='no_conflicts')
#
Merge the variables of same-topology datasets into one.
The mesh counterpart of :meth:pyramids.netcdf.NetCDF.merge. Every dataset must sit
on the same mesh; the union of their variables is returned. A variable name present
in more than one dataset is a conflict and is refused.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
others
|
UgridDataset | list[UgridDataset]
|
One dataset, or a list of them, whose variables join |
required |
compat
|
str
|
How to handle a variable name present in more than one dataset --
|
'no_conflicts'
|
Returns:
| Name | Type | Description |
|---|---|---|
UgridDataset |
UgridDataset
|
A new dataset carrying every variable. |
Raises:
| Type | Description |
|---|---|
AlignmentError
|
A dataset sits on a different mesh. |
ValueError
|
An unknown |
Source code in src/pyramids/netcdf/ugrid/dataset.py
plot(variable_name, ax=None, cmap='viridis', title=None, basemap=None, colorbar=None, points=None, kind='auto', color=None, contour=None, data_style=None, **kwargs)
#
Plot a mesh data variable.
N-6 — this facade now goes through the same module-level
helper as the raster path. The mesh-specific dispatch lives in
:func:pyramids.dataset._plot_helpers.mesh_render; both
Dataset.plot/NetCDF.plot and UgridDataset.plot share
the "resolve data, hand to a single helper" contract so the
two formats no longer maintain independent plotting code paths.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variable_name
|
str
|
Name of the data variable to plot. |
required |
ax
|
Any
|
matplotlib Axes. Created if None. |
None
|
cmap
|
str
|
Colormap name. |
'viridis'
|
title
|
str | None
|
Plot title. Defaults to variable name. |
None
|
basemap
|
bool | str | None
|
If True, add an OpenStreetMap basemap. If a string, use it as the tile provider name (e.g. "CartoDB.Positron"). Default is None (no basemap). Requires the [viz] extra. |
None
|
colorbar
|
bool or ColorBar
|
Colour-bar spec, part of the
shared plot signature. A |
None
|
points
|
ndarray or PointOverlay
|
Accepted for signature symmetry with the raster plot family, but a no-op here — a mesh has no point-overlay layer (the mesh geometry is the data). Ignored. |
None
|
kind
|
str
|
Accepted for signature symmetry with the raster
plot family, but a no-op here — |
'auto'
|
color
|
ColorScaling
|
Colour-scale spec
|
None
|
contour
|
Contour
|
Contour-line spec
|
None
|
data_style
|
DataStyle
|
Data-style / relief spec
|
None
|
**kwargs
|
Any
|
Additional arguments passed to mesh_render
(forwarded to plot_mesh_data). Notably |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
cleopatra.glyphs.gridded.mesh_glyph.MeshGlyph instance with the plot rendered. Use the returned object to access the matplotlib handles and the mappable:
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the selected variable has no loaded data, or if
|
Source code in src/pyramids/netcdf/ugrid/dataset.py
4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 | |
plot_outline(ax=None, **kwargs)
#
Plot mesh wireframe.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ax
|
Any
|
matplotlib Axes. Created if None. |
None
|
**kwargs
|
Any
|
Additional arguments passed to plot_mesh_outline. |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
cleopatra.glyphs.gridded.mesh_glyph.MeshGlyph instance with the wireframe
rendered. |
Source code in src/pyramids/netcdf/ugrid/dataset.py
__str__()
#
Human-readable summary of the dataset.
Source code in src/pyramids/netcdf/ugrid/dataset.py
__repr__()
#
Repr string for the dataset.