Re: Get forecast time from GFS gribfiles

From: Jonas Kaufmann <jonas.kaufmann_at_nyahnyahspammersnyahnyah>
Date: Wed Dec 12 2012 - 08:16:47 MST

Hello Dennis,

thanks! I managed to find the time using the first method you gave:
print ("Initial time:" + wind_u@initial_time)
print ("Forecast time:" + wind_u@forecast_time)

Now, how can I add up the forecast_time hours to the initial_time?
Here is an example output of the above commands:
(0) Initial time:12/12/2012 (06:00)
(0) Forecast time:27

Forecast time is given in hours and goes up to +180. I would like to
display the current forecast timestep, in this case something like
"2012-12-13 09:00". I tried the various date and time functions, but I
could not find one that I could use to add up these hours to a given
date. Am I missing something there? How can I perform this
calculation?

Thanks again for your help!

Jonas

On Wed, Dec 12, 2012 at 4:03 PM, Dennis Shea <shea@ucar.edu> wrote:
> There are a couple of methods for the time. I do not
> have a gfs file but ...
>
> --
> Generally, a variable will have
>
> f = addfile(...)
> x = f->X
> printVarSummary(X) ; <- always look at variable
>
> float x ( :, : )
> [snip]
> forecast_time : 24
> forecast_time_units : hours
> initial_time : 11/11/2008 (00:00)
>
> In your script use x@forecast and/or x@initial_time
>
> --
> Use setfileoption in various modes.
> http://www.ncl.ucar.edu/Document/Functions/Built-in/setfileoption.shtml
>
> Try and see what you get
>
> setfileoption(...)
> f = addfile(...)
> x = f->X
> printVarSummary(x)
>
> Try
> setfileoption("grib","SingleElementDimensions", "Initial_time")
>
> or
> setfileoption("grib","SingleElementDimensions", "Forecast_time")
> or
> setfileoption("grib","SingleElementDimensions", (/"Initial_time",
> "Forecast_time"/))
>
> The latter may look like:
> float x ( initial_time0_hours, forecast_time1, lat_3, lon_3 )
>
> There will be several 'time variables'
>
> ========
> A more efficient method for looking at the files
> is ncl_filedump via options
>
>
> %> ncl_filedump gfs.grb | less
>
> %> ncl_filedump -itime gfs.grb | less
> %> ncl_filedump -ftime gfs.grb | less
> %> ncl_filedump -itime -ftime gfs.grb | less
>
> Good luck
>
>
> On 12/12/12 7:38 AM, Jonas Kaufmann wrote:
>>
>> Hello,
>>
>> I am using NCL to create plots from the GFS grib files. Now I am
>> trying to display a label with the current forecast time on the map. I
>> have already positioned my text label with gsn_text_ndc, but I could
>> not find a method to get the current forecast time. Which variable do
>> I have to use for this?
>>
>> grib_file=filename
>> fin = addfile(grib_file,"r")
>> lat2d = fin->gridlat_0
>> lon2d = fin->gridlon_0
>> wind_u = fin->UGRD_P0_L103_GLC0(:,:)
>> wind_v = fin->VGRD_P0_L103_GLC0(:,:)
>>
>>
>> Thank you for your help!
>>
>>
>> Best regards,
>>
>> Jonas Kaufmann
>> _______________________________________________
>> 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 Dec 13 00:17:42 2012

This archive was generated by hypermail 2.1.8 : Wed Dec 12 2012 - 19:07:01 MST