Skip to content

Commit

Permalink
Fix headings in tutorials (#90)
Browse files Browse the repository at this point in the history
* fix heading levels, add load libraries section and capitalise section names

* capitalise section names

* remove question mark

* fix minor typos

* change Load to Import libraries
  • Loading branch information
acocac authored Nov 6, 2024
1 parent 0bb7a94 commit 0820d4e
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 65 deletions.
68 changes: 38 additions & 30 deletions docs/tutorials/h3.ipynb
Original file line number Diff line number Diff line change
@@ -1,35 +1,43 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"id": "0",
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"\n",
"import xdggs\n",
"# Working with H3 data\n",
"\n",
"_ = xr.set_options(display_expand_data=False)"
"H3 is a popular icosahedral DGGS with hexagonal cells, developed and popularized by Uber. For more information, see https://h3geo.org. The tutorial aims to showcase how to work with H3 data using `xdggs`."
]
},
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"# Working with H3 data\n",
"## Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"\n",
"import xdggs\n",
"\n",
"H3 is a popular icosahedral DGGS with hexagonal cells, developed and popularized by Uber. For more information, see https://h3geo.org"
"_ = xr.set_options(display_expand_data=False)"
]
},
{
"cell_type": "markdown",
"id": "2",
"id": "3",
"metadata": {},
"source": [
"## initialization\n",
"## Initialization\n",
"\n",
"To initialize, we first have to open the dataset. Here we'll use `xarray`'s `air_temperature` tutorial dataset, which was interpolated to the H3 grid.\n",
"\n",
Expand All @@ -45,7 +53,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"id": "4",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -56,17 +64,17 @@
},
{
"cell_type": "markdown",
"id": "4",
"id": "5",
"metadata": {},
"source": [
"After that, we can use {py:func}`xdggs.decode` to tell `xdggs` to interpret the cell ids.\n",
"\n",
"This will create a grid object (see {py:attr}`xarray.Dataset.dggs.grid_info` and {py:class}`xdggs.H3Info` for more information) containing the grid parameters and a custom index for the `cell_ids` coordinate (notice how the coordinate name is displayed in bold?), which will allow us to perform grid-aware operations.\n",
"This will create a grid object (see {py:attr}`xarray.Dataset.dggs.grid_info` and {py:class}`xdggs.H3Info` for more information) containing the grid parameters and a custom index for the `cell_ids` coordinate (notice how the coordinate name is displayed in bold), which will allow us to perform grid-aware operations.\n",
"\n",
"````{important}\n",
"For this to work, the dataset has to have a coordinate called `cell_ids`, and it also has to have the `grid_name` and `level` attributes.\n",
"\n",
"The `grid_name` refers to the short name of the grid, while `level` refers to the grid hierarchical level (the `h3` libraries call this the \"resolution\", while `xdggs` will use \"level\" for all grids)\n",
"The `grid_name` refers to the short name of the grid, while `level` refers to the grid hierarchical level (the `h3` libraries call this the \"resolution\", while `xdggs` will use \"level\" for all grids).\n",
"\n",
"In this case, the attributes on `cell_ids` are:\n",
"```python\n",
Expand All @@ -81,7 +89,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"id": "6",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -91,22 +99,22 @@
},
{
"cell_type": "markdown",
"id": "6",
"id": "7",
"metadata": {},
"source": [
"## deriving data\n",
"## Deriving data\n",
"\n",
"With the grid object and the custom index, we can derive additional data from the cell ids.\n",
"\n",
"### cell center coordinates\n",
"### Cell center coordinates\n",
"\n",
"For example, we can reconstruct the cell centers we dropped from the original dataset, using {py:meth}`xarray.Dataset.dggs.cell_centers`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"id": "8",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -116,16 +124,16 @@
},
{
"cell_type": "markdown",
"id": "8",
"id": "9",
"metadata": {},
"source": [
"these are the same as the ones we dropped before:"
"These are the same as the ones we dropped before:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"id": "10",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -138,7 +146,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "10",
"id": "11",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -147,18 +155,18 @@
},
{
"cell_type": "markdown",
"id": "11",
"id": "12",
"metadata": {},
"source": [
"### cell boundary polygons\n",
"### Cell boundary polygons\n",
"\n",
"Additionally, we can derive the cell boundary polygons as an array of {doc}`shapely:index` using {py:meth}`xarray.Dataset.dggs.cell_boundaries`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "12",
"id": "13",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -168,10 +176,10 @@
},
{
"cell_type": "markdown",
"id": "13",
"id": "14",
"metadata": {},
"source": [
"## plotting\n",
"## Plotting\n",
"\n",
"We can quickly visualize the data using {py:meth}`xarray.DataArray.dggs.explore`, which is powered by [lonboard](https://github.com/developmentseed/lonboard).\n",
"\n",
Expand All @@ -183,7 +191,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "14",
"id": "15",
"metadata": {},
"outputs": [],
"source": [
Expand Down
78 changes: 43 additions & 35 deletions docs/tutorials/healpix.ipynb
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "0",
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"\n",
"import xdggs\n",
"\n",
"_ = xr.set_options(display_expand_data=False)"
]
},
{
"cell_type": "markdown",
"id": "1",
"id": "0",
"metadata": {},
"source": [
"# Working with Healpix data\n",
Expand All @@ -25,7 +11,7 @@
"\n",
"Healpix divides the sphere into sperical rectangles (\"pixels\") of equal size, starting with 12 \"base pixels\". Each of these \"base pixels\" is then further subdivided into 4 equally sized rectangles. The number of subdivisions is called \"order\", while the total number of rectangles within a \"base pixel\" is called \"nside\" (the relation between both is {math}`n_{\\mathrm{side}} = 2^{\\mathrm{order}}`).\n",
"\n",
"There is two major ways of numbering the \"pixels\" (the \"indexing scheme\"):\n",
"There are two major ways of numbering the \"pixels\" (the \"indexing scheme\"):\n",
"- `\"ring\"`, which assigns IDs to pixels based on the latitude rings they are on, such that pixels on the same latitude will have IDs close to each other.\n",
"- `\"nested\"`, which assigns IDs based on the pixel hierarchy, such that pixels within the same parent pixel have IDs close to each other.\n",
"\n",
Expand All @@ -34,10 +20,32 @@
},
{
"cell_type": "markdown",
"id": "1",
"metadata": {},
"source": [
"## Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2",
"metadata": {},
"outputs": [],
"source": [
"import xarray as xr\n",
"\n",
"import xdggs\n",
"\n",
"_ = xr.set_options(display_expand_data=False)"
]
},
{
"cell_type": "markdown",
"id": "3",
"metadata": {},
"source": [
"## initialization\n",
"## Initialization\n",
"\n",
"To initialize, we first have to open the dataset. Here we'll use `xarray`'s `air_temperature` tutorial dataset, which was interpolated to the healpix grid.\n",
"\n",
Expand All @@ -53,7 +61,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3",
"id": "4",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -64,12 +72,12 @@
},
{
"cell_type": "markdown",
"id": "4",
"id": "5",
"metadata": {},
"source": [
"After that, we can use {py:func}`xdggs.decode` to tell `xdggs` to interpret the cell ids.\n",
"\n",
"This will create a grid object (see {py:attr}`xarray.Dataset.dggs.grid_info` and {py:class}`xdggs.HealpixInfo` for more information) containing the grid parameters and a custom index for the `cell_ids` coordinate (notice how the coordinate name is displayed in bold?), which will allow us to perform grid-aware operations.\n",
"This will create a grid object (see {py:attr}`xarray.Dataset.dggs.grid_info` and {py:class}`xdggs.HealpixInfo` for more information) containing the grid parameters and a custom index for the `cell_ids` coordinate (notice how the coordinate name is displayed in bold), which will allow us to perform grid-aware operations.\n",
"\n",
"````{important}\n",
"For this to work, the dataset has to have a coordinate called `cell_ids`, and it also has to have the `grid_name`, `level` and `indexing_scheme` attributes.\n",
Expand All @@ -90,7 +98,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "5",
"id": "6",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -100,22 +108,22 @@
},
{
"cell_type": "markdown",
"id": "6",
"id": "7",
"metadata": {},
"source": [
"## deriving data\n",
"## Deriving data\n",
"\n",
"With the grid object and the custom index, we can derive additional data from the cell ids.\n",
"\n",
"### cell center coordinates\n",
"### Cell center coordinates\n",
"\n",
"For example, we can reconstruct the cell centers we dropped from the original dataset, using {py:meth}`xarray.Dataset.dggs.cell_centers`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "7",
"id": "8",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -125,16 +133,16 @@
},
{
"cell_type": "markdown",
"id": "8",
"id": "9",
"metadata": {},
"source": [
"these are the same as the ones we dropped before:"
"These are the same as the ones we dropped before:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"id": "10",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -147,7 +155,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "10",
"id": "11",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -156,18 +164,18 @@
},
{
"cell_type": "markdown",
"id": "11",
"id": "12",
"metadata": {},
"source": [
"### cell boundary polygons\n",
"### Cell boundary polygons\n",
"\n",
"Additionally, we can derive the cell boundary polygons as an array of {doc}`shapely:index` using {py:meth}`xarray.Dataset.dggs.cell_boundaries`:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "12",
"id": "13",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -177,10 +185,10 @@
},
{
"cell_type": "markdown",
"id": "13",
"id": "14",
"metadata": {},
"source": [
"## plotting\n",
"## Plotting\n",
"\n",
"We can quickly visualize the data using {py:meth}`xarray.DataArray.dggs.explore`, which is powered by [lonboard](https://github.com/developmentseed/lonboard).\n",
"\n",
Expand All @@ -192,7 +200,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "14",
"id": "15",
"metadata": {},
"outputs": [],
"source": [
Expand Down

0 comments on commit 0820d4e

Please sign in to comment.