Re: copy WRF output variables' coordinates to a new variable

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Thu Mar 21 2013 - 14:47:22 MDT

The WRF data are on a curvilinear grid:
    XLAT(Time, south_north, west_east)

The & syntax is *only* applicable to a special
subset of coordinates called a 'coordinate variable' (CV).
By definition a CV is one dimensional.

          xlat = a->XLAT(0,:,:)
          xlong= a->XLONG(0,:,:)

          shf = a->HFX
          lhf = a->LH

          new_var = shf+lhf
          copy_VarAtts(shf, new_var)
          new_var@long_name = "SHF+LHF"
          new_var@description = new_var@long_name
          printVarSummary(new_var)

;===================================================================

          system("/bin/rm -f new.nc") ; remove any pre-existing file
          hf_out= addfile("new.nc" ,"c") ; open output
netCDF file

          hf_out->XLAT = xlat
          hf_out->XLONG= xlong
          hf_out->new_var = new_var

On 3/21/13 2:15 PM, Lisi Pei wrote:
> Hello there,
>
> When I try to copy WRF output variable's dimension info to a new variable,I
> always get errors.
> I've tried in two ways.
> First:
>
> begin
> ;========================build up a directory loop and hours loop
> a = addfile("wrfout_d02_2004-07-19_03:00:00"+".nc","r")
>
> xlat = a->XLAT
> xlong= a->XLONG
> ;print(xlat)
>
> shf = a->HFX
> lhf = a->LH
>
> new_var = shf+lhf
> ;===================================================================
>
> system("/bin/rm -f new.nc") ; remove any
> pre-existing file
> hf_out= addfile("new.nc" ,"c") ; open output netCDF file
>
> new_var!0 = "hour"
> new_var!1 = "lat"
> new_var!2 = "lon"
>
> new_var&hour = 0
> new_var&lat = xlat
> new_var&lon = xlong
>
> new_var@long_name = "test test" ; assign attributes
> new_var@units = "W m-2"
>
> hf_out->new_var = new_var
> end
>
> the error message is:
> *fatal:Coordinate variables must have one dimension only*
> *fatal:No coordinate variable exists for dimension (lat) in variable
> (new_var)*
>
> Second way:
>
> begin
> ;========================build up a directory loop and hours loop
> a =
> addfile("/mnt/research/madai-weather/lisipei/GreatPlains/noah_mp/output_60s_wsm6/2004/d02/wrfout_d02_2004-07-19_03:00:00"+".nc","r")
>
> shf = a->HFX
> lhf = a->LH
>
> new_var = shf+lhf
> ;===================================================================
>
> system("/bin/rm -f new.nc") ; remove any
> pre-existing file
> hf_out= addfile("new.nc" ,"c") ; open output netCDF file
>
> new_var!0 = "hour"
> new_var!1 = "lat"
> new_var!2 = "lon"
>
> new_var&hour = 0
> new_var&lat = shf&XLAT
> new_var&lon = shf&XLONG
>
> new_var@long_name = "test test" ; assign attributes
> new_var@units = "W m-2"
>
> hf_out->new_var = new_var
>
> end
>
> the error message of the second way is:
> *fatal:(XLAT) is not a named dimension in variable (shf).*
> *
> *
> Can anybody help on this? Thank you in advance.
>
> Best Regards,
> Lisi
>
>
>
> _______________________________________________
> 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 Mar 21 14:47:29 2013

This archive was generated by hypermail 2.1.8 : Fri Mar 22 2013 - 16:45:18 MDT