buoypy
buoypy copied to clipboard
AttributeError: 'historic_data' object has no attribute 'year_range'
Hello Nick,
I'm using your library to extract historic 'standard meteorological data' from multiple stations from all the available years. However, the "get_all_stand_meteo" function is giving the error "AttributeError: 'historic_data' object has no attribute 'year_range'". I tried executing the same code from your script "buoy_data_analysis.ipynb" and it returned the same error. Please see below snapshot.
FYI, I'm using Python 3.6.5
Thanks, Surya
Hi Surya,
It's been over a year, so hopefully you were able to work to a solution, but I never assigned year_range as an attribute on the class. I don't have time to update the repository (as you might have guessed :) ), but I am happy to point you in the right direction or merge pull requests.
Hello, I really wonder if anyone has solved this issue, please.
Hello @surya10t and @Alqushaibi,
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
Thank you so much @nickc1. Really appreciate your kind response and contribution.