# Import modules
import numpy as np
import matplotlib.pyplot as plt
65 Maximum return to nitrogen application
An important decision that farmers have to make during the growing season is decide the amount of nitrogen fertilizer that needs to be applied to the crop. Multiple factors contribute to this decision including the potential yield of the crop, the price of the harvestable part of the crop, the cost of nitrogen fertilizer, the current amount of nitrogen in the soil, and the nitrogen requirements of the crop.
The maximum return to nitrogen rate is one way to balance the estimated gross revenue and the cost of the input fertilizer. For this method to work, a yield response function to nitrogen is essential because it determines the amount of yield increase per unit input added to the crop, until a point where a new unit of nitrogen fertilizer does not produce gross revenue to pay for itself.
We will use the yield response function to nitrogen define in the previous exercise as an example.
# Define inputs
= 0.17 # US$ per kg of grain
grain_price = 0.02 # US$ per kg of nitrogen
fertilizer_cost = grain_price/fertilizer_cost
grain_fertilizer_ratio print(grain_fertilizer_ratio)
8.5
# Define yield response function
def responsefn(nitrogen_input):
= 115.6
beta_0 = 0.9613
beta_1 = -0.003412
beta_2 = -beta_1/(2*beta_2)
x_critical
= []
Y for N in nitrogen_input:
if (N<x_critical):
+ beta_1*N + beta_2*N**2 )
Y.append( beta_0 else:
- beta_1**2/(4*beta_2) )
Y.append( beta_0
return np.array(Y)
# Find maximum return to nitrogen
= np.arange(200)
nitrogen_range = responsefn(nitrogen_range)
yield_range = yield_range * grain_price
gross_revenue = nitrogen_range * fertilizer_cost
variable_costs = gross_revenue - variable_costs
net_revenue = np.argmax(net_revenue)
idx
print(nitrogen_range[idx],'kg per hectare')
124 kg per hectare
# Compute maximum nitrogen rate
=(6,4))
plt.figure(figsize='royalblue', linewidth=2)
plt.plot(nitrogen_range, gross_revenue, color='tomato', linewidth=2)
plt.plot(nitrogen_range, variable_costs, color='green', linewidth=2)
plt.plot(nitrogen_range, net_revenue, color='green')
plt.scatter(nitrogen_range[idx], net_revenue[idx], facecolor'Nitrogen Rate (kg/ha)')
plt.xlabel('Return to Nitrogen ($/ha)')
plt.ylabel( plt.show()