def main(subArea, runName, chartTitlePre, ownership): outDir = "C:\\Users\\olsenk\\Dropbox\\FPF\\Envision Runs\\keith_production\\" varList = [' Stand Replacing FirePMG3', ' Stand Replacing FirePMG4', ' Stand Replacing FirePMG5'] yLabelText = 'Percent of PMG 3, 4, and 5 in Stand Replacing Fire (top 10%)' chartTitle = chartTitlePre PMG345Ha = reporterFunc.getPMG345Ha(subArea) # list of ownerships to graphs if ownership == 'All': ownersToGraph = ['Federal','State','Private Non-Industrial','Private Industrial','Tribal','Homeowner'] pdfFile = PdfPages(outDir + 'report3_PMG345_in_HS_Fire_top10pct_All.pdf') else: ownersToGraph = [ownership] pdfFile = PdfPages(outDir + 'report3_PMG345_in_HS_Fire_top10pct_' + ownersToGraph[0] + '.pdf') # setup plot for all scenarios fig = pl.figure(1, figsize=(11,8.5)) ax = fig.add_subplot(1,1,1) for scenario in ['CurrentPolicy','NoFedTreat','Restoration']: inDir = outDir + runName + "_" + scenario + "\\" yearList = list(set(pd.io.parsers.read_csv(inDir + r'FireOccurance_by_OWNER_pivot.csv')[' Year'])) repList = list(set(pd.io.parsers.read_csv(inDir + r'FireOccurance_by_OWNER_pivot.csv')[' Run'])) totalArea = pd.io.parsers.read_csv(inDir + r'FireOccurance_by_OWNER_pivot.csv') dataTable = pd.DataFrame(totalArea[totalArea[' Year'] > 0]) dataTable['key'] = dataTable[' OWNER_label'] + '_' + dataTable[' Run'].astype(str) + '_' + dataTable[' Year'].astype(str) if scenario == 'CurrentPolicy': scenarioTable = dataTable else: scenarioTable = pd.merge(scenarioTable, dataTable, how='left', on='key') # sum over owners scenarioTable.index = scenarioTable['key'] fireProneArea = PMG345Ha[ownersToGraph[0]] if ownership == 'All': for rep in range(len(repList)): for year in range(1, len(yearList)): for owner in ownersToGraph: key = owner + '_' + str(rep) + '_' + str(year) print(key) if owner != ownersToGraph[0]: for varName in varList: scenarioTable.loc[ownersToGraph[0] + '_' + str(rep) + '_' + str(year),varName] += scenarioTable.loc[key,varName] scenarioTable.loc[ownersToGraph[0] + '_' + str(rep) + '_' + str(year),varName + '_x'] += scenarioTable.loc[key,varName + '_x'] scenarioTable.loc[ownersToGraph[0] + '_' + str(rep) + '_' + str(year),varName + '_y'] += scenarioTable.loc[key,varName + '_y'] for owner in ownersToGraph: fireProneArea += PMG345Ha[owner] ownerArea = pd.DataFrame(scenarioTable[scenarioTable[' OWNER_label'] == ownersToGraph[0]]) # calculate percent of PMG345 area for each row ownerArea['CP_HS_pct'] = (ownerArea[varList[0] + '_x'] + ownerArea[varList[1] + '_x'] + ownerArea[varList[2] + '_x']) / fireProneArea * 100 ownerArea['NFT_HS_pct'] = (ownerArea[varList[0] + '_y'] + ownerArea[varList[1] + '_y'] + ownerArea[varList[2] + '_y']) / fireProneArea * 100 ownerArea['Res_HS_pct'] = (ownerArea[varList[0]] + ownerArea[varList[1]] + ownerArea[varList[2]]) / fireProneArea * 100 #Sort dataTable on percent PMG345 in HS fire dataTable = ownerArea.sort('NFT_HS_pct', ascending=False) statsList1 = [] statsList2 = [] statsList3 = [] valueSet = [] maxValueSet = [] for i in range(int(round(len(dataTable) * 0.1))): statsList1.append(dataTable['CP_HS_pct'].iloc[i]) statsList2.append(dataTable['NFT_HS_pct'].iloc[i]) statsList3.append(dataTable['Res_HS_pct'].iloc[i]) valueSet.append(statsList1) valueSet.append(statsList2) valueSet.append(statsList3) maxValueSet.append(max(statsList1)) maxValueSet.append(max(statsList2)) maxValueSet.append(max(statsList3)) labelList = ['Current Policy','No Fed Treatment','Restoration'] reporterFunc.plotReporter3(fig, ax, ownership + ' - ' + str(len(repList)) + ' reps', pdfFile, valueSet, labelList, subArea, chartTitle, yLabelText, scenario, maxValueSet) pdfFile.savefig() pl.close() pdfFile.close() print "Done."
def main(subArea, runName, chartTitlePre, ownership): outDir = "C:\\Users\\olsenk\\Dropbox\\FPF\\Envision Runs\\keith_production\\" varList = [' Total Merch Harvest (m3)'] yLabelText = 'Merchantable Volume Harvested (m3)' chartTitle = chartTitlePre PMG345Ha = {'Federal':422702, 'State':22622, 'Private Non-Industrial':23372, 'Private Industrial':51911, 'Tribal':101160, 'Homeowner':3176} # list of ownerships to graphs if ownership == 'All': ownersToGraph = ['Federal','State','Private Non-Industrial','Private Industrial','Tribal','Homeowner'] pdfFile = PdfPages(outDir + 'report3_Merch_Volume_All.pdf') else: ownersToGraph = [ownership] pdfFile = PdfPages(outDir + 'report3_Merch_Volume_' + ownersToGraph[0] + '.pdf') # setup plot for all scenarios fig = pl.figure(1, figsize=(11,8.5)) ax = fig.add_subplot(1,1,1) # Current policy required for scenario in ['CurrentPolicy','NoFedTreat','Restoration']: inDir = outDir + runName + "_" + scenario + "\\" if os.path.isdir(inDir): yearList = list(set(pd.io.parsers.read_csv(inDir + r'WoodProducts_by_OWNER_pivot.csv')[' Year'])) repList = list(set(pd.io.parsers.read_csv(inDir + r'WoodProducts_by_OWNER_pivot.csv')[' Run'])) totalArea = pd.io.parsers.read_csv(inDir + r'WoodProducts_by_OWNER_pivot.csv') dataTable = pd.DataFrame(totalArea[totalArea[' Year'] > 0]) dataTable['key'] = dataTable[' OWNER_label'] + '_' + dataTable[' Run'].astype(str) + '_' + dataTable[' Year'].astype(str) if scenario == 'CurrentPolicy': scenarioTable = dataTable else: scenarioTable = pd.merge(scenarioTable, dataTable, how='left', on='key') # sum over owners scenarioTable.index = scenarioTable['key'] fireProneArea = PMG345Ha[ownersToGraph[0]] if ownership == 'All': for rep in range(len(repList)): for year in range(1, len(yearList)): for owner in ownersToGraph: key = owner + '_' + str(rep) + '_' + str(year) print(key) if owner != ownersToGraph[0]: for varName in varList: scenarioTable.loc[ownersToGraph[0] + '_' + str(rep) + '_' + str(year),varName] += scenarioTable.loc[key,varName] scenarioTable.loc[ownersToGraph[0] + '_' + str(rep) + '_' + str(year),varName + '_x'] += scenarioTable.loc[key,varName + '_x'] scenarioTable.loc[ownersToGraph[0] + '_' + str(rep) + '_' + str(year),varName + '_y'] += scenarioTable.loc[key,varName + '_y'] for owner in ownersToGraph: fireProneArea += PMG345Ha[owner] ownerArea = pd.DataFrame(scenarioTable[scenarioTable[' OWNER_label'] == ownersToGraph[0]]) #Sort dataTable on percent PMG345 in HS fire ## dataTable = ownerArea.sort('NFT_HS_pct', ascending=False) # subset table for specific year valueSet = [] maxValueSet = [] labelList = [] for yearVal in [24,49]: yearTable = ownerArea[ownerArea[' Year'] == yearVal] statsList1 = [] statsList2 = [] statsList3 = [] for i in range(int(round(len(yearTable)))): statsList1.append(yearTable[varList[0] + '_x'].iloc[i]) statsList2.append(yearTable[varList[0] + '_y'].iloc[i]) statsList3.append(yearTable[varList[0]].iloc[i]) valueSet.append(statsList1) valueSet.append(statsList2) valueSet.append(statsList3) maxValueSet.append(max(statsList1)) maxValueSet.append(max(statsList2)) maxValueSet.append(max(statsList3)) labelList += ['CP Year ' + str(yearVal),'NFT Year ' + str(yearVal),'Res Year ' + str(yearVal)] reporterFunc.plotReporter3(fig, ax, ownership + ' - ' + str(len(repList)) + ' reps', pdfFile, valueSet, labelList, subArea, chartTitle, yLabelText, 'CurrentPolicy', maxValueSet) pdfFile.savefig() pl.close() pdfFile.close() print "Done."
def main(subArea, runName, chartTitlePre, ownership): outDir = "C:\\Users\\olsenk\\Dropbox\\FPF\\Envision Runs\\keith_production\\" varList = [' White-headed Woodpecker Good (ha)'] yLabelText = 'White-headed Woodpecker Good Habitat (ha)' chartTitle = chartTitlePre PMG345Ha = { 'Federal': 422702, 'State': 22622, 'Private Non-Industrial': 23372, 'Private Industrial': 51911, 'Tribal': 101160, 'Homeowner': 3176 } # list of ownerships to graphs if ownership == 'All': ownersToGraph = [ 'Federal', 'State', 'Private Non-Industrial', 'Private Industrial', 'Tribal', 'Homeowner' ] pdfFile = PdfPages(outDir + 'report3_WHWO_iLAP_All.pdf') else: ownersToGraph = [ownership] pdfFile = PdfPages(outDir + 'report3_WHWO_iLAP_' + ownersToGraph[0] + '.pdf') # setup plot for all scenarios fig = pl.figure(1, figsize=(11, 8.5)) ax = fig.add_subplot(1, 1, 1) for scenario in ['CurrentPolicy', 'NoFedTreat', 'Restoration']: inDir = outDir + runName + "_" + scenario + "\\" yearList = list( set( pd.io.parsers.read_csv( inDir + r'ILAP_wildlife_models_pivot.csv')[' Year'])) repList = list( set( pd.io.parsers.read_csv( inDir + r'ILAP_wildlife_models_pivot.csv')[' Run'])) totalArea = pd.io.parsers.read_csv(inDir + r'ILAP_wildlife_models_pivot.csv') dataTable = pd.DataFrame(totalArea[totalArea[' Year'] > 0]) dataTable['key'] = 'key_' + dataTable[' Run'].astype( str) + '_' + dataTable[' Year'].astype(str) if scenario == 'CurrentPolicy': scenarioTable = dataTable else: scenarioTable = pd.merge(scenarioTable, dataTable, how='left', on='key') # subset table for specific year valueSet = [] maxValueSet = [] labelList = [] for yearVal in [24, 49]: yearTable = scenarioTable[scenarioTable[' Year'] == yearVal] statsList1 = [] statsList2 = [] statsList3 = [] for i in range(int(round(len(yearTable)))): statsList1.append(yearTable[varList[0] + '_x'].iloc[i]) statsList2.append(yearTable[varList[0] + '_y'].iloc[i]) statsList3.append(yearTable[varList[0]].iloc[i]) valueSet.append(statsList1) valueSet.append(statsList2) valueSet.append(statsList3) maxValueSet.append(max(statsList1)) maxValueSet.append(max(statsList2)) maxValueSet.append(max(statsList3)) labelList += [ 'CP Year ' + str(yearVal), 'NFT Year ' + str(yearVal), 'Res Year ' + str(yearVal) ] reporterFunc.plotReporter3(fig, ax, ownership + ' - ' + str(len(repList)) + ' reps', pdfFile, valueSet, labelList, subArea, chartTitle, yLabelText, 'CurrentPolicy', maxValueSet) pdfFile.savefig() pl.close() pdfFile.close() print "Done."
def main(subArea, runName, chartTitlePre, ownership): outDir = "C:\\Users\\olsenk\\Dropbox\\FPF\\Envision Runs\\keith_production\\" varList = [ ' Stand Replacing FirePMG3', ' Stand Replacing FirePMG4', ' Stand Replacing FirePMG5' ] yLabelText = 'Percent of PMG 3, 4, and 5 in Stand Replacing Fire' chartTitle = chartTitlePre PMG345Ha = reporterFunc.getPMG345Ha(subArea) # list of ownerships to graphs if ownership == 'All': ownersToGraph = [ 'Federal', 'State', 'Private Non-Industrial', 'Private Industrial', 'Tribal', 'Homeowner' ] pdfFile = PdfPages(outDir + 'report3_PMG345_in_HS_Fire_All.pdf') else: ownersToGraph = [ownership] pdfFile = PdfPages(outDir + 'report3_PMG345_in_HS_Fire_' + ownersToGraph[0] + '.pdf') # setup plot for all scenarios fig = pl.figure(1, figsize=(11, 8.5)) ax = fig.add_subplot(1, 1, 1) valueSet1 = [] valueSet2 = [] maxValueSet1 = [] maxValueSet2 = [] for scenario in ['CurrentPolicy', 'NoFedTreat', 'Restoration']: inDir = outDir + runName + "_" + scenario + "\\" yearList = list( set( pd.io.parsers.read_csv( inDir + r'FireOccurance_by_OWNER_pivot.csv')[' Year'])) repList = list( set( pd.io.parsers.read_csv( inDir + r'FireOccurance_by_OWNER_pivot.csv')[' Run'])) totalArea = pd.io.parsers.read_csv(inDir + r'FireOccurance_by_OWNER_pivot.csv') # get stats from multiple reps statsList1 = [] statsList2 = [] for year in range(1, max(yearList) + 1): yearArea = totalArea[totalArea[' Year'] == year] dataList = [] for rep in repList: repArea = yearArea[yearArea[' Run'] == rep] # sum output over selected ownerships for ownerToGraph in ownersToGraph: if ownerToGraph == ownersToGraph[0]: ownerArea = pd.DataFrame( repArea[repArea[' OWNER_label'] == ownerToGraph]) fireProneArea = PMG345Ha[ownerToGraph] else: tempArea = repArea[repArea[' OWNER_label'] == ownerToGraph] for varName in varList: # totalArea.loc[list(ownerArea.index)[0],varName] += tempArea[varName].iloc[0] ownerArea[varName].iloc[0] += tempArea[ varName].iloc[0] fireProneArea += PMG345Ha[ownerToGraph] ownerToGraph = 'All' if fireProneArea > 0: dataList.append( (ownerArea[varList[0]].iloc[0] + ownerArea[varList[1]].iloc[0] + ownerArea[varList[2]].iloc[0]) / fireProneArea * 100) else: dataList.append(0.0) # add year data to dictionary if year < 25: statsList1 += dataList else: statsList2 += dataList valueSet1.append(statsList1) valueSet2.append(statsList2) maxValueSet1.append(max(statsList1)) maxValueSet2.append(max(statsList2)) labelList = [ 'CP 0-24', 'NFT 0-24', 'Res 0-24', 'CP 25-50', 'NFT 25-50', 'Res 25-50' ] reporterFunc.plotReporter3( fig, ax, ownerToGraph + ' - ' + str(len(repList)) + ' reps', pdfFile, valueSet1 + valueSet2, labelList, subArea, chartTitle, yLabelText, scenario, maxValueSet1 + maxValueSet2) pdfFile.savefig() pl.close() pdfFile.close() print "Done."