diff --git a/Real_world_examples/Intertidal_exposure.ipynb b/Real_world_examples/Intertidal_exposure.ipynb new file mode 100644 index 000000000..79093c2a3 --- /dev/null +++ b/Real_world_examples/Intertidal_exposure.ipynb @@ -0,0 +1,2130 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "# Model and customise intertidal exposure \n", + "\n", + "* [**Sign up to the DEA Sandbox**](https://docs.dea.ga.gov.au/setup/sandbox.html) to run this notebook interactively from a browser\n", + "* **Compatibility:** Notebook currently compatible with the `DEA Sandbox` environment\n", + "* **Products used:** \n", + "[ga_s2ls_intertidal_cyear_3](https://knowledge.dea.ga.gov.au/data/product/dea-intertidal/),\n", + "[ga_ls8cls9c_gm_cyear_3](https://explorer.dea.ga.gov.au/products/ga_ls8cls9c_gm_cyear_3)" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "tags": [] + }, + "source": [ + "## Background\n", + "### Intertidal exposure\n", + "\n", + "Intertidal coastlines support a wide array of habitats and coastal and marine species.\n", + "Low energy tidal flats often support mangrove and seagrass habitats which in turn play host to sea birds, mammals and reptiles. \n", + "Tropical and subtropical intertidal coral reefs provide habitat, food and shelter.\n", + "Soft sediment coastlines support microphytobenthos and intertidal algae are ubiquitously distributed across Australia.\n", + "\n", + "The combined effects of tide, sun and air make intertidal environments one of the most dynamic places for life on Earth.\n", + "Consequently, ecological niches exist within these environments where optimal conditions vary over timescales that range from daily to seasonally and beyond.\n", + "Seagrass, coral and algae, for instance, all experience decline under varying combinations of exposure with season, solar irradiance and air temperature.\n", + "Intertidal exposure characteristics and the prevalence of these species in intertidal habitats can further influence the presence and distribution of other intertidal occupying species, such as seabirds and dugongs.\n", + "\n", + "Intertidal exposure describes the amount of time that intertidal areas are exposed to air from tide coverage.\n", + "Leveraging intertidal elevation mapping, the exposure calculation translates high temporal resolution tidal modelling to determine percentage exposure times for intertidal regions, at 10 m2 resolution.\n", + "Exploiting the local influences of tidal harmonic inputs into global tidal modelling, intertidal exposure mapping can tease out exposure patterns over temporal scales such as daytime, nighttime or season.\n", + "\n", + "Mapping the exposure dynamics of intertidal areas and contrasting their patterns of change over varying timescales supports our ability to further characterise and understand intertidal habitats.\n", + "Supporting an array of important marine species, it also offers insights into how exposure patterns influence species behaviours and distributions over short (month to season) to long (multi-annual) timescales." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Description\n", + "\n", + "This notebook outlines the general methodology required to calculate intertidal exposure and demonstrates how tailored calculations can be used to investigate specific temporal influences on exposure times in intertidal ecosystems.\n", + "\n", + "In this notebook, users will:\n", + "1. Use a conceptual model to understand how the intertidal exposure calculation is derived.\n", + "2. Through the use of case studies, calculate:\n", + "\n", + " - Full exposure characteristics\n", + " - Seasonally filtered exposure characteristics\n", + " - Combined seasonal and daily exposure characteristics\n", + " - Inverted exposure to calculate monthly, night time inundation characteristics\n", + " \n", + "***" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Introduction to the intertidal exposure calculation method\n", + "\n", + "DEA Intertidal Exposure models the percentage of time that any intertidal pixel of known elevation is exposed from tidal inundation. \n", + "Exposure is calculated by comparing the pixel elevation back against a high temporal resolution model of tide heights for that location. \n", + "Exposure percentage represents the proportion of tidally exposed observations (those lower than the pixel elevation) relative to the total number of tide model observations, generated for the 3-year product epoch.\n", + "\n", + "This is demonstrated in the figure below where panel *a* shows the digital elevation model for Carnot Bay in Western Australia, produced for the three year epoch centered around 2016.\n", + "A tide model was generated at 30 minute time intervals for the same temporal epoch (panel b) and is summarised in the cumulative distribution curve in panel *d*.\n", + "For computational efficiency, a single tide height model is generated to represent the entire area of interest (panel a).\n", + "Additionally, modelled tide heights and intertidal elevations are mapped to the same datum - meters above mean sea level (msl).\n", + "Intertidal exposure (panel c) is calculated for every elevation value (y-axis panel d) as the equivalent percentile distribution of modelled tide heights (x-axis, panel d).\n", + "This equates to the fraction of all modelled tides that were exposed per elevation during the modelled epoch and is used as a proxy for time, where:\n", + "\n", + "
Exposure Elevation z = Tide height percentile * 100 %
\n", + "In panel d, this is demonstrated by the grey-dashed line, where\n", + "Exposure -1.0 msl =0.3 * 100 = 30 %
\n", + "In other words, 30 % of tide heights, modelled at 30 min intervals between 1 Jan 2015 and 31 Dec 2017 (panel b), occur at or below intertidal elevations of -1.0 msl, meaning this elevation is exposed from inundation for 30 % of the modelled time period.\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Custom filtering of the intertidal exposure calculation\n", + "\n", + "In addition to modelling exposure for a full time period, the exposure algorithm supports filtering of selected time periods from within the epoch.\n", + "This enables the exploration of exposure dynamics across a range of custom time periods, including day, night, month and season as well as combinations of time periods, e.g. Daytime-Summer exposure.\n", + "Users should note that the exposure calculation is performed against a single all-epoch time elevation model of the area of interest.\n", + "\n", + "The animated figure below demonstrates the effect on exposure (panel a) of filtering time periods of interest from within the tidal model (panel b) on the resultant percentile tide height curve (panel c).\n", + "Temporal filtering of the exposure model exploits natural changes in the local tide model, influenced by tidal harmonics, local bathymetry and the relative position of the Earth to the moon and sun.\n", + "The effect of temporal filtering on the exposure maps (panel a) is most pronounced at the upper and lower ends of the modelled tide height range (panel c).\n", + "Local tide modelling varies widely across Australian coastlines and so the impact of these end-member influences will vary with location.\n", + "Furthermore, satellite biases in high and low tide image acquisition for some locations may also produce gaps in the modelling of intertidal elevation as well as exposure at these extreme ends of the tide range.\n", + "Caused by the sun-synchronous orbits of the sensors used to capture baseline datasets in these models, offsets in the imaging of extreme tide heights are mapped in the [DEA Intertidal](https://knowledge.dea.ga.gov.au/data/product/dea-intertidal/) data suite and are demonstrated in a following section of this notebook.\n", + "\n", + "\n", + "" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Getting started\n", + "\n", + "To run this analysis, start with the \"Load packages\" cell.\n", + "Using the \"Run\" menu at the top of the page, select \"Run All Cells\".\n", + "\n", + "To edit this analysis for your own area of interest, update the parameters in the \"Analysis parameters\" cell below.\n", + "Rename the `study_area` parameter and replace the `x` and `y` coordinates for diagonally opposite latitude and longitude pairs in your area of interest, using the WGS84/EPSG:4326 coordinate reference system.\n", + "For support using other coordinate reference systems, see the [DEA Notebooks Beginners Guide](../Beginners_guide/04_Loading_data.ipynb).\n", + "To find your coordinates, we recommend using [DEA Maps](https://maps.dea.ga.gov.au).\n", + "To change the annual summary views, look for documented directions to update the `time` parameter throughout the analysis." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Load packages\n", + "Import Python packages that are used for the analysis." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Collecting git+https://github.com/GeoscienceAustralia/dea-intertidal.git@develop\n", + " Cloning https://github.com/GeoscienceAustralia/dea-intertidal.git (to revision develop) to /tmp/pip-req-build-dfkyguku\n", + " Running command git clone --filter=blob:none --quiet https://github.com/GeoscienceAustralia/dea-intertidal.git /tmp/pip-req-build-dfkyguku\n", + " Resolved https://github.com/GeoscienceAustralia/dea-intertidal.git to commit d794b9ff509952e2ca462b22d20d9f0166f639e2\n", + " Preparing metadata (setup.py) ... \u001b[?25ldone\n", + "\u001b[?25hCollecting sunriset\n", + " Using cached sunriset-1.0-py3-none-any.whl.metadata (2.2 kB)\n", + "Requirement already satisfied: pytz in /env/lib/python3.10/site-packages (from sunriset) (2024.1)\n", + "Requirement already satisfied: pandas in /env/lib/python3.10/site-packages (from sunriset) (2.2.2)\n", + "Requirement already satisfied: numpy>=1.22.4 in /env/lib/python3.10/site-packages (from pandas->sunriset) (1.26.4)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in /env/lib/python3.10/site-packages (from pandas->sunriset) (2.9.0)\n", + "Requirement already satisfied: tzdata>=2022.7 in /env/lib/python3.10/site-packages (from pandas->sunriset) (2024.1)\n", + "Requirement already satisfied: six>=1.5 in /env/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas->sunriset) (1.16.0)\n", + "Using cached sunriset-1.0-py3-none-any.whl (9.6 kB)\n", + "Installing collected packages: sunriset\n", + "Successfully installed sunriset-1.0\n" + ] + } + ], + "source": [ + "# Install some non-default functionality\n", + "!pip install git+https://github.com/GeoscienceAustralia/dea-intertidal.git@develop\n", + "!pip install sunriset" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you encounter any issues running the following cell after this install step, consider restarting the kernel.\n", + "From the top menu, select `Kernel` then `Restart Kernel...` and continue running the notebook from the following cell." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "import datacube\n", + "import cmocean\n", + "import glob\n", + "import os\n", + "import numpy as np\n", + "import xarray as xr\n", + "import imageio.v2 as imageio\n", + "import matplotlib.pyplot as plt\n", + "from IPython.display import Image\n", + "from IPython import display\n", + "from IPython.core.display import Video\n", + "from ipywidgets import Output, GridspecLayout\n", + "\n", + "import odc.geo.xr\n", + "from datacube.utils.cog import write_cog\n", + "from datacube.utils.masking import mask_invalid_data\n", + "from dea_tools.plotting import display_map, xr_animation, rgb\n", + "\n", + "from intertidal.exposure import exposure" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Connect to the DEA datacube\n", + "\n", + "Connect to the DEA database. The `app` parameter is unique to the analysis in this notebook." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "# Connect to the datacube to access DEA data.\n", + "dc = datacube.Datacube(app='Customising_Intertidal_Exposure')" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Load data\n", + "The following cells will:\n", + "* connect to the DEA datacube,\n", + "* identify and show the analysis parameters, \n", + "* load satellite and intertidal data for an area of interest, and \n", + "* plot the outputs as maps, summary graphs and animations\n", + "\n", + "The default area of interest for this analysis is Queensland's Smithburne River mouth which flows into the eastern side of the Gulf of Carpentaria.\n", + "Its vast and dynamic intertidal area forms part of the extensive East Asian-Australasian Flyway for migratory seabirds in the Gulf of Carpentaria.\n", + "Recognised as a wetland of national significance, it is also a region that hosts significant patches of seagrass and supports a wide variety of marine fauna populations." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Analysis parameters\n", + "\n", + "The Smithburne River is used here to demonstrate how various calculations of intertidal exposure can reveal insights into intertidal environments.\n", + "Once you have run this notebook through start to finish, try editing the study area and coordinates in the cell below to explore your own small area of interest.\n", + "\n", + "* `study_area` : Location name (e.g. `\"Gladstone_Harbour\"`)\n", + "* `query_params` : Parameters to define the total area and period of interest\n", + " * `y` : Latitude coordinates (e.g. `(-23.74437, -23.78851)`). Decimal degree coordinates for the diagonnally opposite corners of your area of interest\n", + " * `x` : Longitude coordinates (e.g. `(151.24299, 151.32091)`). Decimal degree coordinates for the diagonnally opposite corners of your area of interest (corresponding to corners used for `y`)\n", + " * `time` : Analysis period (e.g. `(\"2016\", \"2022\")`). A single year or pair of years between which, all `DEA Intertidal` datasets will be returned. Note: data can only be requested annually from 2016 onwards.\n", + "* `freq` : The temporal frequency used to generate the modelled tide heights (e.g. \"2 H\" or \"30 min\"). For computational efficiency, we have nominated a 2 hour frequency for this workbook. For research applications, we recommend a higher frequency, e.g. 30 minutes. Higher frequencies come at the expense of a slower compute time." + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/html": [ + "<xarray.Dataset> Size: 54MB\n", + "Dimensions: (time: 7, y: 654, x: 734)\n", + "Coordinates:\n", + " * time (time) datetime64[ns] 56B 2016-07-01T23:59:59.999999 ... ...\n", + " * y (y) float64 5kB -1.85e+06 -1.85e+06 ... -1.857e+06\n", + " * x (x) float64 6kB 9.495e+05 9.495e+05 ... 9.568e+05 9.569e+05\n", + " spatial_ref int32 4B 3577\n", + "Data variables:\n", + " elevation (time, y, x) float32 13MB nan nan nan nan ... nan nan nan\n", + " exposure (time, y, x) float32 13MB nan nan nan nan ... nan nan nan\n", + " ta_offset_high (time, y, x) float32 13MB 7.0 7.0 7.0 7.0 ... 3.0 3.0 3.0\n", + " ta_offset_low (time, y, x) float32 13MB 5.0 5.0 5.0 5.0 ... 2.0 2.0 2.0\n", + "Attributes:\n", + " crs: EPSG:3577\n", + " grid_mapping: spatial_ref