Skip to content

Commit a719e56

Browse files
committed
fix logic in setdates
1 parent b99db98 commit a719e56

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

src/pygrib/_pygrib.pyx

+11-15
Original file line numberDiff line numberDiff line change
@@ -688,21 +688,17 @@ def setdates(gribmessage grb):
688688
grb.indicatorOfUnitOfTimeRange in _ftimedict:
689689
grb.fcstimeunits = _ftimedict[grb.indicatorOfUnitOfTimeRange]
690690
if grb.has_key('forecastTime'):
691-
if grb.has_key('forecastTime'):
692-
ftime = grb.forecastTime
693-
elif grb.has_key('stepRange'):
694-
# if forecastTime doesn't exist, use end of stepRange.
695-
ftime = grb['stepRange'] # computed key, uses stepUnits
696-
if grb.has_key('stepUnits') and grb.stepUnits in _ftimedict:
697-
grb.fcstimeunits = _ftimedict[grb.stepUnits]
698-
# if it's a range, use the end of the range to define validDate
699-
try:
700-
ftime = float(ftime.split('-')[1])
701-
except:
702-
ftime = None
703-
else:
704-
ftime = 0
705-
if ftime is None: ftime = 0. # make sure ftime is not None
691+
ftime = grb.forecastTime
692+
elif grb.has_key('stepRange'):
693+
# if forecastTime doesn't exist, use end of stepRange.
694+
ftime = grb['stepRange'] # computed key, uses stepUnits
695+
if grb.has_key('stepUnits') and grb.stepUnits in _ftimedict:
696+
grb.fcstimeunits = _ftimedict[grb.stepUnits]
697+
# if it's a range, use the end of the range to define validDate
698+
try:
699+
ftime = float(ftime.split('-')[1])
700+
except:
701+
ftime = 0.
706702
if grb.has_key('julianDay'):
707703
# don't do anything if datetime fails (because of a miscoded julianDay)
708704
try:

0 commit comments

Comments
 (0)