Re: extract value of attribute

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 8 Sep 2008 16:15:44 -0600 (MDT)

On Mon, 8 Sep 2008, prabhakar shrestha wrote:

> Can anyone help to extract the value of attribute from netcdf files using
> ncl?

If it's a file (global) attribute that you want, use the "@" sign:

   f = addfile("youfile_nc","r")
   hist = f_at_history ; Reads attribute "history" into local variable "hist"

If it's a variable attribute that you want, say "units", from variable
"T" on the file:

   f = addfile("youfile_nc","r")
   units = f->T_at_units
   print("T's units are '" + units + "'.")

Of course, you can first read "T" to a local variable "t", and then
just use "t_at_units" whenever you need to reference this attribute:

   f = addfile("youfile_nc","r")
   t = f->T
   print("T's units are '" + t_at_units + "'.")

For some more complicated examples, see the "addfile" documentation:

   http://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml

--Mary
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Sep 08 2008 - 16:15:44 MDT

This archive was generated by hypermail 2.2.0 : Mon Sep 08 2008 - 16:16:07 MDT