Skip to content

add Boyle/Coello (Humboldt State Univ) soiling model #850

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

Merged
merged 23 commits into from
Jan 17, 2020
Merged
Changes from 1 commit
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
19 changes: 10 additions & 9 deletions pvlib/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,30 @@
import pandas as pd
from pvlib.tools import cosd


def erf(x):
"""
Calculates the ERF function
Calculates the ERF function

Parameters
----------
x : numeric
Input value/array
Input value/array

Returns
-------
erf : numeric
The values of the error function at the given points x.
The values of the error function at the given points x.

"""


# constants
a1 = 0.254829592
a1 = 0.254829592
a2 = -0.284496736
a3 = 1.421413741
a3 = 1.421413741
a4 = -1.453152027
a5 = 1.061405429
p = 0.3275911
a5 = 1.061405429
p = 0.3275911

# Save the sign of x
sign = 1
Expand All @@ -45,6 +45,7 @@ def erf(x):

return sign*y


def soiling_hsu(rainfall, cleaning_threshold, tilt, pm2_5, pm10,
depo_veloc={'2_5': 0.004, '10': 0.0009},
rain_accum_period=pd.Timedelta('1h')):
Expand Down Expand Up @@ -114,6 +115,6 @@ def soiling_hsu(rainfall, cleaning_threshold, tilt, pm2_5, pm10,
mass_removed[cleaning_times] = mass_no_cleaning[cleaning_times]
accum_mass = mass_no_cleaning - mass_removed.ffill()

soiling_ratio = 1 - 0.3437 * math.erf(0.17 * accum_mass**0.8473)
soiling_ratio = 1 - 0.3437 * erf(0.17 * accum_mass**0.8473)
Copy link
Member

Choose a reason for hiding this comment

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

Oh bother. It appears I've sent you off on a fruitless chase, please accept my apologies. I have numpy.erf in my local namespace but its not part of numpy: discussion here. I need to figure out how numpy.erf was added and undo it.

Rather than add an erf function to pvlib, we should use scipy.special.erf as you originally coded.

To fix the test errors, add the following lines to test_losses.py:

at the head:
from pvlib.test.conftest import requires_scipy

on the line preceding def test_soiling_hsu():
@requires_scipy

Example here.

Again, I'm very sorry that I failed to confirm numpy.erf in the numpy documentation.

Copy link
Contributor Author

@nappaillav nappaillav Jan 16, 2020

Choose a reason for hiding this comment

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

Not a problem, It was always a great learning experience for me.


return soiling_ratio