[Thread Prev][Thread Next][Index]

Re: [ferret_users] Conditional with more than one variable

You can have multiple AND statements, but if there is an error in one of the expressions, or incompatible grids, it can be hard to know where that is happening.

What I would do to track down what's going wrong is to use Ferret to plot or list parts of your _expression_.

(I don't know what the grids are. Set the region specifiers so you can do useful 2D plots)

  shade/k=1 ifv (temp_out ge 6 and temp_out le 20 ) then 1
or define variables similar to what you're going to compute and look at them

  let temp_var = ifv (temp_out ge 6 and temp_out le 20 ) then 1
  list/x=-43 temp_var[y=-24:-23@din,z=@din]

Once you know what's going on with your individual expressions, you could start putting them together, building towards the full _expression_ and again evaluate. So, can you do the calculation with temp and salt? 

   let u_acas_out = if (temp_out ge 6 and temp_out le 20 and salt_out ge 34.6 and salt_out le 36 ) then u_out
   load u_out

   let tr_u_out_430=u_acas_out[x=-43,y=-24:-23@din,z=@din]/1e6
   load tr_u_out_430

If that is successful, add more terms and work along.  If you run into problems or see error messages, you've got a smaller set of things going on so you may be able to see where that's happening.

Also, if you write back, please say what error messages or other behavior you are seeing.


On 3/9/2015 6:54 AM, Lívia Sancho wrote:
Dear fellows,

I am trying to calculate the velocity integrated over an area, but I need it to be in the intersection of 3 variables and I can't do it.

Previously, I was able to do it with just 1 variable (density), but when I put the three of them together, something bad happens.

I believe is an error of syntax but I can't figure out the right way to do it.

Here is part of the code:

! Load the data
use temp_salt_out.nc    !d=1
use u_v_out.nc            !d=2
use temp_salt_nov.nc    !d=3
use u_v_nov.nc            !d=4
use temp_salt_dez.nc    !d=5
use u_v_dez.nc            !d=6

set mem/size=100

! Some corrections of the data
let temp_out  = (temperature[d=1]*0.000732)+294-273.15
let salt_out  = (salinity[d=1]*0.00153)+(-0.00153)
let dens_out=rho_un(salinity[d=1],temperature[d=1],0)-1000
let u_out  = (u[d=2]*0.00061)+(0)
let v_out  = (v[d=2]*0.00061)+(0)

! The condition part for temperature, salinity and depth
let u_acas_out = if (temp_out ge 6 and temp_out le 20 and salt_out ge 34.6 and salt_out le 36 and dens_out ge 25.5 and dens_out le 27.2) then u_out

! Calculate the integrated velocity.
let tr_u_out_430=u_acas_out[x=-43,y=-24:-23@din,z=@din]/1e6

Is there anyway to make this work? Any thoughts?


Lívia Sancho

Oceanógrafa, MSc
+55 (21) 9 8574-0843
+55 (21) 9 8211-5158

Mestrado no Programa de Engenharia Civil (PEC/COPPE - UFRJ)
Área de Petróleo e Gás

Universidade Federal do Rio de Janeiro
Laboratório de Métodos Computacionais em Engenharia
E-mail: sancho@xxxxxxxxxxxxxxxxxxx
Tel: +55 (21) 3938-8419

Currículo Lattes

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

Privacy Policy | Disclaimer | Accessibility Statement