I am creating a script that uses AreaSolarRadiation. Currently arcpy gives a cryptic error during the night hours.
arcgisscripting.ExecuteError: ERROR 999999: Error executing function.
Failed to open raster dataset
Failed to execute (AreaSolarRadiation)
Is there a way to simply check to know when it is night hours so I can skip running the tool? Currently I just catch the cryptic error and skip it. The script calculates Solar Radiation every hour over several days. It would be nice to have a quick check to save computation time during night hours.
import arcpy
from arcpy.sa import *
import datetime
arcpy.env.workspace = r'C:\Workspace'
arcpy.CheckOutExtension('Spatial')
print('Begin Script')
date_time = datetime.datetime.strptime('2014-01-01', '%Y-%m-%d')
day_of_year = date_time.timetuple().tm_yday #(Jan 1 = 1)
start = 12 # Hour to start calculation
end = 13 # Hour to end
twd = TimeWithinDay(day_of_year, start, end)
sky_size = 200
dem = r'C:\Workspace\dem.tif' # Any DEM file (use a small one for testing)
# Works during the day
out_solar_radiation = AreaSolarRadiation(dem, '', sky_size, twd)
print(out_solar_radiation)
start = 2
end = 3
twd = TimeWithinDay(day_of_year, start, end)
# Does not work at night
out_solar_radiation = AreaSolarRadiation(dem, '', sky_size, twd)
print out_solar_radiation
print('End Script')
Using ArcGIS 10.3
When the workspace is a place arcpy can write to I get a different error
arcgisscripting.ExecuteError: ERROR 010036: Error in creating the sun map.
ERROR 010003: The time range is at night when sun light is not available
Failed to execute (AreaSolarRadiation)
Esri help pages don't have very helpful information though.
http://resources.arcgis.com/en/help/main/10.1/index.html#//00vq0000000n010036 http://resources.arcgis.com/en/help/main/10.1/index.html#//00vq00000002010003
Tool dialogue and error screenshots