Skip to content

Commit

Permalink
handle equals
Browse files Browse the repository at this point in the history
  • Loading branch information
cwhanse committed Apr 10, 2024
1 parent 42e582a commit 2af3fa0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 2 additions & 0 deletions docs/examples/snow-detection/snow-mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ def wrapper(voltage, current, temp_cell, effective_irradiance,
2. Calculate transmission
3. Uses transmission to model voltage with the SAPM.
# TODO How is this voltage different than measured (snow-affected voltage)?
# Answer: All cells are modeled to get the incoming irradiance
4. Determine the snow mode for each point.
Parameters
Expand Down Expand Up @@ -652,6 +653,7 @@ def wrapper(voltage, current, temp_cell, effective_irradiance,
modeled_line = Line2D([0], [0], label='Modeled', color='k', ls='--')
measured_line = Line2D([0], [0], label='Measured', color='k')

# TODO don't mark offline periods as Mode 0
red_patch = mpatches.Patch(color='r', alpha=0.05, label='Mode 0')
blue_patch = mpatches.Patch(color='b', alpha=0.05, label='Mode 1')
yellow_patch = mpatches.Patch(color='y', alpha=0.05, label='Mode 2')
Expand Down
24 changes: 12 additions & 12 deletions pvanalytics/features/snow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
def get_horizon_mask(horizon, azimuth, elevation):

"""
Determines if a given (azimuth, elevation) pair is above or
below a horizon profile
Determines if a given (azimuth, elevation) pair is above a horizon profile.
Parameters
----------
Expand All @@ -22,7 +21,7 @@ def get_horizon_mask(horizon, azimuth, elevation):
out : bool or NaN
"""
yp = np.interp(azimuth, horizon.index, horizon.values)
out = elevation >= yp # TODO or strictly >
out = elevation >= yp
return out


Expand Down Expand Up @@ -106,9 +105,9 @@ def get_transmission(measured_e_e, modeled_e_e, i_mp):
measured irradiance.
Measured irradiance should be in the array's plane and represent snow-free
conditions. When possible, the irradiance should be adjusted for
reflections and spectral content. For example, the measured irradiance
could be obtained with a heated plane-of-array pyranometer.
conditions. For example, the measured irradiance could be obtained with a
heated plane-of-array pyranometer. When necessary, the irradiance should be
adjusted for reflections and spectral content.
Parameters
----------
Expand All @@ -123,7 +122,7 @@ def get_transmission(measured_e_e, modeled_e_e, i_mp):
Returns
-------
T : array
Effective transmission. [unitless]
Effective transmission. [unitless] # TODO describe when expect nan, 0
References
----------
Expand All @@ -133,8 +132,9 @@ def get_transmission(measured_e_e, modeled_e_e, i_mp):
2023, pp. 1-5. :doi:`10.1109/PVSC48320.2023.10360065`
"""
# TODO only works with Series
T = modeled_e_e/measured_e_e
T[T.isna()] = np.nan # TODO what does this accomplish
T = modeled_e_e / measured_e_e
# no transmission if no current
T[i_mp.isna()] = np.nan
T[i_mp == 0] = 0
T[T < 0] = np.nan
T[T > 1] = 1
Expand Down Expand Up @@ -262,9 +262,9 @@ def categorize(vmp_ratio, transmission, voltage, min_dcv,
50th Photovoltaic Specialists Conference (PVSC), San Juan, PR, USA,
2023, pp. 1-5, :doi:`10.1109/PVSC48320.2023.10360065`.
"""
umin = voltage > min_dcv # necessary for all modes except 0
uvr = np.where(vmp_ratio > threshold_vratio, 3, 1)
utrans = np.where(transmission > threshold_transmission, 1, 0)
umin = voltage >= min_dcv # necessary for all modes except 0
uvr = np.where(vmp_ratio >= threshold_vratio, 3, 1)
utrans = np.where(transmission >= threshold_transmission, 1, 0)

mode = np.where(np.isnan(vmp_ratio) | np.isnan(transmission), None,
umin * (uvr + utrans))
Expand Down
2 changes: 1 addition & 1 deletion pvanalytics/tests/features/test_snow.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def test_categorize():
# np.nan, vr<thres, vr<thres, vr=thres, vr>thres, vr>thres, vr<thres
# vo>thres, vo>thres, vo>thres, vo>thres, vo>thres, vo>thres, vo<thres
# tr<thres, np.nan, tr>thres, tr<thres, tr<thres, tr<thres, tr>thres
expected = np.array([None, None, 2, 2, 2, 4, 0])
expected = np.array([None, None, 2, 2, 3, 4, 0])
result = snow.categorize(vmp_ratio, transmission, voltage, min_dcv,
threshold_vratio, threshold_transmission)
assert_array_equal(result, expected)

0 comments on commit 2af3fa0

Please sign in to comment.