Skip to content

Commit

Permalink
🔀 Merge branch 'atlxi_dhdt' (#41)
Browse files Browse the repository at this point in the history
Closes #41 Calculate dhdt with ICESat-2 ATL11 data over Antarctica.
weiji14 committed Jun 2, 2020
2 parents 4aabf6e + 9cc397a commit 8be8687
Showing 16 changed files with 1,395 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -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
52 changes: 28 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

@@ -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
@@ -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

84 changes: 40 additions & 44 deletions atl11_play.ipynb
Original file line number Diff line number Diff line change
@@ -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",
"]"
]
},
{
@@ -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()"
]
@@ -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",
")"
]
},
@@ -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",
@@ -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"
]
@@ -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"
]
},
@@ -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()"
]
},
{
@@ -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)"
]
},
{
@@ -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"
]
},
@@ -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)"
]
},
@@ -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",
@@ -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",
Loading

0 comments on commit 8be8687

Please sign in to comment.