Calculating using the CFT¶
This topic guide explains how to send data to the CFT’s calculation modules.
Note
calculate.py
has Python examples of these methodsData schemas are available for reference
This version of the API has significant changes to these methods; see What’s new in CFT 1.0
The CFT now contains two calculation engines for irrigation.
Using the volume of water, pumping depth and pumping distance.
Using the volume of water only.
Method 2, using volume only, uses factors provided by IPCC in 2013 based on geographical location, irrigation method and the power source.
The CFT has updated its machinery module, please see updated Data schemas The expected data has not changed much, except when using a baler type machine. To find out if you are using one, please check the Machine to see if you need to add an additional field
number_of_bales
to your machinery data.
All URLs start with /api/v1/
.
Contents
Crop assessment¶
- POST /crop_product/calculate/¶
Calculate emissions for a crop product, without saving it to the database
Example request
POST /crop_product/calculate/ HTTP/1.1 Host: app.coolfarmtool.org Accept: application/json Content-Type: application/json
[ { "farm": { "country": "United States of America", "territory": "Alabama", "climate": "temperate", "average_temperature": { "value": 15, "unit": "°C" }, "farm_identifier": "" }, "crop": { "type": "Potato", "feed_type": null, "field_size": { "value": 100, "unit": "ha" }, "soil": { "texture_id": 1, "organic_matter_id": 2, "moisture_id": 1, "drainage_id": 1, "ph_id": 4, "organic_matter_custom": null }, "product_fresh": { "value": 1000, "unit": "tonne" }, "product_finished": { "value": 990, "unit": "tonne" }, "residue": { "value": null, "unit": null, "management": "Left distributed on field, OR incorporated, OR mulched" }, "seed_amount": { "value": 10, "unit": "tonne" }, "irrigation_calculation_type": "volume_depth_distance_irrigation_type" }, "pesticides": [ { "type_id": 1, "category_id": 3, "percentage_rate": 100, "application_rate": { "value": 1, "unit": "kg / acre" } } ], "fertilisers": [ { "type": "Compose your own NPK", "production": "Europe 2014", "custom_ingredients": { "n_total_percentage": 0.0, "n_ammonia_percentage": 0.0, "n_nitric_percentage": 0.0, "n_urea_percentage": 0.0, "p2o5_percentage": 0.0, "p2o5_percentage_type_id": 4, "k2o_percentage": 0.0, "k2o_percentage_type_id": 5 }, "application_rate": { "value": 15, "unit": "kg / ha" }, "rate_measure": "product", "method": 2, "inhibition_id": 1, "added_within_20_years": false, "years_ago": null, "allocation": null } ], "machinery": [ { "operations": 1, "machinery": 24, "fuel_type": "diesel" } ], "irrigation": [ { "method": 1, "water_source": 1, "allocation": 100, "pumping_depth": { "value": 1, "unit": "m" }, "horizontal_distance": { "value": 2, "unit": "km" }, "water_added": { "value": 2, "unit": "ha-mm" }, "power_source": 1 } ], "direct_energy": [ { "category": "irrigation", "source": "diesel", "usage": { "value": 1000, "unit": "litre" } } ], "land_management": [ { "change_id": 10, "years_ago": 1, "allocation": 100, "forest": { "type": "temperate oceanic forest", "age_years": 1 } } ], "transport": [ { "mode": "road LGV diesel (light goods vehicle <3.5t)", "weight": { "value": 4, "unit": "tonne" }, "distance": { "value": 2000, "unit": "km" } } ], "tree_biomass": [ { "tree_type": 5, "density_last_year": { "value": 100, "unit": "trees / hectare" }, "size_last_year": { "value": 10, "unit": "cm" }, "size_this_year": { "value": 15, "unit": "cm" }, "num_trees_delta": { "value": 1, "unit": "trees / hectare" } } ], "co_products": [ { "name": "test_co_product", "percentage_main_value": 50 } ], "processing": [ { "_type": 1, "allocation": 100, "power_source": 102 } ], "storage": [ { "cipc_application": 1, "cipc_dose": 1, "storage_power_source": 106, "store_loading_power_source": 102, "unloading_power_source": 102, "stored_allocation": 100, "temperature": { "unit": "°C", "value": 5 }, "time": { "unit": 46, "value": 1 } } ], "waste_water": { "waste_water_production": { "unit": 15, "value": 12 }, "oxygen_demand": { "unit": 18, "value": 15 }, "oxygen_demand_type": 1, "water_treatment_type": 1 } }, { "information": { "cft_version": "API_DEMO_TOOL" } } ]
Example response
HTTP/1.1 200 OK Content-Type: application/json
[ { "farm": { "farm_identifier": "" }, "summary": { "emissions_total": [ "-399588.13", "kg CO2e" ], "emissions_per_area": [ "-3982.69", "kg CO2e / ha" ], "emissions_per_product": [ "-402.29", "kg CO2e / tonne" ], "soil_organic_carbon": "2.00%", "machinery_fuel_usage": "140.00 litre" }, "total_emissions": [ { "name": "co_product", "CO2": "-199794.06", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "-199794.06", "total_CO2e_per_area": "-1997.94", "total_CO2e_per_product": "-201.81" }, { "name": "fertiliser_production", "CO2": "67.35", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "67.35", "total_CO2e_per_area": "0.67", "total_CO2e_per_product": "0.07" }, { "name": "fertiliser_soil", "CO2": "0.00", "N2O": "23.80", "CH4": "0.00", "total_CO2e": "6305.84", "total_CO2e_per_area": "63.06", "total_CO2e_per_product": "6.37" }, { "name": "field_energy", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" }, { "name": "irrigation", "CO2": "1790.09", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "1790.09", "total_CO2e_per_area": "17.90", "total_CO2e_per_product": "1.81" }, { "name": "machinery", "CO2": "250.13", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "250.13", "total_CO2e_per_area": "2.50", "total_CO2e_per_product": "0.25" }, { "name": "management_changes", "CO2": "-415427.91", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "-415427.91", "total_CO2e_per_area": "-4154.28", "total_CO2e_per_product": "-419.62" }, { "name": "pesticide", "CO2": "1366.67", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "1366.67", "total_CO2e_per_area": "13.67", "total_CO2e_per_product": "1.38" }, { "name": "processing", "CO2": "5.77", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "5.77", "total_CO2e_per_area": "0.06", "total_CO2e_per_product": "0.01" }, { "name": "residue", "CO2": "0.00", "N2O": "18.60", "CH4": "0.00", "total_CO2e": "4929.71", "total_CO2e_per_area": "49.30", "total_CO2e_per_product": "4.98" }, { "name": "seed", "CO2": "-3956.32", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "-3956.32", "total_CO2e_per_area": "-39.56", "total_CO2e_per_product": "-4.00" }, { "name": "storage", "CO2": "3269.87", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "3269.87", "total_CO2e_per_area": "32.70", "total_CO2e_per_product": "3.30" }, { "name": "transportation", "CO2": "1810.67", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "1810.67", "total_CO2e_per_area": "18.11", "total_CO2e_per_product": "1.83" }, { "name": "waste_water", "CO2": "0.00", "N2O": "0.00", "CH4": "7.20", "total_CO2e": "180.00", "total_CO2e_per_area": "1.80", "total_CO2e_per_product": "0.18" } ] }, { "information": { "cft_version": "API_DEMO_TOOL" } } ]
- Request Headers
X-Api-App-Authorisation – app key; see Authentication
- Status Codes
400 Bad Request – missing or incorrect form data
Crop type Rice¶
- POST /crop_product/calculate/¶
Calculate emissions for a rice crop product, without saving it to the database
Example request
Note
When calculating a rice crop product please note two additional fields: Flooding is a required parameter but optional to provide (if not provided a default value will be used) The time under cultivation may be entered directly in number of days. If it is not provided the IPCC 2019 default number of days based on farm location and region will be applied. Green manure is an optional parameter and may be provided as shown below
"flooding": { "time_under_cultivation": { "value": 123, "unit": "d" }, "before_cultivation": "Not flooded pre-season (for < 180 days)", "during_cultivation": "Continuously flooded" }, "green_manure": { "amount": { "value": 6.6, "unit": "tonne / ha" }, "years_ago": 11, "allocation": 100 }
POST /crop_product/calculate/ HTTP/1.1 Host: app.coolfarmtool.org Accept: application/json Content-Type: application/json
[ { "farm": { "country": "United Kingdom", "territory": null, "climate": "temperate", "average_temperature": { "value": 16, "unit": "\u00b0C" }, "farm_identifier": "" }, "crop": { "type": "Rice", "feed_type": null, "field_size": { "value": 10, "unit": 10 }, "soil": { "texture_id": 2, "organic_matter_id": 2, "moisture_id": 1, "drainage_id": 1, "ph_id": 1, "organic_matter_custom": null }, "product_fresh": { "value": 10000, "unit": "kg" }, "product_finished": { "value": 10000, "unit": "kg" }, "residue": { "value": 4.55, "unit": "tonne / ha", "management": "Rice straw incorporation less than 30 days before cultivation" }, "seed_amount": { "value": 0, "unit": "" }, "irrigation_calculation_type": 1 }, "pesticides": [], "fertilisers": [], "machinery": [], "irrigation": [], "direct_energy": [], "land_management": [ { "change_id": 49, "years_ago": 11, "allocation": 100, "forest": {} } ], "transport": [], "tree_biomass": [], "co_products": [], "processing": [], "storage": [], "flooding": { "time_under_cultivation": { "value": 123, "unit": "d" }, "before_cultivation": "Not flooded pre-season (for < 180 days)", "during_cultivation": "Continuously flooded" }, "green_manure": { "amount": { "value": 6.6, "unit": "tonne / ha" }, "years_ago": 11, "allocation": 100 } } ]
Example response
HTTP/1.1 200 OK Content-Type: application/json
[ { "farm": { "farm_identifier": "" }, "summary": { "emissions_total": [ "61838830.05", "kg CO2e" ], "emissions_per_area": [ "6183883.00", "kg CO2e / ha" ], "emissions_per_product": [ "6183.88", "kg CO2e / kg" ], "soil_organic_carbon": "2.00%", "machinery_fuel_usage": "0.00 litre" }, "total_emissions": [ { "name": "fertiliser_production", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" }, { "name": "fertiliser_soil", "CO2": "0.00", "N2O": "0.48", "CH4": "0.00", "total_CO2e": "141.74", "total_CO2e_per_area": "14.17", "total_CO2e_per_product": "0.01" }, { "name": "field_energy", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" }, { "name": "irrigation", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" }, { "name": "machinery", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" }, { "name": "management_changes", "CO2": "-14142.86", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "-14142.86", "total_CO2e_per_area": "-1414.29", "total_CO2e_per_product": "-1.41" }, { "name": "paddy_methane", "CO2": "0.00", "N2O": "0.00", "CH4": "2473936.97", "total_CO2e": "61848424.32", "total_CO2e_per_area": "6184842.43", "total_CO2e_per_product": "6184.84" }, { "name": "pesticide", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" }, { "name": "processing", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" }, { "name": "residue", "CO2": "0.00", "N2O": "14.79", "CH4": "0.00", "total_CO2e": "4406.85", "total_CO2e_per_area": "440.68", "total_CO2e_per_product": "0.44" }, { "name": "seed", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" }, { "name": "storage", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" }, { "name": "transportation", "CO2": "0.00", "N2O": "0.00", "CH4": "0.00", "total_CO2e": "0.00", "total_CO2e_per_area": "0.00", "total_CO2e_per_product": "0.00" } ] } ]
- Request Headers
X-Api-App-Authorisation – app key; see Authentication
- Status Codes
400 Bad Request – missing or incorrect form data
Dairy assessment¶
- POST /dairy_product/calculate/¶
Calculate emissions for a dairy product, without saving it to the database
Example request
POST /dairy_product/calculate/ HTTP/1.1 Host: app.coolfarmtool.org Accept: application/json Content-Type: application/json
[ { "farm": { "country": 840, "territory": "Wisconsin", "climate": "temperate", "average_temperature": { "value": 15, "unit": "°C" }, "farm_identifier": "" }, "general": { "grazing_area": { "value": 50, "unit": "ha" }, "feed_approach": "dmi", "fertilisation_approach": 1 }, "milk_production": { "variety": "Normande", "reporting_year": 2019, "date_time": "start", "date_month": 1, "name": "normande_2019", "product_dry": { "value": 500000, "unit": "litre" }, "fat_content": 4.2, "protein_content": 3.5, "protein_measure": 1 }, "herd_sections": [ { "phase": "Dairy calves", "animals": 40, "live_weight": { "value": 166, "unit": "kg" }, "sold_animals": 15, "sold_weight": { "value": 166, "unit": "kg" }, "purchased_animals": 10, "purchased_weight": { "value": 166, "unit": "kg" } }, { "phase": "Meat calves", "animals": 30, "live_weight": { "value": 230, "unit": "kg" }, "sold_animals": 10, "sold_weight": { "value": 230, "unit": "kg" }, "purchased_animals": 5, "purchased_weight": { "value": 230, "unit": "kg" } }, { "phase": "Milk cows", "animals": 100, "live_weight": { "value": 555, "unit": "kg" }, "sold_animals": 5, "sold_weight": { "value": 555, "unit": "kg" }, "purchased_animals": 0, "purchased_weight": { "value": 555, "unit": "kg" } } ], "grazing": [ { "herd_section": "Dairy calves", "days": 100, "hours": 12, "category": 2, "quality": 1 }, { "herd_section": "Meat calves", "days": 100, "hours": 12, "category": 3, "quality": 2 }, { "herd_section": "Milk cows", "days": 150, "hours": 12, "category": 2, "quality": 1 } ], "fertilisers": [ { "type": "Ammonium nitrate - 33.5% N (prilled)", "production": "Europe 2014", "custom_ingredients": {}, "application_rate": { "value": 30, "unit": "kg / ha" }, "rate_measure": "" }, { "type": "Compose your own NPK", "production": "Europe 2014", "custom_ingredients": { "n_ammonia_percentage": 6, "n_total_percentage": 12, "n_nitric_percentage": 4, "n_urea_percentage": 2, "p2o5_percentage": 8, "p2o5_percentage_type_id": 4, "k2o_percentage": 4, "k2o_percentage_type_id": 5 }, "application_rate": { "value": 20, "unit": "kg / ha" }, "rate_measure": "" } ], "feed_components": [ { "herd_section": "Dairy calves", "item": "Grass fresh managed - on farm", "region": "Global (world)", "dry_matter": { "value": 0.41, "unit": "kg" }, "certified": false }, { "herd_section": "Dairy calves", "item": "Maize / corn grain", "region": "Global (world)", "dry_matter": { "value": 10, "unit": "kg" }, "certified": false }, { "herd_section": "Dairy calves", "item": "Oats", "region": "Global (world)", "dry_matter": { "value": 4, "unit": "kg" }, "certified": false }, { "herd_section": "Dairy calves", "item": "Compound dairy feed: Belgium (65% soy)", "region": "Global (world)", "dry_matter": { "value": 5, "unit": "kg" }, "certified": false }, { "herd_section": "Meat calves", "item": "Grass fresh managed - on farm", "region": "Global (world)", "dry_matter": { "value": 0.62, "unit": "kg" }, "certified": false }, { "herd_section": "Meat calves", "item": "Maize / corn grain", "region": "Global (world)", "dry_matter": { "value": 5, "unit": "kg" }, "certified": false }, { "herd_section": "Meat calves", "item": "Soybean cake/meal", "region": "Global (world)", "dry_matter": { "value": 5, "unit": "kg" }, "certified": false }, { "herd_section": "Milk cows", "item": "Straw", "region": "Global (world)", "dry_matter": { "value": 10, "unit": "kg" }, "certified": false } ], "feed_additives": [ { "herd_section": "Dairy calves", "type": "3NOP", "dose": 100, "dose_unit": "mg / kg", "ndf": 40, "crude_fat": 5, "days": 10, "herd_section_percentage": 100 }, { "herd_section": "Milk cows", "type": "Nitrate", "dose": 30, "dose_unit": "g / kg", "days": 10, "herd_section_percentage": 100 } ], "manure": [ { "herd_section": "Dairy calves", "type": "Solid storage", "allocation": 100 }, { "herd_section": "Milk cows", "type": "Aerobic treatment - natural aeration", "allocation": 100 } ], "bedding": [ { "type": 621, "quantity": { "value": 100, "unit": "kg" } } ], "direct_energy": [ { "source": "diesel", "usage": { "value": 1200, "unit": "litre" }, "category": 1 }, { "source": "electricity (grid)", "usage": { "value": 1000, "unit": "kWh" }, "category": 1 } ], "transport": [ { "mode": "road LGV diesel (light goods vehicle <3.5t)", "weight": { "value": 5, "unit": "tonne" }, "distance": { "value": 3500, "unit": "km" } } ] }, { "information": { "cft_version": "API_DEMO_TOOL" } } ]
Example response
HTTP/1.1 200 OK Content-Type: application/json { "total_emissions": [ { "CH4": "0.00", "CO2": "1344.73", "N2O": "0.00", "name": "energy", "total_CO2e": "1344.73" }, { "CH4": "2267.14", "CO2": "0.00", "N2O": "0.00", "name": "enteric", "total_CO2e": "56678.61" }, { "CH4": "0.00", "CO2": "26461.58", "N2O": "0.00", "name": "feed", "total_CO2e": "26461.58" }, { "CH4": "0.00", "CO2": "6939.96", "N2O": "0.00", "name": "grazing", "total_CO2e": "6939.96" }, { "CH4": "0.00", "CO2": "10480.26", "N2O": "0.00", "name": "manure", "total_CO2e": "10480.26" }, { "CH4": "0.00", "CO2": "2716.00", "N2O": "0.00", "name": "transport", "total_CO2e": "2716.00" } ], "summary": { "emissions_total": [ "100560.4049907536020612299397", "kg CO2e" ] } }
- Request Headers
X-Api-App-Authorisation – app key; see Authentication
- Status Codes
400 Bad Request – missing or incorrect form data
Feed¶
The Cool farm tool allows 2 types of format for the feed section.
Feed approach 1: Dry Matter Intake (if you know the DMI values)¶
{ "general": { "grazing_area": { "value": 60, "unit": "ha" }, "feed_approach": "dmi" }, "feed_components": [ { "herd_section": "Dairy calves", "item": "Oats", "region": "Global (world)", "dry_matter": { "value": 10, "unit": "kg" }, "certified": false }, { "herd_section": "Meat calves", "item": "Grass fresh managed - on farm", "region": "Global (world)", "dry_matter": { "value": 1.37, "unit": "kg" }, "certified": false }, { "herd_section": "Meat calves", "item": "Maize / corn grain", "region": "Global (world)", "dry_matter": { "value": 5, "unit": "kg" }, "certified": false }, { "herd_section": "Milk cows", "item": "Sorghum", "region": "Global (world)", "dry_matter": { "value": 15, "unit": "kg" }, "certified": false } ] }
Feed approach 2: Average feed (the tool will estimate the DMI)¶
{ "general": { "grazing_area": { "value": 60, "unit": "ha" }, "feed_approach": "average" }, "feed_components": [ { "item": "Oat hay", "region": "Global (world)", "percentage": 60 }, { "item": "Straw", "region": "Global (world)", "percentage": 40 } ] }
Calculate a crop assessment first¶
You can also use the crop API to first calculate a crop assessment that then can be used as a feed item within the Dairy API for both feed approach 1 and 2. See calculate a crop assessment.
You will need to choose an existing feed item to use as the base for manure and enteric fermentation properties.
List of the available feed types
Example for feed approach 1
{ "feed_components": [ { "herd_section": "Meat calves", "crop_product": { "type": "Soyabean", "product_dry": { "value": 5, "unit": "tonne" }, "feed_type": "Soybean", "emissions_total": { "value": 22469.393582158074, "unit": "kg CO2e" } }, "dry_matter": { "value": 5, "unit": "kg" }, "certified": false } ] }
Example for feed approach 2
{ "feed_components": [ { "item": "Oat hay", "region": "Global (world)", "percentage": 60 }, { "crop_product": { "type": "Maize", "product_dry": { "value": 2, "unit": "tonne" }, "feed_type": "Maize silage", "emissions_total": { "value": 267.5460271629662, "unit": "kg CO2e" } }, "region": "Global (world)", "percentage": 40 } ] }
Water assessment¶
- POST /crop_product/water/calculate/¶
Calculate water assessment for a crop, without saving it to the database
Example request
POST /crop_product/water/calculate/ HTTP/1.1 Host: app.coolfarmtool.org Accept: application/json Content-Type: application/json
[ { "farm": { "country": "Spain", "territory": "Madrid", "climate": "temperate", "average_temperature": { "value": 15, "unit": "°C" }, "farm_identifier": "my_identifier", "latitude": 40.417, "longitude": -3.704 }, "crop": { "type": "Potato", "field_size": { "value": 51, "unit": "ha" }, "product_fresh": { "value": 3000, "unit": "tonne" }, "product_dry": { "value": 3000, "unit": "tonne" }, "reporting_year": 2016, "planting_date": { "time": 1, "month": 1, "year": 2016 }, "harvest_date": { "time": 1, "month": 3 }, "name": "potato_2016", "soil": { "label": "sandy wet", "type": "sandy_clay", "moisture_at_sowing": "wet" } }, "irrigation": { "irri_start_date": { "time": 1, "month": 1, "year": 2016 }, "irri_end_date": { "time": 1, "month": 2, "year": 2016 }, "method": 2, "water_source": 1, "irrigation_events": [ { "water_added": { "value": 20.78, "unit": "mm" }, "allocation": 100, "has_source_pump": false, "water_source": 3 }, { "water_added": { "value": 27.3, "unit": "mm" }, "allocation": 100 }, { "water_added": { "value": 23.55, "unit": "mm" }, "allocation": 100 }, { "water_added": { "value": 25, "unit": "mm" }, "allocation": 100 }, { "water_added": { "value": 21, "unit": "mm" }, "allocation": 100 } ] } }, { "information": { "cft_version": "API_DEMO_TOOL" } } ]
Example response
HTTP/1.1 200 OK Content-Type: application/json
[ { "farm": { "farm_identifier": "my_identifier" }, "summary": { "water_productivity": { "value": 93.3, "unit": "kg / m3" }, "water_footprint": { "value": 10.72, "unit": "litre / kg", "green": 7.22, "blue": 3.5 }, "irrigation_efficiency": { "value": 1.87, "unit": "litre / litre" }, "water_balance": { "unit": "mm", "water_requirement": { "total_value": 63.05, "weekly": [ 3.75, 5.31, 6.35, 6.58, 7.85, 5.15, 11.82, 9.04, 7.2 ] }, "water_added": { "rainfall": { "total_value": 93.35, "weekly": [ 21.69, 4.94, 0.0, 1.55, 4.55, 28.47, 4.85, 25.76, 1.54 ] }, "irrigation": { "total_value": 117.63, "weekly": [ 20.78, 27.3, 23.55, 25.0, 21.0 ] } }, "irrigation_percolation": -70.85, "irrigation_runoff": -26.19, "rainfall_runoff": -18.44, "rainfall_percolation": -40.07, "irrigation_balance": 20.5, "interception_losses": -12.88 } } }, { "information": { "cft_version": "API_DEMO_TOOL" } } ]
- Request Headers
X-Api-App-Authorisation – app key; see Authentication
- Status Codes
400 Bad Request – missing or incorrect form data
Calculating the number of weeks between irrigation dates
To enter the correct number of irrigation events follow the formula below to calculate the correct number of weeks/irrigation events between the irrigation start date and irrigation end date.
Number of days between irrigation start date and irrigation end date (knowing that “start” = 5th, “middle” = 15th and “end” = 25th day of the month and last day not included) divided by 7 and rounded to the highest integer number. See the example below:
irrigation start date: start April 2016 -> 2016-04-05
irrigation end date: middle May 2016 -> 2016-05-15
days between: 40
40 / 7 = 5.71428 -> So rounded to highest integer is 6 weeks
Water source
To select an irrigation water source enter the “water_source” key under the irrigation key. This value will be used as the default for all irrigation events.
In order to enter a different water source for a specific irrigation event just add two fields to override the default value as per the example below:
{
"water_added": {
"value": 12000,
"unit": "litre"
},
"allocation": 100,
"has_source_pump": false,
"water_source": 3
}
JSON export¶
From the web interface on a crop or dairy assessment, you can generate a JSON file compatible with the API. This can be used to test and debug the API. To find the JSON export functionality, go to the ‘more’ page of an assessment.
Energy only¶
- POST /energy/calculate/¶
Calculate the energy content of the specified fuel usage
- Form Parameters
int factor – emissions factor (source) ID; see
GET /energy/
float usage – consumption
int unit – unit ID
Example request
POST /energy/calculate/ HTTP/1.1 Host: app.coolfarmtool.org Accept: application/json Content-Type: application/json
factor=102&usage=1000&unit=15
Example response
HTTP/1.1 200 OK Content-Type: application/json 37900.0
- Request Headers
X-Api-App-Authorisation – app key; see Authentication
- Status Codes
400 Bad Request – missing or incorrect form data
Fertiliser only¶
- POST /fertiliser/calculate/¶
Calculate the nutrient content of specified fertiliser application
- Form Parameters
int fertiliser_type – fertiliser type ID; see
GET /fertiliser/
float rate – rate
int unit – unit ID; must be convertible to kg / ha, see
GET /unit/
Example request
POST /fertiliser/calculate/ HTTP/1.1 Host: app.coolfarmtool.org Accept: application/json Content-Type: application/json fertiliser_type=1&rate=16&unit=24
Example response
HTTP/1.1 200 OK Content-Type: application/json {"n": [2.88, "kg / ha"]}
- Request Headers
X-Api-App-Authorisation – app key; see Authentication
- Status Codes
400 Bad Request – missing or incorrect form data
Irrigation only¶
- POST /irrigation/calculate/¶
Calculate the volume of water applied
- Form Parameters
float depth – depth of irrigation
int depth_unit – unit ID; must be convertible to m, see
GET /unit/
float area – area irrigated
int area_unit – unit ID; must be convertible to ha, see
GET /unit/
Example request
POST /irrigation/calculate/ HTTP/1.1 Host: app.coolfarmtool.org Accept: application/json Content-Type: application/json depth=10&depth_unit=3&area=10&area_unit=56
Example response
HTTP/1.1 200 OK Content-Type: application/json {"rate": 1}
- Request Headers
X-Api-App-Authorisation – app key; see Authentication
- Status Codes
400 Bad Request – missing or incorrect form data