def getRmse(storename, forecastPnt, actPnt, avcPnt): forecastVals = getRemcPntData(storename, forecastPnt).tolist() actVals = getRemcPntData(storename, actPnt).tolist() avcVals = getRemcPntData(storename, avcPnt).tolist() rmsePerc = calcNrmsePerc(actVals, forecastVals, avcVals) return rmsePerc
def getIstsGenSectionDataDf(configFilePath, configSheetName): # get conf dataframe confDf = pd.read_excel(configFilePath, sheet_name=configSheetName) # confDf columns should be # name,installed_capacity,avc_id,act_id,sch_id,type,pooling_station,gen_type confDf['name'] = confDf['name'].str.strip() confDf['type'] = confDf['type'].str.strip() confDf['pooling_station'] = confDf['pooling_station'].str.strip() confDf['gen_type'] = confDf['gen_type'].str.strip() normalPntsConfDf = confDf[(confDf['type'] == 'normal') | (confDf['type'] == '') | (confDf['type'].isnull())] # initialize results resValsList = [] for rowIter in range(confDf.shape[0]): confRow = confDf.iloc[rowIter] printWithTs('ists gen processing row number {0}'.format(rowIter + 2)) timeValSeries = getPntData('HRS') # get the type of row, itcan be dummy / normal / agg_pool / agg_gen_type rowType = confRow['type'] if rowType == 'dummy': # since the row is dummy, just insert a None row into result resValsList.append({ "name": confRow['name'], "installed_capacity": None, "max_avc": None, "day_max_actual": None, "day_max_actual_time": None, "day_min_actual": None, "day_min_actual_time": None, "sch_mu": None, "act_mu": None, "dev_mu": None, "cuf": None }) continue elif not (pd.isnull(rowType)) and rowType.startswith('agg_'): aggColName = rowType[len('agg_'):] aggIdentifier = confRow[aggColName] confDfForAgg = normalPntsConfDf[normalPntsConfDf[aggColName] == aggIdentifier] avcPnt = ','.join(confDfForAgg['avc_id'].dropna().tolist()) actPnt = ','.join(confDfForAgg['act_id'].tolist()) schPnt = ','.join(confDfForAgg['sch_id'].tolist()) else: avcPnt = confRow['avc_id'] actPnt = confRow['act_id'] schPnt = confRow['sch_id'] if ((avcPnt == '') or pd.isnull(avcPnt)): maxAvc = None else: maxAvc = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, avcPnt).max() dayMaxActual = getPntData(actPnt).max() dayMaxActualTime = timeValSeries.iloc[getPntData(actPnt).idxmax()] dayMinActual = getPntData(actPnt).min() dayMinActualTime = timeValSeries.iloc[getPntData(actPnt).idxmin()] schMu = getPntData(schPnt).mean() * 0.024 actMu = getPntData(actPnt).mean() * 0.024 devMu = actMu - schMu installedCapacity = confRow['installed_capacity'] cufPerc = (actMu * 100000) / (24 * installedCapacity) resValsList.append({ "name": confRow['name'], "installed_capacity": installedCapacity, "max_avc": maxAvc, "day_max_actual": dayMaxActual, "day_max_actual_time": dayMaxActualTime, "day_min_actual": dayMinActual, "day_min_actual_time": dayMinActualTime, "sch_mu": schMu, "act_mu": actMu, "dev_mu": devMu, "cuf": cufPerc }) return pd.DataFrame(resValsList)
def getRemcRegionalR16ErrSectionDataDf(configFilePath, configSheetName): # get conf dataframe confDf = pd.read_excel(configFilePath, sheet_name=configSheetName) # confDf columns should be # name,r16_pnt,actual_pnt,cuf_pnt,avc_pnt,type for stripCol in 'name,r16_pnt,actual_pnt,avc_pnt,type'.split(','): confDf[stripCol] = confDf[stripCol].str.strip() # initialize results resValsList = [] # find the row index of first non dummy row for rowIter in range(len(confDf)): confRow = confDf.iloc[rowIter] rowType = confRow['type'] if rowType == 'dummy': resValsList.append({ "name": confRow['name'], "solar": None, "wind": None, "combined": None }) # get regional rows solarConf = confDf[confDf['name'] == 'solar'].squeeze() windConf = confDf[confDf['name'] == 'wind'].squeeze() combinedConf = confDf[confDf['name'] == 'combined'].squeeze() # get data values regSolActVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, solarConf['actual_pnt']) regSolR16Vals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, solarConf['r16_pnt']) regSolAvcVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, solarConf['avc_pnt']) regWindActVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, windConf['actual_pnt']) regWindR16Vals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, windConf['r16_pnt']) regWindAvcVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, windConf['avc_pnt']) regCombActVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, combinedConf['actual_pnt']) regCombR16Vals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, combinedConf['r16_pnt']) regCombAvcVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, combinedConf['avc_pnt']) # get ISTS rows solarConf = confDf[confDf['name'] == 'ists_solar'].squeeze() windConf = confDf[confDf['name'] == 'ists_wind'].squeeze() combinedConf = confDf[confDf['name'] == 'ists_combined'].squeeze() # get data values istsSolActVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, solarConf['actual_pnt']) istsSolR16Vals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, solarConf['r16_pnt']) istsSolAvcVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, solarConf['avc_pnt']) istsWindActVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, windConf['actual_pnt']) istsWindR16Vals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, windConf['r16_pnt']) istsWindAvcVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, windConf['avc_pnt']) istsCombActVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, combinedConf['actual_pnt']) istsCombR16Vals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, combinedConf['r16_pnt']) istsCombAvcVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, combinedConf['avc_pnt']) # calculate the output rows for region # calculate regional solar mape for r16 regSolR16MapePerc = calcMapePerc(regSolActVals, regSolR16Vals, regSolAvcVals) # calculate regional solar nrmse for r16 regSolR16NrmsePerc = calcNrmsePerc(regSolActVals, regSolR16Vals, regSolAvcVals) # calculate regional wind mape for r16 regWindR16MapePerc = calcMapePerc(regWindActVals, regWindR16Vals, regWindAvcVals) # calculate regional wind nrmse for r16 regWindR16NrmsePerc = calcNrmsePerc(regWindActVals, regWindR16Vals, regWindAvcVals) # calculate regional combined mape for r16 regCombR16MapePerc = calcMapePerc(regCombActVals, regCombR16Vals, regCombAvcVals) # calculate regional combined nrmse for r16 regCombR16NrmsePerc = calcNrmsePerc(regCombActVals, regCombR16Vals, regCombAvcVals) # calculate the output rows for ists # calculate ists solar mape for r16 istsSolR16MapePerc = calcMapePerc(istsSolActVals, istsSolR16Vals, istsSolAvcVals) # calculate ists solar nrmse for r16 istsSolR16NrmsePerc = calcNrmsePerc(istsSolActVals, istsSolR16Vals, istsSolAvcVals) # calculate ists wind mape for r16 istsWindR16MapePerc = calcMapePerc(istsWindActVals, istsWindR16Vals, istsWindAvcVals) # calculate ists wind nrmse for r16 istsWindR16NrmsePerc = calcNrmsePerc(istsWindActVals, istsWindR16Vals, istsWindAvcVals) # calculate ists combined mape for r16 istsCombR16MapePerc = calcMapePerc(istsCombActVals, istsCombR16Vals, istsCombAvcVals) # calculate ists combined nrmse for r16 istsCombR16NrmsePerc = calcNrmsePerc(istsCombActVals, istsCombR16Vals, istsCombAvcVals) printWithTs( 'Processing REMC Regional R16 Error summary Section at row {0}'.format( len(resValsList) + 1)) # create result dataframe rows resValsList.extend([{ "name": "MAPE", "solar": regSolR16MapePerc, "wind": regWindR16MapePerc, "combined": regCombR16MapePerc, "istsSolar": istsSolR16MapePerc, "istsWind": istsWindR16MapePerc, "istsCombined": istsCombR16MapePerc }, { "name": "NRMSE", "solar": regSolR16NrmsePerc, "wind": regWindR16NrmsePerc, "combined": regCombR16NrmsePerc, "istsSolar": istsSolR16NrmsePerc, "istsWind": istsWindR16NrmsePerc, "istsCombined": istsCombR16NrmsePerc }]) return pd.DataFrame(resValsList)
def getRemcIstsErrSummSectionDataDf(configFilePath, configSheetName): # get conf dataframe confDf = pd.read_excel(configFilePath, sheet_name=configSheetName) # confDf columns should be # name,r0_pnt,r16_pnt,actual_pnt,cuf_pnt,avc_pnt,type,pooling_station for stripCol in 'name,r0_pnt,r16_pnt,actual_pnt,avc_pnt,type,pooling_station'.split( ','): confDf[stripCol] = confDf[stripCol].str.strip() normalPntsConfDf = confDf[(confDf['type'] == 'normal') | (confDf['type'] == '') | (confDf['type'].isnull())] # initialize results resValsList = [] for rowIter in range(confDf.shape[0]): confRow = confDf.iloc[rowIter] printWithTs('REMC ISTS error summary processing row number {0}'.format( rowIter + 2)) # get the type of row, itcan be dummy / normal / agg_pool / agg_gen_type rowType = confRow['type'] if rowType == 'dummy': # since the row is dummy, just insert a None row into result resValsList.append({ "name": confRow['name'], "r0_mape": None, "r0_nrmse": None, "r16_mape": None, "r16_nrmse": None }) continue elif not (pd.isnull(rowType)) and rowType.startswith('agg_'): aggColName = rowType[len('agg_'):] aggIdentifier = confRow[aggColName] confDfForAgg = normalPntsConfDf[normalPntsConfDf[aggColName] == aggIdentifier] avcPnt = ','.join(confDfForAgg['avc_pnt'].tolist()) actPnt = ','.join(confDfForAgg['actual_pnt'].tolist()) r0Pnt = ','.join(confDfForAgg['r0_pnt'].tolist()) r16Pnt = ','.join(confDfForAgg['r16_pnt'].tolist()) else: avcPnt = confRow['avc_pnt'] actPnt = confRow['actual_pnt'] r0Pnt = confRow['r0_pnt'] r16Pnt = confRow['r16_pnt'] avcVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, avcPnt).tolist() r0Vals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, r0Pnt).tolist() r16Vals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, r16Pnt).tolist() actVals = getRemcPntData(FCA_FORECAST_VS_ACTUAL_STORE_NAME, actPnt).tolist() r0MapePerc = calcMapePerc(actVals, r0Vals, avcVals) r0NrmsePerc = calcNrmsePerc(actVals, r0Vals, avcVals) r16MapePerc = calcMapePerc(actVals, r16Vals, avcVals) r16NrmsePerc = calcNrmsePerc(actVals, r16Vals, avcVals) resValsList.append({ "name": confRow['name'], "r0_mape": r0MapePerc, "r0_nrmse": r0NrmsePerc, "r16_mape": r16MapePerc, "r16_nrmse": r16NrmsePerc }) return pd.DataFrame(resValsList)