fertiliser package
fertiliser.forms module
- class fertiliser.forms.BaseFertiliserApplicationForm(data=None, files=None, auto_id='id_%s', prefix=None, initial=None, error_class=<class 'django.forms.utils.ErrorList'>, label_suffix=None, empty_permitted=False, instance=None, use_required_attribute=None, renderer=None)
Bases:
coolfarmtool.forms.ConditionalModelForm
Base form to be used by crop and cattle fertiliser application forms
- CUSTOM_FIELDS = ['n_ammonia_percentage', 'n_nitric_percentage', 'n_urea_percentage', 'p2o5_percentage', 'k2o_percentage']
list of fields relating to “primary” nutrients
- class FertiliserNutrientK(filter=(<object object>, ), item=<object object>, grouped=False)
Bases:
dj.choices.Choices
- class FertiliserNutrientP(filter=(<object object>, ), item=<object object>, grouped=False)
Bases:
dj.choices.Choices
- property media
Return all media required to render the widgets on this form.
- class fertiliser.forms.BaseFertiliserFormSet(data=None, files=None, instance=None, save_as_new=False, prefix=None, queryset=None, **kwargs)
Bases:
coolfarmtool.forms.BaseInlineFormSet
- save(*args, **kwargs)
Save model instances for every form, adding and changing instances as necessary, and return the list of instances.
- save_new(form, commit=True)
Save and return a new model instance for the given form.
- class fertiliser.forms.FertiliserApplicationForm(product, *args, **kwargs)
Bases:
fertiliser.forms.BaseFertiliserApplicationForm
Individual fertiliser application
- clean()
Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.
- has_changed()
Return True if data differs from initial.
- property media
Return all media required to render the widgets on this form.
- save(*args, **kwargs)
Save this form’s self.instance object if commit=True. Otherwise, add a save_m2m() method to the form which can be called after the instance is saved manually at a later time. Return the model instance.
fertiliser.models module
- class fertiliser.models.BaseFertiliserApplication(*args, **kwargs)
Bases:
factor.models.EmissionsModel
Abstract class for base functionality of fertiliser applications
- class Inhibition(filter=(<object object>, ), item=<object object>, grouped=False)
Bases:
dj.choices.Choices
Nitrification inhibitor technology options – only relevant for nitrogen-containing fertilisers
- _e_volatilisation() quantity.models.Quantity
N2O indirect emissions from atmospheric deposition of N volatilised from managed soils (Tier 2).
IPCC 2019 vol 4 chap 11 equation 11.11.
- _emissions_leaching
N2O indirect emissions from managed soils in regions where leaching/runoff occurs (Tier 1).
See IPCC 2019 vol 4 chap 11 equation 11.10.
- _emissions_n2o_direct
N2O direct emissions from N inputs to managed soils
- _emissions_volatilisation
Calculated N2O emissions from volatilisation
- _nutrient_rate(nutrient: str) quantity.models.Quantity
Calculated application rate of the specified nutrient
- Returns
- static _set_custom_ingredient(instance, nutrient, percentage, _type=None, source=None)
Add nutrient to
custom_ingredients
, converting if requiredLeaving
source
blank whennutrient
isFertiliserNutrient.n
triggers automatic definition of two ingredients according to the default source split provided by Fertilizers Europe.Calling functions should loop over
farm.forms.crop.FertiliserApplicationForm.CUSTOM_FIELDS
to determine the primary nutrients to display.- Parameters
nutrient (
FertiliserNutrient
) – Primary nutrient to addpercentage (
decimal.Decimal
) – Percentage of this nutrient_type (
FertiliserNutrient
) – Specific nutrient (for conversion)source (
NitrogenType
) – Nitrogen type
- Raises
TypeError
if_type
is not provided and the ingredient is not primary
- area
Returns the fertiliser’s product area object or None if it doesn’t have one.
Override it in the child model if the fertiliser product has an area.
- custom_ingredients
Custom N/P/K mixture
- date
Application date
- emissions_n2o
Total N2O emissions.
- inhibition
Nitrification
Inhibition
method used
- n2o_direct_emission_factor
Emission factor to estimate direct N2O emissions from managed soils (values adapted from IPCC 2019 vol 4 Table 11.1)
Unit kg N2O-N (kg N input)-1
- property n_rate: quantity.models.Quantity
Calculated nitrogen application rate
Note
Equal to
rate
ifrate_measure
is “N”- Returns
- property product_rate
Calculated application rate of fertiliser specified in
type
Note
Equal to
rate
ifrate_measure
is “Product”- Returns
- rate = <quantity.models.QuantityField: rate>
Application rate
- regionalised
Get the regionalised calculations for the fertiliser application.
- Returns:
FertiliserRegionalised or None: An instance of the FertiliserRegionalised class representing the regionalised calculations for the fertiliser application if regionalised calculations are available. Otherwise, returns None.
- Note:
Accessing the regionalised property allows you to retrieve all regionalised fertiliser calculations associated with this fertiliser application.
- type
FertiliserType
applied
- class fertiliser.models.FertiliserApplication(*args, **kwargs)
Bases:
fertiliser.models.BaseFertiliserApplication
Single application of a specific fertiliser mixture to a field
- exception DoesNotExist
- class Method(filter=(<object object>, ), item=<object object>, grouped=False)
Bases:
dj.choices.Choices
Fertiliser application method
- exception MultipleObjectsReturned
- class ProductionInput(filter=(<object object>, ), item=<object object>, grouped=False)
Bases:
dj.choices.Choices
- property _emissions_liming: quantity.models.Quantity
Calculated CO2-C for CaCO3 from limestone using IPCC (2006) factor
- property _emissions_production: quantity.models.Quantity
Calculated embodied CO2e emissions from production process
- property _emissions_urea
Calculated CO2-C emissions for urea application
- area
- clean()
Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field defined by NON_FIELD_ERRORS.
- growing_area
GrowingArea
to which the fertiliser was applied
- method
Application method
- production_custom_impact = <quantity.models.QuantityField: production_custom_impact>
User-defined fertiliser production impact
- production_custom_reference
Citation for user-defined production impact
- property production_factor
Emissions factor for producing this kind of fertiliser
- Returns
- production_input
Whether
production_factor
should use database or custom value
- started_adding_change
ManagementPracticeChangeInstance
, if this is an organic fertiliser which was first added to the growing area less than 20 years ago
- class fertiliser.models.FertiliserNutrient(filter=(<object object>, ), item=<object object>, grouped=False)
Bases:
dj.choices.Choices
Active fertiliser ingredients
- class fertiliser.models.FertiliserNutrientProductionImpact(*args, **kwargs)
Bases:
django.db.models.base.Model
CO2e impact of producing a fertiliser nutrient, in tCO2e per kg
- exception DoesNotExist
- exception MultipleObjectsReturned
- class fertiliser.models.FertiliserProduction(*args, **kwargs)
Bases:
django.db.models.base.Model
Fertiliser production database (e.g. EFMA 2011) – also used as an approximation for production methodolody
- exception DoesNotExist
- exception MultipleObjectsReturned
- class fertiliser.models.FertiliserProductionImpact(*args, **kwargs)
Bases:
django.db.models.base.Model
CO2e impact of producing a fertiliser, in tCO2e per kg fertiliser
In the case of custom fertiliser mixtures (i.e. where
FertiliserType.is_customisable
), this refers to the component of production impact which does not depend on mixture, e.g. energy for melt granulation.- exception DoesNotExist
- exception MultipleObjectsReturned
- class fertiliser.models.FertiliserType(*args, **kwargs)
Bases:
django.db.models.base.Model
Named fertiliser mixture
- class Categorisation(filter=(<object object>, ), item=<object object>, grouped=False)
Bases:
dj.choices.Choices
- exception DoesNotExist
- exception MultipleObjectsReturned
- class fertiliser.models.NitrogenType(filter=(<object object>, ), item=<object object>, grouped=False)
Bases:
dj.choices.Choices
Nitrogen sources
fertiliser.views module
- class fertiliser.views.FertiliserApplicationDetailView(**kwargs)
Bases:
farm.views.FarmMixin
,farm.views.AjaxResponseMixin
,braces.views._ajax.JSONResponseMixin
,django.views.generic.detail.DetailView
- get_object(queryset=None)
Return the object the view is displaying.
Require self.queryset and a pk or slug argument in the URLconf. Subclasses can override this to return any object.
- model
- class fertiliser.views.FertiliserTypeDetailView(**kwargs)
Bases:
farm.views.FarmMixin
,farm.views.AjaxResponseMixin
,braces.views._ajax.JSONResponseMixin
,django.views.generic.detail.DetailView
- model
alias of
fertiliser.models.FertiliserType