GithubHelp home page GithubHelp logo

pyet-org / pyet Goto Github PK

View Code? Open in Web Editor NEW
104.0 3.0 27.0 140.99 MB

:sunflower: pyet is a Python package to estimate reference and potential evaporation.

Home Page: https://pyet.readthedocs.io/

License: MIT License

Python 100.00%
hydrological-modelling hydrology water

pyet's People

Contributors

ainurkoki avatar codacy-badger avatar martinvonk avatar mvremec avatar raoulcollenteur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pyet's Issues

Pypi Version 3.2

Seems a bit optimistic ;-) What about 1.0? or 0.1?

Remove that version manually from Pypi index?

The radiation input provided is greater than 100 MJ/m2d, which is not realistic. Please convert the radiation input to MJ/m2d

To whom it may concern:

I've tried to invoke the pyet package to calculate ET0. I downloaded the pyet package from this github account. I tested the ZAMG exsample data (https://pyet.readthedocs.io/en/latest/examples/01_example_zamg.ipynb.html).

Unfortunately I got an error with message of "The radiation input provided is greater than 100 MJ/m2d, which is not realistic. Please convert the radiation input to MJ/m2d". The radiation is correct and less than 100 MJ/m2d. Please see my screenshot. Any suggestions will be welcome.
question1.pptx

Thanks,

Zewei

[BUG] daylight_hours return nans for high latitudes

pyet.daylight_hours returns NaNs for high latitudes (e.g., Sweden) in winter, this should returns zero (hours of daylight) I think.

To reproduce:

pyet.daylight_hours(df.index, 70*(np.pi/180)). # where df.index is somewhere in January

Excluding areas above/below certain latitude

For 'simple' methods like Hamon, the resulting PET estimates can exclude areas above and below a certain latitude (i.e. returns NaNs), even though the input data ranges between -90 and 90.

The area excluded changes depending on the date of the input data.

So probably that has to do with sunlight hours derived from latitude at a given date? Not per se wrong, but maybe good to either return 0 instead of NaNs (if that makes sense) or throw a warning so the user knows why this happens.

Also, probably good to specify this behaviour in the documentation somewhere.

Speeding up calculations

On my Mac with 16GB RAM and M1 chip, processing roughly half a year of daily at 0.1 degree resolution and global scale** took me 30+ min*** for the Oudin method, accoring to % time in jupyter notebook. It used around 50 % of my CPU and 20 % of my memory, according to htop.

For methods requiring more input data, the processing time will likely increase.

Maybe worthwile looking into ways to speed up the calculations, such as numba, if that's compatible with xarray?

** so yes, using gridded data. And admittedly, it also contained the ocean surface. In total, 1800*3600 cells had to be processed per time step.

*** I stopped it then.

Drop unnecessary dependencies

I think the following dependencies can be removed:

  • Matplotlib
  • Scipy

Only the following are necessary:

  • Numpy
  • XArray
  • Pandas

Add coverage

We should add coverage to this repo. After running the tests on GitHub Actions send it to Codacy:

https://docs.codacy.com/coverage-reporter/

  • Add sending coverage to Codacy
  • Add badge to the README.MD with coverage.

This way we can much more easily see what % of the code is being tested.

pyet.calc_rad_net attribute error with pandas.series

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!

Hargreaves method is not calculating for some days in winter

Dear

I have tried the Hargreaves method to calculate the PET in some places in Chile, but in winter days (June, July and August) it gives me missing values and the following message:

"RuntimeWarning: invalid value encountered in sqrt result_data = func(*input_data)"

I have tried the "clip_zero" option and manually change negative values. However there is no change. With Oudin's method I don't have this problem.

What could be the problem?

Thanks for your time

fix ReadTheDocs issues

Some things need to be improved in the Docs:

  • PDFlatex cannot be built, simply do not built it.
  • Some methods are not in the API docs, see e.g., Haude
  • Add Github link to Docs right-top corner
  • .. something else?

Unrealistic negative/positive values for the Turch equation at sub-freezing temperatures

The Turc equation generates unrealistic results when the mean daily temperature falls below 0 degrees Celsius. The lower the temperature, the more unrealistic the results become. Although I was not able to find any literature indicating that the Turc equation should not be used in subfreezing temperatures, I plan to set PET equal to 0 when the mean temperature is less than 0 degrees Celsius.

PET = 0, if tmean < 0.

Many thanks to Jannis for this heads-up!

pm_fao56 error

i got some errors using the pm_fao56 method
Traceback (most recent call last):
File "FAO/Evapotranspiration.py", line 239, in
s = pm_fao56(tmean=16,wind=5,rn = 2.3,tmax=16,tmin=16,rh=81,elevation=2,pressure=101.6,clip_zero=False)
File "C:\Users\wardi\AppData\Local\Programs\Python\Python37\lib\site-packages\pyet\combination.py", line 484, in pm_fao56
return pet.rename("PM_FAO_56")
AttributeError: 'numpy.float64' object has no attribute 'rename'

Traceback (most recent call last):
File "FAO/Evapotranspiration.py", line 239, in
s = pm_fao56(tmean=16,wind=5,rn = 2.3,tmax=16,tmin=16,rh=81,elevation=2,pressure=101.6,clip_zero=True)
File "C:\Users\wardi\AppData\Local\Programs\Python\Python37\lib\site-packages\pyet\combination.py", line 483, in pm_fao56
pet = clip_zeros(pet, clip_zero)
File "C:\Users\wardi\AppData\Local\Programs\Python\Python37\lib\site-packages\pyet\utils.py", line 81, in clip_zeros
return s.where((s > 0) | (s.isnull()), 0)
AttributeError: 'numpy.float64' object has no attribute 'where'

