Re: How to read in different types of input

From: Wee-Beng Tay <zonexo_at_nyahnyahspammersnyahnyah>
Date: Thu Dec 24 2009 - 00:47:48 MST

Thanks Dennis.

However, what I wanted is to have different variables stored. I managed to
edit your script to get it working

Hence supposed I want to plot a graph with the 1st variable using line
contour , 2nd variable using color contour.

The variable can be TS,PS,U,V,W

All are 2 dim array ie PS/TS(size_x,size_y) hence I don't I need the "rank"
since they are alway 2.

In this case, using 'var_type=(/"TS","PS"/)'

nVar = dimsizes(var_type)

phi1 = a->$var_type(0)$

phi2 = a->$var_type(1)$

phi1/2 will then store TS/PS, or maybe some other combination.

I also found that I can input more variables by using:

nVar = dimsizes(var_type)

print (nVar)

phi1 = a->$var_type(0)$

if ((nVar) .gt. 1) then

  phi2 = a->$var_type(1)$

end if

if ((nVar) .gt. 2) then

  phi3 = a->$var_type(2)$

end if

if ((nVar) .gt. 3) then

  phi4 = a->$var_type(3)$

end if

Thanks for the enlightenment!

On Thu, Dec 24, 2009 at 2:07 AM, Dennis Shea <shea@ucar.edu> wrote:

> On the command line:
> 'var_type=(/"TS","PS",.../)'
>
> In the script:
> nVar = dimsizes(var_type)
>
> do nv=0,nVar-1
> rank = dimsizes( getvardimsizes( a, var_type(nv)) )
> if (rank.eq.3)
> x = a->$var_type(nv)$(0,:,:)
> end if
>
> if (rank.eq.4)
> x = a->$var_type(nv)$(0,:,:,0)
> end if
>
> ; ..... code ......
>
> delete(x) ; rank may change with next variable
> end do
>
> ====
>
>
> On 12/23/2009 12:03 AM, Wee-Beng Tay wrote:
>
> Hi,
>
> I have a netcdf file with variables like temperature, pressure, velocity
> etc
>
> I want ncl to read in different types of input at different times through
> command line and then plot them out.
>
> It's simple if I only need to plot 1 variables. In that case, I'll use at
> the command line:
>
> e.g. ncl abc.ncl 'var_type="temperature"'
>
> if ((var_type) .eq. "temperature") then
>
> phi = a->TS(0,:,:) ; read temperature
>
> end if
>
> if ((var_type) .eq. "pressure") then
>
> phi = a->PS(0,:,:) ; read pressure
>
> end if
>
> However the problem arises when I need to plot more than 1 variable, maybe
> 3 to 4. Supposed there's 4 variables and there's phi1,phi2,phi3,phi4. How
> should I write the code to read in the correct variables?
>
> Thanks again!
>
> Wee-Beng
>
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> --
> ======================================================
> Dennis J. Shea tel: 303-497-1361 |
> P.O. Box 3000 fax: 303-497-1333 |
> Climate Analysis Section |
> Climate & Global Dynamics Div. |
> National Center for Atmospheric Research |
> Boulder, CO 80307 |
> USA email: shea 'at' ucar.edu |
> ======================================================
>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Dec 24 00:47:56 2009

This archive was generated by hypermail 2.1.8 : Tue Dec 29 2009 - 10:29:16 MST