Skip to content
Snippets Groups Projects
Commit 7278c5ed authored by Fraser William Goldsworth's avatar Fraser William Goldsworth
Browse files

added outline of how to use numpy style docstrings

parent 5781bc41
No related branches found
No related tags found
No related merge requests found
......@@ -56,3 +56,6 @@ Once, `cartopy` is installed in your environment:
```bash
pip install git+https://gitlab.dkrz.de/m300602/pyicon.git
```
## Developing
When adding new functions, make sure to document them with a docstring. This should detail what the function does, the arguments and what type of objects it returns. Examples are encouraged. We use so-called "numpy" style docstrings which are then automatically rendered into the sphinx documentation. A guide to numpy style docstrings is available [here](https://numpydoc.readthedocs.io/en/latest/format.html) and they even produce some nice [examples](https://numpydoc.readthedocs.io/en/latest/example.html#example).
\ No newline at end of file
......@@ -206,19 +206,20 @@ def xr_crop_tgrid(ds_tg, ireg_c, verbose=1):
ds_tg_cut: xarray Dataset, which contains (most of) the cropped grid variables.
Example usage
--------------
ds_tg = xr.open_mfdataset(fpath_tgrid)
clon = ds_tg.clon.compute().data * 180./np.pi
clat = ds_tg.clat.compute().data * 180./np.pi
lon_reg_3 = [6, 10]
lat_reg_3 = [-32, -30]
ireg_c = np.where(
(clon>lon_reg[0]) & (clon<=lon_reg[1]) & (clat>lat_reg[0]) & (clat<=lat_reg[1])
)[0]
ds_tg_cut = pyic.xr_crop_tgrid(ds_tg, ireg_c)
Examples
--------
>>> ds_tg = xr.open_mfdataset(fpath_tgrid)
>>> clon = ds_tg.clon.compute().data * 180./np.pi
>>> clat = ds_tg.clat.compute().data * 180./np.pi
>>>
>>> lon_reg_3 = [6, 10]
>>> lat_reg_3 = [-32, -30]
>>> ireg_c = np.where(
... (clon>lon_reg[0]) & (clon<=lon_reg[1]) & (clat>lat_reg[0]) & (clat<=lat_reg[1])
... )[0]
>>>
>>> ds_tg_cut = pyic.xr_crop_tgrid(ds_tg, ireg_c)
"""
if "converted_tgrid" in ds_tg.attrs:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment