Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyet.calc_rad_net attribute error with pandas.series #55

Open
madapegue opened this issue Dec 5, 2023 · 4 comments
Open

pyet.calc_rad_net attribute error with pandas.series #55

madapegue opened this issue Dec 5, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@madapegue
Copy link

Hi,

I am trying to calculate the net radiation using as testing the dataset from example_4. When using only 'Tmean' as input I am getting the following attribute error :

test = pyet.calc_rad_net(meteo['tmean'])


AttributeError Traceback (most recent call last)
~\Anaconda3\envs\pyet\lib\site-packages\pyet\utils.py in get_index(df)
90 try:
---> 91 index = pandas.DatetimeIndex(df.index)
92 except AttributeError:

AttributeError: 'NoneType' object has no attribute 'index'

During handling of the above exception, another exception occurred:

AttributeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_4808\2874759589.py in
----> 1 test = pyet.calc_rad_net(meteo['tmean'])

~\Anaconda3\envs\pyet\lib\site-packages\pyet\rad_utils.py in calc_rad_net(tmean, rn, rs, lat, n, nn, tmax, tmin, rhmax, rhmin, rh, elevation, rso, a, b, ea, albedo, as1, bs1, kab)
85 else:
86 if rs is None:
---> 87 rs = calc_rad_sol_in(n, lat, as1=as1, bs1=bs1, nn=nn)
88 rns = calc_rad_short(rs=rs, lat=lat, n=n, nn=nn, albedo=albedo,
89 as1=as1, bs1=bs1) # [MJ/m2/d]

~\Anaconda3\envs\pyet\lib\site-packages\pyet\rad_utils.py in calc_rad_sol_in(n, lat, as1, bs1, nn)
231
232 """
--> 233 tindex = get_index(n)
234 ra = extraterrestrial_r(tindex, lat)
235 if nn is None:

~\Anaconda3\envs\pyet\lib\site-packages\pyet\utils.py in get_index(df)
91 index = pandas.DatetimeIndex(df.index)
92 except AttributeError:
---> 93 index = pandas.DatetimeIndex(df.time)
94 return index

AttributeError: 'NoneType' object has no attribute 'time'

Do you know what could be the issue? The Pandas series indeed has a Datetimeindex, so not sure what is the problem here.

Thanks!

@raoulcollenteur
Copy link
Member

Hi @madapegue ! Thanks for trying out Pyet. Can you share a CSV file of the data so I can check?

Cheers,
Raoul

@raoulcollenteur raoulcollenteur self-assigned this Dec 6, 2023
@raoulcollenteur raoulcollenteur added the bug Something isn't working label Dec 6, 2023
@raoulcollenteur raoulcollenteur added this to the 1.3: PyEt Reloaded milestone Dec 6, 2023
@madapegue
Copy link
Author

Sure, here it is!

test_data.txt

@madapegue
Copy link
Author

Hi @raoulcollenteur ,

Is there any workaround you could suggest to temporarily solve this issue to calculate pm_fao56 with only tmax, tmin, wind, and rh data?

Any advice will be appreciated. Thanks!

@mvremec mvremec closed this as completed Feb 2, 2024
@mvremec
Copy link
Contributor

mvremec commented Feb 2, 2024

Dear madapegue,

To compute net radiation, if you do not have data on solar radiation, then you need to have at least data on latitude (lat) or the actual duration of sunshine (n). (This information we need to add to the documentation or specified as requirements for each method.)

Check the FAO56 guidelines on how to compute missing radiation data: equation 49 or 50.

You can compute extraterrestrial radiation with PyEt:
tindex = meteo.index
Ra = extraterrestrial_r(tindex, lat)

Hope this helps!

Best,
Matevz

@mvremec mvremec reopened this Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants