def calculate_cell_temperature(self, delta_T=3, temperature_cell_key='temperature_cell'): """ Set cell temeperature in dataframe. Returns ------- """ # Calculate cell temperature self.df[temperature_cell_key] = sapm_cell_from_module( module_temperature=self.df[self.temperature_module_key], poa_global=self.df[self.irradiance_poa_key], deltaT=delta_T) print("Cell temperature assigned to '{}'".format(temperature_cell_key))
def test_sapm_cell_from_module(sapm_default): default = temperature.sapm_cell_from_module(50, 900, sapm_default['deltaT']) assert_allclose(default, 50 + 900 / 1000 * sapm_default['deltaT'])
import matplotlib matplotlib.use('TkAgg') import matplotlib.pyplot as plt from pvpro.fit import production_data_curve_fit from pvpro.classify import classify_operating_mode # Import synthetic data df = pd.read_pickle('synth01_out.pkl') from pvlib.temperature import sapm_cell_from_module # Estimate cell temperature. df['temperature_cell_meas'] = sapm_cell_from_module( module_temperature=df['temperature_module_meas'], poa_global=df['poa_meas'], deltaT=3) # Classify operating modes. df['operating_cls'] = classify_operating_mode(voltage=df['v_dc'], current=df['i_dc'], power_clip=np.inf) # Clip dataframe shorter. df = df[:5000] # Run the fit pfit, residual, ret = production_data_curve_fit( temperature_cell=df['temperature_cell_meas'], effective_irradiance=df['poa_meas'], operating_cls=df['operating_cls'],
voltage = np.array(list(df.keys())[1:]).astype('float') # Choose fields for sensors. irradiance_poa_key = 'RefCell5_Wm2_Avg' temperature_module_key = 'RTD_C_Avg_13' deltaT = 3 specs = { 'cells_in_series': 60, 'alpha_sc': 0.053 * 1e-2 * 8.6, 'beta_voc': -0.351 * 1e-2 * 37.0 } # Get sensor values. poa = ws1[irradiance_poa_key] tm = ws2[temperature_module_key] tc = sapm_cell_from_module(tm, poa, deltaT) # Initialize ivcurves = {} for key in [ 'i', 'v', 'tc', 'tm', 'ee', 'i_sc', 'v_oc', 'i_mp', 'v_mp', 'timestamp', 'idx' ]: ivcurves[key] = [] n = 0 for k in range(len(df)): # for k in range(1): current = np.array(df.iloc[k, 1:]).astype('float')
# Clip dataframe to avoid bad data on startup. Could improve fit using # better filtering of bad data df = df[np.logical_and.reduce(( df[temperature_module_key] < 50, df[temperature_module_key] > 15, df.index > df.index[20000], df.index < df.index[25000], ))] # Datasheet values (Sharp NU-U235F2)' imp_ref_datasheet = 7.84 vmp_ref_datasheet = 30 # Estimate cell temperature. df['temperature_cell'] = sapm_cell_from_module( module_temperature=df[temperature_module_key], poa_global=df[poa_key], deltaT=3) # Classify operating modes, this is a simple fast algorithm to find MPP points. df['operating_cls'] = classify_operating_mode(voltage=df[voltage_key], current=df[current_key], power_clip=np.inf) # Mask off MPP points mpp = df['operating_cls'] == 0 # Estimate imp ref est_imp = estimate_imp_ref(poa=df.loc[mpp, poa_key], temperature_cell=df.loc[mpp, 'temperature_cell'], imp=df.loc[mpp, current_key], figure=True)