import pandas as pd
import matplotlib as plt
from captest import capdata as pvc
First we load the NREL data used for testing and set the translation dictionary.
meas = pvc.CapData('meas')
meas.load_data(path='../../tests/data/', fname='nrel_data.csv', source='AlsoEnergy')
meas.column_groups
meas.set_regression_cols(poa='irr-poa-', w_vel='wind--', t_amb='temp--', power='')
meas.filter_irr(500, 600)
Below is an exmaple of calculating reporting conditions using all defaults, which are set based on the ASTM E2939 standard. The reporting condition method always performs calculations using the filtered dataframe stored in the df_flt attribute.
meas.rep_cond()
Use all defaults, except inplace
meas.rc
meas.rc = None
meas.rep_cond(inplace=False)
print(meas.rc)
The irr_bal option replaces the aggregation methods specified with the func agrument with the irrRC_balanced function. This function is intended to implement a strict interpratation of common contract language that specifies the reporting irradiance be determined by finding the irradiance that results in a balance of points within a +/- percent range of the reporting irradiance. The irrRC_balanced function iterates to a solution for the reporting irradiance by calculating the irradiance that has 10 datpoints in the filtered dataset above it, then filtering for a percentage of points around that irradiance, calculating what percentile the reporting irradiance is in
meas.reset_filter()
meas.filter_irr(500, 900)
The plot below shows a visualization of the irrRC_balanced calculations. The teal dots in a vertical column along the left side of the figure are all the irradiance measurements in the dataset. Each red dot is an irradiance reporting condition and the colored vertical lines are the extent of the percent band around the reportin irradiance. The reportign irradiance is decreased for each loop until 40% of the irradiance points are above the reporting irradiance.
rep_irr = pvc.irr_rc_balanced(meas.data_filtered, 0.8, 1.2, irr_col=meas._CapData__get_poa_col(), plot=True)
rep_irr[0]
meas.data_filtered.shape[0]
rep_irr[1].shape[0]
meas.rep_cond(irr_bal=True, percent_filter=20)
meas.rc
The cntg_eoy year function can be used to wrap tmy data around the beginning/end of the year to prepare for calculating reporting conditions using time periods that span the new year.
pvsyst = pvc.CapData('pvsyst')
pvsyst.load_data(load_pvsyst=True)
pvsyst.column_groups
pvsyst.set_regression_cols(power='real_pwr--', poa='irr-poa-', t_amb='temp-amb-', w_vel='wind--')
pvsyst.df_flt = pvc.wrap_year_end(pvsyst.data_filtered,
pd.Timestamp(year=1989, month=12, day=15),
pd.Timestamp(year=1990, month=1, day=15))
pvsyst.df_flt.head(2)
pvsyst.df_flt.tail(2)
pvsyst.filter_irr(200, 900)
pvsyst.filter_pvsyst()
pvsyst.rep_cond()
The freq option can be used to calculate reporting conditions for groups of time like months or seasons. Any standard aggregation method can be used to calculate the reporting conditions for each group using the func or the irr_bal method options.
pvsyst.reset_filter()
print(pvsyst.data_filtered.index[0])
print(pvsyst.data_filtered.index[-1])
pvsyst.filter_irr(500, 900)
pvsyst.rep_cond(freq='MS')
pvsyst.rc
Using the irr_bal option to calculate reporting conditions for each month of the year results in higher reporting irradiances.
Note that the with inplace set to False the reporting conditions attribute of the CapData object, pvsyst, is not overwritten.
ib_rcs = pvsyst.rep_cond(freq='MS', irr_bal=True, percent_filter=20, inplace=False)
ib_rcs
(ib_rcs - pvsyst.rc)['poa']
The predict_capacities
method will use reporting conditions calculated using the freq option to determine predicted and guaranteed capacities.
From the previous exercise we still have the montly reporting conditions.
pvsyst.rc
pvsyst.tolerance = '+/- 7'
pvsyst.predict_capacities()