buoypy icon indicating copy to clipboard operation
buoypy copied to clipboard

AttributeError: 'historic_data' object has no attribute 'year_range'

Open surya10t opened this issue 5 years ago • 5 comments

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

image

Thanks, Surya

surya10t avatar Mar 07 '19 16:03 surya10t

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.

nickc1 avatar Sep 11 '20 01:09 nickc1

Hello, I really wonder if anyone has solved this issue, please.

Alqushaibi avatar Jan 05 '21 10:01 Alqushaibi

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')

41108_waveheight

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/

nickc1 avatar Jan 07 '21 13:01 nickc1

Integrated this into seebuoy. You can see an example here:

https://www.seebuoy.com/ndbc/#historical-data

nickc1 avatar Jan 17 '21 12:01 nickc1

Thank you so much @nickc1. Really appreciate your kind response and contribution.

Alqushaibi avatar Jan 18 '21 19:01 Alqushaibi