Re: wrf_user_getvar - select time period

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Dec 01 2009 - 16:13:48 MST

Hi Richard,

You're right, there's no way to retrieve a subset of times using
wrf_user_getvar. It's not hard to get it to do so, however.

There are two ways you can do this.

The first way is to get all the times, and then subscript the
variable after the fact:

slp = wrf_user_getvar(z,"slp",-1) ; slp (-1 indicates for all times)
slp_subset = slp(0:10,:,:)

The second way is to use a modified version of "wrf_user_getvar" that
I called "wrf_user_get_slp" and attached to this message.

Load this script after your other loads:

load "./wrfslp.ncl"

and then call with:

times = ispan(0,10,1)

slp = wrf_user_get_slp(z,times)

--Mary

On Dec 1, 2009, at 11:35 AM, Richard Hewston wrote:

> Hi,
> I'm using ncl 5.0, and have a relatively simple question (i think)
> which
> I can't seem to find an answer to anywhere.
>
> In the simple script:
>
> ;---------------------------------------------
> ; derive a mslp field from the wrfout file, and writes it out to
> netcdf file
> ;---------------------------------------------
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
> begin
> ;---------------------------------------------
> ;open file and read in data
> ;---------------------------------------------
>
> z = addfile ("wrfout_d01_2000-01-01_00:00:00.nc", "r")
> slp = wrf_user_getvar(z,"slp",-1) ; slp (-1 indicates for all
> times)
>
> ;---------------------------------------------
> ;create reference to output file
> ;---------------------------------------------
> fout = addfile("MSLP_530.nc" , "c")
> ;---------------------------------------------
> ;Output variable slp to netCDF file
> ;-----------------------------------------------
> fout->MSLP= slp
> end
>
> I'm trying to select a subset of the temp.nc file, based on time. How
> can i select eg. timesteps 0-10?
> I can select timestep 0 by using
> slp = wrf_user_getvar(z,"slp",0)
>
> or timestep 5 with:
> slp = wrf_user_getvar(z,"slp",5)
>
> etc etc
>
> But I cannot figure out how to make to use a selection of 0 to 10??
>
> Any help greatly appreciated.
>
> Thanks,
> Rich
> _______________________________________________
> 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 Tue Dec 1 16:14:05 2009

This archive was generated by hypermail 2.1.8 : Thu Dec 03 2009 - 09:53:22 MST