Run AquaCrop-OSPy spatial over a basin

Dear All,
I would like to run AquaCrop spatially over a basin.
I have the max, min Temprature as well as ETo data in netcdf files.
I need help to do that.

Thank you

1 Like

Hi Agotossou,

This is indeed an itneresting us-case and I have thought about this as well. Sadly though, AquaCrop is not made to be used in a grid and I think it would be rather slow to do so, since the algorithms are not optimized, whereas normally they are (in erosion models for example).

You could maybe run a simulation for a representative location and derive results from that…

Anyways, for extracting and handling data from netCDF files, you can use the Xarray package:

Import xarray as xr

data = xr.open_dataset("")

Then, I would wrap the entire AquaCrop model in a function, and use the (apply_ufunc)[] on your Dataset. edit: this won’t work, I think you’ll have to use a double for loop

However, I do really think this should be supported and maybe could put some work in it.

You will also need some soil data. SoilGrids (by ISRIC) is OK if you don’t have actual measurements.

Hi @agotossou

As @joeperdefloep said, For each location you would have to create an AquaCropModel with that location’s weather time series, crop, soil etc. Then run that simulation and save the output. You can run simulations in parallell to make this faster but the model must be recreated and run inside that function you want to parallellize.

I have used this method to run simulations across a river segment for example. There are a few new tutorial notebooks i need to finish and this is one of the use cases.


Dear joeperdefloep,
I thank you for your comments.
I am a beginner in Python, so it is a bit unclear for me to do the exercise until the end, I mean running AquaCrop over a basin.
I also thought about the SoilGrid data which I am trying also to convert into soil hydraulic data using Rosetta pedotransfer function.
Maybe I need to get in touch with you via email or skype if you are available.

Dear Tom,
That notebook will be helpful for me if I have access to it.


Hey Tom,

Can’t we somehow work around the same method that was suggested in AquaCropOS (Matlab version) manual? That worked fine for me in one of my upcoming papers. One good thing about AquaCrop-OSPy is that it seems to be running faster than Matlab version for multiple years simulations, which is a great thing!

Hello Ali_Aj,
I am interested in what you are suggesting.
Can we work on this together?
Currently, I am trying this in the Matlab version.

Hi Agossou,

Thanks for your message. I will send you a DM to discuss this further.

I hope @tom publishes the tutorial for spatial application of the AC-Python model soon.



Hello agotossou:
Did you succeed?
My idea is to input a number of different weather files in grid units, output them as values, and then interpolate them. Do you think this is feasible?
Or do you have any new developments?

Thank you,have a nice day!

1 Like