Giter VIP home page Giter VIP logo

surfpy's Introduction

surfpy

Wave and weather tools written in python.

This package aims to create a suite of tools than can be used to generate and create surf forecasts. It aims to give a developer the ability to build their own customize wave and weather forecasts and applications based off only NOAA data available for free. It does not interface third party APIs, as they dont give the same depth of information needed to craft fully customized and free forecasts.

Running the Tests

python3 -m unittest

Examples

See the examples directory for usage

License

This project is MIT Licensed

surfpy's People

Contributors

davjr96 avatar mjmayank avatar mpiannucci avatar vpereira avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

surfpy's Issues

Example script

Thank you for this interesting project.

Where would I find the data needed to customize these lines to a different break/beach:

ri_wave_location = surfpy.Location(41.4, -71.45, altitude=30.0, name='Block Island Sound')
ri_wave_location.depth = 30.0
ri_wave_location.angle = 145.0
ri_wave_location.slope = 0.02

Depth, angle, and slope have me stumped.

Surfline API

@coopersamuel @rschenk Thanks a lot for the awesome project.

I wanted to point you to my app https://github.com/fabriziobertoglio1987/surf-rails which includes all surfspots in the world, but surf forecast are not built so well...
You can consume them with my api.

I read your messages from https://www.reddit.com/r/surfing/comments/a3rh3n/for_those_of_you_who_like_to_play_with_buoy_data/

It’s pretty simple. The buoys expose the raw energy spectra so you take the energy spectra and split it and solve for wave height as a function of frequency and power. I can link to the exact math I use to do it if you want

I'll prob write a blog post this weekend about it from a high level

But if you understand code heres a simple breakdown.. look here for parsing

def parse_wave_spectra_reading_data(self, energy_data, directional_data, count_limit):

and here for math

def swell_components(self):

From the rest of the discussion I find out about the magicseaweek-cli which allows you to scrape msw.... Probably that the best solution once you have all the surfspots information from my api... I will probably give up on calculating surf forecast and just retrieve them via api from MSW.

But I am not sure if all the information from my backend are available while scraping the api, for example degrees direction of swell and wind, as you can check in my mobile app I use them to display and arrow with the wind.. Additionally I calculate for almost 90% of the spots the optimal wind/swell direction .. and many other things that by scraping MSW would not be possible (like calculating long term surf forecast in the future using AI)

Edit: https://github.com/rschenk/surfdash/tree/master/lib the two files you're interested in are new_surfline_scraper.rb and surfline_county_scraper.rb

Ya! So it's kind of a pain in the butt to figure out because surfline's api is a mess. I think that they recently updated their id system, because each spot has two ids (a four digit one, that I think is legacy, and a longer one (looks like 12 bytes) this is the one you want)

Basically, what I do is find a spot id with a searchterm (ie "hanalei") from here https://services.surfline.com/search/site?q=hanalei&querySize=10&suggestionSize=10 then use that spot id (you'll have to dig it out of the response) to get the forecast for that spot. There is an overall forecast endpoint that gives you wind, swell and conditions for 17 days out. However, I find that one more difficult to use b/c it requires the legacy spot ID, go for the individual forecast endpoints instead, described below.

