[Thread Prev][Thread Next][Index]

Re: [ferret_users] if condition error



Title: Signature
Hi

I'm not sure that you can use the endif condition in an _expression_.

I would use this instead:
let theta1 = if(v5 gt 0 and v6 gt 0) then Q1 ELSE 0
let theta2 = if(v5 lt 0 and v6 gt 0) then Q2 ELSE 0
let theta3 = if(v5 lt 0 and v6 lt 0) then Q3 ELSE 0
let theta4 = if(v5 gt 0 and v6 lt 0) then Q4 ELSE 0

let theta = theta1 + theta2 + theta3 + theta4

Bruno

On 05/31/2016 12:23 PM, Steeven Paul Yerraguntla wrote:
Dear ferreters,
                I tried to compute the direction of the current vectors from u,v components. I need to add some degrees, like 180,360,0 to the calculated direction angle based on the positive and negative signs of the U and V velocities. I tried to apply the four conditions using if - elif-  endif but i am facing error at IF condition which i could not make out.  Please try to help me. script is as follows and data file is also attached.
************************************
file/format=delimited/delimiter=" "/var="v1,v2,v3,v4,v5,v6" currents_data.dat
let r2d = atan2(v6,v5)*(180/3.142857)
let Q1 = r2d + 0
let Q2 = r2d + 360
let Q3 = r2d + 180
let Q4 = r2d + 180

let theta = if(v5 gt 0 and v6 gt 0) then Q1
         elif(v5 lt 0 and v6 gt 0) then Q2
         elif(v5 lt 0 and v6 lt 0) then Q3
         elif(v5 gt 0 and v6 lt 0) then Q4
         endif

list v5,v6,theta
****************************************
Thanks and regards

Steeven Paul
NIO RC
India                


 





Click here to report this email as spam.



--
Mercator Ocean

Bruno LEVIER

Monitoring and Forecasting Systems Evaluation Team

+33 5 61 39 38 51
bruno.levier@xxxxxxxxxxxxxxxxx
mercator-ocean.eu   marine.copernicus.eu


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement