I'm using the field calculator in a model to calculate a field. I have the following expression, type is set to VB.
0.27 * ( ( Tan ( [RASTERVALU] ) * %Wave Height (Hs)% * %Wave Period (T)% ) ^ (0.5) )
This returns an error. If I remove the Power function (i.e., ^ 0.5) it works. Note, RASTERVALU is not null.
Ideas?
Solved! Go to Solution.
Ok, found the issue 😉 Need to convert degrees to radians to prevent negative values.
(0.27 * ( ( math.tan ( !RASTERVALU! * ( 3.14159 / 180 ) ) * %Wave Height (Hs)% * %Wave Period (T)% ) ** (0.5) )) * 1.39
Ok, found the issue 😉 Need to convert degrees to radians to prevent negative values.
(0.27 * ( ( math.tan ( !RASTERVALU! * ( 3.14159 / 180 ) ) * %Wave Height (Hs)% * %Wave Period (T)% ) ** (0.5) )) * 1.39
Yes, degrees to radians AND use the python ** operator, of course using the PYTHON_9.3 parser:
(0.27 * ( ( math.tan ( !RASTERVALU! * ( 3.14159 / 180 ) ) *
%Wave Height (Hs)% * %Wave Period (T)% ) ** (0.5) )) * 1.39
Note the math module has a function for this:
(0.27 * (( math.tan(math.radians(!RASTERVALU!))
* %Wave Height (Hs)% * %Wave Period (T)% ) ** 0.5)) * 1.39