buoypy
buoypy copied to clipboard
Issue with the get_all_stand_meteo()
Hi Nick, thanks for writing this library. It's is very useful. However, I'm having trouble getting the data in a range.
below is the error.
Thank you so much and again, it is a very nice library.
"...\buoy.py", line 528, in get_all_stand_meteo start,stop = self.year_range
AttributeError: 'historic_data' object has no attribute 'year_range'
Hey fredbeach,
Thanks for checking out buoypy. Glad you have found it helpful.
It looks like I never assigned year_range
as an attribute on the class. I won't have time to update this repository myself, but happy to point you in the right direction to get things working.
Hello @fredbeach,
I have started working on a new project, seebuoy.
docs: https://www.seebuoy.com/
repo: https://github.com/nickc1/seebuoy
install: pip install seebuoy
It's still a little rough around the edges, but should be able to get the data you need. For example to get all available standard meteo data, you can run:
import pandas as pd
from seebuoy import ndbc
buoy = 41108
dataset = "stdmet"
# get years that have data
def available_years(buoy, dataset):
df = ndbc.available_datasets(buoy)
mask = df["dataset"] == dataset
years = df.loc[mask, "year"].unique()
return years
years = available_years(buoy, dataset)
# loop through each year
df_buoy = []
for year in years:
print(year)
df_buoy.append(ndbc.historic(buoy, year, dataset))
# combine each year into single dataframe
df = pd.concat(df_buoy)
# plot
fig, ax = plt.subplots(figsize=(12,5))
df["wvht"].plot(ax=ax)
df["wvht"].resample("w").mean().plot(ax=ax)
ax.set_ylim(0, 10)
ax.set_xlabel('')
ax.set_ylabel('Wave Height')
I'll keep a closer eye on this thread, so feel free to reach out with issues. Thanks!
P.S. The missing data above is due to most likely to the buoy being off. You can verify the first gap here: https://www.ndbc.noaa.gov/view_text_file.php?filename=41108h2014.txt.gz&dir=data/historical/stdmet/
Integrated this into seebuoy. You can see an example here:
https://www.seebuoy.com/ndbc/#historical-data