INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
r Determine in - plane irradiance components. | def poa_components(aoi, dni, poa_sky_diffuse, poa_ground_diffuse):
r'''
Determine in-plane irradiance components.
Combines DNI with sky diffuse and ground-reflected irradiance to calculate
total, direct and diffuse irradiance components in the plane of array.
Parameters
----------
aoi : nu... |
Estimate diffuse irradiance from ground reflections given irradiance albedo and surface tilt | def get_ground_diffuse(surface_tilt, ghi, albedo=.25, surface_type=None):
'''
Estimate diffuse irradiance from ground reflections given
irradiance, albedo, and surface tilt
Function to determine the portion of irradiance on a tilted surface
due to ground reflections. Any of the inputs may be DataFr... |
r Determine diffuse irradiance from the sky on a tilted surface using Klucher s 1979 model | def klucher(surface_tilt, surface_azimuth, dhi, ghi, solar_zenith,
solar_azimuth):
r'''
Determine diffuse irradiance from the sky on a tilted surface
using Klucher's 1979 model
.. math::
I_{d} = DHI \frac{1 + \cos\beta}{2} (1 + F' \sin^3(\beta/2))
(1 + F' \cos^2\theta\sin^3\t... |
r Determine diffuse irradiance from the sky on a tilted surface using Hay & Davies 1980 model | def haydavies(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
solar_zenith=None, solar_azimuth=None, projection_ratio=None):
r'''
Determine diffuse irradiance from the sky on a tilted surface using
Hay & Davies' 1980 model
.. math::
I_{d} = DHI ( A R_b + (1 - A) (\frac{1 + \co... |
r Determine diffuse irradiance from the sky on a tilted surface using Reindl s 1990 model | def reindl(surface_tilt, surface_azimuth, dhi, dni, ghi, dni_extra,
solar_zenith, solar_azimuth):
r'''
Determine diffuse irradiance from the sky on a tilted surface using
Reindl's 1990 model
.. math::
I_{d} = DHI (A R_b + (1 - A) (\frac{1 + \cos\beta}{2})
(1 + \sqrt{\frac{I_{h... |
Determine diffuse irradiance from the sky on a tilted surface using the King model. | def king(surface_tilt, dhi, ghi, solar_zenith):
'''
Determine diffuse irradiance from the sky on a tilted surface using
the King model.
King's model determines the diffuse irradiance from the sky (ground
reflected irradiance is not included in this algorithm) on a tilted
surface using the surfa... |
Determine diffuse irradiance from the sky on a tilted surface using one of the Perez models. | def perez(surface_tilt, surface_azimuth, dhi, dni, dni_extra,
solar_zenith, solar_azimuth, airmass,
model='allsitescomposite1990', return_components=False):
'''
Determine diffuse irradiance from the sky on a tilted surface using
one of the Perez models.
Perez models determine the di... |
Calculate the clearsky index. | def clearsky_index(ghi, clearsky_ghi, max_clearsky_index=2.0):
"""
Calculate the clearsky index.
The clearsky index is the ratio of global to clearsky global irradiance.
Negative and non-finite clearsky index values will be truncated to zero.
Parameters
----------
ghi : numeric
Glo... |
Calculate the clearness index. | def clearness_index(ghi, solar_zenith, extra_radiation, min_cos_zenith=0.065,
max_clearness_index=2.0):
"""
Calculate the clearness index.
The clearness index is the ratio of global to extraterrestrial
irradiance on a horizontal plane.
Parameters
----------
ghi : numeri... |
Calculate the zenith angle independent clearness index. | def clearness_index_zenith_independent(clearness_index, airmass,
max_clearness_index=2.0):
"""
Calculate the zenith angle independent clearness index.
Parameters
----------
clearness_index : numeric
Ratio of global to extraterrestrial irradiance on a h... |
Estimate Direct Normal Irradiance from Global Horizontal Irradiance using the DISC model. | def disc(ghi, solar_zenith, datetime_or_doy, pressure=101325,
min_cos_zenith=0.065, max_zenith=87, max_airmass=12):
"""
Estimate Direct Normal Irradiance from Global Horizontal Irradiance
using the DISC model.
The DISC algorithm converts global horizontal irradiance to direct
normal irradi... |
Calculate Kn for disc | def _disc_kn(clearness_index, airmass, max_airmass=12):
"""
Calculate Kn for `disc`
Parameters
----------
clearness_index : numeric
airmass : numeric
max_airmass : float
airmass > max_airmass is set to max_airmass before being used
in calculating Kn.
Returns
-------... |
Determine DNI from GHI using the DIRINT modification of the DISC model. | def dirint(ghi, solar_zenith, times, pressure=101325., use_delta_kt_prime=True,
temp_dew=None, min_cos_zenith=0.065, max_zenith=87):
"""
Determine DNI from GHI using the DIRINT modification of the DISC
model.
Implements the modified DISC model known as "DIRINT" introduced in
[1]. DIRINT ... |
Calculate DIRINT DNI from supplied DISC DNI and Kt. | def _dirint_from_dni_ktprime(dni, kt_prime, solar_zenith, use_delta_kt_prime,
temp_dew):
"""
Calculate DIRINT DNI from supplied DISC DNI and Kt'.
Supports :py:func:`gti_dirint`
"""
times = dni.index
delta_kt_prime = _delta_kt_prime_dirint(kt_prime, use_delta_kt_prim... |
Calculate delta_kt_prime ( Perez eqn 2 and eqn 3 ) or return a default value for use with: py: func: _dirint_bins. | def _delta_kt_prime_dirint(kt_prime, use_delta_kt_prime, times):
"""
Calculate delta_kt_prime (Perez eqn 2 and eqn 3), or return a default value
for use with :py:func:`_dirint_bins`.
"""
if use_delta_kt_prime:
# Perez eqn 2
kt_next = kt_prime.shift(-1)
kt_previous = kt_prime.... |
Calculate precipitable water from surface dew point temp ( Perez eqn 4 ) or return a default value for use with: py: func: _dirint_bins. | def _temp_dew_dirint(temp_dew, times):
"""
Calculate precipitable water from surface dew point temp (Perez eqn 4),
or return a default value for use with :py:func:`_dirint_bins`.
"""
if temp_dew is not None:
# Perez eqn 4
w = pd.Series(np.exp(0.07 * temp_dew - 0.075), index=times)
... |
Determine the DISC to DIRINT multiplier dirint_coeffs. | def _dirint_coeffs(times, kt_prime, solar_zenith, w, delta_kt_prime):
"""
Determine the DISC to DIRINT multiplier `dirint_coeffs`.
dni = disc_out['dni'] * dirint_coeffs
Parameters
----------
times : pd.DatetimeIndex
kt_prime : Zenith-independent clearness index
solar_zenith : Solar zen... |
Determine the bins for the DIRINT coefficients. | def _dirint_bins(times, kt_prime, zenith, w, delta_kt_prime):
"""
Determine the bins for the DIRINT coefficients.
Parameters
----------
times : pd.DatetimeIndex
kt_prime : Zenith-independent clearness index
zenith : Solar zenith angle
w : precipitable water estimated from surface dew-po... |
Determine DNI from GHI using the DIRINDEX model which is a modification of the DIRINT model with information from a clear sky model. | def dirindex(ghi, ghi_clearsky, dni_clearsky, zenith, times, pressure=101325.,
use_delta_kt_prime=True, temp_dew=None, min_cos_zenith=0.065,
max_zenith=87):
"""
Determine DNI from GHI using the DIRINDEX model, which is a modification of
the DIRINT model with information from a clea... |
Determine GHI DNI DHI from POA global using the GTI DIRINT model. | def gti_dirint(poa_global, aoi, solar_zenith, solar_azimuth, times,
surface_tilt, surface_azimuth, pressure=101325.,
use_delta_kt_prime=True, temp_dew=None, albedo=.25,
model='perez', model_perez='allsitescomposite1990',
calculate_gt_90=True, max_iterations=30... |
GTI - DIRINT model for AOI < 90 degrees. See Marion 2015 Section 2. 1. | def _gti_dirint_lt_90(poa_global, aoi, aoi_lt_90, solar_zenith, solar_azimuth,
times, surface_tilt, surface_azimuth, pressure=101325.,
use_delta_kt_prime=True, temp_dew=None, albedo=.25,
model='perez', model_perez='allsitescomposite1990',
... |
GTI - DIRINT model for AOI > = 90 degrees. See Marion 2015 Section 2. 2. | def _gti_dirint_gte_90(poa_global, aoi, solar_zenith, solar_azimuth,
surface_tilt, times, kt_prime,
pressure=101325., temp_dew=None, albedo=.25):
"""
GTI-DIRINT model for AOI >= 90 degrees. See Marion 2015 Section 2.2.
See gti_dirint signature for parameter det... |
Determine kt values to be used in GTI - DIRINT AOI > = 90 deg case. See Marion 2015 Section 2. 2. | def _gti_dirint_gte_90_kt_prime(aoi, solar_zenith, solar_azimuth, times,
kt_prime):
"""
Determine kt' values to be used in GTI-DIRINT AOI >= 90 deg case.
See Marion 2015 Section 2.2.
For AOI >= 90 deg: average of the kt_prime values for 65 < AOI < 80
in each day's mo... |
r Estimate DNI and DHI from GHI using the Erbs model. | def erbs(ghi, zenith, datetime_or_doy, min_cos_zenith=0.065, max_zenith=87):
r"""
Estimate DNI and DHI from GHI using the Erbs model.
The Erbs model [1]_ estimates the diffuse fraction DF from global
horizontal irradiance through an empirical relationship between DF
and the ratio of GHI to extrater... |
Determine DNI DHI GHI from extraterrestrial flux transmittance and optical air mass number. | def liujordan(zenith, transmittance, airmass, dni_extra=1367.0):
'''
Determine DNI, DHI, GHI from extraterrestrial flux, transmittance,
and optical air mass number.
Liu and Jordan, 1960, developed a simplified direct radiation model.
DHI is from an empirical equation for diffuse radiation from Liu ... |
Find coefficients for the Perez model | def _get_perez_coefficients(perezmodel):
'''
Find coefficients for the Perez model
Parameters
----------
perezmodel : string (optional, default='allsitescomposite1990')
a character string which selects the desired set of Perez
coefficients. If model is not provided as an input... |
A place to stash the dirint coefficients. | def _get_dirint_coeffs():
"""
A place to stash the dirint coefficients.
Returns
-------
np.array with shape ``(6, 6, 7, 5)``.
Ordering is ``[kt_prime_bin, zenith_bin, delta_kt_prime_bin, w_bin]``
"""
# To allow for maximum copy/paste from the MATLAB 1-indexed code,
# we create and ... |
Determine DNI from GHI and DHI. | def dni(ghi, dhi, zenith, clearsky_dni=None, clearsky_tolerance=1.1,
zenith_threshold_for_zero_dni=88.0,
zenith_threshold_for_clearsky_limit=80.0):
"""
Determine DNI from GHI and DHI.
When calculating the DNI from GHI and DHI the calculated DNI may be
unreasonably high or negative for z... |
Determine clear sky GHI DNI and DHI from Ineichen/ Perez model. | def ineichen(apparent_zenith, airmass_absolute, linke_turbidity,
altitude=0, dni_extra=1364., perez_enhancement=False):
'''
Determine clear sky GHI, DNI, and DHI from Ineichen/Perez model.
Implements the Ineichen and Perez clear sky model for global
horizontal irradiance (GHI), direct norm... |
Look up the Linke Turibidity from the LinkeTurbidities. h5 data file supplied with pvlib. | def lookup_linke_turbidity(time, latitude, longitude, filepath=None,
interp_turbidity=True):
"""
Look up the Linke Turibidity from the ``LinkeTurbidities.h5``
data file supplied with pvlib.
Parameters
----------
time : pandas.DatetimeIndex
latitude : float
l... |
Determine if a year is leap year. | def _is_leap_year(year):
"""Determine if a year is leap year.
Parameters
----------
year : numeric
Returns
-------
isleap : array of bools
"""
isleap = ((np.mod(year, 4) == 0) &
((np.mod(year, 100) != 0) | (np.mod(year, 400) == 0)))
return isleap |
Interpolated monthly Linke turbidity onto daily values. | def _interpolate_turbidity(lts, time):
"""
Interpolated monthly Linke turbidity onto daily values.
Parameters
----------
lts : np.array
Monthly Linke turbidity values.
time : pd.DatetimeIndex
Times to be interpolated onto.
Returns
-------
linke_turbidity : pd.Series... |
List of middle day of each month used by Linke turbidity lookup | def _calendar_month_middles(year):
"""List of middle day of each month, used by Linke turbidity lookup"""
# remove mdays[0] since January starts at mdays[1]
# make local copy of mdays since we need to change
# February for leap years
mdays = np.array(calendar.mdays[1:])
ydays = 365
# handle ... |
linearly scale input to output used by Linke turbidity lookup | def _linearly_scale(inputmatrix, inputmin, inputmax, outputmin, outputmax):
"""linearly scale input to output, used by Linke turbidity lookup"""
inputrange = inputmax - inputmin
outputrange = outputmax - outputmin
delta = outputrange/inputrange # number of indices per input unit
inputmin = inputmin... |
Determine clear sky GHI using the Haurwitz model. | def haurwitz(apparent_zenith):
'''
Determine clear sky GHI using the Haurwitz model.
Implements the Haurwitz clear sky model for global horizontal
irradiance (GHI) as presented in [1, 2]. A report on clear
sky models found the Haurwitz model to have the best performance
in terms of average mont... |
Calculate the clear sky GHI DNI and DHI according to the simplified Solis model [ 1 ] _. | def simplified_solis(apparent_elevation, aod700=0.1, precipitable_water=1.,
pressure=101325., dni_extra=1364.):
"""
Calculate the clear sky GHI, DNI, and DHI according to the
simplified Solis model [1]_.
Reference [1]_ describes the accuracy of the model as being 15, 20,
and 18... |
Calculate the enhanced extraterrestrial irradiance. | def _calc_i0p(i0, w, aod700, p):
"""Calculate the "enhanced extraterrestrial irradiance"."""
p0 = 101325.
io0 = 1.08 * w**0.0051
i01 = 0.97 * w**0.032
i02 = 0.12 * w**0.56
i0p = i0 * (i02*aod700**2 + i01*aod700 + io0 + 0.071*np.log(p/p0))
return i0p |
Calculate the taub coefficient | def _calc_taub(w, aod700, p):
"""Calculate the taub coefficient"""
p0 = 101325.
tb1 = 1.82 + 0.056*np.log(w) + 0.0071*np.log(w)**2
tb0 = 0.33 + 0.045*np.log(w) + 0.0096*np.log(w)**2
tbp = 0.0089*w + 0.13
taub = tb1*aod700 + tb0 + tbp*np.log(p/p0)
return taub |
Calculate the b coefficient. | def _calc_b(w, aod700):
"""Calculate the b coefficient."""
b1 = 0.00925*aod700**2 + 0.0148*aod700 - 0.0172
b0 = -0.7565*aod700**2 + 0.5057*aod700 + 0.4557
b = b1 * np.log(w) + b0
return b |
Calculate the taug coefficient | def _calc_taug(w, aod700, p):
"""Calculate the taug coefficient"""
p0 = 101325.
tg1 = 1.24 + 0.047*np.log(w) + 0.0061*np.log(w)**2
tg0 = 0.27 + 0.043*np.log(w) + 0.0090*np.log(w)**2
tgp = 0.0079*w + 0.1
taug = tg1*aod700 + tg0 + tgp*np.log(p/p0)
return taug |
Calculate the g coefficient. | def _calc_g(w, aod700):
"""Calculate the g coefficient."""
g = -0.0147*np.log(w) - 0.3079*aod700**2 + 0.2846*aod700 + 0.3798
return g |
Calculate the taud coefficient. | def _calc_taud(w, aod700, p):
"""Calculate the taud coefficient."""
# isscalar tests needed to ensure that the arrays will have the
# right shape in the tds calculation.
# there's probably a better way to do this.
if np.isscalar(w) and np.isscalar(aod700):
w = np.array([w])
aod700 ... |
Calculate the d coefficient. | def _calc_d(aod700, p):
"""Calculate the d coefficient."""
p0 = 101325.
dp = 1/(18 + 152*aod700)
d = -0.337*aod700**2 + 0.63*aod700 + 0.116 + dp*np.log(p/p0)
return d |
Detects clear sky times according to the algorithm developed by Reno and Hansen for GHI measurements [ 1 ]. The algorithm was designed and validated for analyzing GHI time series only. Users may attempt to apply it to other types of time series data using different filter settings but should be skeptical of the results... | def detect_clearsky(measured, clearsky, times, window_length,
mean_diff=75, max_diff=75,
lower_line_length=-5, upper_line_length=10,
var_diff=0.005, slope_dev=8, max_iterations=20,
return_components=False):
"""
Detects clear sky tim... |
Bird Simple Clear Sky Broadband Solar Radiation Model | def bird(zenith, airmass_relative, aod380, aod500, precipitable_water,
ozone=0.3, pressure=101325., dni_extra=1364., asymmetry=0.85,
albedo=0.2):
"""
Bird Simple Clear Sky Broadband Solar Radiation Model
Based on NREL Excel implementation by Daryl R. Myers [1, 2].
Bird and Hulstrom d... |
Read in a daily NOAA SURFRAD [ 1 ] file. | def read_surfrad(filename, map_variables=True):
"""Read in a daily NOAA SURFRAD[1] file.
Parameters
----------
filename: str
Filepath or url.
map_variables: bool
When true, renames columns of the Dataframe to pvlib variable names
where applicable. See variable SURFRAD_COLUMN... |
Create UTC localized DatetimeIndex for the dataframe. | def format_index(data):
"""Create UTC localized DatetimeIndex for the dataframe.
Parameters
----------
data: Dataframe
Must contain columns 'year', 'jday', 'hour' and
'minute'.
Return
------
data: Dataframe
Dataframe with a DatetimeIndex localized to UTC.
"""
... |
Used to display deprecation in a standard way. Parameters ---------- since: str The release at which this API became deprecated. message: str optional Override the default deprecation message. The format specifier % ( name ) s may be used for the name of the function and % ( alternative ) s may be used in the deprecati... | def warn_deprecated(
since, message='', name='', alternative='', pending=False,
obj_type='attribute', addendum='', removal=''):
"""
Used to display deprecation in a standard way.
Parameters
----------
since : str
The release at which this API became deprecated.
message : ... |
Decorator to mark a function or a class as deprecated. Parameters ---------- since: str The release at which this API became deprecated. This is required. message: str optional Override the default deprecation message. The format specifier % ( name ) s may be used for the name of the object and % ( alternative ) s may ... | def deprecated(since, message='', name='', alternative='', pending=False,
addendum='', removal=''):
"""
Decorator to mark a function or a class as deprecated.
Parameters
----------
since : str
The release at which this API became deprecated. This is
required.
mess... |
A mapper function to rename Dataframe columns to their pvlib counterparts. | def map_midc_to_pvlib(variable_map, field_name):
"""A mapper function to rename Dataframe columns to their pvlib counterparts.
Parameters
----------
variable_map: Dictionary
A dictionary for mapping MIDC field name to pvlib name. See
VARIABLE_MAP for default value and description of how... |
Create DatetimeIndex for the Dataframe localized to the timezone provided as the label of the second ( time ) column. | def format_index(data):
"""Create DatetimeIndex for the Dataframe localized to the timezone provided
as the label of the second (time) column.
Parameters
----------
data: Dataframe
Must contain 'DATE (MM/DD/YYYY)' column, second column must be labeled
with the timezone and contain t... |
Create DatetimeIndex for the Dataframe localized to the timezone provided as the label of the third column. | def format_index_raw(data):
"""Create DatetimeIndex for the Dataframe localized to the timezone provided
as the label of the third column.
Parameters
----------
data: Dataframe
Must contain columns 'Year' and 'DOY'. Timezone must be found as the
label of the third (time) column.
... |
Read in National Renewable Energy Laboratory Measurement and Instrumentation Data Center [ 1 ] _ weather data. | def read_midc(filename, variable_map=VARIABLE_MAP, raw_data=False):
"""Read in National Renewable Energy Laboratory Measurement and
Instrumentation Data Center [1]_ weather data.
Parameters
----------
filename: string
Filename or url of data to read.
variable_map: dictionary
Dic... |
Request and read MIDC data directly from the raw data api. | def read_midc_raw_data_from_nrel(site, start, end):
"""Request and read MIDC data directly from the raw data api.
Parameters
----------
site: string
The MIDC station id.
start: datetime
Start date for requested data.
end: datetime
End date for requested data.
Return... |
Gives the relative ( not pressure - corrected ) airmass. | def get_relative_airmass(zenith, model='kastenyoung1989'):
'''
Gives the relative (not pressure-corrected) airmass.
Gives the airmass at sea-level when given a sun zenith angle (in
degrees). The ``model`` variable allows selection of different
airmass models (described below). If ``model`` is not i... |
r Calculates precipitable water ( cm ) from ambient air temperature ( C ) and relatively humidity ( % ) using an empirical model. The accuracy of this method is approximately 20% for moderate PW ( 1 - 3 cm ) and less accurate otherwise. | def gueymard94_pw(temp_air, relative_humidity):
r"""
Calculates precipitable water (cm) from ambient air temperature (C)
and relatively humidity (%) using an empirical model. The
accuracy of this method is approximately 20% for moderate PW (1-3
cm) and less accurate otherwise.
The model was dev... |
r Spectral mismatch modifier based on precipitable water and absolute ( pressure corrected ) airmass. | def first_solar_spectral_correction(pw, airmass_absolute, module_type=None,
coefficients=None):
r"""
Spectral mismatch modifier based on precipitable water and absolute
(pressure corrected) airmass.
Estimates a spectral mismatch modifier M representing the effect on
... |
Calculate Linke turbidity factor using Kasten pyrheliometric formula. | def kasten96_lt(airmass_absolute, precipitable_water, aod_bb):
"""
Calculate Linke turbidity factor using Kasten pyrheliometric formula.
Note that broadband aerosol optical depth (AOD) can be approximated by AOD
measured at 700 nm according to Molineaux [4] . Bird and Hulstrom offer an
alternate ap... |
r Calculate Angstrom alpha exponent. | def angstrom_alpha(aod1, lambda1, aod2, lambda2):
r"""
Calculate Angstrom alpha exponent.
Parameters
----------
aod1 : numeric
first aerosol optical depth
lambda1 : numeric
wavelength in nanometers corresponding to ``aod1``
aod2 : numeric
second aerosol optical depth... |
Converts or localizes a time series to UTC. | def localize_to_utc(time, location):
"""
Converts or localizes a time series to UTC.
Parameters
----------
time : datetime.datetime, pandas.DatetimeIndex,
or pandas.Series/DataFrame with a DatetimeIndex.
location : pvlib.Location object
Returns
-------
pandas object loca... |
Converts a datetime to the Dublin Julian Day | def datetime_to_djd(time):
"""
Converts a datetime to the Dublin Julian Day
Parameters
----------
time : datetime.datetime
time to convert
Returns
-------
float
fractional days since 12/31/1899+0000
"""
if time.tzinfo is None:
time_utc = pytz.utc.locali... |
Converts a Dublin Julian Day float to a datetime. datetime object | def djd_to_datetime(djd, tz='UTC'):
"""
Converts a Dublin Julian Day float to a datetime.datetime object
Parameters
----------
djd : float
fractional days since 12/31/1899+0000
tz : str, default 'UTC'
timezone to localize the result to
Returns
-------
datetime.datet... |
Convert a day of year scalar or array to a pd. DatetimeIndex. | def _doy_to_datetimeindex(doy, epoch_year=2014):
"""
Convert a day of year scalar or array to a pd.DatetimeIndex.
Parameters
----------
doy : numeric
Contains days of the year
Returns
-------
pd.DatetimeIndex
"""
doy = np.atleast_1d(doy).astype('float')
epoch = pd.T... |
Parameters ---------- keys: iterable Typically a list of strings. adict: dict - like A dictionary from which to attempt to pull each key. | def _build_kwargs(keys, input_dict):
"""
Parameters
----------
keys : iterable
Typically a list of strings.
adict : dict-like
A dictionary from which to attempt to pull each key.
Returns
-------
kwargs : dict
A dictionary with only the keys that were in input_dic... |
A vectorized version of Newton Halley and secant methods for arrays. Do not use this method directly. This method is called from: func: newton when np. isscalar ( x0 ) is true. For docstring see: func: newton. | def _array_newton(func, x0, fprime, args, tol, maxiter, fprime2,
converged=False):
"""
A vectorized version of Newton, Halley, and secant methods for arrays. Do
not use this method directly. This method is called from :func:`newton`
when ``np.isscalar(x0)`` is true. For docstring, see ... |
Vectorized golden section search for finding MPP from a dataframe timeseries. | def _golden_sect_DataFrame(params, VL, VH, func):
"""
Vectorized golden section search for finding MPP from a dataframe
timeseries.
Parameters
----------
params : dict
Dictionary containing scalars or arrays
of inputs to the function to be optimized.
Each row should repr... |
Determine the rotation angle of a single axis tracker using the equations in [ 1 ] when given a particular sun zenith and azimuth angle. backtracking may be specified and if so a ground coverage ratio is required. | def singleaxis(apparent_zenith, apparent_azimuth,
axis_tilt=0, axis_azimuth=0, max_angle=90,
backtrack=True, gcr=2.0/7.0):
"""
Determine the rotation angle of a single axis tracker using the
equations in [1] when given a particular sun zenith and azimuth
angle. backtracking... |
Get tracking data. See: py: func: pvlib. tracking. singleaxis more detail. | def singleaxis(self, apparent_zenith, apparent_azimuth):
"""
Get tracking data. See :py:func:`pvlib.tracking.singleaxis` more
detail.
Parameters
----------
apparent_zenith : float, 1d array, or Series
Solar apparent zenith angles in decimal degrees.
... |
Uses the: func: irradiance. get_total_irradiance function to calculate the plane of array irradiance components on a tilted surface defined by the input data and self. albedo. | def get_irradiance(self, surface_tilt, surface_azimuth,
solar_zenith, solar_azimuth, dni, ghi, dhi,
dni_extra=None, airmass=None, model='haydavies',
**kwargs):
"""
Uses the :func:`irradiance.get_total_irradiance` function to
ca... |
Read University of Oregon SRML [ 1 ] 1min. tsv file into pandas dataframe. | def read_srml(filename):
"""
Read University of Oregon SRML[1] 1min .tsv file into pandas dataframe.
Parameters
----------
filename: str
filepath or url to read for the tsv file.
Returns
-------
data: Dataframe
A dataframe with datetime index and all of the variables li... |
Map data element numbers to pvlib names. | def map_columns(col):
"""Map data element numbers to pvlib names.
Parameters
----------
col: str
Column label to be mapped.
Returns
-------
str
The pvlib label if it was found in the mapping,
else the original label.
"""
if col.startswith('7'):
# spe... |
Create a datetime index from day of year and time columns. | def format_index(df):
"""Create a datetime index from day of year, and time columns.
Parameters
----------
df: pd.Dataframe
The srml data to reindex.
Returns
-------
df: pd.Dataframe
The Dataframe with a DatetimeIndex localized to 'Etc/GMT+8'.
"""
# Name of the seco... |
Request a month of SRML [ 1 ] data from solardat and read it into a Dataframe. | def read_srml_month_from_solardat(station, year, month, filetype='PO'):
"""Request a month of SRML[1] data from solardat and read it into
a Dataframe.
Parameters
----------
station: str
The name of the SRML station to request.
year: int
Year to request data for
month: int
... |
Download data from ECMWF MACC Reanalysis API. | def get_ecmwf_macc(filename, params, startdate, stopdate, lookup_params=True,
server=None, target=_ecmwf):
"""
Download data from ECMWF MACC Reanalysis API.
Parameters
----------
filename : str
full path of file where to save data, ``.nc`` appended if not given
params... |
Read data from ECMWF MACC reanalysis netCDF4 file. | def read_ecmwf_macc(filename, latitude, longitude, utc_time_range=None):
"""
Read data from ECMWF MACC reanalysis netCDF4 file.
Parameters
----------
filename : string
full path to netCDF4 data file.
latitude : float
latitude in degrees
longitude : float
longitude in... |
Get nearest indices to ( latitude longitude ). | def get_nearest_indices(self, latitude, longitude):
"""
Get nearest indices to (latitude, longitude).
Parmaeters
----------
latitude : float
Latitude in degrees
longitude : float
Longitude in degrees
Returns
-------
idx_la... |
Interpolate param values to utc_time using indices nearest to ( latitude longitude ). | def interp_data(self, latitude, longitude, utc_time, param):
"""
Interpolate ``param`` values to ``utc_time`` using indices nearest to
(``latitude, longitude``).
Parmaeters
----------
latitude : float
Latitude in degrees
longitude : float
... |
Read NOAA SOLRAD [ 1 ] _ [ 2 ] _ fixed - width file into pandas dataframe. | def read_solrad(filename):
"""
Read NOAA SOLRAD [1]_ [2]_ fixed-width file into pandas dataframe.
Parameters
----------
filename: str
filepath or url to read for the fixed-width file.
Returns
-------
data: Dataframe
A dataframe with DatetimeIndex and all of the variable... |
Read NOAA USCRN [ 1 ] _ [ 2 ] _ fixed - width file into pandas dataframe. | def read_crn(filename):
"""
Read NOAA USCRN [1]_ [2]_ fixed-width file into pandas dataframe.
Parameters
----------
filename: str
filepath or url to read for the fixed-width file.
Returns
-------
data: Dataframe
A dataframe with DatetimeIndex and all of the variables in... |
Read an EPW file in to a pandas dataframe. | def read_epw(filename, coerce_year=None):
'''
Read an EPW file in to a pandas dataframe.
Note that values contained in the metadata dictionary are unchanged
from the EPW file.
EPW files are commonly used by building simulation professionals
and are widely available on the web. For example via:... |
Create an object based on a metadata dictionary from tmy2 or tmy3 data readers. | def from_tmy(cls, tmy_metadata, tmy_data=None, **kwargs):
"""
Create an object based on a metadata
dictionary from tmy2 or tmy3 data readers.
Parameters
----------
tmy_metadata : dict
Returned from tmy.readtmy2 or tmy.readtmy3
tmy_data : None or DataF... |
Uses the: py: func: solarposition. get_solarposition function to calculate the solar zenith azimuth etc. at this location. | def get_solarposition(self, times, pressure=None, temperature=12,
**kwargs):
"""
Uses the :py:func:`solarposition.get_solarposition` function
to calculate the solar zenith, azimuth, etc. at this location.
Parameters
----------
times : DatetimeIn... |
Calculate the clear sky estimates of GHI DNI and/ or DHI at this location. | def get_clearsky(self, times, model='ineichen', solar_position=None,
dni_extra=None, **kwargs):
"""
Calculate the clear sky estimates of GHI, DNI, and/or DHI
at this location.
Parameters
----------
times: DatetimeIndex
model: str, default 'in... |
Calculate the relative and absolute airmass. | def get_airmass(self, times=None, solar_position=None,
model='kastenyoung1989'):
"""
Calculate the relative and absolute airmass.
Automatically chooses zenith or apparant zenith
depending on the selected model.
Parameters
----------
times : N... |
Calculate sunrise sunset and transit times. | def get_sun_rise_set_transit(self, times, method='pyephem', **kwargs):
"""
Calculate sunrise, sunset and transit times.
Parameters
----------
times : DatetimeIndex
Must be localized to the Location
method : str, default 'pyephem'
'pyephem', 'spa',... |
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. | 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.
However, it is much faster to convert to unix/epoch time and then convert
to julian day. Note that the date must be UTC."""
if month <= 2:
year = y... |
Loop through the time array and calculate the solar position | def solar_position_loop(unixtime, loc_args, out):
"""Loop through the time array and calculate the solar position"""
lat = loc_args[0]
lon = loc_args[1]
elev = loc_args[2]
pressure = loc_args[3]
temp = loc_args[4]
delta_t = loc_args[5]
atmos_refract = loc_args[6]
sst = loc_args[7]
... |
Calculate the solar position using the numba compiled functions and multiple threads. Very slow if functions are not numba compiled. | def solar_position_numba(unixtime, lat, lon, elev, pressure, temp, delta_t,
atmos_refract, numthreads, sst=False, esd=False):
"""Calculate the solar position using the numba compiled functions
and multiple threads. Very slow if functions are not numba compiled.
"""
# these args ... |
Calculates the distance from the earth to the sun using the NREL SPA algorithm described in [ 1 ]. | def earthsun_distance(unixtime, delta_t, numthreads):
"""
Calculates the distance from the earth to the sun using the
NREL SPA algorithm described in [1].
Parameters
----------
unixtime : numpy array
Array of unix/epoch timestamps to calculate solar position for.
Unixtime is the... |
Calculate the difference between Terrestrial Dynamical Time ( TD ) and Universal Time ( UT ). | def calculate_deltat(year, month):
"""Calculate the difference between Terrestrial Dynamical Time (TD)
and Universal Time (UT).
Note: This function is not yet compatible for calculations using
Numba.
Equations taken from http://eclipse.gsfc.nasa.gov/SEcat5/deltatpoly.html
"""
plw = 'Delta... |
Calculate front and back surface plane - of - array irradiance on a fixed tilt or single - axis tracker PV array configuration and using the open - source pvfactors package. Please refer to pvfactors online documentation for more details: https:// sunpower. github. io/ pvfactors/ | def pvfactors_timeseries(
solar_azimuth, solar_zenith, surface_azimuth, surface_tilt,
timestamps, dni, dhi, gcr, pvrow_height, pvrow_width, albedo,
n_pvrows=3, index_observed_pvrow=1,
rho_front_pvrow=0.03, rho_back_pvrow=0.05,
horizon_band_angle=15.,
run_parallel_calculat... |
File based sample for the Google Assistant API. | def main(api_endpoint, credentials,
device_model_id, device_id, lang, verbose,
input_audio_file, output_audio_file,
block_size, grpc_deadline, *args, **kwargs):
"""File based sample for the Google Assistant API.
Examples:
$ python -m audiofileinput -i <input file> -o <output fi... |
Pretty prints events. | def process_event(event):
"""Pretty prints events.
Prints all events that occur with two spaces between each new
conversation and a single space between turns of a conversation.
Args:
event(event.Event): The current event to process.
"""
if event.type == EventType.ON_CONVERSATION_TURN_... |
Build ClickException from a failed request. | def failed_request_exception(message, r):
"""Build ClickException from a failed request."""
try:
resp = json.loads(r.text)
message = '%s: %d\n%s' % (message, resp['error']['code'],
resp['error']['message'])
return click.ClickException(message)
except... |
Prints out a device model in the terminal by parsing dict. | def pretty_print_model(devicemodel):
"""Prints out a device model in the terminal by parsing dict."""
PRETTY_PRINT_MODEL = """Device Model ID: %(deviceModelId)s
Project ID: %(projectId)s
Device Type: %(deviceType)s"""
logging.info(PRETTY_PRINT_MODEL % devicemodel)
if 'traits' in devicemo... |
Prints out a device instance in the terminal by parsing dict. | def pretty_print_device(device):
"""Prints out a device instance in the terminal by parsing dict."""
logging.info('Device Instance ID: %s' % device['id'])
if 'nickname' in device:
logging.info(' Nickname: %s' % device['nickname'])
if 'modelId' in device:
logging.info(' Model: %s' %... |
Registers a device model and instance. | def register(ctx, model, type, trait, manufacturer, product_name, description,
device, nickname, client_type):
"""Registers a device model and instance.
Device model fields can only contain letters, numbers, and the following
symbols: period (.), hyphen (-), underscore (_), space ( ) and plus ... |
Registers a device model. | def register_model(ctx, model, type, trait,
manufacturer, product_name, description):
"""Registers a device model.
Device model fields can only contain letters, numbers, and the following
symbols: period (.), hyphen (-), underscore (_), space ( ) and plus (+).
The first character of ... |
Registers a device instance under an existing device model. | def register_device(ctx, device, model, nickname, client_type):
"""Registers a device instance under an existing device model.
Device instance fields must start with a letter or number. The device ID
can only contain letters, numbers, and the following symbols: period (.),
hyphen (-), underscore (_), a... |
Gets all of the information ( fields ) for a given device model or instance. | def get(ctx, resource, id):
"""Gets all of the information (fields) for a given device model or
instance.
"""
session, api_url, project_id = build_client_from_context(ctx)
url = '/'.join([api_url, resource, id])
r = session.get(url)
if r.status_code != 200:
raise failed_request_excep... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.