From c67d77fc4946da002d334dcec80b148deabb1f41 Mon Sep 17 00:00:00 2001 From: Elsa Culler Date: Mon, 16 May 2022 09:46:55 -0600 Subject: [PATCH] Intro Dask notebook --- .gitignore | 3 + .../modules/__pycache__/bbox.cpython-38.pyc | Bin 1731 -> 0 bytes ...al-remote-sensing-demo-landsat-blank.ipynb | 0 ...ncertainty-lidar-raster-vector-blank.ipynb | 0 .../05-l1-landsat-cloud-masks-blank.ipynb | 0 ...05-l2-open-mask-functions-demo-blank.ipynb | 0 ...-testing-speed-timeit-examples-blank.ipynb | 0 .../blank-demos/05-l4-loops-lists-blank.ipynb | 0 .../07-open-hdf4-python-blank.ipynb | 0 .../blank-demos/08-api-geospatial.ipynb | 0 .../blank-demos/08-api-work-with-json.ipynb | 0 .../blank-demos/10-kmeans-blank.ipynb | 0 ...ltispectral-remote-sensing-demo-NAIP.ipynb | 0 ...spectral-remote-sensing-demo-landsat.ipynb | 0 .../04-uncertainty-lidar-raster-vector.ipynb | 0 .../05-l1-landsat-cloud-masks.ipynb | 0 ...05-l2-open-mask-functions-demo-Copy1.ipynb | 0 .../05-l2-open-mask-functions-demo.ipynb | 0 .../05-l3-testing-speed-timeit-examples.ipynb | 0 .../completed-demos/05-l4-loops-lists.ipynb | 0 .../06-workflow-lesson-landat-loops.ipynb | 0 .../07-landsat-clean-clip-demo.ipynb | 0 .../completed-demos/07-open-hdf4-python.ipynb | 0 .../08-ap-intro-work-with-json.ipynb | 0 .../completed-demos/08-api-geospatial.ipynb | 0 .../completed-demos/08-api-intro.ipynb | 0 .../08-api-work-with-json.ipynb | 0 .../completed-demos/09-random-forest.ipynb | 0 .../completed-demos/10-kmeans.ipynb | 0 .../05-l1-landsat-cloud-masks-blank.ipynb | 0 ...05-l2-open-mask-functions-demo-blank.ipynb | 0 ...-testing-speed-timeit-examples-blank.ipynb | 0 .../05-l4-loops-lists-blank-2.ipynb | 0 .../05-l4-loops-lists-blank.ipynb | 0 .../07-open-hdf4-python-blank-filled.ipynb | 0 .../08-api-geospatial.ipynb | 0 .../08-api-work-with-json.ipynb | 0 .../in-class-notebooks/10-kmeans-blank.ipynb | 0 .../11-classes-objects.ipynb | 0 .../dask-worker-space/global.lock | 0 .../dask-worker-space/purge.lock | 0 .../eapython-11-dask-hdf.ipynb | 2618 +++++++++++++++++ .../in-class-notebooks/modules/bbox.py | 0 43 files changed, 2621 insertions(+) delete mode 100644 2022/in-class-notebooks/modules/__pycache__/bbox.cpython-38.pyc rename {2022 => eapython}/blank-demos/03-multispectral-remote-sensing-demo-landsat-blank.ipynb (100%) rename {2022 => eapython}/blank-demos/04-uncertainty-lidar-raster-vector-blank.ipynb (100%) rename {2022 => eapython}/blank-demos/05-l1-landsat-cloud-masks-blank.ipynb (100%) rename {2022 => eapython}/blank-demos/05-l2-open-mask-functions-demo-blank.ipynb (100%) rename {2022 => eapython}/blank-demos/05-l3-testing-speed-timeit-examples-blank.ipynb (100%) rename {2022 => eapython}/blank-demos/05-l4-loops-lists-blank.ipynb (100%) rename {2022 => eapython}/blank-demos/07-open-hdf4-python-blank.ipynb (100%) rename {2022 => eapython}/blank-demos/08-api-geospatial.ipynb (100%) rename {2022 => eapython}/blank-demos/08-api-work-with-json.ipynb (100%) rename {2022 => eapython}/blank-demos/10-kmeans-blank.ipynb (100%) rename {2022 => eapython}/completed-demos/03-multispectral-remote-sensing-demo-NAIP.ipynb (100%) rename {2022 => eapython}/completed-demos/03-multispectral-remote-sensing-demo-landsat.ipynb (100%) rename {2022 => eapython}/completed-demos/04-uncertainty-lidar-raster-vector.ipynb (100%) rename {2022 => eapython}/completed-demos/05-l1-landsat-cloud-masks.ipynb (100%) rename {2022 => eapython}/completed-demos/05-l2-open-mask-functions-demo-Copy1.ipynb (100%) rename {2022 => eapython}/completed-demos/05-l2-open-mask-functions-demo.ipynb (100%) rename {2022 => eapython}/completed-demos/05-l3-testing-speed-timeit-examples.ipynb (100%) rename {2022 => eapython}/completed-demos/05-l4-loops-lists.ipynb (100%) rename {2022 => eapython}/completed-demos/06-workflow-lesson-landat-loops.ipynb (100%) rename {2022 => eapython}/completed-demos/07-landsat-clean-clip-demo.ipynb (100%) rename {2022 => eapython}/completed-demos/07-open-hdf4-python.ipynb (100%) rename {2022 => eapython}/completed-demos/08-ap-intro-work-with-json.ipynb (100%) rename {2022 => eapython}/completed-demos/08-api-geospatial.ipynb (100%) rename {2022 => eapython}/completed-demos/08-api-intro.ipynb (100%) rename {2022 => eapython}/completed-demos/08-api-work-with-json.ipynb (100%) rename {2022 => eapython}/completed-demos/09-random-forest.ipynb (100%) rename {2022 => eapython}/completed-demos/10-kmeans.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/05-l1-landsat-cloud-masks-blank.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/05-l2-open-mask-functions-demo-blank.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/05-l3-testing-speed-timeit-examples-blank.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/05-l4-loops-lists-blank-2.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/05-l4-loops-lists-blank.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/07-open-hdf4-python-blank-filled.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/08-api-geospatial.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/08-api-work-with-json.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/10-kmeans-blank.ipynb (100%) rename {2022 => eapython}/in-class-notebooks/11-classes-objects.ipynb (100%) create mode 100644 eapython/in-class-notebooks/dask-worker-space/global.lock create mode 100644 eapython/in-class-notebooks/dask-worker-space/purge.lock create mode 100644 eapython/in-class-notebooks/eapython-11-dask-hdf.ipynb rename {2022 => eapython}/in-class-notebooks/modules/bbox.py (100%) diff --git a/.gitignore b/.gitignore index 0ae071f..acd55c9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,6 @@ # Cache *__pycache__* + +# Dask +*dask_worker_space* diff --git a/2022/in-class-notebooks/modules/__pycache__/bbox.cpython-38.pyc b/2022/in-class-notebooks/modules/__pycache__/bbox.cpython-38.pyc deleted file mode 100644 index 917d6364aa82eeccb6bbb7d664f2abd3df1de2a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1731 zcmbVM&2QsG6rUN}iQ^`1c9#$BYK0;Wh#=A|-4#LzA=nQpai}U*%fXk?#4}BkI-cx| zgW||sXs`SaaO@o+@vr#Gseb{|9uV(Ml49+a3uDdm`xwvr`aQqsbRq)l_dmqwFOQHv zQK&D_k*{FekAO%L6G@jg7A0YI4-4RdB2)S)QO+U)M2w2Uz4pnN!@TpD~GnM5a3X`7>L?+TApCl;H3utBr%wWw8 z61^~14Io4{()!E}4;~yG3@6#Z;h?6UX}L(19gd*3`}3j-IiF;cobxUOV0VEK8q$#6 zrVWaF)xmDEw>A@L5NcOQ z`jL4TUR5L49LB5iQk|H$QA3vw0u?P@8#4fiLn7uIM-Vt^1|E( zvDOL9$hohDPZUGMFB9p=z{37n!Q!!U* evA@N~dS39_oBUPb7wc@k#ClttZNC}PHv0#o>1!qc diff --git a/2022/blank-demos/03-multispectral-remote-sensing-demo-landsat-blank.ipynb b/eapython/blank-demos/03-multispectral-remote-sensing-demo-landsat-blank.ipynb similarity index 100% rename from 2022/blank-demos/03-multispectral-remote-sensing-demo-landsat-blank.ipynb rename to eapython/blank-demos/03-multispectral-remote-sensing-demo-landsat-blank.ipynb diff --git a/2022/blank-demos/04-uncertainty-lidar-raster-vector-blank.ipynb b/eapython/blank-demos/04-uncertainty-lidar-raster-vector-blank.ipynb similarity index 100% rename from 2022/blank-demos/04-uncertainty-lidar-raster-vector-blank.ipynb rename to eapython/blank-demos/04-uncertainty-lidar-raster-vector-blank.ipynb diff --git a/2022/blank-demos/05-l1-landsat-cloud-masks-blank.ipynb b/eapython/blank-demos/05-l1-landsat-cloud-masks-blank.ipynb similarity index 100% rename from 2022/blank-demos/05-l1-landsat-cloud-masks-blank.ipynb rename to eapython/blank-demos/05-l1-landsat-cloud-masks-blank.ipynb diff --git a/2022/blank-demos/05-l2-open-mask-functions-demo-blank.ipynb b/eapython/blank-demos/05-l2-open-mask-functions-demo-blank.ipynb similarity index 100% rename from 2022/blank-demos/05-l2-open-mask-functions-demo-blank.ipynb rename to eapython/blank-demos/05-l2-open-mask-functions-demo-blank.ipynb diff --git a/2022/blank-demos/05-l3-testing-speed-timeit-examples-blank.ipynb b/eapython/blank-demos/05-l3-testing-speed-timeit-examples-blank.ipynb similarity index 100% rename from 2022/blank-demos/05-l3-testing-speed-timeit-examples-blank.ipynb rename to eapython/blank-demos/05-l3-testing-speed-timeit-examples-blank.ipynb diff --git a/2022/blank-demos/05-l4-loops-lists-blank.ipynb b/eapython/blank-demos/05-l4-loops-lists-blank.ipynb similarity index 100% rename from 2022/blank-demos/05-l4-loops-lists-blank.ipynb rename to eapython/blank-demos/05-l4-loops-lists-blank.ipynb diff --git a/2022/blank-demos/07-open-hdf4-python-blank.ipynb b/eapython/blank-demos/07-open-hdf4-python-blank.ipynb similarity index 100% rename from 2022/blank-demos/07-open-hdf4-python-blank.ipynb rename to eapython/blank-demos/07-open-hdf4-python-blank.ipynb diff --git a/2022/blank-demos/08-api-geospatial.ipynb b/eapython/blank-demos/08-api-geospatial.ipynb similarity index 100% rename from 2022/blank-demos/08-api-geospatial.ipynb rename to eapython/blank-demos/08-api-geospatial.ipynb diff --git a/2022/blank-demos/08-api-work-with-json.ipynb b/eapython/blank-demos/08-api-work-with-json.ipynb similarity index 100% rename from 2022/blank-demos/08-api-work-with-json.ipynb rename to eapython/blank-demos/08-api-work-with-json.ipynb diff --git a/2022/blank-demos/10-kmeans-blank.ipynb b/eapython/blank-demos/10-kmeans-blank.ipynb similarity index 100% rename from 2022/blank-demos/10-kmeans-blank.ipynb rename to eapython/blank-demos/10-kmeans-blank.ipynb diff --git a/2022/completed-demos/03-multispectral-remote-sensing-demo-NAIP.ipynb b/eapython/completed-demos/03-multispectral-remote-sensing-demo-NAIP.ipynb similarity index 100% rename from 2022/completed-demos/03-multispectral-remote-sensing-demo-NAIP.ipynb rename to eapython/completed-demos/03-multispectral-remote-sensing-demo-NAIP.ipynb diff --git a/2022/completed-demos/03-multispectral-remote-sensing-demo-landsat.ipynb b/eapython/completed-demos/03-multispectral-remote-sensing-demo-landsat.ipynb similarity index 100% rename from 2022/completed-demos/03-multispectral-remote-sensing-demo-landsat.ipynb rename to eapython/completed-demos/03-multispectral-remote-sensing-demo-landsat.ipynb diff --git a/2022/completed-demos/04-uncertainty-lidar-raster-vector.ipynb b/eapython/completed-demos/04-uncertainty-lidar-raster-vector.ipynb similarity index 100% rename from 2022/completed-demos/04-uncertainty-lidar-raster-vector.ipynb rename to eapython/completed-demos/04-uncertainty-lidar-raster-vector.ipynb diff --git a/2022/completed-demos/05-l1-landsat-cloud-masks.ipynb b/eapython/completed-demos/05-l1-landsat-cloud-masks.ipynb similarity index 100% rename from 2022/completed-demos/05-l1-landsat-cloud-masks.ipynb rename to eapython/completed-demos/05-l1-landsat-cloud-masks.ipynb diff --git a/2022/completed-demos/05-l2-open-mask-functions-demo-Copy1.ipynb b/eapython/completed-demos/05-l2-open-mask-functions-demo-Copy1.ipynb similarity index 100% rename from 2022/completed-demos/05-l2-open-mask-functions-demo-Copy1.ipynb rename to eapython/completed-demos/05-l2-open-mask-functions-demo-Copy1.ipynb diff --git a/2022/completed-demos/05-l2-open-mask-functions-demo.ipynb b/eapython/completed-demos/05-l2-open-mask-functions-demo.ipynb similarity index 100% rename from 2022/completed-demos/05-l2-open-mask-functions-demo.ipynb rename to eapython/completed-demos/05-l2-open-mask-functions-demo.ipynb diff --git a/2022/completed-demos/05-l3-testing-speed-timeit-examples.ipynb b/eapython/completed-demos/05-l3-testing-speed-timeit-examples.ipynb similarity index 100% rename from 2022/completed-demos/05-l3-testing-speed-timeit-examples.ipynb rename to eapython/completed-demos/05-l3-testing-speed-timeit-examples.ipynb diff --git a/2022/completed-demos/05-l4-loops-lists.ipynb b/eapython/completed-demos/05-l4-loops-lists.ipynb similarity index 100% rename from 2022/completed-demos/05-l4-loops-lists.ipynb rename to eapython/completed-demos/05-l4-loops-lists.ipynb diff --git a/2022/completed-demos/06-workflow-lesson-landat-loops.ipynb b/eapython/completed-demos/06-workflow-lesson-landat-loops.ipynb similarity index 100% rename from 2022/completed-demos/06-workflow-lesson-landat-loops.ipynb rename to eapython/completed-demos/06-workflow-lesson-landat-loops.ipynb diff --git a/2022/completed-demos/07-landsat-clean-clip-demo.ipynb b/eapython/completed-demos/07-landsat-clean-clip-demo.ipynb similarity index 100% rename from 2022/completed-demos/07-landsat-clean-clip-demo.ipynb rename to eapython/completed-demos/07-landsat-clean-clip-demo.ipynb diff --git a/2022/completed-demos/07-open-hdf4-python.ipynb b/eapython/completed-demos/07-open-hdf4-python.ipynb similarity index 100% rename from 2022/completed-demos/07-open-hdf4-python.ipynb rename to eapython/completed-demos/07-open-hdf4-python.ipynb diff --git a/2022/completed-demos/08-ap-intro-work-with-json.ipynb b/eapython/completed-demos/08-ap-intro-work-with-json.ipynb similarity index 100% rename from 2022/completed-demos/08-ap-intro-work-with-json.ipynb rename to eapython/completed-demos/08-ap-intro-work-with-json.ipynb diff --git a/2022/completed-demos/08-api-geospatial.ipynb b/eapython/completed-demos/08-api-geospatial.ipynb similarity index 100% rename from 2022/completed-demos/08-api-geospatial.ipynb rename to eapython/completed-demos/08-api-geospatial.ipynb diff --git a/2022/completed-demos/08-api-intro.ipynb b/eapython/completed-demos/08-api-intro.ipynb similarity index 100% rename from 2022/completed-demos/08-api-intro.ipynb rename to eapython/completed-demos/08-api-intro.ipynb diff --git a/2022/completed-demos/08-api-work-with-json.ipynb b/eapython/completed-demos/08-api-work-with-json.ipynb similarity index 100% rename from 2022/completed-demos/08-api-work-with-json.ipynb rename to eapython/completed-demos/08-api-work-with-json.ipynb diff --git a/2022/completed-demos/09-random-forest.ipynb b/eapython/completed-demos/09-random-forest.ipynb similarity index 100% rename from 2022/completed-demos/09-random-forest.ipynb rename to eapython/completed-demos/09-random-forest.ipynb diff --git a/2022/completed-demos/10-kmeans.ipynb b/eapython/completed-demos/10-kmeans.ipynb similarity index 100% rename from 2022/completed-demos/10-kmeans.ipynb rename to eapython/completed-demos/10-kmeans.ipynb diff --git a/2022/in-class-notebooks/05-l1-landsat-cloud-masks-blank.ipynb b/eapython/in-class-notebooks/05-l1-landsat-cloud-masks-blank.ipynb similarity index 100% rename from 2022/in-class-notebooks/05-l1-landsat-cloud-masks-blank.ipynb rename to eapython/in-class-notebooks/05-l1-landsat-cloud-masks-blank.ipynb diff --git a/2022/in-class-notebooks/05-l2-open-mask-functions-demo-blank.ipynb b/eapython/in-class-notebooks/05-l2-open-mask-functions-demo-blank.ipynb similarity index 100% rename from 2022/in-class-notebooks/05-l2-open-mask-functions-demo-blank.ipynb rename to eapython/in-class-notebooks/05-l2-open-mask-functions-demo-blank.ipynb diff --git a/2022/in-class-notebooks/05-l3-testing-speed-timeit-examples-blank.ipynb b/eapython/in-class-notebooks/05-l3-testing-speed-timeit-examples-blank.ipynb similarity index 100% rename from 2022/in-class-notebooks/05-l3-testing-speed-timeit-examples-blank.ipynb rename to eapython/in-class-notebooks/05-l3-testing-speed-timeit-examples-blank.ipynb diff --git a/2022/in-class-notebooks/05-l4-loops-lists-blank-2.ipynb b/eapython/in-class-notebooks/05-l4-loops-lists-blank-2.ipynb similarity index 100% rename from 2022/in-class-notebooks/05-l4-loops-lists-blank-2.ipynb rename to eapython/in-class-notebooks/05-l4-loops-lists-blank-2.ipynb diff --git a/2022/in-class-notebooks/05-l4-loops-lists-blank.ipynb b/eapython/in-class-notebooks/05-l4-loops-lists-blank.ipynb similarity index 100% rename from 2022/in-class-notebooks/05-l4-loops-lists-blank.ipynb rename to eapython/in-class-notebooks/05-l4-loops-lists-blank.ipynb diff --git a/2022/in-class-notebooks/07-open-hdf4-python-blank-filled.ipynb b/eapython/in-class-notebooks/07-open-hdf4-python-blank-filled.ipynb similarity index 100% rename from 2022/in-class-notebooks/07-open-hdf4-python-blank-filled.ipynb rename to eapython/in-class-notebooks/07-open-hdf4-python-blank-filled.ipynb diff --git a/2022/in-class-notebooks/08-api-geospatial.ipynb b/eapython/in-class-notebooks/08-api-geospatial.ipynb similarity index 100% rename from 2022/in-class-notebooks/08-api-geospatial.ipynb rename to eapython/in-class-notebooks/08-api-geospatial.ipynb diff --git a/2022/in-class-notebooks/08-api-work-with-json.ipynb b/eapython/in-class-notebooks/08-api-work-with-json.ipynb similarity index 100% rename from 2022/in-class-notebooks/08-api-work-with-json.ipynb rename to eapython/in-class-notebooks/08-api-work-with-json.ipynb diff --git a/2022/in-class-notebooks/10-kmeans-blank.ipynb b/eapython/in-class-notebooks/10-kmeans-blank.ipynb similarity index 100% rename from 2022/in-class-notebooks/10-kmeans-blank.ipynb rename to eapython/in-class-notebooks/10-kmeans-blank.ipynb diff --git a/2022/in-class-notebooks/11-classes-objects.ipynb b/eapython/in-class-notebooks/11-classes-objects.ipynb similarity index 100% rename from 2022/in-class-notebooks/11-classes-objects.ipynb rename to eapython/in-class-notebooks/11-classes-objects.ipynb diff --git a/eapython/in-class-notebooks/dask-worker-space/global.lock b/eapython/in-class-notebooks/dask-worker-space/global.lock new file mode 100644 index 0000000..e69de29 diff --git a/eapython/in-class-notebooks/dask-worker-space/purge.lock b/eapython/in-class-notebooks/dask-worker-space/purge.lock new file mode 100644 index 0000000..e69de29 diff --git a/eapython/in-class-notebooks/eapython-11-dask-hdf.ipynb b/eapython/in-class-notebooks/eapython-11-dask-hdf.ipynb new file mode 100644 index 0000000..00392bb --- /dev/null +++ b/eapython/in-class-notebooks/eapython-11-dask-hdf.ipynb @@ -0,0 +1,2618 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "c5ab460e", + "metadata": { + "toc": true + }, + "source": [ + "

