Skip to content

Commit 781d8f5

Browse files
committed
fix for issue #241
1 parent 00c8892 commit 781d8f5

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/pygrib/_pygrib.pyx

+6-4
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,8 @@ def setdates(gribmessage grb):
686686
elif grb.has_key('stepRange'):
687687
# if forecastTime doesn't exist, use end of stepRange.
688688
ftime = grb['stepRange'] # computed key, uses stepUnits
689+
if grb.has_key('stepUnits') and grb.stepUnits in _ftimedict:
690+
grb.fcstimeunits = _ftimedict[grb.stepUnits]
689691
# if it's a range, use the end of the range to define validDate
690692
try:
691693
ftime = float(ftime.split('-')[1])
@@ -869,16 +871,16 @@ cdef class gribmessage(object):
869871
inventory.append(levstring)
870872
elif self.valid_key('level'):
871873
inventory.append(':level %s' % self['level'])
872-
if self.valid_key('stepRange'):
874+
if self.valid_key('forecastTime'):
875+
ftime = repr(self['forecastTime'])
876+
inventory.append(':fcst time %s %s'% (ftime,self.fcstimeunits))
877+
elif self.valid_key('stepRange'):
873878
ftime = self['stepRange'] # computed key, uses stepUnits
874879
if self.valid_key('stepType') and self['stepType'] != 'instant':
875880
inventory.append(':fcst time %s %s (%s)'%\
876881
(ftime,self.fcstimeunits,self.stepType))
877882
else:
878883
inventory.append(':fcst time %s %s'% (ftime,self.fcstimeunits))
879-
elif self.valid_key('forecastTime'):
880-
ftime = repr(self['forecastTime'])
881-
inventory.append(':fcst time %s %s'% (ftime,self.fcstimeunits))
882884
if self.valid_key('dataDate') and self.valid_key('dataTime'):
883885
inventory.append(
884886
':from '+repr(self['dataDate'])+'%04i' % self['dataTime'])

0 commit comments

Comments
 (0)