示例#1
0
def Export_Efficiency_Scattergraphs_with_More_than_1_Multi_Value_Variable(outputDirname, \
outputFilePrefix, efficienciesDict, efficiencyKeyToPlot, keysToPlot=None, addKeyToHeader=False):

    from rewiredcarbon.vectorOutput import generateOutputMatrixWithHeaders, writeOutputMatrix
    import pdb

    if keysToPlot == None:
        scenarioKeys = list(efficienciesDict.keys())
    else:
        scenarioKeys = keysToPlot

    for key in scenarioKeys:

        multiValueVariableKeys = efficienciesDict[key][
            'multiValueVariableKeys']

        for multiValueVariableKey in multiValueVariableKeys:

            xAxis = efficienciesDict[key][multiValueVariableKey]
            yAxis = efficienciesDict[key][efficiencyKeyToPlot]

            if addKeyToHeader == False:
                headers = [multiValueVariableKey, efficiencyKeyToPlot]
            elif addKeyToHeader == True:
                headers = [
                    multiValueVariableKey + '_' + key,
                    efficiencyKeyToPlot + '_' + key
                ]

            vectorList = [xAxis, yAxis]

            oMatrix = generateOutputMatrixWithHeaders(vectorList,
                                                      headers,
                                                      delimeter=',')

            if outputDirname == '':
                outputFilename = outputFilePrefix + '_' + key + '.csv'
            else:
                outputFilename = outputDirname + '/' + outputFilePrefix + '_' \
                + multiValueVariableKey + '_' + key + '.csv'

            writeOutputMatrix(outputFilename, oMatrix)

    return
示例#2
0
def Export_Efficiency_Bargraph(filename, efficienciesDict, scenarioDict, efficiencyKeyToPlot, \
efficiencyErrorLowerKeyToPlot, efficiencyErrorUpperKeyToPlot, keysToPlot=None):

    from rewiredcarbon.vectorOutput import generateOutputMatrixWithHeaders, writeOutputMatrix
    import pdb

    if keysToPlot == None:
        scenarioKeys = list(efficienciesDict.keys())
    else:
        scenarioKeys = keysToPlot

    efficiencyValuesArray = []
    efficiencyValuesUpperErrorArray = []
    efficiencyValuesLowerErrorArray = []
    labelsArray = []

    for key in scenarioKeys:
        efficiencyValuesArray.append(
            efficienciesDict[key][efficiencyKeyToPlot])

        lowerError = efficienciesDict[key][efficiencyErrorLowerKeyToPlot]
        upperError = efficienciesDict[key][efficiencyErrorUpperKeyToPlot]
        efficiencyValuesLowerErrorArray.append(lowerError)
        efficiencyValuesUpperErrorArray.append(upperError)

        labelsArray.append('"' + scenarioDict[key]['BargraphLabel'] + '"')

    headers = ['scenario', 'label', efficiencyKeyToPlot, efficiencyErrorLowerKeyToPlot, \
    efficiencyErrorUpperKeyToPlot]

    vectorList = [scenarioKeys, labelsArray, efficiencyValuesArray, \
    efficiencyValuesLowerErrorArray, efficiencyValuesUpperErrorArray]

    oMatrix = generateOutputMatrixWithHeaders(vectorList,
                                              headers,
                                              delimeter=',')

    writeOutputMatrix(filename, oMatrix)

    return
    + key)

    vectorList_tankAreaRelativeToSolarPVArea.append(totalElectricalPowerArray)
    vectorList_tankAreaRelativeToSolarPVArea.append(
        tankAreaRelativeToSolarPVAreaArray)

xlabel('Total Electrical Power (W)')
ylabel('Tank Area Relative To Solar PV Area')
grid()
legend()

oMatrix_tankAreaRelativeToSolarPVArea \
= generateOutputMatrixWithHeaders(vectorList_tankAreaRelativeToSolarPVArea, \
headerList_tankAreaRelativeToSolarPVArea, delimeter=',')

writeOutputMatrix(outputFilename_tankAreaRelativeToSolarPVArea, \
oMatrix_tankAreaRelativeToSolarPVArea)

# Plot out the cell density at target efficient calculations and export them to a CSV file
keys = collectedOutputDict.keys()
vectorList_cellDensityAtTargetEfficiencyRatio = []
headerList_cellDensityAtTargetEfficiencyRatio = []


outputFilename_cellDensityAtTargetEfficiencyRatio \
= outputFileDirname + '/' + 'fig-h2agitation-D-cell_density.csv'
ensure_dir(outputFilename_cellDensityAtTargetEfficiencyRatio)

figure()
for key in keys:
    outputDict = collectedOutputDict[key]
    totalElectricalPowerArray = outputDict['totalElectricalPowerArray']
# ------------------------------------------------------------------------------------------------ #
# Plot out resistivity versus biofilm thickness
figure()
for key in keys:
    outputDict = collectedOutputDict[key]
    # Convert from Ω m to Ω cm
    inputResistivityArray = array(outputDict['inputResistivityArray']) * 100
    areaBiofilmAtTargetEfficiencyRatioArray = outputDict[
        'areaBiofilmAtTargetEfficiencyRatioArray']
    areaBiofilmRelativeToSolarPVAreaArray = outputDict[
        'areaBiofilmRelativeToSolarPVAreaArray']

    biofilmThicknessAtTargetEfficiencyRatioArray \
    = outputDict['biofilmThicknessAtTargetEfficiencyRatioArray']

    loglog(inputResistivityArray,
           biofilmThicknessAtTargetEfficiencyRatioArray,
           label=key)

xlabel('Biofilm Resistivity (Ohm cm)')
ylabel('Biofilm Thickness (m)')
grid()
legend()
# ------------------------------------------------------------------------------------------------ #

oMatrix = generateOutputMatrixWithHeaders(vectorList,
                                          headerList,
                                          delimeter=',')
writeOutputMatrix(outputFilename, oMatrix)
show()