I'm new to the forum, so: Hello Everybody!I'm trying to add a def function to ArcGIS Desktops Field Calculator.The code of the def written in python is as follows:import arcpy
import math
import numpy
from arcpy import env
from numpy import *
pointshape = arcpy.GetParameterAsText (0)
raster = arcpy.GetParameterAsText (1)
solar_azimuth = arcpy.GetParameterAsText (2)
solar_height = arcpy.GetParameterAsText (3)
tilt = arcpy.GetParameterAsText (4)
output_raster = arcpy.GetParameterAsText (5)
def calculate_angles(ET_ANGLE):
#Calculating IN-Vector
phi_in = math.radians(180 - solar_azimuth)
theta_in = math.radians(90 - solar_height)
r = 1
x = -(r * math.sin(theta_in) * math.cos(phi_in))
y = -(r * math.sin(theta_in) * math.sin(phi_in))
z = -(r * math.cos(theta_in))
VSonneIn = numpy.matrix([, , ])
# Calculating Module-Vector
phi_modul = math.radians(180 - ET_ANGLE)
theta_modul = math.radians(tilt)
# r = 1 from above
u = r * math.sin(theta_modul) * math.cos(phi_modul)
v = r * math.sin(theta_modul) * math.sin(phi_modul)
w = r * math.cos(theta_modul)
# Defining Transformation-Matrix
MReflexion = numpy.matrix([[1-2*u*u, -2*u*v, -2*u*w],
[-2*u*v, 1-2*v*v, -2*v*w],
[-2*u*w, -2*v*w, 1-2*w*w]])
VSonneOut = MReflexion * VSonneIn
# Calculating OUT-Angles
theta_out = math.degrees(math.acos(VSonneOut[2]/(math.sqrt(VSonneOut[0]*VSonneOut[0]+VSonneOut[1]*VSonneOut[1]+VSonneOut[2]*VSonneOut[2]))))
VERT1 = (90 - theta_out)
return VERT1
if (VSonneOut[0] > 0):
phi_out = math.degrees(math.atan(VSonneOut[1]/VSonneOut[0]))
elif (VSonneOut[0] == 0):
phi_out = math.degrees(numpy.sign(VSonneOut[1])*(math.pi/2))
elif (VSonneOut[1] >= 0):
phi_out = math.degrees(math.atan(VSonneOut[1]/VSonneOut[0])+math.pi)
else:
phi_out = math.degrees(math.atan(VSonneOut[1]/VSonneOut[0])-math.pi)
AZIMUTH1 = (180 - phi_out)
return AZIMUTH1
The expression I use in the Field Calculator is as follows:calculate_angles(!ET_ANGLE!)
Now my problem is, that this def doesn't work. The Error message I get is not defined.-> <class 'arcgisscripting.ExecuteError'>: ERROR 999999: Error executing function.Failed to execute (CalculateField).Any Idea how to debug this or how to get it to work?I'm not getting it.Thanks for any help!