Skip to content

Commit

Permalink
Merge pull request #17 from phydrus/dev
Browse files Browse the repository at this point in the history
Update ci.yml
  • Loading branch information
raoulcollenteur authored Sep 17, 2021
2 parents 28b4afb + 6f0e015 commit 527cf39
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 14 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: codacy-coverage-reporter

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install codacy-coverage
pip install coverage
pip install -e .
- name: Test with unittest
run: |
coverage run -m unittest discover
coverage xml
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@master
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: coverage.xml
20 changes: 12 additions & 8 deletions joss_paper/paper.bib
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ @article{priestley1972assessment
number={2},
pages={81--92},
year={1972}
doi={10.1175/1520-0493(1972)100<0081:OTAOSH>2.3.CO;2},
}

@article{wright1982new,
Expand All @@ -47,7 +48,8 @@ @article{thom1977penman
number={436},
pages={345--357},
year={1977},
publisher={Wiley Online Library}
publisher={Wiley Online Library},
doi={10.1002/qj.49710343610},
}

@article{thornthwaite1948approach,
Expand All @@ -59,6 +61,7 @@ @article{thornthwaite1948approach
pages={55--94},
year={1948},
publisher={JSTOR}
doi={10.2307/210739},
}

@article{blaney1952determining,
Expand Down Expand Up @@ -86,7 +89,7 @@ @article{xu2001evaluation
number = {2},
pages = {305-319},
keywords = {evaporation, temperature-based methods, north-western Ontario},
doi = {https://doi.org/10.1002/hyp.119},
doi = {10.1002/hyp.119},
url = {https://onlinelibrary.wiley.com/doi/abs/10.1002/hyp.119},
eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.1002/hyp.119},
abstract = {Abstract Seven temperature-based equations, each representing a typical form, were evaluated and compared for determining evaporation at two climatological stations (Rawson Lake and Atikokan) in north-western Ontario, Canada. The comparison was first made using the original constant values involved in each equation, and then using the recalibrated constant values. The results show that when the original constant values were used, larger biases existed for most of the equations for both stations. When recalibrated constant values were substituted for the original constant values, six of the seven equations improved for both stations. Using locally calibrated parameter values, all seven equations worked well for determining mean seasonal evaporation values. For monthly evaporation values, the modified Blaney–Criddle method produced least error for all months for both stations, followed by the Hargreaves and Thornthwaite methods. The Linacre, Kharrufa and Hamon methods showed a significant bias in September for both stations. With properly determined constant values, the modified Blaney–Criddle, the Hargreaves and Thornthwaite methods can be recommended for estimating evaporation in the study region, as far as temperature-based methods are concerned. Copyright © 2001 John Wiley \& Sons, Ltd.},
Expand All @@ -101,7 +104,7 @@ @article{xu2000evaluation
number = {2},
pages = {339-349},
keywords = {evaporation, radiation-based methods, pan evaporation, Switzerland},
doi = {https://doi.org/10.1002/(SICI)1099-1085(20000215)14:2<339::AID-HYP928>3.0.CO;2-O},
doi = {10.1002/(SICI)1099-1085(20000215)14:2<339::AID-HYP928>3.0.CO;2-O},
url = {https://onlinelibrary.wiley.com/doi/abs/10.1002/%28SICI%291099-1085%2820000215%2914%3A2%3C339%3A%3AAID-HYP928%3E3.0.CO%3B2-O},
eprint = {https://onlinelibrary.wiley.com/doi/pdf/10.1002/%28SICI%291099-1085%2820000215%2914%3A2%3C339%3A%3AAID-HYP928%3E3.0.CO%3B2-O},
abstract = {Abstract Eight radiation-based equations for determining evaporation were evaluated and expressed in five generalized forms. Five evaporation equations (Abtew, Hargreaves, Makkink, Priestley and Taylor and Turc), where each represents one generalized form, were then compared with pan evaporation measured at Changins station in Switzerland. The comparison was first made using the original constant values involved in each equation, and then using the recalibrated constant values. Evaluation of the Priestley and Taylor equation requires net radiation data as input, in this study, net radiation was estimated using Equation (16) owing to the lack of observation data. The results showed that when the original constant values were used, large errors resulted for most of the equations. When recalibrated constant values were substituted for the original constant values, four of the five equations improved greatly, and all five equations performed well for determining mean annual evaporation. For seasonal and monthly evaporation, the Hargreaves and Turc equations showed a significant bias, especially for cold months. With properly determined constant values, the Makkink and modified Priestley and Taylor equations resulted in monthly evaporation values that agreed most closely with pan evaporation in the study region. The simple Abtew equation can also be used when other meteorological data except radiation are not available. Copyright © 2000 John Wiley \& Sons, Ltd.},
Expand All @@ -116,7 +119,7 @@ @article{linacre1977simple
pages = {409-424},
year = {1977},
issn = {0002-1571},
doi = {https://doi.org/10.1016/0002-1571(77)90007-3},
doi = {10.1016/0002-1571(77)90007-3},
url = {https://www.sciencedirect.com/science/article/pii/0002157177900073},
author = {Edward T. Linacre},
abstract = {The Penman formula for the evaporation rate from a lake is simplified to the following: E0=700Tm/(100−A)+15(T−Td)(80−T)(mmday−1) where Tm = T + 0.006h, h is the elevation (metres), T is the mean temperature, A is the latitude (degrees) and Td is the mean dew-point. Values given by this formula typically differ from measured values by about 0.3 mm day−1 for annual means, 0.5 mm day−1 for monthly means, 0.9 mm day−1 for a week and 1.7 mm day−1 for a day. The formula applies over a wide range of climates. Monthly mean values of the term (T − Td) can be obtained either from an empirical table or from the following empirical relationship, provided precipitation is at least 5 mm month−1 and (T − Td) is at least 4°C:(T−Td)=0.0023h+0.37T+0.53R+0.35Rann−10.9°C where R is the mean daily range of temperature and Rann is the difference between the mean temperatures of the hottest and coldest months. Thus the evaporation rate can be estimated simply from values for the elevation, latitude and daily maximum and minimum temperatures.}
Expand Down Expand Up @@ -188,6 +191,7 @@ @article{abtew1996evapotranspiration
pages={465--473},
year={1996},
publisher={Wiley Online Library}
doi={10.1111/j.1752-1688.1996.tb04044.x},
}

@article{makkink1957testing,
Expand All @@ -207,7 +211,7 @@ @article{OUDIN2005290
pages = {290-306},
year = {2005},
issn = {0022-1694},
doi = {https://doi.org/10.1016/j.jhydrol.2004.08.026},
doi = {10.1016/j.jhydrol.2004.08.026},
url = {https://www.sciencedirect.com/science/article/pii/S0022169404004056},
author = {Ludovic Oudin and Frédéric Hervieu and Claude Michel and Charles Perrin and Vazken Andréassian and François Anctil and Cécile Loumagne},
keywords = {Rainfall–runoff modelling, Sensitivity analysis, Potential evapotranspiration, Parsimony},
Expand All @@ -221,7 +225,7 @@ @article{Danlu2016r
pages = {216-224},
year = {2016},
issn = {1364-8152},
doi = {https://doi.org/10.1016/j.envsoft.2015.12.019},
doi = {10.1016/j.envsoft.2015.12.019},
url = {https://www.sciencedirect.com/science/article/pii/S136481521530133X},
author = {Danlu Guo and Seth Westra and Holger R. Maier},
keywords = {Evapotranspiration (ET), Evaporation, Ensemble modelling, R package, Evapotranspiration software},
Expand All @@ -236,7 +240,7 @@ @article{miralles2020
number = {11},
pages = {e2020WR028055},
keywords = {evaporation, evapotranspiration, transpiration, interception},
doi = {https://doi.org/10.1029/2020WR028055},
doi = {10.1029/2020WR028055},
url = {https://agupubs.onlinelibrary.wiley.com/doi/abs/10.1029/2020WR028055},
eprint = {https://agupubs.onlinelibrary.wiley.com/doi/pdf/10.1029/2020WR028055},
note = {e2020WR028055 2020WR028055},
Expand All @@ -263,7 +267,7 @@ @article{Yang2018HydrologicIO
year={2018},
volume={9},
pages={44-48},
doi={https://doi.org/10.1038/s41558-018-0361-0}
doi={10.1038/s41558-018-0361-0}
}

@book{pyet0_2019, title={PyETo}, url={https://github.com/woodcrafty/PyETo}, author={Richards, Mark}, year={2019}}
Expand Down
12 changes: 6 additions & 6 deletions pyet/rad_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,24 +118,24 @@ def calc_rad_short(rs=None, tindex=None, lat=None, alpha=0.23, n=None,
if rs is not None:
return (1 - alpha) * rs
else:
return (1 - alpha) * calc_rad_sol_in(tindex, lat, n=n, nn=nn)
return (1 - alpha) * calc_rad_sol_in(tindex, lat, n, nn=nn)


def calc_rad_sol_in(tindex, lat, as1=0.25, bs1=0.5, n=None, nn=None):
def calc_rad_sol_in(tindex, lat, n, as1=0.25, bs1=0.5, nn=None):
"""Incoming solar radiation [MJ m-2 d-1].
Parameters
----------
tindex: pandas.DatetimeIndex
lat: float, optional
the site latitude [rad]
n: pandas.Series/float
actual duration of sunshine [hour]
as1: float, optional
regression constant, expressing the fraction of extraterrestrial
reaching the earth on overcast days (n = 0) [-]
bs1: float, optional
empirical coefficient for extraterrestrial radiation [-]
n: pandas.Series/float, optional
actual duration of sunshine [hour]
nn: pandas.Series/float, optional
maximum possible duration of sunshine or daylight hours [hour]
Expand All @@ -148,8 +148,8 @@ def calc_rad_sol_in(tindex, lat, as1=0.25, bs1=0.5, n=None, nn=None):
Based on equation 35 in [allen_1998]_.
"""
ra = extraterrestrial_r(tindex, lat)
if n is None:
n = daylight_hours(tindex, lat)
if nn is None:
nn = daylight_hours(tindex, lat)
return (as1 + bs1 * n / nn) * ra


Expand Down
16 changes: 16 additions & 0 deletions tests/testmeteo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import unittest

import numpy as np
import pandas as pd

import pyet as et


class Testmeteo(unittest.TestCase):
def test_calc_rad_sol_in(self):
# Based on example 10, p 50 TestFAO56
tindex = pd.to_datetime("2021-5-15")
lat = -22.9 * np.pi / 180
n = 7.1
rad_sol_in = et.calc_rad_sol_in(tindex, lat, n)
self.assertAlmostEqual(float(rad_sol_in), 14.5, 1)

0 comments on commit 527cf39

Please sign in to comment.