Re: Does anyone have a WRF-based script...

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Tue, 21 Oct 2008 12:11:02 -0600

The attached file does this ... u will
get some warning message which you can ignore.

As noted the U10 and V10 are not relative to the earth.

Gerry Creager wrote:
> Mary Haley wrote:
>> Gerry,
>>
>> I'm not sure what you mean by extracting "to" a netCDF file. Did you
>> mean "from"?
>
> Mary,
>
> Sorta both. wrfout is a netcdf but they did funny things w/ time. It's
> a dimension, rather than a variable. We can get around that, I think,
> with a little code; I'd done it before and need to find the snippet I
> did it with, but SLP isn't a native diagnostic: wrf_user_getvar() helps
> that problem a lot. Thanks!
>
> We want to output to a CF-1.0 compliant netCDF, consistent with the
> project's goals and objectives. We're already doing this with NCEP NAM
> data but the Time variable is, well, a variable and SLP is native in
> their GRiB2 files.
>
> What Dennis just sent helps, and I I'm back on-track.
>
> Regards, Gerry
>
>> You might want to check out the "wrf_user_getvar" function:
>>
>>
>> http://www.ncl.ucar.edu/Document/Functions/WRF_arw/wrf_user_getvar.shtml
>>
>> Let me know if this isn't what you need.
>>
>> --Mary
>>
>>
>> On Mon, 20 Oct 2008, Gerry Creager wrote:
>>
>>> that extracts u10, v10 and SLP to a netCDF file? Before I go
>>> reinvent something?
>>>
>>> Or something similar?
>>>
>>> Thanks, Gerry
>>> --
>>> Gerry Creager -- gerry.creager_at_tamu.edu
>>> Texas Mesonet -- AATLT, Texas A&M University
>>> Cell: 979.229.5301 Office: 979.862.3982 FAX: 979.862.3983
>>> Office: 1700 Research Parkway Ste 160, TAMU, College Station, TX 77843
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"

procedure nameDims(x[*][*][*]:numeric, dNames[*]:string)
begin
  x!0 = dNames(0)
  x!1 = dNames(1)
  x!2 = dNames(2)
end

begin
  diri = "./"
  diro = "./"
  fili = "wrfout_d01_2003-07-15_00:00:00.nc"
  filo = "CF."+fili

  a = addfile("wrfout_d01_2003-07-15_00:00:00.nc","r")

  Times = a->Times ; character: ( Time, DateStrLen )
  dimT = dimsizes(Times)
  ntim = dimT(0)

  Time = wrf_times_c( Times, 0 ) ; "hours since" initial time on file (double)
 ;Time = wrf_times_c( Times, 1 ) ; "hours since 1901-01-01 00:00:00" (double)
  ymdhms= wrf_times_c( Times, 2 ) ; yyyymmddhhmnss (double)
  ymdh = wrf_times_c( Times, 3 ) ; yyyymmddhh (integer)
  
                          ; Time, bottom_top_stag, south_north, west_east)
  dNames= getfilevardims(a,"PH")
  print(dNames)
  dSizes= getfilevardimsizes(a,"PH")
  print(dSizes)
  vType = getfilevartypes(a,"PH")
  print(dSizes)

  ntim = dSizes(0)
  nlat = dSizes(2)
  mlon = dSizes(3)

  XLAT = a->XLAT
  XLONG = a->XLONG

  slp = new ( (/ntim,nlat,mlon/), vType, "No_FillValue")
  u10 = new ( (/ntim,nlat,mlon/), vType, "No_FillValue")
  v10 = new ( (/ntim,nlat,mlon/), vType, "No_FillValue")

  do nt=0,ntim-1
     slp(nt,:,:) = wrf_user_getvar(a,"slp",nt) ; slp
     u10(nt,:,:) = wrf_user_getvar(a,"U10",nt) ; u at 10 m
     v10(nt,:,:) = wrf_user_getvar(a,"V10",nt) ; v at 10 m
  end do

  nameDims(slp, (/dNames(0),dNames(2),dNames(3)/) )
  nameDims(u10, (/dNames(0),dNames(2),dNames(3)/) )
  nameDims(v10, (/dNames(0),dNames(2),dNames(3)/) )
  
  printVarSummary(slp)
  printVarSummary(u10)

  system("/bin/rm -f "+diro+filo)
  aout = addfile(diro+filo, "c")

  fileattdef( aout, a ) ; copy file attribute
  filedimdef(aout,"Time",-1,True) ; make time an UNLIMITED dimension

  aout->Time = Time
  aout->Times = Times
 ;aout->ymdhms= ymdhms ; yyyymmddhhmnss (double)
 ;aout->ymdh = ymdh ; yyyymmddhh (integer)
  aout->XLAT = XLAT
  aout->XLONG = XLONG
  aout->SLP = slp
  aout->U10 = u10
  aout->V10 = v10
  
end
Received on Tue Oct 21 2008 - 12:11:02 MDT

This archive was generated by hypermail 2.2.0 : Wed Oct 22 2008 - 13:49:07 MDT