toddkarin / vocmax

Calculate the maximum string length for a photovoltaic system
Other
10 stars 5 forks source link

KeyError: "year" #11

Open Liamnorris25 opened 1 year ago

Liamnorris25 commented 1 year ago

I am recieving an error importing the weather data stating their is a keyerror: "year". Has the column "year" been renamed? Is there something else I am missing? See my error below

Importing weather data... cached_weather_data*35.049-118.250.npz Downloading weather data and saving to "cached_weather_data" ... 0%| | 0/21 [00:00<?, ?it/s]C:\Users\LiamNorris\anaconda3\Lib\site-packages\pvlib\iotools\psm3.py:360: pvlibDeprecationWarning: PSM3 variable names will be renamed to pvlib conventions by default starting in pvlib 0.11.0. Specify map_variables=True to enable that behavior now, or specify map_variables=False to hide this warning. 'PSM3 variable names will be renamed to pvlib conventions by ' 0%| | 0/21 [00:06<?, ?it/s] Traceback (most recent call last):

File ~\anaconda3\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec exec(code, globals, locals)

File c:\users\liamnorris\string_sizing.py:91 weather, info = vocmax.get_weather_data(Site_Data['lat'], Site_Data['lon'], api_key=api_key)

File ~\anaconda3\Lib\site-packages\vocmax\main.py:279 in get_weather_data

KeyError: 'year'

BenFirstIntern commented 9 months ago

Hello Liamnorris25, I believe I have the answer to your issue.

If you are referring to the get_weather_data function, there is a small error in the source code that needs to be fixed. If you have git cloned the vocmax repo, you should be able to right click in your script where you have vocmax.get_weather_data(lat,lon,api_key) and select "Go to definition". This will open up the vocmax main.py script where the error is. In vocmax main.py, get_weather_data is defined on line 107. The error is in the function definition on line 233, that should be:

    info_iter, df_iter = get_psm3(
        latitude=lat,
        longitude=lon,
        api_key=api_key,
        email=email,
        names=year,
        interval=30,
        leap_day=False,
        full_name=full_name,
        affiliation=affiliation,
        timeout=30)

The change is very simple. All you must do is flip info_iter and df_iter like so:

    df_iter, info_iter = get_psm3(
        latitude=lat,
        longitude=lon,
        api_key=api_key,
        email=email,
        names=year,
        interval=30,
        leap_day=False,
        full_name=full_name,
        affiliation=affiliation,
        timeout=30)

info_iter is a dictionary for the backend steps, and df_iter is the data frame you are downloading. The variable are just swapped in the source code, but flipping them should fix your issue.

I hope this helps!