Skip to content
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
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ jobs:
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml

16 changes: 7 additions & 9 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
- name: Upload Python Package
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,29 @@ $^a$ $T_{max}$ and $T_{min}$ can also be provided. $^b$ $RH_{max}$ and $RH_{min}

Examples of using *pyet* can be found in the example folder:

* [Example 1](examples/01_example_zamg.ipynb): Estimating PET using pandas.Series
* [Example 1](<https://pyet.readthedocs.io/en/dev/examples/01_example_zamg.html#>): Estimating PET using pandas.Series

* [Example 2](examples/02_example_zamg_netcdf.ipynb): Estimating PET using xarray.DataArray
* [Example 2](<https://pyet.readthedocs.io/en/dev/examples/02_example_zamg_netcdf.html>): Estimating PET using xarray.DataArray

* [Example 3](examples/03_example_knmi.ipynb): Benchmarking Makkink
* [Example 3](<https://pyet.readthedocs.io/en/dev/examples/03_example_knmi.html>): Benchmarking Makkink
against [KNMI data](https://www.knmi.nl/over-het-knmi/about)

* [Example 4](examples/04_example_coagmet.ipynb): Benchmarking FAO56
* [Example 4](<https://pyet.readthedocs.io/en/dev/examples/04_example_coagmet.html>): Benchmarking FAO56
against [CoAgMET data](https://coagmet.colostate.edu/)

* [Example 5](examples/05_example_calibration.ipynb): Calibrating the Romanenko and Abtew method against the PM-FAO56
* [Example 5](<https://pyet.readthedocs.io/en/dev/examples/05_example_calibration.html>): Calibrating the Romanenko and Abtew method against the PM-FAO56

* [Example 6](examples/06_worked_examples_McMahon_etal_2013.ipynb): Worked examples for estimating meteorological
* [Example 6](<https://pyet.readthedocs.io/en/dev/examples/06_worked_examples_McMahon_etal_2013.html>): Worked examples for estimating meteorological
variables and potential evapotranspiration after McMahon et al., 2013

* [Example 7](examples/07_example_climate_change.ipynb): Example for estimating potential evapotranspiration under
* [Example 7](<https://pyet.readthedocs.io/en/dev/examples/07_example_climate_change.html>): Example for estimating potential evapotranspiration under
warming and elevated $CO_2$ concentrations following Yang et al., (2019)

* [Example 8](examples/08_crop_coefficient.ipynb): Determining the crop coefficient function with Python
* [Example 8](<https://pyet.readthedocs.io/en/dev/examples/08_crop_coefficient.html>): Determining the crop coefficient function with Python

* [Example 9](examples/09_CMIP6_data.ipynb): Estimating PET using CMIP data
* [Example 9](<https://pyet.readthedocs.io/en/dev/examples/09_CMIP6_data.html>): Estimating PET using CMIP data

* [Example 10](examples/10_example_paper.ipynb): Notebook supporting PyEt manuscript
* [Example 10](<https://pyet.readthedocs.io/en/dev/examples/10_example_paper.html>): Notebook supporting PyEt manuscript

Documentation is hosted on [ReadTheDocs](https://pyet.readthedocs.io).

Expand Down
99 changes: 59 additions & 40 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,56 +18,54 @@

year = date.today().strftime("%Y")

sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath("."))

# Get a Bibtex reference file from the Zotero group for referencing
url = "https://api.zotero.org/groups/4846265/collections/M9ZRDX2U/items/"
params = {"format": "bibtex",
"style": "apa",
"limit": 100}
params = {"format": "bibtex", "style": "apa", "limit": 100}

r = requests.get(url=url, params=params)
with open("references.bib", mode="w") as file:
file.write(r.text)

# Get a Bibtex reference file from the Zotero group for publications list
url = "https://api.zotero.org/groups/4846265/collections/UR7PHVDK/items/"
params = {"format": "bibtex",
"style": "apa",
"limit": 100}
params = {"format": "bibtex", "style": "apa", "limit": 100}

r = requests.get(url=url, params=params)
with open("publications.bib", mode="w") as file:
file.write(r.text)

# -- Project information -----------------------------------------------------

project = 'pyet'
copyright = '{}, M. Vremec, R.A. Collenteur'.format(year)
author = 'M. Vremec, R.A. Collenteur'
project = "pyet"
copyright = "{}, M. Vremec, R.A. Collenteur".format(year)
author = "M. Vremec, R.A. Collenteur"

# The full version, including alpha/beta/rc tags
release = '2020'
release = "2020"

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

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.napoleon',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'IPython.sphinxext.ipython_console_highlighting', # lowercase didn't work
'sphinx.ext.autosectionlabel',
'sphinxcontrib.bibtex',
'myst_nb',
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx.ext.doctest",
"sphinx.ext.intersphinx",
"sphinx.ext.todo",
"sphinx.ext.mathjax",
"sphinx.ext.ifconfig",
"sphinx.ext.viewcode",
"IPython.sphinxext.ipython_console_highlighting", # lowercase didn't work
"sphinx.ext.autosectionlabel",
"sphinxcontrib.bibtex",
"myst_nb",
"numpydoc",
"sphinx_design",
]

# Create custom bracket style with round brackets
Expand All @@ -77,14 +75,13 @@
import sphinxcontrib.bibtex.plugin

from sphinxcontrib.bibtex.style.referencing import BracketStyle
from sphinxcontrib.bibtex.style.referencing.author_year \
import AuthorYearReferenceStyle
from sphinxcontrib.bibtex.style.referencing.author_year import AuthorYearReferenceStyle


def bracket_style() -> BracketStyle:
return BracketStyle(
left='(',
right=')',
left="(",
right=")",
)


Expand All @@ -98,40 +95,52 @@ class MyReferenceStyle(AuthorYearReferenceStyle):


sphinxcontrib.bibtex.plugin.register_plugin(
'sphinxcontrib.bibtex.style.referencing',
'author_year_round', MyReferenceStyle)
"sphinxcontrib.bibtex.style.referencing", "author_year_round", MyReferenceStyle
)

bibtex_bibfiles = ['references.bib', 'publications.bib']
bibtex_bibfiles = ["references.bib", "publications.bib"]
bibtex_reference_style = "author_year_round"

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
templates_path = ["_templates"]

source_suffix = '.rst'
source_suffix = ".rst"

# The master toctree document.
master_doc = 'index'
master_doc = "index"

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', '**.ipynb_checkpoints']
exclude_patterns = ["_build", "**.ipynb_checkpoints"]

# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.

html_theme = "pydata_sphinx_theme"
html_theme_options = {
"github_url": "https://github.com/phydrus/pyet",
"use_edit_page_button": False
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
html_static_path = ["_static"]
html_logo = "_static/logo.png"
html_use_smartypants = True
html_show_sourcelink = True

html_theme_options = {
"github_url": "https://github.com/pyet-org/pyet",
"use_edit_page_button": True,
"header_links_before_dropdown": 6,
"icon_links": [
{
"name": "GitHub", # Label for this link
"url": "https://github.com/pyet-org/pyet", # required
"icon": "fab fa-github-square",
"type": "fontawesome", # Default is fontawesome
}
],
}

autosummary_generate = True
numpydoc_show_class_members = False
Expand All @@ -148,3 +157,13 @@ class MyReferenceStyle(AuthorYearReferenceStyle):

nb_execution_allow_errors = True # Allow errors in notebooks, to see the error online
nb_execution_mode = "auto"

# Enable specific MyST extensions, such as "dollarmath" for math rendering
myst_enable_extensions = [
"dollarmath",
]

# -- Numpydoc settings ----------------------------------------------------------------

numpydoc_class_members_toctree = True
numpydoc_show_class_members = False
30 changes: 16 additions & 14 deletions docs/examples/10_example_paper.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"import pylab\n",
"import matplotlib.dates as mdates\n",
"from mpl_toolkits.axes_grid1.inset_locator import inset_axes\n",
"import gc # Import the garbage collection module\n",
"\n",
"import pyet\n",
"import spotpy\n",
Expand Down Expand Up @@ -120,7 +121,6 @@
"source": [
"#edit default values for plots\n",
"params = {\n",
" \"font.family\": \"Arial\",\n",
" \"legend.fontsize\": \"15\",\n",
" \"axes.labelsize\": \"16\",\n",
" \"xtick.labelsize\": \"15\",\n",
Expand Down Expand Up @@ -773,7 +773,7 @@
"fig.supxlabel(\"PET$_{benchmark}$ [mm/day]\", x=0.475, fontsize=16)\n",
"fig.supylabel(\"PET$_{pyet}$ [mm/day]\", fontsize=16)\n",
"fig.subplots_adjust(wspace=0.05, hspace=0.05, left=0.05)\n",
"plt.tight_layout()\n",
"plt.tight_layout();\n",
"#fig.savefig(\"figure1.png\", dpi=600, bbox_inches=\"tight\")"
]
},
Expand Down Expand Up @@ -872,7 +872,7 @@
"\n",
"plt.tight_layout()\n",
"\n",
"axs[2].legend(loc=(1.05,0.1), ncol=2, bbox_transform=axs[0].transAxes, fontsize=8)\n",
"axs[2].legend(loc=(1.05,0.1), ncol=2, bbox_transform=axs[0].transAxes, fontsize=8);\n",
"#fig.savefig(\"figure2.png\", dpi=600, bbox_inches=\"tight\")"
]
},
Expand Down Expand Up @@ -1007,7 +1007,7 @@
" cbar.set_label(\"PET [mm/day]\", labelpad=10)\n",
" plt.subplots_adjust(hspace=0.02, wspace=0.1)\n",
"\n",
"plt.subplots_adjust(hspace=0.02, wspace=0.01)\n",
"plt.subplots_adjust(hspace=0.02, wspace=0.01);\n",
"\n",
"#fig.savefig(\"figure3.png\", dpi=300, bbox_inches=\"tight\")"
]
Expand Down Expand Up @@ -1287,7 +1287,7 @@
"axs[1,5].set_yticklabels([\"\",800,1000,\"\"])\n",
"axs[0,5].legend(loc=(-3.65,1.05), ncol=7, bbox_transform=axs[1,5].transAxes)\n",
"clb = fig.colorbar(density, orientation=\"horizontal\", ax=axs[0, 0], cax = axs[0, 0].inset_axes([0.04, 1.2, 1, 0.05]))\n",
"clb.ax.set_title(\"Number of points per pixel\")\n",
"clb.ax.set_title(\"Number of points per pixel\");\n",
"#fig.savefig(\"figure4.png\", dpi=600, bbox_inches=\"tight\")"
]
},
Expand Down Expand Up @@ -1336,13 +1336,13 @@
"source": [
"# Load CO2 data for each RCP scenario\n",
"rcp_co2 = pd.DataFrame()\n",
"rcp_co2[\"rcp_26\"] = pd.read_csv(\"data/example_10/co2_conc/RCP3PD_MIDYR_CONC.dat\", skiprows=38, \n",
"rcp_co2[\"rcp_26\"] = pd.read_csv(\"data/example_10/co2_conc/RCP3PD_MIDYR_CONC.DAT\", skiprows=38, \n",
" delim_whitespace=True, index_col=\"YEARS\").loc[\"2020\":\"2100\", \"CO2\"]\n",
"rcp_co2[\"rcp_45\"] = pd.read_csv(\"data/example_10/co2_conc/RCP45_MIDYR_CONC.dat\", skiprows=38, \n",
"rcp_co2[\"rcp_45\"] = pd.read_csv(\"data/example_10/co2_conc/RCP45_MIDYR_CONC.DAT\", skiprows=38, \n",
" delim_whitespace=True, index_col=\"YEARS\").loc[\"2020\":\"2100\", \"CO2\"]\n",
"rcp_co2[\"rcp_60\"] = pd.read_csv(\"data/example_10/co2_conc/RCP6_MIDYR_CONC.dat\", skiprows=38, \n",
"rcp_co2[\"rcp_60\"] = pd.read_csv(\"data/example_10/co2_conc/RCP6_MIDYR_CONC.DAT\", skiprows=38, \n",
" delim_whitespace=True, index_col=\"YEARS\").loc[\"2020\":\"2100\", \"CO2\"]\n",
"rcp_co2[\"rcp_85\"] = pd.read_csv(\"data/example_10/co2_conc/RCP85_MIDYR_CONC.dat\", skiprows=38, \n",
"rcp_co2[\"rcp_85\"] = pd.read_csv(\"data/example_10/co2_conc/RCP85_MIDYR_CONC.DAT\", skiprows=38, \n",
" delim_whitespace=True, index_col=\"YEARS\").loc[\"2020\":\"2100\", \"CO2\"]"
]
},
Expand Down Expand Up @@ -1416,11 +1416,11 @@
"dpet_rcp_etco2 = pd.DataFrame(index=rcp_temp.index, columns=[\"rcp_26\", \"rcp_45\", \"rcp_60\", \"rcp_85\"])\n",
"dpet_rcp_etco2_5th = pd.DataFrame(index=rcp_temp.index, columns=[\"rcp_26\", \"rcp_45\", \"rcp_60\", \"rcp_85\"])\n",
"dpet_rcp_etco2_95th = pd.DataFrame(index=rcp_temp.index, columns=[\"rcp_26\", \"rcp_45\", \"rcp_60\", \"rcp_85\"])\n",
"for year in rcp_temp.index:\n",
"for year in rcp_temp.index: \n",
" for rcp in [\"rcp_26\", \"rcp_45\", \"rcp_60\", \"rcp_85\"]:\n",
" df_rcp_et = pd.DataFrame()\n",
" df_rcp_etco2 = pd.DataFrame()\n",
" for i in np.arange(0, len(methods)):\n",
" for i in np.arange(0, len(methods[:2])): # only for two methods to reduce processing for RTD to handle!!!!!!!!!!!!\n",
" input1 = input_rcp(rcp_temp.loc[year, rcp])\n",
" df_rcp_et[methods[i]] = simulate(sollutions2[i], methods[i], input1[i])\n",
" df_rcp_etco2[methods[i]] = simulate(sollutions2[i], methods[i], \n",
Expand All @@ -1430,7 +1430,9 @@
" dpet_rcp_et_95th.loc[year, rcp] = df_rcp_et.resample(\"y\").mean().mean().quantile(0.95)\n",
" dpet_rcp_etco2.loc[year, rcp] = df_rcp_etco2.resample(\"y\").mean().mean().mean()\n",
" dpet_rcp_etco2_5th.loc[year, rcp] = df_rcp_etco2.resample(\"y\").mean().mean().quantile(0.05)\n",
" dpet_rcp_etco2_95th.loc[year, rcp] = df_rcp_etco2.resample(\"y\").mean().mean().quantile(0.95)"
" dpet_rcp_etco2_95th.loc[year, rcp] = df_rcp_etco2.resample(\"y\").mean().mean().quantile(0.95)\n",
" # Call gc.collect() after processing each RCP scenario for a year\n",
" gc.collect()"
]
},
{
Expand Down Expand Up @@ -1487,7 +1489,7 @@
"\n",
"for i, letter in enumerate([\"a\", \"b\", \"c\", \"d\"]):\n",
" axs[i].text(0.85, 0.9, \"({})\".format(letter), transform=axs[i].transAxes, fontsize=12)\n",
" axs[i].tick_params(axis='both', which='major', labelsize=13)\n",
" axs[i].tick_params(axis='both', which='major', labelsize=13);\n",
"\n",
"#fig.savefig(\"figure5.png\", dpi=600, bbox_inches=\"tight\")"
]
Expand Down Expand Up @@ -1529,7 +1531,7 @@
"pet_df.plot() # daily PET [mm/day]\n",
"pet_df.boxplot() # boxplot PET[mm/day]\n",
"pet_df.cumsum().plot() # cummulative PET [mm]\n",
"plt.scatter(pyet_makkink, pet_knmi) # plot Makkink pyet vs KNMI"
"plt.scatter(pyet_makkink, pet_knmi) # plot Makkink pyet vs KNMI;"
]
},
{
Expand Down
Loading