Skip to content

Commit

Permalink
Add instructions for setting ESMFMKFILE and update links to xESMF d…
Browse files Browse the repository at this point in the history
…ocs (#643)
  • Loading branch information
tomvothecoder authored Apr 16, 2024
1 parent b835032 commit 145a03e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ Things We Are Striving For
* Support for parallelism using `dask`_ where it is both possible and makes sense

.. _Metadata Interpretation: https://xcdat.readthedocs.io/en/stable/faqs.html#metadata-interpretation
.. _xESMF: https://pangeo-xesmf.readthedocs.io/en/latest/
.. _xESMF: https://xesmf.readthedocs.io/en/latest/
.. _regrid2: https://cdms.readthedocs.io/en/latest/regrid2.html
.. _xgcm: https://xgcm.readthedocs.io/en/latest/index.html
.. _dask: https://dask.org/
Expand Down
29 changes: 20 additions & 9 deletions docs/examples/regridding-horizontal.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"\n",
"- [xarray.Dataset.regridder.horizontal](../generated/xarray.Dataset.regridder.horizontal.rst)\n",
"\n",
"The data used in this example can be found through the [Earth System Grid Federation (ESGF) search portal](https://aims2.llnl.gov/search).\n",
"## Other Resources\n",
"\n",
"- [xESMF documentation](https://xesmf.readthedocs.io/en/latest/)\n",
"- The data used in this example can be found through the [Earth System Grid Federation (ESGF) search portal](https://aims2.llnl.gov/search).\n",
"\n",
"## Overview\n",
"\n",
Expand Down Expand Up @@ -653,7 +656,7 @@
"# Unit adjust (-273.15, K to C)\n",
"ds[\"tas\"] = ds[\"tas\"] - 273.15\n",
"\n",
"ds\n"
"ds"
]
},
{
Expand Down Expand Up @@ -751,10 +754,12 @@
"\n",
"fig, axes = plt.subplots(ncols=2, figsize=(16, 4))\n",
"\n",
"ds.tas.isel(time=0).plot(ax=axes[0], vmin=-40, vmax=40, extend='both', cmap = 'RdBu_r')\n",
"ds.tas.isel(time=0).plot(ax=axes[0], vmin=-40, vmax=40, extend=\"both\", cmap=\"RdBu_r\")\n",
"axes[0].set_title(\"Input data\")\n",
"\n",
"output.tas.isel(time=0).plot(ax=axes[1], vmin=-40, vmax=40, extend='both', cmap = 'RdBu_r')\n",
"output.tas.isel(time=0).plot(\n",
" ax=axes[1], vmin=-40, vmax=40, extend=\"both\", cmap=\"RdBu_r\"\n",
")\n",
"axes[1].set_title(\"Output data\")\n",
"\n",
"plt.tight_layout()"
Expand All @@ -771,7 +776,7 @@
"\n",
"In this example, we will compare the different regridding methods supported by `xESMF`.\n",
"\n",
"You can find a more in depth comparison on `xESMF`'s [documentation](https://pangeo-xesmf.readthedocs.io/en/latest/notebooks/Compare_algorithms.html).\n",
"You can find a more in depth comparison on `xESMF`'s [documentation](https://xesmf.readthedocs.io/en/latest/notebooks/Compare_algorithms.html).\n",
"\n",
"Methods:\n",
"\n",
Expand Down Expand Up @@ -809,7 +814,9 @@
"for i, method in enumerate(methods):\n",
" output = ds.regridder.horizontal(\"tas\", output_grid, tool=\"xesmf\", method=method)\n",
"\n",
" output.tas.isel(time=0).plot(ax=axes[i], vmin=-40, vmax=40, extend='both', cmap = 'RdBu_r')\n",
" output.tas.isel(time=0).plot(\n",
" ax=axes[i], vmin=-40, vmax=40, extend=\"both\", cmap=\"RdBu_r\"\n",
" )\n",
"\n",
" axes[i].set_title(method)\n",
"\n",
Expand Down Expand Up @@ -861,7 +868,9 @@
"ds[\"mask\"].plot(ax=axes[0], cmap=\"binary_r\")\n",
"axes[0].set_title(\"Mask\")\n",
"\n",
"masked_output.tas.isel(time=0).plot(ax=axes[1], vmin=-40, vmax=40, extend='both', cmap='RdBu_r')\n",
"masked_output.tas.isel(time=0).plot(\n",
" ax=axes[1], vmin=-40, vmax=40, extend=\"both\", cmap=\"RdBu_r\"\n",
")\n",
"axes[1].set_title(\"Masked output\")\n",
"\n",
"plt.tight_layout()"
Expand Down Expand Up @@ -915,9 +924,11 @@
"\n",
"fig, axes = plt.subplots(ncols=2, figsize=(16, 4))\n",
"\n",
"ds.tas.isel(time=0).plot(ax=axes[0], vmin=-40, vmax=40, extend='both', cmap = 'RdBu_r')\n",
"ds.tas.isel(time=0).plot(ax=axes[0], vmin=-40, vmax=40, extend=\"both\", cmap=\"RdBu_r\")\n",
"\n",
"output.tas.isel(time=0).plot(ax=axes[1], vmin=-40, vmax=40, extend='both', cmap = 'RdBu_r')"
"output.tas.isel(time=0).plot(\n",
" ax=axes[1], vmin=-40, vmax=40, extend=\"both\", cmap=\"RdBu_r\"\n",
")"
]
}
],
Expand Down
22 changes: 21 additions & 1 deletion docs/getting-started-guide/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ Instructions
.. _mamba create: https://mamba.readthedocs.io/en/latest/user_guide/mamba.html#quickstart
.. _mamba install: https://mamba.readthedocs.io/en/latest/user_guide/mamba.html#quickstart


Updating
--------

Expand All @@ -95,3 +94,24 @@ To update to a specific version of ``xcdat``:
>>> mamba activate <ENV_NAME>
>>> mamba update xcdat=<MAJOR.MINOR.PATCH>
Jupyter Users set ``ESMFMKFILE`` env variable
---------------------------------------------

If you are a Jupyter user, the ``ESMFMKFILE`` environment variable will need to be set
either directly on the machine or through your Jupyter Notebook.

This env variable is normally set when calling ``conda activate`` with the conda
environment that has ``xesmf``. However, Jupyter does not run ``conda activate`` when using
the Python kernel associated with the environment so ``ESMFMKFILE`` is not set, resulting
in ``ImportError: The ESMFMKFILE environment variable is not available.`` (related `GitHub
Issue <https://github.com/xCDAT/xcdat/issues/574>`_).

To set the ``ESMFMKFILE`` in a Jupyter Notebook add:

.. code-block:: python
>>> import os
>>> os.environ['ESMFMKFILE'] = 'conda-envs/xcdat/lib/esmf.mk'
>>>
>>> import xcdat
2 changes: 1 addition & 1 deletion docs/getting-started-guide/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ Things We Are Striving For
* Support for parallelism using `dask`_ where it is both possible and makes sense

.. _Metadata Interpretation: https://xcdat.readthedocs.io/en/stable/faqs.html#metadata-interpretation
.. _xESMF: https://pangeo-xesmf.readthedocs.io/en/latest/
.. _xESMF: https://xesmf.readthedocs.io/en/latest/
.. _regrid2: https://cdms.readthedocs.io/en/latest/regrid2.html
.. _xgcm: https://xgcm.readthedocs.io/en/latest/index.html
.. _dask: https://dask.org/
Expand Down
2 changes: 1 addition & 1 deletion xcdat/regridder/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def horizontal(
Supported tools, methods and grids:
- xESMF (https://pangeo-xesmf.readthedocs.io/en/latest/)
- xESMF (https://xesmf.readthedocs.io/en/latest/)
- Methods: Bilinear, Conservative, Conservative Normed, Patch, Nearest s2d, or Nearest d2s.
- Grids: Rectilinear, or Curvilinear.
- Find options at :py:func:`xcdat.regridder.xesmf.XESMFRegridder`
Expand Down

0 comments on commit 145a03e

Please sign in to comment.