2

I've dealing with the code below with such a long time. I have to show in a raster image the result of calculating the cost of the electricity for a solar plant. The thing is that I have to interact a layer "DNI" (direct normal irradiation) with the formula, and the value of the formula changes with a factor for each year (costReductionFactorPlant) during the 30 years of the life plant. The factors are shown below.

When I run the code, I receive the following error:

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
>>> 

I'm afraid that there is something wrong when calling the layer "DNI". But no clue. Maybe there is also an error with the loop... I've tryed to look at it also, for me looks good, but I'm not an expert.

I'm running ArcGis 10.1.

CODE:

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"
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Apr 10, 2013 at 12:49
1
  • Does the raster DNI indeed exist? Commented Apr 10, 2013 at 13:00

2 Answers 2

4

The paths with a single backslash are no valid paths. Use:

  • one forward slash:

"c:/test/test.shp"

  • Two backslash:

"c:\\test\\test.shp"

  • letter r before a string containing a backslash:

r"c:\test\test.shp"

answered Apr 10, 2013 at 13:03
6
  • Thanks guys. I've modified "\\" and defined the total route for the layer "DNI". Yes, this layer exists, is a .img ratster contained in the folder LCOE_test. The problem I've seen lies in this layer. I've writen a print "Ok" and it gives and error before the print "Ok1". Excatly the line where the layer is called. No idea what happens. If the raster .img exists and the folder exists and this is teh exact path. What else can be wrong? Commented Apr 10, 2013 at 14:27
  • The modifications in the code: env.workspace = "D:\02円_ArcGIS\\Python\\LCOE_test" DNI = "D:\02円_ArcGIS\\Python\\LCOE_test\\DNI" #layer# size2 = Times(DNI, timesConstant) lcoePlantTotal.save = "D:\02円_ArcGIS\\Python" + str(lcoePlantTotal) + ".img" Commented Apr 10, 2013 at 14:28
  • Here is the message error: Runtime error Traceback (most recent call last): File "<string>", line 44, 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) Commented Apr 10, 2013 at 14:29
  • 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:02円_ArcGIS\Python\LCOE_test\DNI does not exist or is not supported Commented Apr 10, 2013 at 14:30
  • 1
    Please don't try to put code/error messages in the comments section. Edit your question instead, referencing a particular answer if necessary. Commented Apr 10, 2013 at 19:40
2

In addition to what Jens mentions about correcting the path syntax, another problem is the workspace\input layer distinction. In the code you posted, env.workspace and DNI are identical, and the stack trace indicates that DNI is incorrectly set.

env.workspace = "D:02円_ArcGIS\Python\LCOE_test"
DNI = "D:02円_ArcGIS\Python\LCOE_test" 

I'm assuming LCOE_test is a folder, which will work fine as the workspace. However, for DNI you need to specify further. Depending on DNI's format, it will look something like

DNI = "D:\02円_ArcGIS\\Python\\LCOE_test\\DNI"

I also don't see DNI being called within the while loop (except for a commented line). I'm guessing this is a result of your debugging efforts, though.

answered Apr 10, 2013 at 13:45
9
  • I have runned it three times: One with the slash ,円 \,円 /. And the path of the layer "DNI" id properly defined. Nevertheless I still geting this error: Commented Apr 10, 2013 at 15:09
  • Traceback (most recent call last): File "<string>", line 47, in <module> Commented Apr 10, 2013 at 15:10
  • File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Functions.py", line 4049, in Times in_raster_or_constant2) Commented Apr 10, 2013 at 15:11
  • File "c:\program files (x86)\arcgis\desktop10.1\arcpy\arcpy\sa\Utils.py", line 47, in swapper result = wrapper(*args, **kwargs) Commented Apr 10, 2013 at 15:12
  • 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]) Commented Apr 10, 2013 at 15:13

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.