Re: read global attributes

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jun 03 2010 - 06:25:27 MDT

You can treat a file variable like a regular NCL variable and use the @ symbol to access global attributes:

   f = addfile("wrfout_d01_2008-09-13_22:00:00.nc","r")

   start_date = f@START_DATE

Note that for attributes that have a dash ('-') in them, you have to enclose the name in $...$:

   west_east_grid_dim = f@$WEST-EAST_GRID_DIMENSION$

You can use a variable to hold the attribute name too:

  attname = "WEST-EAST_GRID_DIMENSION"
  west_east_grid_dim = f@$attname$

You can use the getvaratts function to read all global attribute names off a file:

    attnames = getvaratts(f)

See:

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

for more information.

--Mary

On Jun 2, 2010, at 11:28 PM, Li, Yongzuo wrote:

> Hi,
>
> How can the "file global attributes", e.g. START_DATE, be read into script ?
>
> Yongzuo
>
> Raptor-login[4] yli$ ncl_file edump wrfout_d01_2008-09-13_22:00:00.nc |more
> Copyright (C) 1995-2010 - All Rights Reserved
> University Corporation for Atmospheric Research
> NCAR Command Language Version 5.2.0
> The use of this software is governed by a License Agreement.
> See http://www.ncl.ucar.edu/ for more details.
> Variable: f (file variable)
>
> filename: wrfout_d01_2008-09-13_22:00:00
> path: wrfout_d01_2008-09-13_22:00:00.nc
> file global attributes:
> TITLE : OUTPUT FROM WRF V3.0 MODEL
> START_DATE : 2008-09-13_06:00:00
> SIMULATION_START_DATE : 2008-09-13_06:00:00
> WEST-EAST_GRID_DIMENSION : 401
> SOUTH-NORTH_GRID_DIMENSION : 401
> BOTTOM-TOP_GRID_DIMENSION : 41
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jun 3 06:25:33 2010

This archive was generated by hypermail 2.1.8 : Mon Jun 07 2010 - 16:48:44 MDT