def testTimeZone(self): t = tidetable.get(8517921, time_zone=tidetable.GMT) assert t.time_zone == 'GMT' s = tidetable.get(8517921, time_zone=tidetable.LOCAL_STANDARD_TIME) assert s.time_zone == 'LST' assert t[0]['datetime'] != s[0]['datetime']
def testBeginDate(self): t = tidetable.get(8517921, year=2016) try: assert t[0]['datetime'].year == 2015 assert t[0]['datetime'].month == 12 assert t[0]['datetime'].day == 31 except: print (t.raw)
def testDownloadTable(self): t = tidetable.get(8517921) assert isinstance(t, tidetable.TideTable) assert isinstance(t, list) try: assert isinstance(t.disclaimer, unicode) except NameError: assert isinstance(t.disclaimer, str) io = IO() t.write_csv(io)
if __name__ == "__main__": #set up location in Astral to get sunrise/set a = astral.Astral() a.solar_depression = 'civil' l = astral.Location() l.name = "Shelter Cove" l.region = 'California' l.latitude = 40.0304 l.longitude = -124.0731 l.timezone = 'GMT' l.elevation = 0 #we'll need to convert to pacfic later fromzone = tz.gettz('UTC') tozone = tz.gettz('America/Los_Angeles') #fetch in GMT so we don't have to calculate offsets in a bajillion places tides = tidetable.get(STATION, year=YEAR, time_zone=tidetable.GMT) passable = [ x for x in tides if (x['high_low'] == 'L' and x['pred_ft'] <= LOWMAX) ] print("Found {} passable low tide points".format(passable.__len__())) doable = [x for x in passable if timeokay(x['datetime'], l)] print("Found {} doable low time points".format(doable.__len__())) for m in doable: d = pytz.UTC.localize(m['datetime']).astimezone(tozone) print("Date: {}\nTime: {}\nLow Ft: {}\nMoon: {}\n".format( d.date(), d.time(), m['pred_ft'], l.moon_phase(d.date()))) print("Moon phases: 0:new, 7:first q, 14:full, 21:last q")