Re: create a new data file with specific variable name

From: Rick Brownrigg <brownrig_at_nyahnyahspammersnyahnyah>
Date: Wed Jun 11 2014 - 09:20:33 MDT

Hi Mark,

I *think* you want something like:

  c->$nnam$ = wa_x

A quick experiment here seemed to confirm that.

Rick



On Wed, Jun 11, 2014 at 5:45 AM, Mark Chan <cym263@yahoo.com> wrote:

> Dear NCL helper,
>
> In the below is an NCL script, in which a file "Lind_wrf_W_Wind.nc" would
> be created. However, I want the variables name as "W300", "W400" and so on,
> instead of "nnam" ( I hope "nnam" is a variable, which represent "W300"
> etc.). This moment I always got the variable name as "nnam" in the data
> file. Can any one help!
>
> Best regards,
> Mark
>
> ====================
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
>
> begin
> ;
> ; The WRF ARW input file.
> ; This needs to have a ".nc" appended, so just do it.
>
> a = addfile(infile,"r")
> system("/bin/rm -f " + "Lind_wrf_W_Wind.nc")
> c = addfile("Lind_wrf_W_Wind.nc","c")
>
> ;------- for 3D variables------------
> dim_names = getvardims(a)
> dim_sizes = getfiledimsizes(a)
> dimUnlim = (/True, False, False, False, False, False, False, False,
> False/)
> filedimdef(c, dim_names, dim_sizes, dimUnlim)
> lat = a->XLAT
> lon = a->XLONG
> times = a->Times
> fileattdef(c,a)
>
> pres=
> (/300,400,500,550,600,625,650,700,725,750,775,800,825,850,900,925,950,1000/)
> Vname=
> (/"W300","W400","W500","W550","W600","W625","W650","W700","W725","W750","W775","W800","W825","W850","W900","W925","W950","W1000"/)
> npres=dimsizes(pres)
> print(pres)
> print(Vname)
> c->Times = times
> c->XLAT = lat
> c->XLONG = lon
>
> time = -1
>
> wa = wrf_user_getvar(a,"wa",time) ;
> p = wrf_user_getvar(a,"pressure",time) ; total pressure
>
> ; Horizontally interpolate to pressure coordinates ("p")
>
> do n=0,npres-1
> pressure = pres(n) ; pressure hPa
> wa_x = wrf_user_intrp3d(wa,p,"h",pressure,0.,False)
> nnam= (/Vname(n)/)
> print(nnam)
> c->nnam = wa_x ;**************my question here
> ****************
> delete(wa_x)
> delete(nnam)
>
> end do
>
> end
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

Received on Wed Jun 11 03:20:43 2014

This archive was generated by hypermail 2.1.8 : Wed Jul 23 2014 - 15:33:46 MDT