Skip to content

Commit

Permalink
Added UTC time value to tidal data
Browse files Browse the repository at this point in the history
  • Loading branch information
hyakuhei committed Apr 27, 2015
1 parent 31ccd7f commit 0aaf05d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions TideForecastScraper.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def scrapeTideForecast(self,locations,bestguess=None):
'height' : float(elements[3]),
'date' : time.strftime("%d-%m-%Y", ydelta),
'time' : time.strftime("%H:%M", ydelta),
'utc' : int(elements[2])+int(elements[1]),
}
data.append(ld)

Expand Down Expand Up @@ -101,14 +102,14 @@ def getTides(self,wholedataset,datestr):
if dataset[i]['height'] > dataset[i-1]['height']:
#logger.debug("{} {:.1f}m - Low tide".format(dataset[i-1]['time'],dataset[i-1]['height']))
heightPretty = "{:.1f}m".format(dataset[i-1]['height'])
tides.append({'time':dataset[i-1]['time'], 'height':dataset[i-1]['height'], 'type':'Low', 'heightPretty':heightPretty})
tides.append({'time':dataset[i-1]['time'], 'height':dataset[i-1]['height'], 'type':'Low', 'heightPretty':heightPretty, 'utc':dataset[i-1]['utc']})
state = 'rising'

if state == 'rising':
if dataset[i]['height'] < dataset[i-1]['height']:
#logger.debug("{} {:.1f}m - High tide".format(dataset[i-1]['time'],dataset[i-1]['height']))
heightPretty = "{:.1f}m".format(dataset[i-1]['height'])
tides.append({'time':dataset[i-1]['time'], 'height':dataset[i-1]['height'], 'type':'High', 'heightPretty':heightPretty})
tides.append({'time':dataset[i-1]['time'], 'height':dataset[i-1]['height'], 'type':'High', 'heightPretty':heightPretty, 'utc':dataset[i-1]['utc']})
state = 'dropping'

if dataset[i]['height'] == dataset[i-1]['height']:
Expand Down
3 changes: 2 additions & 1 deletion WaveAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ def conditions():

try:
logger.debug("Got conditions {}".format(json.dumps(localConditions,sort_keys=True,indent=4,separators=(',',': '))))
except:
except Exception as e:
logger.debug("Unable to identify weather for location {},{}".format(request.args['lat'],request.args['lon']))
logger.debug(e.message)
abort(500)

return json.dumps(localConditions,encoding='ascii')
Expand Down

0 comments on commit 0aaf05d

Please sign in to comment.