Skip to content
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
6 changes: 4 additions & 2 deletions pvlib/clearsky.py
Original file line number Diff line number Diff line change
Expand Up @@ -668,9 +668,11 @@ def _clearsky_get_threshold(sample_interval):
window_length = np.interp(sample_interval, data_freq, [50, 60, 90, 120])
mean_diff = np.interp(sample_interval, data_freq, [75, 75, 75, 75])
max_diff = np.interp(sample_interval, data_freq, [60, 65, 75, 90])
lower_line_length = np.interp(sample_interval, data_freq, [-45,-45,-45,-45])
lower_line_length = np.interp(sample_interval, data_freq,
[-45, -45, -45, -45])
upper_line_length = np.interp(sample_interval, data_freq, [80, 80, 80, 80])
var_diff = np.interp(sample_interval, data_freq, [0.005, 0.01, 0.032, 0.07])
var_diff = np.interp(sample_interval, data_freq,
[0.005, 0.01, 0.032, 0.07])
slope_dev = np.interp(sample_interval, data_freq, [50, 60, 75, 96])

return (window_length, mean_diff, max_diff, lower_line_length,
Expand Down
7 changes: 3 additions & 4 deletions pvlib/iotools/acis.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _get_acis(start, end, params, map_variables, url, **kwargs):
metadata = payload['meta']

try:
# for StnData endpoint, unpack combination "ll" into lat, lon
# for StnData endpoint, unpack combination "ll" into lat, lon
metadata['lon'], metadata['lat'] = metadata.pop('ll')
except KeyError:
pass
Expand Down Expand Up @@ -244,7 +244,6 @@ def get_acis_nrcc(latitude, longitude, start, end, grid, map_variables=True,
return df, meta



def get_acis_mpe(latitude, longitude, start, end, map_variables=True,
url="https://data.rcc-acis.org/GridData", **kwargs):
"""
Expand Down Expand Up @@ -453,7 +452,7 @@ def get_acis_available_stations(latitude_range, longitude_range,
-------
stations : pandas.DataFrame
A dataframe of station metadata, one row per station.
The ``sids`` column contains IDs that can be used with
The ``sids`` column contains IDs that can be used with
:py:func:`get_acis_station_data`.

Raises
Expand Down Expand Up @@ -489,7 +488,7 @@ def get_acis_available_stations(latitude_range, longitude_range,
params = {
"bbox": bbox,
"meta": ("name,state,sids,sid_dates,ll,elev,"
"uid,county,climdiv,tzo,network"),
"uid,county,climdiv,tzo,network"),
}
if start is not None and end is not None:
params['elems'] = ['maxt', 'mint', 'avgt', 'obst',
Expand Down
6 changes: 4 additions & 2 deletions pvlib/iotools/midc.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@


def _format_index(data):
"""Create DatetimeIndex for the Dataframe localized to the timezone provided
"""
Create DatetimeIndex for the Dataframe localized to the timezone provided
as the label of the second (time) column.

Parameters
Expand All @@ -132,7 +133,8 @@ def _format_index(data):


def _format_index_raw(data):
"""Create DatetimeIndex for the Dataframe localized to the timezone provided
"""
Create DatetimeIndex for the Dataframe localized to the timezone provided
as the label of the third column.

Parameters
Expand Down
9 changes: 6 additions & 3 deletions pvlib/irradiance.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ def _handle_extra_radiation_types(datetime_or_doy, epoch_year):
# a better way to do it.
if isinstance(datetime_or_doy, pd.DatetimeIndex):
to_doy = tools._pandas_to_doy # won't be evaluated unless necessary
def to_datetimeindex(x): return x # noqa: E306
Copy link
Contributor Author

Choose a reason for hiding this comment

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

E704 multiple statements on one line (def)

def to_datetimeindex(x): # noqa: E306
return x
to_output = partial(pd.Series, index=datetime_or_doy)
elif isinstance(datetime_or_doy, pd.Timestamp):
to_doy = tools._pandas_to_doy
Expand All @@ -146,12 +147,14 @@ def to_datetimeindex(x): return x # noqa: E306
tools._datetimelike_scalar_to_datetimeindex
to_output = tools._scalar_out
elif np.isscalar(datetime_or_doy): # ints and floats of various types
def to_doy(x): return x # noqa: E306
def to_doy(x): # noqa: E306
return x
to_datetimeindex = partial(tools._doy_to_datetimeindex,
epoch_year=epoch_year)
to_output = tools._scalar_out
else: # assume that we have an array-like object of doy
def to_doy(x): return x # noqa: E306
def to_doy(x): # noqa: E306
return x
to_datetimeindex = partial(tools._doy_to_datetimeindex,
epoch_year=epoch_year)
to_output = tools._array_out
Expand Down
28 changes: 17 additions & 11 deletions pvlib/singlediode.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,8 +782,9 @@ def _lambertw_v_from_i(current, photocurrent, saturation_current,

# Explicit solutions where Gsh=0
if np.any(idx_z):
V[idx_z] = a[idx_z] * np.log1p((IL[idx_z] - I[idx_z]) / I0[idx_z]) - \
Copy link
Contributor Author

Choose a reason for hiding this comment

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

F401 'warnings.warn' imported but unused

I[idx_z] * Rs[idx_z]
V[idx_z] = \
a[idx_z] * np.log1p((IL[idx_z] - I[idx_z]) / I0[idx_z]) - \
I[idx_z] * Rs[idx_z]

# Only compute using LambertW if there are cases with Gsh>0
if np.any(idx_p):
Expand Down Expand Up @@ -865,17 +866,21 @@ def _lambertw_i_from_v(voltage, photocurrent, saturation_current,

# Explicit solutions where Rs=0
if np.any(idx_z):
I[idx_z] = IL[idx_z] - I0[idx_z] * np.expm1(V[idx_z] / a[idx_z]) - \
Gsh[idx_z] * V[idx_z]
I[idx_z] = \
IL[idx_z] - I0[idx_z] * np.expm1(V[idx_z] / a[idx_z]) - \
Gsh[idx_z] * V[idx_z]

# Only compute using LambertW if there are cases with Rs>0
# Does NOT handle possibility of overflow, github issue 298
if np.any(idx_p):
# LambertW argument, cannot be float128, may overflow to np.inf
argW = Rs[idx_p] * I0[idx_p] / (
a[idx_p] * (Rs[idx_p] * Gsh[idx_p] + 1.)) * \
np.exp((Rs[idx_p] * (IL[idx_p] + I0[idx_p]) + V[idx_p]) /
(a[idx_p] * (Rs[idx_p] * Gsh[idx_p] + 1.)))
argW = (
Rs[idx_p] * I0[idx_p]
/ (a[idx_p] * (Rs[idx_p] * Gsh[idx_p] + 1.))
* np.exp(
(Rs[idx_p] * (IL[idx_p] + I0[idx_p]) + V[idx_p])
/ (a[idx_p] * (Rs[idx_p] * Gsh[idx_p] + 1.))
))

# lambertw typically returns complex value with zero imaginary part
# may overflow to np.inf
Expand All @@ -884,9 +889,10 @@ def _lambertw_i_from_v(voltage, photocurrent, saturation_current,
# Eqn. 2 in Jain and Kapoor, 2004
# I = -V/(Rs + Rsh) - (a/Rs)*lambertwterm + Rsh*(IL + I0)/(Rs + Rsh)
# Recast in terms of Gsh=1/Rsh for better numerical stability.
I[idx_p] = (IL[idx_p] + I0[idx_p] - V[idx_p] * Gsh[idx_p]) / \
(Rs[idx_p] * Gsh[idx_p] + 1.) - (
a[idx_p] / Rs[idx_p]) * lambertwterm
I[idx_p] = \
(IL[idx_p] + I0[idx_p] - V[idx_p] * Gsh[idx_p]) / \
(Rs[idx_p] * Gsh[idx_p] + 1.) - (a[idx_p] / Rs[idx_p]) * \
lambertwterm

if output_is_scalar:
return I.item()
Expand Down
6 changes: 4 additions & 2 deletions pvlib/solarposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -1053,7 +1053,8 @@ def equation_of_time_spencer71(dayofyear):
Myers [4]_ and printed in both the Fourier paper from the Sundial
Mailing List and R. Hulstrom's [5]_ book.

.. _Fourier paper: http://www.mail-archive.com/sundial@uni-koeln.de/msg01050.html
.. _Fourier paper:
http://www.mail-archive.com/sundial@uni-koeln.de/msg01050.html

Parameters
----------
Expand Down Expand Up @@ -1101,7 +1102,8 @@ def equation_of_time_pvcdrom(dayofyear):
`PVCDROM`_ is a website by Solar Power Lab at Arizona State
University (ASU)

.. _PVCDROM: http://www.pveducation.org/pvcdrom/2-properties-sunlight/solar-time
.. _PVCDROM:
http://www.pveducation.org/pvcdrom/2-properties-sunlight/solar-time

Parameters
----------
Expand Down
15 changes: 10 additions & 5 deletions pvlib/spa.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,11 @@
@jcompile('float64(int64, int64, int64, int64, int64, int64, int64)',
nopython=True)
def julian_day_dt(year, month, day, hour, minute, second, microsecond):
"""This is the original way to calculate the julian day from the NREL paper.
"""
This is the original way to calculate the julian day from the NREL paper.
However, it is much faster to convert to unix/epoch time and then convert
to julian day. Note that the date must be UTC."""
to julian day. Note that the date must be UTC.
"""
if month <= 2:
year = year-1
month = month+12
Expand Down Expand Up @@ -461,6 +463,7 @@
s += arr[row, 0] * np.cos(arr[row, 1] + arr[row, 2] * x)
return s


@jcompile('float64(float64)', nopython=True)
def heliocentric_longitude(jme):
l0 = sum_mult_cos_add_mult(L0, jme)
Expand All @@ -472,9 +475,10 @@

l_rad = (l0 + l1 * jme + l2 * jme**2 + l3 * jme**3 + l4 * jme**4 +
l5 * jme**5)/10**8
l = np.rad2deg(l_rad)

Check failure on line 478 in pvlib/spa.py

View workflow job for this annotation

GitHub Actions / flake8-linter

E741 ambiguous variable name 'l'
return l % 360


@jcompile('float64(float64)', nopython=True)
def heliocentric_latitude(jme):
b0 = sum_mult_cos_add_mult(B0, jme)
Expand Down Expand Up @@ -762,9 +766,10 @@


@jcompile('float64(float64, float64, float64, float64)', nopython=True)
def atmospheric_refraction_correction(local_pressure, local_temp,
topocentric_elevation_angle_wo_atmosphere,
atmos_refract):
def atmospheric_refraction_correction(
local_pressure, local_temp,
topocentric_elevation_angle_wo_atmosphere,
atmos_refract):
# switch sets delta_e when the sun is below the horizon
switch = topocentric_elevation_angle_wo_atmosphere >= -1.0 * (
0.26667 + atmos_refract)
Expand Down
2 changes: 0 additions & 2 deletions pvlib/spectrum/mismatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import pandas as pd
from scipy.integrate import trapezoid

from warnings import warn
Copy link
Contributor Author

Choose a reason for hiding this comment

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

F401 'warnings.warn' imported but unused



def calc_spectral_mismatch_field(sr, e_sun, e_ref=None):
"""
Expand Down
1 change: 0 additions & 1 deletion pvlib/temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import numpy as np
import pandas as pd
from pvlib.tools import sind
from pvlib._deprecation import warn_deprecated
Copy link
Contributor Author

Choose a reason for hiding this comment

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

F401 'warnings.warn' imported but unused

from pvlib.tools import _get_sample_intervals
import scipy
import scipy.constants
Expand Down
Loading