0

我处理下面的代码已经很长时间了。我必须在光栅图像中显示计算太阳能发电厂电力成本的结果。问题是我必须将层“DNI”(直接正常辐照)与公式交互,并且在生命工厂的 30 年期间,公式的值随着每年的因子(costReductionFactorPlant)而变化。因素如下所示。

当我运行代码时,我收到以下错误:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 56, in <module>
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 4049, in Times
    in_raster_or_constant2)
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Utils.py", line 47, in swapper
    result = wrapper(*args, **kwargs)
  File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 4046, in wrapper
    return _wrapLocalFunctionRaster(u"Times_sa", ["Times", in_raster_or_constant1, in_raster_or_constant2])
RuntimeError: ERROR 000732: Input Raster: Dataset D:_ArcGIS\Python\LCOE_test does not exist or is not supported
>>> 

恐怕调用层“DNI”时有问题。但没有头绪。也许循环也有错误......我也试过看它,对我来说看起来不错,但我不是专家。

我正在运行 ArcGis 10.1。所有建议都非常受欢迎。

代码:

import arcpy, os, sys
from arcpy import env
from arcpy.sa import *

# Set Workspace
env.workspace = "D:\02_ArcGIS\Python\LCOE_test"

# Check out the ArcGIS Spatial Analyst extension license
arcpy.CheckOutExtension("Spatial")

# Variables definition
capacity = 100000
actualOutput = .94 * capacity
storageHours = 16
loadFactor = (.57 * storageHours + 7.1)/24
costReductionFactorPlant = [0.4790, 0.4533, 0.4297, 0.4080, 0.3880, 0.3696, 0.3526, 0.3368, 0.3222, 0.3087, 0.2961, 0.2844, 0.2735, 0.2633, 0.2538, 0.2449, 0.2366, 0.2288, 0.2215, 0.2146, 0.2081, 0.2021, 0.1964, 0.1910, 0.1859, 0.1811, 0.1765, 0.1723, 0.1682, 0.1643, 0.1607]
efficiency = [0.1822, 0.1827, 0.1831, 0.1834, 0.1837, 0.1840, 0.1841, 0.1843, 0.1844, 0.1845, 0.1846, 0.1847, 0.1847, 0.1848, 0.1848, 0.1849, 0.1849, 0.1849, 0.1849, 0.1849, 0.1849, 0.1850, 0.1850, 0.1850, 0.1850, 0.1850, 0.1850, 0.1850, 0.1850, 0.1850, 0.1850]
years = 30
i = .1
ir = .01
lcoePlantTotal = 0
productionPlant = loadFactor * actualOutput * 8760
DNI =  "D:\02_ArcGIS\Python\LCOE_test" #layer#

Count=len(costReductionFactorPlant)+ 1
counter=1

while counter < Count:
    for i in range(counter,(counter+1)):

            # Set the cell size environment using a keyword.
            arcpy.env.cellSize = "MAXOF"

            # Set the extent environment using a keyword
            arcpy.env.extent = "MAXOF"

            #intermediate formula plant

            # size = (capacity * 8760 * loadFactor)/(DNI * efficiency[counter-1])

            size1 = (capacity * 8760 * loadFactor)
            timesConstant = efficiency[counter-1]
            size2 = Times(3, timesConstant)
            print size2
            size = Divide(size1, size2)

            # Calculate power block & storage              
            powerBlock = capacity * 1484.9918 * costReductionFactorPlant[counter-1]
            storage = storageHours * capacity * 39.45759 * costReductionFactorPlant[counter-1]

            # Calculate mirrowField 
            # mirrorField = size * 155.6975 * costReductionFactorPlant[cont-1]
            timesConstant2 = costReductionFactorPlant[counter-1]
            inconstant = Times(155.6975, timesConstant2)
            mirrorField = Times(size, inconstant)

            # calculate PowerTower
            powerTower = ((capacity * 121.03883) + (capacity * 128.50378)) * costReductionFactorPlant[counter-1]

            # Calculate investmentPlant
            investmentPlant = powerBlock + storage + mirrorField + powerTower

            # Calculate omPlant
            omPlant = Times(investmentPlant, 0.048)

            #formula: lcoePlant = ((investmentPlant * (((i * (1 + i)^counter)/((1 + i)^counter-1))+ ir))+omPlant)/productionPlant*100
            # Formula Part 1 = (investmentPlant * (((i * (1 + i)^counter) Power symbol = **
            InConstant3= i * ((1 + i)**counter)
            FormulaPart1 = Times(investmentPlant, InConstant3)

            # Formula Part 2 = ((1 + i)^counter-1))+ ir))+omPlant)/productionPlant*100
            FormulaPart2 =(((1 + i)**(counter-1)+ ir)+omPlant)/productionPlant*100

            # Formula
            lcoePlant = Divide(FormulaPart1, FormulaPart2)

            lcoePlantTotal = lcoePlantTotal + lcoePlant

            lcoePlantTotal.save = "D:\\02_ArcGIS\\Python" + str(lcoePlantTotal) + ".img"

print "lcoePlanttotal calculated"
4

1 回答 1

0

你需要避开你的反斜杠,你可以看到它认为你在说 hex-2。如果您查看错误消息中的最后一行,它会告诉您该文件不存在,并且它显示它的文件名与您提供的文件名不同。

>>> DNI =  "D:\02_ArcGIS\Python\LCOE_test"
>>> DNI
'D:\x02_ArcGIS\\Python\\LCOE_test'

>>> DNI =  "D:\\02_ArcGIS\\Python\\LCOE_test"
>>> DNI
'D:\\02_ArcGIS\\Python\\LCOE_test'
>>> print DNI
D:\02_ArcGIS\Python\LCOE_test
于 2013-04-10T14:23:57.377 回答