Ejemplo n.º 1
0
def main(sqlPath):
    pp = pprint.PrettyPrinter(indent=4)
    sqlPath = _sqlFilePath
    print sqlPath
    sqlFile = ops.SqlFile(ops.Path(sqlPath))
    print sqlFile
    conversionFactorElec = float(str(ops.OptionalDouble(277.777778)))
    outputs = {}
    electricity = {}
    naturalgas = {}
    try:
        print 'starting'
        elecVals = elecSqlVals(sqlFile)
        waterVals = waterSqlVals(sqlFile)
        electricity = {
            'units':
            'kilowatt-hours',
            'Electricity Interior Lights':
            float(elecVals.intlighting) * conversionFactorElec,
            'Electricity Exterior Lights':
            float(elecVals.extlighting) * conversionFactorElec,
            'Electricity Interior Equipment':
            float(elecVals.intequip) * conversionFactorElec,
            'Electricity Exterior Equipment':
            float(elecVals.extequip) * conversionFactorElec,
            'Electricity Heating':
            float(elecVals.heating) * conversionFactorElec,
            'Electricity Water Systems':
            float(elecVals.watersystems) * conversionFactorElec,
            'Electricity Cooling':
            float(elecVals.cooling) * conversionFactorElec,
            'Electricity Humidification':
            float(elecVals.humidity) * conversionFactorElec,
            'Electricity Heat Recovery':
            float(elecVals.hr) * conversionFactorElec,
            'Electricity Heat Rejection':
            float(elecVals.heatrej) * conversionFactorElec,
            'Electricity Refrigeration':
            float(elecVals.refrig) * conversionFactorElec,
            'Electricity Generators':
            float(elecVals.generators) * conversionFactorElec,
            'Fan Electricity':
            float(elecVals.fans) * conversionFactorElec,
            'Pumps Electricity':
            float(elecVals.pumps) * conversionFactorElec,
            'Electricity Total End Uses':
            float(elecVals.totalenduses) * conversionFactorElec
        }
        conversionFactorNG = 9.480434
        naturalgas = {
            'units':
            'therms',
            'Natural Gas Heating':
            float(str(sqlFile.naturalGasHeating())) * conversionFactorNG,
            'Natural Gas Cooling':
            float(str(sqlFile.naturalGasCooling())) * conversionFactorNG,
            'Natural Gas Interior Lighting':
            float(str(sqlFile.naturalGasInteriorLighting())) *
            conversionFactorNG,
            'Natural Gas Exterior Lighting':
            float(str(sqlFile.naturalGasExteriorLighting())) *
            conversionFactorNG,
            'Natural Gas Interior Equipment':
            float(str(sqlFile.naturalGasInteriorEquipment())) *
            conversionFactorNG,
            'Natural Gas Exterior Equipment':
            float(str(sqlFile.naturalGasExteriorEquipment())) *
            conversionFactorNG,
            'Natural Gas Fans':
            float(str(sqlFile.naturalGasFans())) * conversionFactorNG,
            'Natural Gas Pumps':
            float(str(sqlFile.naturalGasPumps())) * conversionFactorNG,
            'Natural Gas Heat Rejection':
            float(str(sqlFile.naturalGasHeatRejection())) * conversionFactorNG,
            'Natural Gas Humidification':
            float(str(sqlFile.naturalGasHumidification())) *
            conversionFactorNG,
            'Natural Gas Heat Recovery':
            float(str(sqlFile.naturalGasHeatRecovery())) * conversionFactorNG,
            'Natural Gas Water Systems':
            float(str(sqlFile.naturalGasWaterSystems())) * conversionFactorNG,
            'Natural Gas Refrigeration':
            float(str(sqlFile.naturalGasRefrigeration())) * conversionFactorNG,
            'Natural Gas Generators':
            float(str(sqlFile.naturalGasGenerators())) * conversionFactorNG,
            'Natural Gas Total End Uses':
            float(str(sqlFile.naturalGasTotalEndUses())) * conversionFactorNG,
        }
        conversionFactorPropane = 9.480434
        propane = {
            'units': 'therms',
            #'Propane Heating':float(str(sqlFile.propaneHeating())) * conversionFactorPropane
        }
        conversionFactorWater = 1
        water = {
            'units': 'm3',
            'Water Interior Lights':
            float(waterVals.intlighting) * conversionFactorWater,
            'Water Exterior Lights':
            float(waterVals.extlighting) * conversionFactorWater,
            'Water Interior Equipment':
            float(waterVals.intequip) * conversionFactorWater,
            'Water Exterior Equipment':
            float(waterVals.extequip) * conversionFactorWater,
            'Water Heating': float(waterVals.heating) * conversionFactorWater,
            'Water Water Systems':
            float(waterVals.watersystems) * conversionFactorWater,
            'Water Cooling': float(waterVals.cooling) * conversionFactorWater,
            'Water Humidification':
            float(waterVals.humidity) * conversionFactorWater,
            'Water Heat Recovery': float(waterVals.hr) * conversionFactorWater,
            'Water Heat Rejection':
            float(waterVals.heatrej) * conversionFactorWater,
            'Water Refrigeration':
            float(waterVals.refrig) * conversionFactorWater,
            'Water Generators':
            float(waterVals.generators) * conversionFactorWater,
            'Fan Water': float(waterVals.fans) * conversionFactorWater,
            'Pumps Water': float(waterVals.pumps) * conversionFactorWater,
            'Water Total End Uses':
            float(waterVals.total) * conversionFactorWater
        }

        outputs['elec'] = electricity
        outputs['ng'] = naturalgas
        outputs['water'] = water
        pp.pprint(outputs)
        print "GJ to kWy Conversion Factor: " + str(conversionFactorElec)
        print "GH to therms Conversion Factor: " + str(conversionFactorNG)
        print "m3 to m3 Conversion Factor: " + str(conversionFactorWater)
        retval = checkVals(outputs['elec'], 'Electricity Total End Uses')
        print "Electricty test: " + retval
        retval = checkVals(outputs['ng'], 'Natural Gas Total End Uses')
        print "Natural gas test: " + retval
        retval = checkVals(outputs['water'], 'Water Total End Uses')
        print "Water test: " + retval

        allAnnualTotals = dictToClass(outputs)
        annualElectricity = dictToClass(electricity)
        annualNaturalGas = dictToClass(naturalgas)
        annualWater = dictToClass(water)
        sqlFile.close()
        print "Closing sql file..."
        print "Is Sqlite file still open?", sqlFile.connectionOpen()
        return allAnnualTotals, annualElectricity, annualNaturalGas, annualWater
    except Exception, e:
        print e
        if (key != totaltag):
            if (type(dictionary[key]) is float):
                subtotal += dictionary[key]
        else:
            storedtotal = dictionary[key]
    if (subtotal == storedtotal):
        return "PASS"
    else:
        return "FAIL"


#ops.
#sqlPath = r'C:\Users\Administrator\Downloads\eplusout.sql'
pp = pprint.PrettyPrinter(indent=4)
sqlPath = _sqlFilePath
sqlFile = ops.SqlFile(ops.Path(sqlPath))
conversionFactorElec = float(str(ops.OptionalDouble(277.777778)))
outputs = {}
electricity = {
    'units':
    'kilowatt-hours',
    'Electricity Interior Lights':
    float(str(sqlFile.electricityInteriorLighting())) * conversionFactorElec,
    'Electricity Exterior Lights':
    float(str(sqlFile.electricityExteriorLighting())) * conversionFactorElec,
    'Electricity Interior Equipment':
    float(str(sqlFile.electricityInteriorEquipment())) * conversionFactorElec,
    'Electricity Exterior Equipment':
    float(str(sqlFile.electricityExteriorEquipment())) * conversionFactorElec,
    'Electricity Heating':
    float(str(sqlFile.electricityHeating())) * conversionFactorElec,