Skip to content

Commit

Permalink
fix for issue #241
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed Apr 22, 2024
1 parent 00c8892 commit 781d8f5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/pygrib/_pygrib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ def setdates(gribmessage grb):
elif grb.has_key('stepRange'):
# if forecastTime doesn't exist, use end of stepRange.
ftime = grb['stepRange'] # computed key, uses stepUnits
if grb.has_key('stepUnits') and grb.stepUnits in _ftimedict:
grb.fcstimeunits = _ftimedict[grb.stepUnits]
# if it's a range, use the end of the range to define validDate
try:
ftime = float(ftime.split('-')[1])
Expand Down Expand Up @@ -869,16 +871,16 @@ cdef class gribmessage(object):
inventory.append(levstring)
elif self.valid_key('level'):
inventory.append(':level %s' % self['level'])
if self.valid_key('stepRange'):
if self.valid_key('forecastTime'):
ftime = repr(self['forecastTime'])
inventory.append(':fcst time %s %s'% (ftime,self.fcstimeunits))
elif self.valid_key('stepRange'):
ftime = self['stepRange'] # computed key, uses stepUnits
if self.valid_key('stepType') and self['stepType'] != 'instant':
inventory.append(':fcst time %s %s (%s)'%\
(ftime,self.fcstimeunits,self.stepType))
else:
inventory.append(':fcst time %s %s'% (ftime,self.fcstimeunits))
elif self.valid_key('forecastTime'):
ftime = repr(self['forecastTime'])
inventory.append(':fcst time %s %s'% (ftime,self.fcstimeunits))
if self.valid_key('dataDate') and self.valid_key('dataTime'):
inventory.append(
':from '+repr(self['dataDate'])+'%04i' % self['dataTime'])
Expand Down

0 comments on commit 781d8f5

Please sign in to comment.