[gradsusr] writing results & variables to a text file

Andrew Revering andy at f5data.com
Thu Nov 24 17:36:43 EST 2011


I'm not following this thread real closely, so I might not be answering it
properly... but:

*wgrib2* shows help
*wgrib2 gfs12Z090411_00hr.grib -s -lon -93 43* Shows everything for this
point (43,-93)
*wgrib2 infile.grib -s -lon -93 43 | egrep '(:TMP:2 m|:DPT:2 m:)'* shows
exact values for specific records at a specific coordinate.
*wgrib2 infile.grib -ctl_inv* shows inventory with units
*wgrib2 infile.grib -match_inv* shows inventory for use with egrep
adding a *> output.txt* to the end will print out the output to a file.


Andrew Revering
Convective Development, Inc.
http://www.convectivedevelopment.com/


On Thu, Nov 24, 2011 at 3:02 PM, Eric Altshuler <ela at cola.iges.org> wrote:

> Mason,
>
> Just typing 'wgrib' will show all available options. I may be wrong, but
> it appears that wgrib lacks the capability to extract a data value at a
> specific point on the horizontal grid. wgrib can extract a single GRIB
> record (which is usually one single-level field or one multi-level field on
> a specified vertical level) and output the data in several formats,
> including text, but you still get the entire horizontal grid. In order to
> get the value at a single point, you need to identify the proper location
> of the value at that point in the output text file. Alternatively, you
> could obtain the output data in binary format and read the binary data
> using a Fortran or C program which prints out the value for a given input
> location (I,J). You would need to figure out the correct I and J for the
> point you are interested in. If the horizontal grid is on a projection
> (e.g. polar stereographic, Lambert), you would need to use the
> transformation formulas that relate (lon,lat) to (I,J) for!
>  that projection and its parameters. It's somewhat complicated, but it can
> be done. However, using grads is probably much easier in this situation,
> since grads will automatically interpolate preprojected data onto the
> lat-lon grid specified in the XDEF and YDEF lines in the control file. You
> can use grib2ctl to generate a control file from the original GRIB file.
> grib2ctl recognizes most common map projections (it reads the projection
> information from the GRIB header) and usually generates a correct PDEF
> statement, if one is necessary. After running grib2ctl, run gribmap on the
> control file to make the index file, and you'll be all set.
>
> Eric
>
> ----- Original Message -----
> From: "Mason D. Rowell" <Mason.D.Rowell-1 at ou.edu>
> To: "GrADS Users Forum" <gradsusr at gradsusr.org>
> Sent: Thursday, November 24, 2011 12:28:30 AM
> Subject: Re: [gradsusr] writing results & variables to a text file
>
> If you looked, you would see the 'comprehensive' documentation provided
> here (ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib/grib2ieee.txt) given in
> this link you give me (which I am aware of already) has some examples, but
> not about how to extract for a specific location in space. Even these
> 'tricks' also provided here (
> ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib/tricks.wgrib) within your link
> only mention how to extract at a specific height. Perhaps I am just not
> digging into this page enough, as I have tried in the past. My original
> inquiry alluded to needing this specific functionality, or least this was
> what was most paramount. These pages do mention more details in the readme
> files, but I am using the wgrib made available in the grads utility bin, so
> readme files are not present (at least in the build made available to me).
> I didn't want to unnecessarily download and compile wgrib just to get the
> readme files when I already have the utility itself through grads. My
> question was!
>  a simple yes or no, can this exact syntax provided below be used with
> wgrib, not just wgrib2? I apologize if it seems I am not trying. If you do
> not know then thank you anyways, but the answer is simple.
>
> Mason
> ________________________________________
> From: gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org] on
> behalf of Jeff Lake [admin at michiganwxsystem.com]
> Sent: Wednesday, November 23, 2011 10:13 PM
> To: gradsusr at gradsusr.org
> Subject: Re: [gradsusr] writing results & variables to a text file
>
> http://www.cpc.ncep.noaa.gov/products/wesley/wgrib.html
> hmm look and see
>
> -Jeff Lake
> MichiganWxSystem.com
> WeatherMichigan.net
> TheWeatherCenter.net
> GRLevelXStuff.com
>
>
> On 11/23/2011 10:33 PM, Rowell, Mason D. wrote:
> > The question was, if that syntax, and thus specific type of extraction,
> was possible with wgrib, rather than wgrib2. Yes there is a wgrib, but it
> is just called wgrib, not wgrib1.
> >
> > Mason
> > ________________________________________
> > From: gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org] on
> behalf of Jeff Lake [admin at michiganwxsystem.com]
> > Sent: Wednesday, November 23, 2011 4:56 PM
> > To: gradsusr at gradsusr.org
> > Subject: Re: [gradsusr] writing results&  variables to a text file
> >
> > wgrib is for GRIB1
> > wgrib2 is for GRIB2
> > I don't think there is many GRIB1 around is there ?
> >
> > -Jeff Lake
> > MichiganWxSystem.com
> > WeatherMichigan.net
> > TheWeatherCenter.net
> > GRLevelXStuff.com
> >
> >
> > On 11/23/2011 5:36 PM, Rowell, Mason D. wrote:
> >> Wesley,
> >>
> >> Will command syntax like this work for wgrib as well (not wgrib2)? I
> have had instances of just wanting to extract one variable at one exact
> location but the wgrib documentation didn't have examples of how to do this
> (what options to use after wgrib) for a specific location.
> >>
> >> Mason
> >> ________________________________________
> >> From: gradsusr-bounces at gradsusr.org [gradsusr-bounces at gradsusr.org] on
> behalf of Wesley Ebisuzaki [Wesley.Ebisuzaki at noaa.gov]
> >> Sent: Wednesday, November 23, 2011 12:43 PM
> >> To: GrADS Users Forum
> >> Subject: Re: [gradsusr] writing results&   variables to a text file
> >>
> >> Alireza,
> >>
> >>      "If all you have is a hammer, everything looks like a nail."
> >>
> >>       Before trying to find a GrADS solution, consider whether GrADS is
> >> the right tool.
> >>
> >>
> >> (A)  To find Washington DCs T2m for a single file, 1.grb2
> >>
> >>       wgrib2 1.txt -match ":TMP:" -match ":2 m above ground:"  -s -lon
> -53
> >> 38>1.txt
> >>
> >>
> >> (B) Do the same for *.grb2 (only works for v0.1.9.3  5/2011 or later)
> >>
> >>       cat  *.grb2 | wgrib2 - -match ":TMP:" -match ":2 m above ground:"
> >> -s -lon -53 38>all.txt
> >>
> >>
> >>       for older wgrib2:  cat *.grb2>tmp.grb2
> >>                                     wgrib2 tmp.grb2 -match ":TMP:"
> -match
> >> ":2 m above ground:"  -s -lon -53 38>all.txt
> >>
> >>
> >>         Wesley Ebisuzaki
> >>
> >>
> >>
> >> Alireza Azargoun wrote:
> >>> Dear GrADS users
> >>> Hi everybody
> >>>
> >>> I have about 200 grib2 files ( 1.grb2 ~ 200.grb ) . i need to read a
> >>> temperature of a city (lat, lon, lev, time are constant in all files)
> >>> . how i can read this files using a while loop!?  ( I receive this
> >>> error when i write a while. Unknown Command: while )
> >>>    and how can i write these data to a text file!? I've searched all
> >>> grads option for a command that writes variables in a text file! but i
> >>> couldn't find it!
> >>>
> >>> Thanks in advance,
> >>> Alireza
> >>> Sharif University of Technology
> >>>
> >>>
> >>> --
> >>> Alireza Azargoun
> >>>
> ------------------------------------------------------------------------
> >>>
> >>> _______________________________________________
> >>> gradsusr mailing list
> >>> gradsusr at gradsusr.org
> >>> http://gradsusr.org/mailman/listinfo/gradsusr
> >>>
> >> _______________________________________________
> >> gradsusr mailing list
> >> gradsusr at gradsusr.org
> >> http://gradsusr.org/mailman/listinfo/gradsusr
> >>
> >> _______________________________________________
> >> gradsusr mailing list
> >> gradsusr at gradsusr.org
> >> http://gradsusr.org/mailman/listinfo/gradsusr
> >>
> > _______________________________________________
> > gradsusr mailing list
> > gradsusr at gradsusr.org
> > http://gradsusr.org/mailman/listinfo/gradsusr
> >
> > _______________________________________________
> > gradsusr mailing list
> > gradsusr at gradsusr.org
> > http://gradsusr.org/mailman/listinfo/gradsusr
> >
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20111124/7a4feb7d/attachment-0003.html 


More information about the gradsusr mailing list