Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed extra argument given #78

Open
wants to merge 16 commits into
base: dev
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install setuptools wheel twine build
- name: Build package
run: python -m build
- name: Upload Python Package
uses: pypa/gh-action-pypi-publish@release/v1
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
password: ${{ secrets.PYPY_TOKEN }}
4 changes: 2 additions & 2 deletions pyet/rad_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def calc_rad_long(
rso = rso.where(rso != 0, 0.001)
if len(rs.shape) == 3 and len(rso.shape) == 1:
rso = rso.values[:, newaxis, newaxis]
solar_rat = clip(rs / rso, 0.3, 1)
solar_rat = clip(rs.values / rso.values, 0.3, 1)
if tmax is not None:
tmp1 = STEFAN_BOLTZMANN_DAY * ((tmax + 273.16) ** 4 + (tmin + 273.16) ** 4) / 2
else:
Expand Down Expand Up @@ -279,7 +279,7 @@ def calc_rad_sol_in(n, lat, as1=0.25, bs1=0.5, nn=None):
ra = extraterrestrial_r(tindex, lat)
if nn is None:
nn = daylight_hours(tindex, lat)
return (as1 + bs1 * n / nn) * ra
return (as1 + bs1 * n.values / nn) * ra


def calc_rso(ra, elevation, kab=None):
Expand Down
22 changes: 15 additions & 7 deletions pyet/radiation.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from numpy import sqrt, log
from xarray import DataArray
from pandas import Series
from pandas import Series ,to_datetime
from .meteo_utils import extraterrestrial_r, calc_press, calc_psy, calc_vpc, calc_lambda
from .utils import get_index, check_rad, clip_zeros, pet_out, check_rh

Expand Down Expand Up @@ -104,8 +104,11 @@ def jensen_haise(tmean, rs=None, cr=0.025, tx=-3, lat=None, method=0, clip_zero=
if lat is None:
raise Exception("If you choose method == 1, provide lat!")
index = get_index(tmean)
ra = extraterrestrial_r(index, lat, tmean)
pet = ra * (tmean + 5) / 68 / lambd
ra = extraterrestrial_r(index, lat)

temp = (tmean + 5) / 68 / lambd

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can i suggest to put the parenthesis here to make clear which division is made first.

I'm sure the code is correct but it is not clear which is the first division :)

temp.index = to_datetime(temp.index)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why use "to_datetime"? The temp should already be DatetimeIndex?

Thank you for your contributions!

pet = ra * temp
else:
raise Exception("Method can be either 0 or 1.")
pet = clip_zeros(pet, clip_zero)
Expand Down Expand Up @@ -148,7 +151,9 @@ def mcguinness_bordne(tmean, lat, k=0.0147, clip_zero=True):
ra = extraterrestrial_r(index, lat)
if isinstance(tmean, DataArray) and isinstance(ra, Series):
ra = ra.values[:, None, None]
pet = k * ra * (tmean + 5) / lambd
temp = (tmean + 5) / lambd
temp.index = to_datetime(temp.index)
pet = k * ra * temp
pet = clip_zeros(pet, clip_zero)
return pet_out(tmean, pet, "Mcguinness_Bordne")

Expand Down Expand Up @@ -445,8 +450,11 @@ def oudin(tmean, lat, k1=100, k2=5, clip_zero=True):
"""
lambd = calc_lambda(tmean)
index = get_index(tmean)
ra = extraterrestrial_r(index, lat)
pet = ra * (tmean + k2) / lambd / k1
pet = pet.where((tmean + k2) >= 0, 0)
ra = extraterrestrial_r(index, lat)
temp = (tmean + k2) / lambd / k1
temp.index = to_datetime(temp.index)
pet = ra * temp
# pet = pet.where((tmean + k2) >= 0, 0)
# the above line of code is not working properly and setting all the values in pet 0.0
pet = clip_zeros(pet, clip_zero)
return pet_out(tmean, pet, "Oudin")