Python package to interact with Sofar wave data
Project description
Sofar Ocean API Python Client
Python toolbox to interact with Sofar Ocean Spotter API.
Requirements
- Python3
- pysofar
- numpy
- Pytest (If developing/Contributing)
- Setuptools (If developing/Contributing)
Installation
- Make sure that you have the requirements listed above
pip install roguewave
to your desired python environment- Test with
python3 -c 'import roguewave'
. If this runs successfully, chances are everything worked.
Examples
Retrieve Spectrum from API
from roguewave import get_spectrum_from_sofar_spotter_api
from pysofar.spotter import Spotter
from datetime import datetime, timezone
# The Spotter we want the data from
spotter_id = 'SPOT-0740'
# Start time to grab
start_date = datetime(2021,1,1,0,0,0,tzinfo=timezone.utc)
# End time
end_date = datetime(2021,1,6,0,0,0,tzinfo=timezone.utc)
# You will need a valid access token setup for the pysofar library for this to
# work. We refer to the pysofar documentation how to set that up.
spotter = Spotter(spotter_id,spotter_id)
# Get the spectra
spectra = get_spectrum_from_sofar_spotter_api(spotter,start_date,end_date,limit=10)
# We now have spectra from the spotter we can interact with
for spectrum in spectra:
string = f'The waveheight at {spectrum.timestamp} was {spectrum.hm0()} meter'
print(string)
# or do a simple plot
plt.plot(spectra[0].frequency, spectra[0].variance_density,'k')
plt.xlabel('Frequency (hz)')
plt.ylabel('Variance Density (m$^2$/s)')
plt.yscale('log')
plt.title(f'spectrum for {spotter_id} at time {spectra[0].timestamp}')
plt.grid()
plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
roguewave-0.1.2.tar.gz
(11.7 kB
view hashes)
Built Distribution
roguewave-0.1.2-py3-none-any.whl
(13.7 kB
view hashes)
Close
Hashes for roguewave-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78c573f7aa0bda6834776533a07d02efdec0e4e153eb6ab624938191d7e9cc65 |
|
MD5 | 07f2f87a2646238c545723c4d4b2f981 |
|
BLAKE2b-256 | 5255316a6a2ad876c2199aca887f228bc92e7a22f34a6556797bb81560d2e46b |