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

Add cfgrib,ipywidgets to doc env #7888

Merged
merged 4 commits into from
Jun 16, 2023
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
3 changes: 2 additions & 1 deletion ci/requirements/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ dependencies:
- python=3.10
- bottleneck
- cartopy
- cfgrib
- dask-core>=2022.1
- h5netcdf>=0.13
- ipykernel
- ipywidgets # silence nbsphinx warning
- ipython
- iris>=2.3
- jupyter_client
Expand All @@ -24,7 +26,6 @@ dependencies:
- pip
- pre-commit
- pyproj
- rasterio>=1.1
- scipy!=1.10.0
- seaborn
- setuptools
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
]
)

nbsphinx_allow_errors = True
nbsphinx_allow_errors = False

# -- General configuration ------------------------------------------------

Expand Down
91 changes: 7 additions & 84 deletions doc/examples/visualization_gallery.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -193,90 +193,6 @@
"# Show\n",
"plt.tight_layout()"
]
},
{
"cell_type": "markdown",
"metadata": {
"jp-MarkdownHeadingCollapsed": true,
"tags": []
},
"source": [
"## `imshow()` and rasterio map projections\n",
"\n",
"\n",
"Using rasterio's projection information for more accurate plots.\n",
"\n",
"This example extends `recipes.rasterio` and plots the image in the\n",
"original map projection instead of relying on pcolormesh and a map\n",
"transformation."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"da = xr.tutorial.open_rasterio(\"RGB.byte\")\n",
"\n",
"# The data is in UTM projection. We have to set it manually until\n",
"# https://github.com/SciTools/cartopy/issues/813 is implemented\n",
"crs = ccrs.UTM(\"18\")\n",
"\n",
"# Plot on a map\n",
"ax = plt.subplot(projection=crs)\n",
"da.plot.imshow(ax=ax, rgb=\"band\", transform=crs)\n",
"ax.coastlines(\"10m\", color=\"r\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Parsing rasterio geocoordinates\n",
"\n",
"Converting a projection's cartesian coordinates into 2D longitudes and\n",
"latitudes.\n",
"\n",
"These new coordinates might be handy for plotting and indexing, but it should\n",
"be kept in mind that a grid which is regular in projection coordinates will\n",
"likely be irregular in lon/lat. It is often recommended to work in the data's\n",
"original map projection (see `recipes.rasterio_rgb`)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pyproj import Transformer\n",
"import numpy as np\n",
"\n",
"da = xr.tutorial.open_rasterio(\"RGB.byte\")\n",
"\n",
"x, y = np.meshgrid(da[\"x\"], da[\"y\"])\n",
"transformer = Transformer.from_crs(da.crs, \"EPSG:4326\", always_xy=True)\n",
"lon, lat = transformer.transform(x, y)\n",
"da.coords[\"lon\"] = ((\"y\", \"x\"), lon)\n",
"da.coords[\"lat\"] = ((\"y\", \"x\"), lat)\n",
"\n",
"# Compute a greyscale out of the rgb image\n",
"greyscale = da.mean(dim=\"band\")\n",
"\n",
"# Plot on a map\n",
"ax = plt.subplot(projection=ccrs.PlateCarree())\n",
"greyscale.plot(\n",
" ax=ax,\n",
" x=\"lon\",\n",
" y=\"lat\",\n",
" transform=ccrs.PlateCarree(),\n",
" cmap=\"Greys_r\",\n",
" shading=\"auto\",\n",
" add_colorbar=False,\n",
")\n",
"ax.coastlines(\"10m\", color=\"r\")"
]
}
],
"metadata": {
Expand All @@ -296,6 +212,13 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
},
"widgets": {
"application/vnd.jupyter.widget-state+json": {
"state": {},
"version_major": 2,
"version_minor": 0
}
}
},
"nbformat": 4,
Expand Down