Esempio n. 1
0
    def test_serialize_location(self):
        original = surfpy.Location(latitude=41.8,
                                   longitude=-71.4,
                                   name="US Northeast Coast",
                                   altitude=0.0)
        s = surfpy.serialize(original)
        cloned = surfpy.deserialize(s)

        self.assertTrue(original.name == cloned.name)
        self.assertTrue(abs(original.latitude - cloned.latitude) < 0.000001)
        self.assertTrue(abs(original.longitude - cloned.longitude) < 0.000001)
        self.assertTrue(abs(original.altitude - cloned.altitude) < 0.000001)
Esempio n. 2
0
    print('Fetching GFS Wave Data')
    data = block_island_buoy.fetch_wave_forecast_bulletin(atlantic_wave_model)

    print('Fetching local weather data')
    ri_wind_location = surfpy.Location(41.41,
                                       -71.45,
                                       altitude=0.0,
                                       name='Narragansett Pier')
    weather_data = surfpy.WeatherApi.fetch_hourly_forecast(ri_wind_location)
    surfpy.merge_wave_weather_data(data, weather_data)

    print('Solving Breaking Wave Heights')
    for dat in data:
        dat.solve_breaking_wave_heights(ri_wave_location)
        dat.change_units(surfpy.units.Units.english)
    json_data = surfpy.serialize(data)
    with open('forecast.json', 'w') as outfile:
        outfile.write(json_data)

    maxs = [x.maximum_breaking_height for x in data]
    mins = [x.minimum_breaking_height for x in data]
    summary = [x.wave_summary.wave_height for x in data]
    times = [x.date for x in data]

    plt.plot(times, maxs, c='green')
    plt.plot(times, mins, c='blue')
    plt.plot(times, summary, c='red')
    plt.xlabel('Hours')
    plt.ylabel('Breaking Wave Height (ft)')
    plt.grid(True)
    plt.title('GFS Wave Atlantic: ' +