pyet-org / pyet

:sunflower: pyet is a Python package to estimate reference and potential evaporation.
https://pyet.readthedocs.io/
MIT License
130 stars 33 forks source link

pyet.calc_rad_net attribute error with pandas.series #55

Open madapegue opened 11 months ago

madapegue commented 11 months ago

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 commented 11 months ago

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

Cheers, Raoul

madapegue commented 10 months ago

Sure, here it is!

test_data.txt

madapegue commented 9 months ago

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 commented 9 months ago

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