There are individual endpoints for wind (https://services.surfline.com/kbyg/spots/forecasts/wind?spotId=5842041f4e65fad6a7708b2c&days=1), swell (https://services.surfline.com/kbyg/spots/forecasts/wave?spotId=5842041f4e65fad6a7708b2c&days=1) and conditions (https://services.surfline.com/kbyg/spots/forecasts/conditions?spotId=5842041f4e65fad6a7708b2c&days=1) that you can use with that spot id. You'll have to decipher the response, IIRC, each of these three has a different structure but the same idea. The swell forecast has a min and max for every two hours all the way up to 17 days out(specify the number of days you want), wind has a value for every hour, and I think conditions is once or twice a day. Hope this helps! Go ahead and plug all of the reqs into postman, they should work.

Edit: You can also take a look at the network tab in the dev tools on the Surfline site to see what requests it's making - IIRC it does the above, makes a request to all three apis.

Edit 2: Also, if you want to contribute to my (unfortunately unfinished) project, here's the repo: https://github.com/coopersamuel/seaweed-cli

For the surfforecast I pull data from stormglass.io but I am not very accurate. stormglass.io does not provide long term surf forecasts. I wonder if Machine Learning models are used to calculate the long term forecasts...

I decided to post this here and unify our efforts as surfforecasting is very complex field... maybe we could build a bunch of apis and make a unified repository/documentation for it ...

or any other ideas, I'm willing to work weekend on them...

other interesting repositories
https://github.com/rschenk/surfdash
https://github.com/coopersamuel/seaweed-cli

Thanks a lot
Fabrizio Bertoglio
https://fabriziobertoglio.xyz

Hawaii GFS Wave Model

Thank you for making this awesome library! I was looking through the examples and I wanted to take a crack at supporting Hawaii.

What other modifications would be needed aside from adding a new function as shown in wavemodel.py:

def us_west_coast_gfs_wave_model():
    return WaveModel(
        name='gfswave',
        subset='wcoast.0p16',
        description='GFS Wave Model: US West Coast 0.16 degree',
        bottom_left=Location(25.00, 210.00),
        top_right=Location(50.00005, 250.00008),
        location_resolution=0.167,
        time_resolution=0.125,
        max_index=384,
        hourly_cutoff_index=0
    )

If you have any pointers in the right direction that would be awesome. I am hoping to build a small forecasting app with FastAPI so hopefully there's ways I can help the project.

Thank you,
James

Go -> Python?

Hi.
I just read the README at surfnerd, which explains why everything is in Go rather then Python, Surfnerd appears to be deprecated with a notice to use this project instead, but this project is Python. I'm trying to understand why the reversal of decision?
Thanks.

fetch_forecast fails silently

Looking into the examples, I'm having a tough time getting fetch_forecast.py running successfully.

My environment:

Python 3.11.3
requests==2.31.0
urllib3==2.0.3
matplotlib==3.7.2
numpy==1.25.0

Running

$ python3 fetch_forecast.py

Fetching GFS Wave Data
Failed to fetch wave forecast data

Some steps I took to debug:

Cloned the grippy repository and installed in my conda environment.

I came across a warning

Failed to download https://noaa-gfs-bdp-pds.s3.amazonaws.com/gfs.20230713/18/wave/gridded/gfswave.t18z.atlocn.0p16.f000.grib2: Retry.__init__() got an unexpected keyword argument 'method_whitelist'

Which prompted me to upgrade requests and urllib3 to the latest versions and modify tools.py:

# method_whitelist deprecated in favor of allowed_methods
def retry_session(retries=1):
    session = requests.Session()
    retries = Retry(total=retries,
                backoff_factor=0.1,
                status_forcelist=[500, 502, 503, 504],
                allowed_methods=frozenset(['GET', 'POST']))

    session.mount('https://', HTTPAdapter(max_retries=retries))
    session.mount('http://', HTTPAdapter(max_retries=retries))
    return session

What package versions are working for you? I would love to help document and assist with this project where possible.

Thank you for your help.

Add reset method to NOAAModel

Allow resetting the data read in?

Or rethink how data is stored in the model class because it could fetch data for different locations etc..

Switch to PyGrib

For the version 1.0, grib files should be accessed using pygrib instead of grippy for robustness. This allows the ability to create more complex data charts and such.

This also means reworking the NOAAModel class some more to prioritize fetching data using the pygrib interface and packing it into BuoyData structure for forecast delivery but also exposing hooks to download full data chunks and for post processing into plots

Modularize NOAAModel

Currently NOAAModel fetches and parses data into member vars, and maintains internal state with the last data parsed and which mode was used to download the data.

The next version should expose functions to fetch and parse the data, but there should be no internal state tracking so the hooks can be controlled by the user.

Further, any download or dataset creation possible should be moved to the tools namespace

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.