From 60cf32f85d89320c496bf033ce12b9892954c9a9 Mon Sep 17 00:00:00 2001 From: Deepak Cherian Date: Fri, 16 Jun 2023 08:13:59 -0600 Subject: [PATCH] Add cfgrib,ipywidgets to doc env (#7888) * Add cfgrib to doc env * [skip-ci] Raise for errors in doc build * Remove rasterio examples * Add ipywidgets to silence nbsphinx warning --- ci/requirements/doc.yml | 3 +- doc/conf.py | 2 +- doc/examples/visualization_gallery.ipynb | 91 ++---------------------- 3 files changed, 10 insertions(+), 86 deletions(-) diff --git a/ci/requirements/doc.yml b/ci/requirements/doc.yml index 115d7dfa533..18c79ee9edc 100644 --- a/ci/requirements/doc.yml +++ b/ci/requirements/doc.yml @@ -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 @@ -24,7 +26,6 @@ dependencies: - pip - pre-commit - pyproj - - rasterio>=1.1 - scipy!=1.10.0 - seaborn - setuptools diff --git a/doc/conf.py b/doc/conf.py index e8ef13f1ec7..f201af859b9 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -58,7 +58,7 @@ ] ) -nbsphinx_allow_errors = True +nbsphinx_allow_errors = False # -- General configuration ------------------------------------------------ diff --git a/doc/examples/visualization_gallery.ipynb b/doc/examples/visualization_gallery.ipynb index e6fa564db0d..e7e9196a6f6 100644 --- a/doc/examples/visualization_gallery.ipynb +++ b/doc/examples/visualization_gallery.ipynb @@ -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": { @@ -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,