Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate dhdt with ICESat-2 ATL11 data over Antarctica #41

Merged
merged 5 commits into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:

- name: Install Poetry python dependencies
shell: bash -l {0}
run: poetry install --
run: poetry install --no-root
if: steps.cache.outputs.cache-hit != 'true'

- name: Install deepicedrain package
Expand Down
52 changes: 28 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ in Antarctica using remote sensing and machine learning.
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=weiji14/deepicedrain)](https://dependabot.com)
![License](https://img.shields.io/github/license/weiji14/deepicedrain)

![ATL11 Cycle 6 minus Cycle 5 height change over Antarctica](https://user-images.githubusercontent.com/23487320/83100017-ffb0ba00-a102-11ea-9603-ac469f09e58b.png)
![ICESat-2 ATL11 rate of height change over time in Antarctica](https://user-images.githubusercontent.com/23487320/83498673-4e4dc200-a510-11ea-8980-b71aa0f89a80.png)

![DeepIceDrain Pipeline](https://yuml.me/diagram/scruffy;dir:LR/class/[Land-Ice-Elevation|atl06_play.ipynb]->[Convert|atl06_to_atl11.ipynb],[Convert]->[Ice-Sheet-H(t)-Series|atl11_play.ipynb])
![DeepIceDrain Pipeline](https://yuml.me/diagram/scruffy;dir:LR/class/[Land-Ice-Elevation|atl06_play.ipynb]->[Convert|atl06_to_atl11.ipynb],[Convert]->[Ice-Sheet-H(t)-Series|atl11_play.ipynb],[Ice-Sheet-H(t)-Series]->[Height-Change-over-Time-(dhdt)|atlxi_dhdt.ipynb])

# Getting started

Expand All @@ -21,6 +21,32 @@ Launch in [Pangeo Binder](https://pangeo-binder.readthedocs.io) (Interactive jup

[![Binder](https://binder.pangeo.io/badge_logo.svg)](https://binder.pangeo.io/v2/gh/weiji14/deepicedrain/master)

## Usage

Once you've installed properly installed the [`deepicedrain` package](deepicedrain)
(see installation instructions further below), you'll have access to a range
of tools for downloading and performing quick calculations on ICESat-2 datasets.
The example below shows how to calculate ice surface elevation change
on a sample ATL11 dataset between ICESat's Cycle 3 and Cycle 4.

import deepicedrain
import xarray as xr

# Loads a sample ATL11 file from the intake catalog into xarray
atl11_dataset: xr.Dataset = deepicedrain.catalog.test_data.atl11_test_case.read()

# Calculate elevation change in metres from ICESat-2 Cycle 3 to Cycle 4
delta_height: xr.DataArray = deepicedrain.calculate_delta(
dataset=atl11_dataset, oldcyclenum=3, newcyclenum=4, variable="h_corr"
)

# Quick plot of delta_height along the ICESat-2 track
delta_height.plot()

![ATL11 delta_height along ref_pt track](https://user-images.githubusercontent.com/23487320/83319030-bf7e4280-a28e-11ea-9bed-331e35dbc266.png)



## Installation

### Basic
Expand Down Expand Up @@ -69,28 +95,6 @@ Finally, double-check that the libraries have been installed.
jupyter kernelspec list --json # see if kernel is installed
jupyter lab &

## Usage

Once you've installed properly installed the `deepicedrain` package,
you can use it to do some quick calculations on ICESat-2 datasets.
The example below shows how to calculate ice surface elevation change
on a sample ATL11 dataset between ICESat's Cycle 3 and Cycle 4.

import deepicedrain
import xarray as xr

# Loads a sample ATL11 file from the intake catalog into xarray
atl11_dataset: xr.Dataset = deepicedrain.catalog.test_data.atl11_test_case.read()

# Calculate elevation change in metres from ICESat-2 Cycle 3 to Cycle 4
delta_height: xr.DataArray = deepicedrain.calculate_delta(
dataset=atl11_dataset, oldcyclenum=3, newcyclenum=4, variable="h_corr"
)

# Quick plot of delta_height along the ICESat-2 track
delta_height.plot()

![ATL11 delta_height along ref_pt track](https://user-images.githubusercontent.com/23487320/83319030-bf7e4280-a28e-11ea-9bed-331e35dbc266.png)

## Related Projects

Expand Down
84 changes: 40 additions & 44 deletions atl11_play.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -250,25 +250,38 @@
"outputs": [],
"source": [
"# Dictionary of Antarctic bounding box locations with EPSG:3031 coordinates\n",
"regions = {\n",
"regions: dict = {\n",
" \"kamb\": deepicedrain.Region(\n",
" name=\"Kamb Ice Stream\",\n",
" xmin=-739741.7702261859,\n",
" xmax=-411054.19240523444,\n",
" ymin=-699564.516934089,\n",
" ymax=-365489.6822096751,\n",
" xmin=-411054.19240523444,\n",
" xmax=-365489.6822096751,\n",
" ymin=-739741.7702261859,\n",
" ymax=-699564.516934089,\n",
" ),\n",
" \"antarctica\": deepicedrain.Region(\n",
" \"Antarctica\", -2700000, 2800000, -2200000, 2300000\n",
" ),\n",
" \"siple_coast\": deepicedrain.Region(\n",
" \"Siple Coast\", -1000000, 250000, -1000000, -100000\n",
" ),\n",
" \"kamb2\": deepicedrain.Region(\"Kamb Ice Stream\", -500000, -400000, -600000, -500000),\n",
" \"whillans\": deepicedrain.Region(\n",
" \"Whillans Ice Stream\", -350000, -100000, -700000, -450000\n",
" ),\n",
"}"
" \"whillans2\": deepicedrain.Region(\n",
" \"Whillans Ice Stream\", -500000, -400000, -600000, -500000\n",
" ),\n",
"}\n",
"# Subset to essential columns\n",
"essential_columns: list = [\n",
" \"x\",\n",
" \"y\",\n",
" \"utc_time\",\n",
" \"h_corr\",\n",
" \"longitude\",\n",
" \"latitude\",\n",
" \"delta_time\",\n",
" \"cycle_number\",\n",
"]"
]
},
{
Expand All @@ -278,8 +291,9 @@
"outputs": [],
"source": [
"# Do the actual computation to find data points within region of interest\n",
"region = regions[\"kamb\"] # Select Kamb Ice Stream region\n",
"ds_subset = region.subset(ds=ds)\n",
"placename: str = \"kamb\" # Select Kamb Ice Stream region\n",
"region: deepicedrain.Region = regions[placename]\n",
"ds_subset: xr.Dataset = region.subset(ds=ds)\n",
"ds_subset = ds_subset.unify_chunks()\n",
"ds_subset = ds_subset.compute()"
]
Expand All @@ -301,12 +315,12 @@
}
],
"source": [
"# Save to NetCDF/Zarr formats for distribution\n",
"ds_subset.to_netcdf(\n",
" path=\"atl11_subset.nc\", engine=\"h5netcdf\",\n",
")\n",
"# Save to Zarr/NetCDF formats for distribution\n",
"ds_subset.to_zarr(\n",
" store=\"atl11_subset.zarr\", mode=\"w\", consolidated=True,\n",
" store=f\"ATLXI/ds_subset_{placename}.zarr\", mode=\"w\", consolidated=True,\n",
")\n",
"ds_subset.to_netcdf(\n",
" path=f\"ATLXI/ds_subset_{placename}.nc\", engine=\"h5netcdf\",\n",
")"
]
},
Expand Down Expand Up @@ -337,7 +351,7 @@
"source": [
"# Plot our subset of points on an interactive map\n",
"df_subset.hvplot.points(\n",
" title=f\"Elevation (metres) at Cycle {cycle_number}\",\n",
" title=f\"Elevation (metres) at Cycle 6\",\n",
" x=\"x\",\n",
" y=\"y\",\n",
" c=\"h_corr\",\n",
Expand Down Expand Up @@ -377,17 +391,6 @@
"outputs": [],
"source": [
"cycle_number: int = 6\n",
"# Subset to essential columns\n",
"essential_columns = [\n",
" \"x\",\n",
" \"y\",\n",
" \"utc_time\",\n",
" \"h_corr\",\n",
" \"longitude\",\n",
" \"latitude\",\n",
" \"delta_time\",\n",
" \"cycle_number\",\n",
"]\n",
"dss = ds.sel(cycle_number=cycle_number)[[*essential_columns]]\n",
"dss"
]
Expand Down Expand Up @@ -599,7 +602,7 @@
"metadata": {},
"outputs": [],
"source": [
"delta_h = dh.dropna(dim=\"ref_pt\").to_dataset(name=\"delta_height\")\n",
"delta_h: xr.Dataset = dh.dropna(dim=\"ref_pt\").to_dataset(name=\"delta_height\")\n",
"delta_h"
]
},
Expand All @@ -609,8 +612,8 @@
"metadata": {},
"outputs": [],
"source": [
"dhdf = delta_h.to_dataframe()\n",
"dhdf.head()"
"df_dh: pd.DataFrame = delta_h.to_dataframe()\n",
"df_dh.head()"
]
},
{
Expand All @@ -619,9 +622,10 @@
"metadata": {},
"outputs": [],
"source": [
"# dhdf.to_parquet(\"temp_dhdf.parquet\")\n",
"# dhdf = pd.read_parquet(\"temp_dhdf.parquet\")\n",
"# dhdf = dhdf.sample(n=1_000_000)"
"# Save or Load delta height data\n",
"# df_dh.to_parquet(f\"ATLXI/df_dh_{placename}.parquet\")\n",
"# df_dh: pd.DataFrame = pd.read_parquet(f\"ATLXI/df_dh_{placename}.parquet\")\n",
"# df_dh = df_dh.sample(n=1_000_000)"
]
},
{
Expand Down Expand Up @@ -681,15 +685,7 @@
"outputs": [],
"source": [
"# Datashade our height values (vector points) onto a grid (raster image)\n",
"canvas = datashader.Canvas(\n",
" plot_width=900,\n",
" plot_height=900,\n",
" x_range=(region.xmin, region.xmax),\n",
" y_range=(region.ymin, region.ymax),\n",
")\n",
"agg_grid = canvas.points(\n",
" source=dhdf, x=\"x\", y=\"y\", agg=datashader.mean(column=\"delta_height\")\n",
")\n",
"agg_grid: xr.DataArray = region.datashade(df=df_dh, z_dim=\"delta_height\")\n",
"agg_grid"
]
},
Expand Down Expand Up @@ -749,7 +745,7 @@
"fig.colorbar(\n",
" position=\"JCR+e\", frame=[\"af\", 'x+l\"Elevation Change from Cycle 5 to 6\"', \"y+lm\"],\n",
")\n",
"fig.savefig(f\"figures/plot_atl11_{placename}.png\")\n",
"fig.savefig(f\"figures/plot_atl11_dh56_{placename}.png\")\n",
"fig.show(width=600)"
]
},
Expand Down Expand Up @@ -798,7 +794,7 @@
"metadata": {},
"outputs": [],
"source": [
"dhdf.hvplot.points(\n",
"df_dh.hvplot.points(\n",
" # title=\"Elevation Change (metres) from Cycle 5 to 6\",\n",
" x=\"x\",\n",
" y=\"y\",\n",
Expand All @@ -824,7 +820,7 @@
"outputs": [],
"source": [
"points = hv.Points(\n",
" data=dhdf,\n",
" data=df_dh,\n",
" kdims=[\"x\", \"y\"],\n",
" vdims=[\"delta_height\"],\n",
" # datatype=[\"xarray\"],\n",
Expand Down
Loading