Table of Contents

\n", + "
    " + ] + }, + { + "cell_type": "code", + "execution_count": 33, + "id": "ff88ffff", + "metadata": {}, + "outputs": [], + "source": [ + "import os\n", + "import pathlib\n", + "from glob import glob\n", + "from math import ceil, floor\n", + "\n", + "import geopandas as gpd\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "import rasterio\n", + "import rioxarray as rxr\n", + "import xarray as xr" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "id": "a354a525", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "matilija_path = os.path.join(\n", + " pathlib.Path.home(),\n", + " 'Documents',\n", + " 'landslide-matilija',\n", + " 'data',\n", + " 'matilija-boundary',\n", + " 'boundary_latlon.zip'\n", + ")\n", + "\n", + "os.path.exists(matilija_path)" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "id": "e3db4d91", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
    FIDgeometry
    0125199354POLYGON ((-119.44426 34.59883, -119.44337 34.5...
    \n", + "
    " + ], + "text/plain": [ + " FID geometry\n", + "0 125199354 POLYGON ((-119.44426 34.59883, -119.44337 34.5..." + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gpd.read_file(matilija_path)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "id": "3e2e66c3", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chirps_path = os.path.join(\n", + " pathlib.Path.home(),\n", + " 'My Drive', \n", + " 'research/', \n", + " 'landslide.regions.sync', \n", + " 'regions_data', \n", + " 'precip_chirps_monthly',\n", + " 'chirps-v2.0.monthly.nc'\n", + ")\n", + "\n", + "os.path.exists(chirps_path)" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "f3488823", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.Dataset>\n",
    +       "Dimensions:    (latitude: 2000, longitude: 7200, time: 479)\n",
    +       "Coordinates:\n",
    +       "  * latitude   (latitude) float32 -49.97 -49.92 -49.88 ... 49.87 49.92 49.97\n",
    +       "  * longitude  (longitude) float32 -180.0 -179.9 -179.9 ... 179.9 179.9 180.0\n",
    +       "  * time       (time) datetime64[ns] 1981-01-01 1981-02-01 ... 2020-11-01\n",
    +       "Data variables:\n",
    +       "    precip     (time, latitude, longitude) float32 ...\n",
    +       "Attributes: (12/15)\n",
    +       "    Conventions:       CF-1.6\n",
    +       "    title:             CHIRPS Version 2.0\n",
    +       "    history:           created by Climate Hazards Group\n",
    +       "    version:           Version 2.0\n",
    +       "    date_created:      2020-12-16\n",
    +       "    creator_name:      Pete Peterson\n",
    +       "    ...                ...\n",
    +       "    reference:         Funk, C.C., Peterson, P.J., Landsfeld, M.F., Pedreros,...\n",
    +       "    comments:           time variable denotes the first day of the given month.\n",
    +       "    acknowledgements:  The Climate Hazards Group InfraRed Precipitation with ...\n",
    +       "    ftp_url:           ftp://chg-ftpout.geog.ucsb.edu/pub/org/chg/products/CH...\n",
    +       "    website:           http://chg.geog.ucsb.edu/data/chirps/index.html\n",
    +       "    faq:               http://chg-wiki.geog.ucsb.edu/wiki/CHIRPS_FAQ
    " + ], + "text/plain": [ + "\n", + "Dimensions: (latitude: 2000, longitude: 7200, time: 479)\n", + "Coordinates:\n", + " * latitude (latitude) float32 -49.97 -49.92 -49.88 ... 49.87 49.92 49.97\n", + " * longitude (longitude) float32 -180.0 -179.9 -179.9 ... 179.9 179.9 180.0\n", + " * time (time) datetime64[ns] 1981-01-01 1981-02-01 ... 2020-11-01\n", + "Data variables:\n", + " precip (time, latitude, longitude) float32 ...\n", + "Attributes: (12/15)\n", + " Conventions: CF-1.6\n", + " title: CHIRPS Version 2.0\n", + " history: created by Climate Hazards Group\n", + " version: Version 2.0\n", + " date_created: 2020-12-16\n", + " creator_name: Pete Peterson\n", + " ... ...\n", + " reference: Funk, C.C., Peterson, P.J., Landsfeld, M.F., Pedreros,...\n", + " comments: time variable denotes the first day of the given month.\n", + " acknowledgements: The Climate Hazards Group InfraRed Precipitation with ...\n", + " ftp_url: ftp://chg-ftpout.geog.ucsb.edu/pub/org/chg/products/CH...\n", + " website: http://chg.geog.ucsb.edu/data/chirps/index.html\n", + " faq: http://chg-wiki.geog.ucsb.edu/wiki/CHIRPS_FAQ" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chirps = xr.open_dataset(chirps_path)\n", + "chirps" + ] + }, + { + "cell_type": "code", + "execution_count": 18, + "id": "6c55be76", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CPU times: user 2min 13s, sys: 3min 32s, total: 5min 45s\n", + "Wall time: 7min 56s\n" + ] + }, + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.Dataset>\n",
    +       "Dimensions:  ()\n",
    +       "Data variables:\n",
    +       "    precip   float32 72.36
    " + ], + "text/plain": [ + "\n", + "Dimensions: ()\n", + "Data variables:\n", + " precip float32 72.36" + ] + }, + "execution_count": 18, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%time\n", + "chirps = xr.open_dataset(chirps_path)\n", + "chirps.mean()" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "bf19691b", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.Dataset>\n",
    +       "Dimensions:    (latitude: 2000, longitude: 7200, time: 479)\n",
    +       "Coordinates:\n",
    +       "  * latitude   (latitude) float32 -49.97 -49.92 -49.88 ... 49.87 49.92 49.97\n",
    +       "  * longitude  (longitude) float32 -180.0 -179.9 -179.9 ... 179.9 179.9 180.0\n",
    +       "  * time       (time) datetime64[ns] 1981-01-01 1981-02-01 ... 2020-11-01\n",
    +       "Data variables:\n",
    +       "    precip     (time, latitude, longitude) float32 dask.array<chunksize=(50, 2000, 7200), meta=np.ndarray>\n",
    +       "Attributes: (12/15)\n",
    +       "    Conventions:       CF-1.6\n",
    +       "    title:             CHIRPS Version 2.0\n",
    +       "    history:           created by Climate Hazards Group\n",
    +       "    version:           Version 2.0\n",
    +       "    date_created:      2020-12-16\n",
    +       "    creator_name:      Pete Peterson\n",
    +       "    ...                ...\n",
    +       "    reference:         Funk, C.C., Peterson, P.J., Landsfeld, M.F., Pedreros,...\n",
    +       "    comments:           time variable denotes the first day of the given month.\n",
    +       "    acknowledgements:  The Climate Hazards Group InfraRed Precipitation with ...\n",
    +       "    ftp_url:           ftp://chg-ftpout.geog.ucsb.edu/pub/org/chg/products/CH...\n",
    +       "    website:           http://chg.geog.ucsb.edu/data/chirps/index.html\n",
    +       "    faq:               http://chg-wiki.geog.ucsb.edu/wiki/CHIRPS_FAQ
    " + ], + "text/plain": [ + "\n", + "Dimensions: (latitude: 2000, longitude: 7200, time: 479)\n", + "Coordinates:\n", + " * latitude (latitude) float32 -49.97 -49.92 -49.88 ... 49.87 49.92 49.97\n", + " * longitude (longitude) float32 -180.0 -179.9 -179.9 ... 179.9 179.9 180.0\n", + " * time (time) datetime64[ns] 1981-01-01 1981-02-01 ... 2020-11-01\n", + "Data variables:\n", + " precip (time, latitude, longitude) float32 dask.array\n", + "Attributes: (12/15)\n", + " Conventions: CF-1.6\n", + " title: CHIRPS Version 2.0\n", + " history: created by Climate Hazards Group\n", + " version: Version 2.0\n", + " date_created: 2020-12-16\n", + " creator_name: Pete Peterson\n", + " ... ...\n", + " reference: Funk, C.C., Peterson, P.J., Landsfeld, M.F., Pedreros,...\n", + " comments: time variable denotes the first day of the given month.\n", + " acknowledgements: The Climate Hazards Group InfraRed Precipitation with ...\n", + " ftp_url: ftp://chg-ftpout.geog.ucsb.edu/pub/org/chg/products/CH...\n", + " website: http://chg.geog.ucsb.edu/data/chirps/index.html\n", + " faq: http://chg-wiki.geog.ucsb.edu/wiki/CHIRPS_FAQ" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "chirps = xr.open_dataset(chirps_path, chunks={'time': 50})\n", + "chirps.chunks\n", + "chirps" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "35960051", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CPU times: user 2min 34s, sys: 36 s, total: 3min 10s\n", + "Wall time: 2min 33s\n" + ] + }, + { + "data": { + "text/plain": [ + "array(72.36323, dtype=float32)" + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%time\n", + "chirps = xr.open_dataset(chirps_path, chunks=\"auto\")\n", + "chirps.mean()['precip'].values" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "a0675190", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "cfb5ba3ee4c140b38e191bb0733edbf3", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + "Tab(children=(HTML(value='
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.DataArray (y: 2400, x: 2400)>\n",
    +       "[5760000 values with dtype=float32]\n",
    +       "Coordinates:\n",
    +       "    band         int64 1\n",
    +       "  * x            (x) float64 -1.112e+07 -1.112e+07 ... -1.001e+07 -1.001e+07\n",
    +       "  * y            (y) float64 4.448e+06 4.447e+06 ... 3.337e+06 3.336e+06\n",
    +       "    spatial_ref  int64 0\n",
    +       "Attributes:\n",
    +       "    scale_factor:  0.1\n",
    +       "    add_offset:    0.0\n",
    +       "    long_name:     MOD15A2H MODIS/Terra Gridded 500M Leaf Area Index LAI (8-d...\n",
    +       "    units:         m^2/m^2
    " + ], + "text/plain": [ + "\n", + "[5760000 values with dtype=float32]\n", + "Coordinates:\n", + " band int64 1\n", + " * x (x) float64 -1.112e+07 -1.112e+07 ... -1.001e+07 -1.001e+07\n", + " * y (y) float64 4.448e+06 4.447e+06 ... 3.337e+06 3.336e+06\n", + " spatial_ref int64 0\n", + "Attributes:\n", + " scale_factor: 0.1\n", + " add_offset: 0.0\n", + " long_name: MOD15A2H MODIS/Terra Gridded 500M Leaf Area Index LAI (8-d...\n", + " units: m^2/m^2" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rxr.open_rasterio(ds_names[0], masked=True).squeeze() " + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "id": "37524e5f", + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
    \n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
    <xarray.DataArray (time: 770, y: 2400, x: 2400)>\n",
    +       "array([[[254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        [254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        [254., 254., 254., ...,   3.,   3.,   2.],\n",
    +       "        ...,\n",
    +       "        [  2.,   3.,   2., ...,   5.,   5.,   5.],\n",
    +       "        [  2.,   3.,   3., ...,   5.,   5.,   5.],\n",
    +       "        [  2.,   2.,   2., ...,   5.,   5.,   6.]],\n",
    +       "\n",
    +       "       [[254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        [254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        [254., 254., 254., ...,   2.,   3.,   3.],\n",
    +       "        ...,\n",
    +       "        [  1.,   2.,   2., ...,   5.,   5.,   5.],\n",
    +       "        [  2.,   2.,   2., ...,   5.,   5.,   5.],\n",
    +       "        [  2.,   2.,   2., ...,   5.,   7.,   5.]],\n",
    +       "\n",
    +       "       [[254., 254., 254., ...,   1.,   1.,   1.],\n",
    +       "        [254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        [254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        ...,\n",
    +       "...\n",
    +       "        ...,\n",
    +       "        [  3.,   2.,   3., ...,   4.,   4.,   3.],\n",
    +       "        [  2.,   2.,   3., ...,   4.,   4.,   3.],\n",
    +       "        [  2.,   3.,   2., ...,   3.,   3.,   3.]],\n",
    +       "\n",
    +       "       [[254., 254., 254., ...,   2.,   2.,   3.],\n",
    +       "        [254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        [254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        ...,\n",
    +       "        [  3.,   3.,   2., ...,   3.,   3.,   3.],\n",
    +       "        [  3.,   2.,   3., ...,   4.,   3.,   3.],\n",
    +       "        [  3.,   2.,   3., ...,   3.,   3.,   3.]],\n",
    +       "\n",
    +       "       [[254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        [254., 254., 254., ...,   2.,   2.,   3.],\n",
    +       "        [254., 254., 254., ...,   2.,   2.,   2.],\n",
    +       "        ...,\n",
    +       "        [  2.,   2.,   3., ...,   5.,   4.,   3.],\n",
    +       "        [  3.,   3.,   3., ...,   4.,   4.,   4.],\n",
    +       "        [  2.,   3.,   3., ...,   3.,   4.,   4.]]], dtype=float32)\n",
    +       "Coordinates:\n",
    +       "    band         int64 1\n",
    +       "  * x            (x) float64 -1.112e+07 -1.112e+07 ... -1.001e+07 -1.001e+07\n",
    +       "  * y            (y) float64 4.448e+06 4.447e+06 ... 3.337e+06 3.336e+06\n",
    +       "    spatial_ref  int64 0\n",
    +       "Dimensions without coordinates: time\n",
    +       "Attributes:\n",
    +       "    scale_factor:  0.1\n",
    +       "    add_offset:    0.0\n",
    +       "    long_name:     MOD15A2H MODIS/Terra Gridded 500M Leaf Area Index LAI (8-d...\n",
    +       "    units:         m^2/m^2
    " + ], + "text/plain": [ + "\n", + "array([[[254., 254., 254., ..., 2., 2., 2.],\n", + " [254., 254., 254., ..., 2., 2., 2.],\n", + " [254., 254., 254., ..., 3., 3., 2.],\n", + " ...,\n", + " [ 2., 3., 2., ..., 5., 5., 5.],\n", + " [ 2., 3., 3., ..., 5., 5., 5.],\n", + " [ 2., 2., 2., ..., 5., 5., 6.]],\n", + "\n", + " [[254., 254., 254., ..., 2., 2., 2.],\n", + " [254., 254., 254., ..., 2., 2., 2.],\n", + " [254., 254., 254., ..., 2., 3., 3.],\n", + " ...,\n", + " [ 1., 2., 2., ..., 5., 5., 5.],\n", + " [ 2., 2., 2., ..., 5., 5., 5.],\n", + " [ 2., 2., 2., ..., 5., 7., 5.]],\n", + "\n", + " [[254., 254., 254., ..., 1., 1., 1.],\n", + " [254., 254., 254., ..., 2., 2., 2.],\n", + " [254., 254., 254., ..., 2., 2., 2.],\n", + " ...,\n", + "...\n", + " ...,\n", + " [ 3., 2., 3., ..., 4., 4., 3.],\n", + " [ 2., 2., 3., ..., 4., 4., 3.],\n", + " [ 2., 3., 2., ..., 3., 3., 3.]],\n", + "\n", + " [[254., 254., 254., ..., 2., 2., 3.],\n", + " [254., 254., 254., ..., 2., 2., 2.],\n", + " [254., 254., 254., ..., 2., 2., 2.],\n", + " ...,\n", + " [ 3., 3., 2., ..., 3., 3., 3.],\n", + " [ 3., 2., 3., ..., 4., 3., 3.],\n", + " [ 3., 2., 3., ..., 3., 3., 3.]],\n", + "\n", + " [[254., 254., 254., ..., 2., 2., 2.],\n", + " [254., 254., 254., ..., 2., 2., 3.],\n", + " [254., 254., 254., ..., 2., 2., 2.],\n", + " ...,\n", + " [ 2., 2., 3., ..., 5., 4., 3.],\n", + " [ 3., 3., 3., ..., 4., 4., 4.],\n", + " [ 2., 3., 3., ..., 3., 4., 4.]]], dtype=float32)\n", + "Coordinates:\n", + " band int64 1\n", + " * x (x) float64 -1.112e+07 -1.112e+07 ... -1.001e+07 -1.001e+07\n", + " * y (y) float64 4.448e+06 4.447e+06 ... 3.337e+06 3.336e+06\n", + " spatial_ref int64 0\n", + "Dimensions without coordinates: time\n", + "Attributes:\n", + " scale_factor: 0.1\n", + " add_offset: 0.0\n", + " long_name: MOD15A2H MODIS/Terra Gridded 500M Leaf Area Index LAI (8-d...\n", + " units: m^2/m^2" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# Open NDVI files with xarray\n", + "ndvi_xr = xr.concat(\n", + " [rxr.open_rasterio(ds, masked=True).squeeze() \n", + " for ds in ds_names], \n", + " dim='time')\n", + "ndvi_xr" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.12" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": true, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": true, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/2022/in-class-notebooks/modules/bbox.py b/eapython/in-class-notebooks/modules/bbox.py similarity index 100% rename from 2022/in-class-notebooks/modules/bbox.py rename to eapython/in-class-notebooks/modules/bbox.py