Skip to content

Commit

Permalink
Fix Warning #516
Browse files Browse the repository at this point in the history
Fixes warning to 516 on performance and mismatch calculations trying to floatize a value that is actually a dataframe. Left it with a if statement in case a dictionary is passed directly (I think that's one of our cases... maybe... we'll see if the pytest breaks :D )
  • Loading branch information
shirubana committed Jun 18, 2024
1 parent d906d3f commit a579479
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
5 changes: 4 additions & 1 deletion bifacial_radiance/mismatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ def mismatch_fit3(data):
fit3 = 0.054*mad + 0.068*mad2

if fit3.__len__() == 1:
fit3 = float(fit3)
if isinstance(fit3, pd.Series):
fit3 = float(fit3.iloc[0])
else:
fit3 = float(fit3)

return fit3

Expand Down
28 changes: 19 additions & 9 deletions bifacial_radiance/performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

import pvlib

import pandas as pd

def calculatePerformance(effective_irradiance, CECMod, temp_air=None,
wind_speed=1, temp_cell=None, glassglass=False):
Expand Down Expand Up @@ -57,17 +57,27 @@ def calculatePerformance(effective_irradiance, CECMod, temp_air=None,
temp_model_params['a'],
temp_model_params['b'],
temp_model_params['deltaT'])


if isinstance(CECMod, pd.DataFrame):
CECMod.to_pickle("CECMod.pkl")
if len(CECMod) == 1:
CECMod1 = CECMod.iloc[0]
else:
print("More than one Module passed. Error, using 1st one")
CECMod1 = CECMod.iloc[0]
else:
CECMod1 = CECMod

IL, I0, Rs, Rsh, nNsVth = pvlib.pvsystem.calcparams_cec(
effective_irradiance=effective_irradiance,
temp_cell=temp_cell,
alpha_sc=float(CECMod.alpha_sc),
a_ref=float(CECMod.a_ref),
I_L_ref=float(CECMod.I_L_ref),
I_o_ref=float(CECMod.I_o_ref),
R_sh_ref=float(CECMod.R_sh_ref),
R_s=float(CECMod.R_s),
Adjust=float(CECMod.Adjust)
alpha_sc=float(CECMod1.alpha_sc),
a_ref=float(CECMod1.a_ref),
I_L_ref=float(CECMod1.I_L_ref),
I_o_ref=float(CECMod1.I_o_ref),
R_sh_ref=float(CECMod1.R_sh_ref),
R_s=float(CECMod1.R_s),
Adjust=float(CECMod1.Adjust)
)

IVcurve_info = pvlib.pvsystem.singlediode(
Expand Down

0 comments on commit a579479

Please sign in to comment.