pm-fao56 method does not work for my Xarray.dataArray data

Hi there!
I am trying to use the pm-fao-56 method in pyet for gridded Xarray.dataArray data (CMIP6 climate data from a climate model). However, I get two Attribute errors every time, namely; 'DataArray' object has no attribute 'index' and 'DataArray' object has no attribute 'time'. The pandas.DatetimeIndex with which the date is retrieved does not seem to work for my dataArrays.

I have not yet discovered how to solve this and looking at the Xarray.dataArray example 2: 'Estimate PET for gridded data' (https://github.com/pyet-org/pyet/blob/master/examples/00_example_paper.ipynb) does not shed more light on the situation. I would be very grateful if someone could help me a bit further!

Have a good day!

methods don't work with Pandas DataFrame

I think the methods are not tested for pandas.DataFrame, and actually don't work for this data yet. Running the following code with dataframes gives an error:

et = pyet.hargreaves(tmean, tmax, tmin, lat=lat)

TypeError: 'str' object is not callable

I think caused by this line:

--> 192 return pe.rename("Hargreaves")

"Haude" method error in calculate_all

Hi,
When running calculate_all I am getting the error:

Edf=pyet.calculate_all(tmean=edf["tmean"],wind=edf["Speed"],rs=edf["Radiation"],elevation=ELEV,lat=RLAT,tmax=edf["MaxT"],tmin=edf["MinT"],rhmax=edf["maxRH"],rhmin=edf["MinRH"])

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pyet\combination.py:867 in calculate_all
pe_df["Haude"] = haude(tmax, rh)

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pyet\temperature.py:140 in haude
ea = check_rh(rh) * e0 / 100

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pandas\core\ops\common.py:72 in new_method
return method(self, other)

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pandas\core\arraylike.py:122 in rmul
return self._arith_method(other, roperator.rmul)

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pandas\core\series.py:6259 in _arith_method
return base.IndexOpsMixin._arith_method(self, other, op)

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pandas\core\base.py:1325 in _arith_method
result = ops.arithmetic_op(lvalues, rvalues, op)

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pandas\core\ops\array_ops.py:226 in arithmetic_op
res_values = _na_arithmetic_op(left, right, op) # type: ignore[arg-type]

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pandas\core\ops\array_ops.py:165 in _na_arithmetic_op
result = func(left, right)

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pandas\core\computation\expressions.py:241 in evaluate
return _evaluate(op, op_str, a, b) # type: ignore[misc]

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pandas\core\computation\expressions.py:70 in _evaluate_standard
return op(a, b)

File ~\AppData\Local\miniconda3\envs\geocube\lib\site-packages\pandas\core\roperator.py:19 in rmul
return right * left

TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'

I am running this in miniconda with pandas 1.5.3 and python 3.10

It works running the pm_fao56()

To do list:

Add additional methods:

  • add Thornthwaite method
  • add ASCE_2000 method

Extend to enable 2D and data input:

  • Numpy Arrays
  • XArray
  • NetCDF

Extend to enable different temporal resolution:

  • hourly
  • monthly
  • yearly
  • half-hourly,15min, 10min

A bug in turc

The origin code for calculate evaporation according to [turc_1961]_ is as follow:
c = tmean / tmean
c[rh] = 1 - (50 - rh) / 70
et = k * c * tmean / (tmean + 15) * (rs + 2.094)
return et
However, there is a bug in c[rh] = 1 - (50 - rh) / 70. The correct code perhaps is c[rh < 50] = 1 - (50 - rh) / 70 according to [turc_1961] based on Eq 3.

Pypi not updating with GitHub Actions

What happened

After I used pip to install pyet, I tried to run the example in https://github.com/phydrus/pyet/blob/master/examples/02_example_coagmet.ipynb

However, I got an unexpected result:

image

But when I downloaded the pyet manually, put them in my directory (I put them in a directory named "src", and import src.pyet as pyet), and run the same code. It worked.

image

I am not sure if it only happened in my own environment.

My python environment:

matplotlib                3.3.2                         0    conda-forge
numpy                     1.20.1           py37h93e21f0_0  
pandas                    1.2.4            py37h2531618_0  
python                    3.7.9           hffdb5ce_0_cpython    conda-forge

Add tests

This is a really great project! Would it be possible to include reference values for each approach, just to test that the representation here behaves as intended in the original publications? I am sure that this was tested behind the scenes when developing the code, but it would be good to include these tests more explicitly, also as examples for the correct units to use.

Calculating Incoming solar radiation - Error in function ?

Discussed in #13

Originally posted by manlaya September 15, 2021
Hello everyone,

I was trying to compute ET with this module and synop data in France and comparing methods (Turc, Hargreaves, Penman-Monteith, FAO56).
When computing Incoming solar radiation with calc_rad_sol_in() I had some differences with the code I used before to do such calculations.

Looking at the code, I saw that the equation used is :
(as1 + bs1 * n / nn) * ra

  • with n as duration of sunshine ;
  • and nn as maximum possible duration of sunshine

In this calc_rad_sol_in() function, n is optionnal and calculate with daylight_hours() when None, using day_of_the_year, sunset_angle, etc.

Actually, aren't n and nn variables inverted here ?

I mean, not in n/nn term but what is compute by daylight_hours() should be nn variable to correspond to eq 34 and 35 given by Allen et al. (1998). n should then be sunshine duration measured.

Not quite sure if it's an issue or if I am missing something in my use of this module, so I am posting this question here...

Thanks in advance for your answers.

Kind regards,
Adrien

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.