Re: input lat and lon to plot one grib box

From: Dennis Shea <shea_at_nyahnyahspammersnyahnyah>
Date: Wed, 21 Dec 2005 13:50:28 -0700 (MST)

>Im working with reanalysis data that has 277 grid boxes for lat and 349
>boxes for lon. I'd like to narrow the area to specific lat and lon (one
>grid box) and then output certain variables in that region to netcdf.
>Is there a way to do this in the script you provide to convert grib to
>netcdf?

The short answer is "yes, of course!"

[1] I assume you are working with the NARR
    [North American Regional Reanalysis] dataset
    
[2] You say "one grid box"
    [a] Do u mean one point?
    [b] Do u mean 4 points that define an area?
    
    What point(s) ?
    
[3] What do u mean by: "the script you provide to
    convert grib to netcdf"
    
    What "script you provide" are you referring to?
    
    The a034 release [Jan 2006] of NCL will have a command
    line tool [ncl_grib2nc] that will convert GRIB to netCDF. However,
    it will not provide the level of granularity described above.
    

---
If you know the subscript location(s) 
of the point(s) you want, say, i and j, 
then [***untested***]
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" 
begin
     i = 
     j =
     
     fili  = "foo.grb"
     fout  = "foo.nc"
     
     f     = addfile (fili , "r")
                                      ; 3d variables
     h     = f->HGT_221_ISBL(:,j,i)
     t     = f->TMP_221_ISBL(:,j,i)
     u     = f->U_221_ISBL(:,j,i)
     v     = f->V_221_ISBL(:,j,i)
     q     = f->SPF_H_221_ISBL(:,j,i)
                                      ; 2d variables
     prc   = f->PRECIP(j,i)
     
     lat   = f->gridlat_221(j,i)
     lon   = f->gridlon_221(j,i)
                                      ; time
     stime = h_at_initial_time           ; 01/01/1997 (18:00)  <==> MM/DD/YYYY
     time  = grib_stime2itime(stime)  ; 1997010118          <==  YYYYMMDDHH
     
     system ("/bin/rm -f "+fout)
     ncdf  = addfile (fout, "c")
     
     ncdf_at_title = "NARR"
     ncdf_at_yyyymmddhh    = time
     ncdf_at_time_string   = stime
     ncdf_at_lat           = lat
     ncdf_at_lon           = lon
     ncdf_at_source        = fili
     ncdh_at_creation_date = systemfunc("date")
     
     ncdf->HGT = h
     ncdf->TMP = t
     ncdf->U   = u
     ncdf->V   = v
     ncdf->Q   = q
     ncdf->HGT = prc
                              
end     
     
The above could be made more efficient and work on multiple files.
good luck
D
     
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Dec 21 2005 - 13:50:28 MST

This archive was generated by hypermail 2.2.0 : Thu Dec 22 2005 - 15:26:00 MST