AquaCrop API

API documentation for AquaCrop.

Types

AquaCrop.NoFileRunType
runtype = NoFileRun()

Indicates the configuration will be loaded manualy via julia variables

source

Methods

AquaCrop.basic_runMethod
outputs = basic_run(; kwargs...)

Runs a basic AquaCrop simulation, the outputs variable has the final dataframes with the results of the simulation

runtype allowed for now is NormalFileRun or TomlFileRun

NormalFileRun will use the input from a files like in AquaCrop Fortran (see AquaCrop.jl/test/testcase)

TomlFileRun will use the input from TOML files (see AquaCrop.jl/test/testcase/TOML_FILES)

You can see the daily result in outputs[:dayout] the result of each harvest in outputs[:harvestsout] the result of the whole season in outputs[:seasonout] the information for the evaluation in outputs[:evaldataout] and the logger information in outputs[:logger]

source
AquaCrop.biomassMethod
biomass = biomass(cropfield::AquaCropField)

Returns the biomass of the cropfield with units ton/ha

source
AquaCrop.canopycoverMethod
canopycover(cropfield::AquaCropField; actual=true)

Returns the canopy cover of the cropfield in percentage of terrain covered.

If actual=true, returns the canopy cover just before harvesting, otherwise returns the canopy cover just after harvesting

The harvesting is done at the end of the day.

source
AquaCrop.change_climate_data!Method
change_climate_data!(cropfield::AquaCropField, climate_data::DataFrame; kwargs...)

Changes the climate data in the cropfield using the data in climate_data.

Note that climate_data must have a column with :Date property, other wise we do not change anything. The function assumes that :Date goes day by day.

climate_data must also have one of the following climate properties [:Tmin, :Tmax, :ETo, :Rain].

source
AquaCrop.dryyieldMethod
dryyield = dryyield(cropfield::AquaCropField)

Returns the dry yield of the cropfield with units ton/ha

source
AquaCrop.freshyieldMethod
freshyield = freshyield(cropfield::AquaCropField)

Returns the fresh yield of the cropfield with units ton/ha

source
AquaCrop.harvest!Method
harvest!(cropfield::AquaCropField)

Indicates to make a harvest on the cropfield it also makes a daily update along with the harvest

source
AquaCrop.save_cropFunction
save_crop(file, cropfield::AquaCropField, head=nothing; kwargs...)

head header to describe the file. Defaults to head = "# Crop saved in "*string(today())

Writes the crop into a toml file. Useful after tunning a crop

source
AquaCrop.season_run!Method
season_run!(cropfield::AquaCropField)

Updates the cropfield for all days in the current season

In case you upload the data using NormalFileRun or TomlFileRun and you indicate multiple seasons, it will only run the first season.

In case you upload the data using NoFileRun it runs the simulation from Simulation_DayNr1 up to Simulation_DayNrN.

source
AquaCrop.start_cropfieldMethod
cropfield, all_ok = start_cropfield(; kwargs...)

Starts the cropfield::AquaCropField with the proper runtype. it uses default values for runtype and parentdir if these kwargs are missing.

It returns a cropfield with default values for crop, soil, etc. After calling this function check if all_ok.logi == true

source
AquaCrop.timetoharvestMethod
th = timetoharvest(cropfield::AquaCropField)

If a crop is not harvestable returns the minimum amount of simulation days until is harvestable.

If a crop is already harvestable returns how many simulations days until crop reaches maturity.

See also isharvestable

source
AquaCrop.write_out_csvMethod
write_out_csv(file, cropfield::AquaCropField, field::Symbol; kwargs...)

Writes the dataframe of cropfield.outputs[field] on file using csv format.

This is a wraper of CSV.write that removes the units, the keywords kwargs are passed to CSV.write.

If the digits keyword argument is provided, it rounds to the specified number of digits after the decimal place, otherwise uses default of digits=4.

source

Additional Functions

AquaCrop.check_kwargsFunction
kwargs, all_ok = check_kwargs(outputs; kwargs...)

Runs all the necessary checks on the kwargs.

After calling this function check if all_ok.logi == true

See also check_runtype, check_parentdir, check_nofilerun

Examples

julia> kwargs, all_ok = AquaCrop.check_kwargs(Dict(:logger => String[]); runtype=TomlFileRun(), parentdir=pwd());

julia> all_ok.logi == true
true
source
AquaCrop.check_runtypeFunction
kwargs, all_ok = check_runtype(outputs; kwargs...)

If we do not have a kwarg for :runtype it sets it to NormalFileRun. If we do have that kwarg, then checks if it is an AbstractRunType.

After calling this function check if all_ok.logi == true

Examples

julia> kwargs, all_ok = AquaCrop.check_runtype(Dict(:logger => String[]); runtype = TomlFileRun());

julia> all_ok.logi == true
true
source
AquaCrop.check_parentdirFunction
kwargs, all_ok = check_parentdir(outputs; kwargs...)

If we do not have a kwarg for parentdir it sets it to pwd(). If we do have that kwarg, then checks if that directory exists.

After calling this function check if all_ok.logi == true

Examples

julia> kwargs, all_ok = AquaCrop.check_parentdir(Dict(:logger => String[]); parentdir=pwd());

julia> all_ok.logi == true
true
source
AquaCrop.check_nofilerunFunction
kwargs, all_ok = check_nofilerun(outputs; kwargs...)

In case we select a runtype = NoFileRun() checks that we have all the necessary kwargs, these are:

For the project input we have the following necessary keywords: Simulation_DayNr1, Simulation_DayNrN, Crop_Day1, Crop_DayN, InitialClimDate each one of them must be a Date type.

The soil_type must be one of these strings indicating the soil type: ["sandy clay", "clay", "clay loam", "loamy sand", "loam", "sand", "silt", "silty loam", "silty clay", "sandy clay loam", "sandy loam", "silty clay loam", "paddy"]

The crop_type must be one of these strings indicating the crop type: ["maize", "wheat", "cotton", "alfalfaGDD", "barley", "barleyGDD", "cottonGDD", "drybean", "drybeanGDD", "maizeGDD", "wheatGDD", "sugarbeet", "sugarbeetGDD", "sunflower", "sunflowerGDD", "sugarcane", "tomato", "tomatoGDD", "potato", "potatoGDD", "quinoa", "tef", "soybean", "soybeanGDD", "sorghum", "sorghumGDD", "paddyrice", "paddyriceGDD", "rapeseed", "oat", "rapeseedGDD"]

We also have the optional keys: [:co2i, :crop, :perennial_period, :soil, :soil_layers, :simulparam, :Tmin, :Tmax, :ETo, :Rain, :temperature_record, :eto_record, :rain_record, :management (with this we need to change projectinput.Management_Filename too)] which give more control when configurating the cropfield::AquaCropField, similarly to using NormalFileRun or TomlFileRun.

After calling this function check if all_ok.logi == true

Examples

julia> using Dates

julia> start_date = Date(2023, 1, 1); # January 1 2023

julia> end_date = Date(2023, 6, 1); # June 1 2023

julia> kwargs = (runtype = NoFileRun(), Simulation_DayNr1 = start_date, Simulation_DayNrN = end_date, Crop_Day1 = start_date, Crop_DayN = end_date, soil_type = "clay", crop_type = "maize", InitialClimDate = start_date);

julia> kwargs, all_ok = AquaCrop.check_nofilerun(Dict(:logger => String[]); kwargs...);

julia> all_ok.logi == true
true
source