copy WRF output variables' coordinates to a new variable

From: Lisi Pei <lisipei_at_nyahnyahspammersnyahnyah>
Date: Thu Mar 21 2013 - 14:15:51 MDT

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
Received on Thu Mar 21 14:16:06 2013

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