|
465 | 465 | }, |
466 | 466 | "outputs": [], |
467 | 467 | "source": [ |
468 | | - "herstappe = herstappe.assign_coords(band=(\"band\", [\"R\", \"G\", \"B\"]))\n", |
| 468 | + "herstappe = herstappe.assign_coords(band=(\"band\", [\"red\", \"green\", \"blue\"]))\n", |
469 | 469 | "herstappe" |
470 | 470 | ] |
471 | 471 | }, |
|
491 | 491 | }, |
492 | 492 | "outputs": [], |
493 | 493 | "source": [ |
494 | | - "herstappe.sel(band='R')" |
| 494 | + "herstappe.sel(band='red')" |
495 | 495 | ] |
496 | 496 | }, |
497 | 497 | { |
|
552 | 552 | "outputs": [], |
553 | 553 | "source": [ |
554 | 554 | "herstappe = xr.open_rasterio(data_file)\n", |
555 | | - "herstappe = herstappe.assign_coords(band=(\"band\", [\"R\", \"G\", \"B\"]))" |
| 555 | + "herstappe = herstappe.assign_coords(band=(\"band\", [\"red\", \"green\", \"blue\"]))" |
556 | 556 | ] |
557 | 557 | }, |
558 | 558 | { |
|
598 | 598 | }, |
599 | 599 | "outputs": [], |
600 | 600 | "source": [ |
601 | | - "herstappe.sel(band=\"R\")" |
| 601 | + "herstappe.sel(band=\"red\")" |
602 | 602 | ] |
603 | 603 | }, |
604 | 604 | { |
|
630 | 630 | }, |
631 | 631 | "outputs": [], |
632 | 632 | "source": [ |
633 | | - "herstappe.sel(x=[600_000, 610_000, 620_000], method=\"nearest\").sel(band=\"R\").plot.line(hue=\"x\");" |
| 633 | + "herstappe.sel(x=[600_000, 610_000, 620_000], method=\"nearest\").sel(band=\"red\").plot.line(hue=\"x\");" |
634 | 634 | ] |
635 | 635 | }, |
636 | 636 | { |
|
653 | 653 | }, |
654 | 654 | "outputs": [], |
655 | 655 | "source": [ |
656 | | - "herstappe.sel(x=slice(580_000, 620_000), band=\"G\").plot.imshow(cmap=\"Greens\")" |
| 656 | + "herstappe.sel(x=slice(580_000, 620_000), band=\"green\").plot.imshow(cmap=\"Greens\")" |
657 | 657 | ] |
658 | 658 | }, |
659 | 659 | { |
|
703 | 703 | "metadata": {}, |
704 | 704 | "outputs": [], |
705 | 705 | "source": [ |
706 | | - "herstappe.where(herstappe > 0.2).sel(band=\"R\").plot.imshow()" |
| 706 | + "herstappe.where(herstappe > 0.2).sel(band=\"red\").plot.imshow()" |
707 | 707 | ] |
708 | 708 | }, |
709 | 709 | { |
|
726 | 726 | "**EXERCISE**:\n", |
727 | 727 | "\n", |
728 | 728 | "* Read in the file `./data/gent/raster/2020-09-17_Sentinel_2_L1C_True_color.tiff` with xarray and assign the data to a new variable `tc_data`. \n", |
| 729 | + "* Inspect the display of `tc_data`. What are the different dimensions of the array? \n", |
729 | 730 | "* Select only the *second* layer of `tc_data` and assign the output to a new variable `tc_g`.\n", |
| 731 | + "* Plot the second (green) layer.\n", |
730 | 732 | "* Create a new array with each of the elements in the `tc_g` array with a value above 15000 set to a new value of 65535.\n", |
731 | 733 | " \n", |
732 | 734 | "<details><summary>Hints</summary>\n", |
|
756 | 758 | "execution_count": null, |
757 | 759 | "metadata": { |
758 | 760 | "clear_cell": true, |
| 761 | + "editable": true, |
759 | 762 | "tags": [] |
760 | 763 | }, |
761 | 764 | "outputs": [], |
762 | 765 | "source": [ |
763 | 766 | "# %load _solutions2/14-xarray-intro2.py" |
764 | 767 | ] |
765 | 768 | }, |
| 769 | + { |
| 770 | + "cell_type": "code", |
| 771 | + "execution_count": null, |
| 772 | + "metadata": { |
| 773 | + "clear_cell": true, |
| 774 | + "tags": [] |
| 775 | + }, |
| 776 | + "outputs": [], |
| 777 | + "source": [ |
| 778 | + "# %load _solutions2/14-xarray-intro3.py" |
| 779 | + ] |
| 780 | + }, |
| 781 | + { |
| 782 | + "cell_type": "code", |
| 783 | + "execution_count": null, |
| 784 | + "metadata": { |
| 785 | + "clear_cell": true, |
| 786 | + "tags": [] |
| 787 | + }, |
| 788 | + "outputs": [], |
| 789 | + "source": [ |
| 790 | + "# %load _solutions2/14-xarray-intro4.py" |
| 791 | + ] |
| 792 | + }, |
766 | 793 | { |
767 | 794 | "cell_type": "code", |
768 | 795 | "execution_count": null, |
|
775 | 802 | }, |
776 | 803 | "outputs": [], |
777 | 804 | "source": [ |
778 | | - "# %load _solutions2/14-xarray-intro3.py" |
| 805 | + "# %load _solutions2/14-xarray-intro5.py" |
779 | 806 | ] |
780 | 807 | }, |
781 | 808 | { |
|
808 | 835 | }, |
809 | 836 | "outputs": [], |
810 | 837 | "source": [ |
811 | | - "# %load _solutions2/14-xarray-intro4.py" |
| 838 | + "# %load _solutions2/14-xarray-intro6.py" |
812 | 839 | ] |
813 | 840 | }, |
814 | 841 | { |
|
823 | 850 | }, |
824 | 851 | "outputs": [], |
825 | 852 | "source": [ |
826 | | - "# %load _solutions2/14-xarray-intro5.py" |
| 853 | + "# %load _solutions2/14-xarray-intro7.py" |
827 | 854 | ] |
828 | 855 | }, |
829 | 856 | { |
|
867 | 894 | }, |
868 | 895 | "outputs": [], |
869 | 896 | "source": [ |
870 | | - "# %load _solutions2/14-xarray-intro6.py" |
| 897 | + "# %load _solutions2/14-xarray-intro8.py" |
871 | 898 | ] |
872 | 899 | }, |
873 | 900 | { |
|
882 | 909 | }, |
883 | 910 | "outputs": [], |
884 | 911 | "source": [ |
885 | | - "# %load _solutions2/14-xarray-intro7.py" |
| 912 | + "# %load _solutions2/14-xarray-intro9.py" |
886 | 913 | ] |
887 | 914 | }, |
888 | 915 | { |
|
894 | 921 | }, |
895 | 922 | "outputs": [], |
896 | 923 | "source": [ |
897 | | - "# %load _solutions2/14-xarray-intro8.py" |
| 924 | + "# %load _solutions2/14-xarray-intro10.py" |
898 | 925 | ] |
899 | 926 | }, |
900 | 927 | { |
|
909 | 936 | }, |
910 | 937 | "outputs": [], |
911 | 938 | "source": [ |
912 | | - "# %load _solutions2/14-xarray-intro9.py" |
| 939 | + "# %load _solutions2/14-xarray-intro11.py" |
913 | 940 | ] |
914 | 941 | }, |
915 | 942 | { |
|
924 | 951 | }, |
925 | 952 | "outputs": [], |
926 | 953 | "source": [ |
927 | | - "# %load _solutions2/14-xarray-intro10.py" |
| 954 | + "# %load _solutions2/14-xarray-intro12.py" |
928 | 955 | ] |
929 | 956 | }, |
930 | 957 | { |
|
943 | 970 | "outputs": [], |
944 | 971 | "source": [ |
945 | 972 | "herstappe = xr.open_rasterio(data_file)\n", |
946 | | - "herstappe = herstappe.assign_coords(band=(\"band\", [\"R\", \"G\", \"B\"]))\n", |
947 | | - "herstappeR = herstappe.sel(band=\"R\")" |
| 973 | + "herstappe = herstappe.assign_coords(band=(\"band\", [\"red\", \"green\", \"blue\"]))\n", |
| 974 | + "herstappeR = herstappe.sel(band=\"red\")" |
948 | 975 | ] |
949 | 976 | }, |
950 | 977 | { |
|
1216 | 1243 | }, |
1217 | 1244 | "outputs": [], |
1218 | 1245 | "source": [ |
1219 | | - "herstappe.sel(band=\"R\") - herstappe.sel(band=\"G\")" |
| 1246 | + "herstappe.sel(band=\"red\") - herstappe.sel(band=\"green\")" |
1220 | 1247 | ] |
1221 | 1248 | }, |
1222 | 1249 | { |
|
1336 | 1363 | }, |
1337 | 1364 | "outputs": [], |
1338 | 1365 | "source": [ |
1339 | | - "# %load _solutions2/14-xarray-intro11.py" |
| 1366 | + "# %load _solutions2/14-xarray-intro13.py" |
1340 | 1367 | ] |
1341 | 1368 | }, |
1342 | 1369 | { |
|
1348 | 1375 | }, |
1349 | 1376 | "outputs": [], |
1350 | 1377 | "source": [ |
1351 | | - "# %load _solutions2/14-xarray-intro12.py" |
| 1378 | + "# %load _solutions2/14-xarray-intro14.py" |
1352 | 1379 | ] |
1353 | 1380 | }, |
1354 | 1381 | { |
|
1363 | 1390 | }, |
1364 | 1391 | "outputs": [], |
1365 | 1392 | "source": [ |
1366 | | - "# %load _solutions2/14-xarray-intro13.py" |
| 1393 | + "# %load _solutions2/14-xarray-intro15.py" |
1367 | 1394 | ] |
1368 | 1395 | }, |
1369 | 1396 | { |
|
1414 | 1441 | }, |
1415 | 1442 | "outputs": [], |
1416 | 1443 | "source": [ |
1417 | | - "# %load _solutions2/14-xarray-intro14.py" |
| 1444 | + "# %load _solutions2/14-xarray-intro16.py" |
1418 | 1445 | ] |
1419 | 1446 | }, |
1420 | 1447 | { |
|
1427 | 1454 | }, |
1428 | 1455 | "outputs": [], |
1429 | 1456 | "source": [ |
1430 | | - "# %load _solutions2/14-xarray-intro15.py" |
| 1457 | + "# %load _solutions2/14-xarray-intro17.py" |
1431 | 1458 | ] |
1432 | 1459 | }, |
1433 | 1460 | { |
|
1440 | 1467 | }, |
1441 | 1468 | "outputs": [], |
1442 | 1469 | "source": [ |
1443 | | - "# %load _solutions2/14-xarray-intro16.py" |
| 1470 | + "# %load _solutions2/14-xarray-intro18.py" |
1444 | 1471 | ] |
1445 | 1472 | }, |
1446 | 1473 | { |
|
1453 | 1480 | }, |
1454 | 1481 | "outputs": [], |
1455 | 1482 | "source": [ |
1456 | | - "# %load _solutions2/14-xarray-intro17.py" |
| 1483 | + "# %load _solutions2/14-xarray-intro19.py" |
1457 | 1484 | ] |
1458 | 1485 | }, |
1459 | 1486 | { |
|
1468 | 1495 | }, |
1469 | 1496 | "outputs": [], |
1470 | 1497 | "source": [ |
1471 | | - "# %load _solutions2/14-xarray-intro18.py" |
| 1498 | + "# %load _solutions2/14-xarray-intro20.py" |
1472 | 1499 | ] |
1473 | 1500 | }, |
1474 | 1501 | { |
|
1504 | 1531 | }, |
1505 | 1532 | "outputs": [], |
1506 | 1533 | "source": [ |
1507 | | - "# %load _solutions2/14-xarray-intro19.py" |
| 1534 | + "# %load _solutions2/14-xarray-intro21.py" |
1508 | 1535 | ] |
1509 | 1536 | }, |
1510 | 1537 | { |
|
1556 | 1583 | }, |
1557 | 1584 | "outputs": [], |
1558 | 1585 | "source": [ |
1559 | | - "# %load _solutions2/14-xarray-intro20.py" |
| 1586 | + "# %load _solutions2/14-xarray-intro22.py" |
1560 | 1587 | ] |
1561 | 1588 | }, |
1562 | 1589 | { |
|
1568 | 1595 | }, |
1569 | 1596 | "outputs": [], |
1570 | 1597 | "source": [ |
1571 | | - "# %load _solutions2/14-xarray-intro21.py" |
| 1598 | + "# %load _solutions2/14-xarray-intro23.py" |
1572 | 1599 | ] |
1573 | 1600 | }, |
1574 | 1601 | { |
|
1581 | 1608 | }, |
1582 | 1609 | "outputs": [], |
1583 | 1610 | "source": [ |
1584 | | - "# %load _solutions2/14-xarray-intro22.py" |
| 1611 | + "# %load _solutions2/14-xarray-intro24.py" |
1585 | 1612 | ] |
1586 | 1613 | }, |
1587 | 1614 | { |
|
1594 | 1621 | }, |
1595 | 1622 | "outputs": [], |
1596 | 1623 | "source": [ |
1597 | | - "# %load _solutions2/14-xarray-intro23.py" |
| 1624 | + "# %load _solutions2/14-xarray-intro25.py" |
1598 | 1625 | ] |
1599 | 1626 | }, |
1600 | 1627 | { |
|
1636 | 1663 | }, |
1637 | 1664 | "outputs": [], |
1638 | 1665 | "source": [ |
1639 | | - "# %load _solutions2/14-xarray-intro24.py" |
| 1666 | + "# %load _solutions2/14-xarray-intro26.py" |
1640 | 1667 | ] |
1641 | 1668 | }, |
1642 | 1669 | { |
|
1648 | 1675 | }, |
1649 | 1676 | "outputs": [], |
1650 | 1677 | "source": [ |
1651 | | - "# %load _solutions2/14-xarray-intro25.py" |
| 1678 | + "# %load _solutions2/14-xarray-intro27.py" |
1652 | 1679 | ] |
1653 | 1680 | }, |
1654 | 1681 | { |
|
1660 | 1687 | }, |
1661 | 1688 | "outputs": [], |
1662 | 1689 | "source": [ |
1663 | | - "# %load _solutions2/14-xarray-intro26.py" |
| 1690 | + "# %load _solutions2/14-xarray-intro28.py" |
1664 | 1691 | ] |
1665 | 1692 | }, |
1666 | 1693 | { |
|
1685 | 1712 | }, |
1686 | 1713 | "outputs": [], |
1687 | 1714 | "source": [ |
1688 | | - "# %load _solutions2/14-xarray-intro27.py" |
| 1715 | + "# %load _solutions2/14-xarray-intro29.py" |
1689 | 1716 | ] |
1690 | 1717 | }, |
1691 | 1718 | { |
|
1701 | 1728 | }, |
1702 | 1729 | "outputs": [], |
1703 | 1730 | "source": [ |
1704 | | - "# %load _solutions2/14-xarray-intro28.py" |
| 1731 | + "# %load _solutions2/14-xarray-intro30.py" |
1705 | 1732 | ] |
1706 | | - }, |
1707 | | - { |
1708 | | - "cell_type": "code", |
1709 | | - "execution_count": null, |
1710 | | - "metadata": {}, |
1711 | | - "outputs": [], |
1712 | | - "source": [] |
1713 | 1733 | } |
1714 | 1734 | ], |
1715 | 1735 | "metadata": { |
|
0 commit comments