Source code for hestia_earth.calculation.emissionsResourceUses.landOccupation

from hestia_earth.calculation.abstract_model import Model
from hestia_earth.calculation.utils import summation


[docs]class LandOccupation(Model): def __init__(self): super().__init__() # Define model requirements self.seed = None self.cycleDuration = None self.rotationDuration = None self.longFallowPeriod = None self.functionalUnitMeasure = None self.product_amount = None self.economicValueShare = None # Instantiate variables self.lan_use = None def calculate(self): # calculate amount of land per kg of product for temporary and permanent crops # TODO: Add a catch here, do the following if product is a temporary or permanent crop, # different model for orchard crops # 1) Estimate land area (m2) needed to produce 1kg of product (10000/yield_Kg) product_amount = self.product_amount land_use_1 = 10000 / product_amount # 2) multiply by yield+seed as a proportion of yield (to account for land use needed for the seed) if self.seed != {}: land_use_2 = land_use_1 * ((self.seed + product_amount) / product_amount) else: land_use_2 = land_use_1 # 3) Account for crop duration (multiple crops on a given field in a given year # TODO: Add an example fixture containing cycleDuration to test this if self.cycleDuration != {}: land_use_3 = land_use_2 * (float(self.cycleDuration) / 365) # TODO: need to account for alternativeStartDate as this can override default cycle duration else: land_use_3 = land_use_2 # 4) Account for fallow period in crop production # TODO: Add an example fixture containing rotationDuration and longFallowPeriod to test this if self.rotationDuration != {} and self.longFallowPeriod != {}: cultivated_duration = sum(self.rotationDuration) - self.longFallowPeriod land_use_4 = land_use_3 * (sum(self.rotationDuration) / cultivated_duration) else: land_use_4 = land_use_3 # TODO: account for numberOfCycles (for example the wheat example fixture over 41 years). # Discuss with JP + Juan self.lan_use = land_use_4 # create emissions resource use node emissionsResourceUses = {'landOccupation': self.lan_use} return emissionsResourceUses def complete(self, completeness): self.seed = 0 if self.seed == {} and completeness['other'] else self.seed def check(self, cycle, product): # set cycle level variables self.seed = summation(cycle['inputs']['seed']['value']) self.cycleDuration = cycle["cycleDuration"] self.rotationDuration = cycle['practices']['rotationDuration']['value'] self.longFallowPeriod = cycle['practices']['longFallowPeriod']['value'] self.functionalUnitMeasure = cycle['functionalUnitMeasure'] self.product_amount = summation(product['value']) if 'value' in product else {} self.economicValueShare = product['economicValueShare'] if 'economicValueShare' in product else {} self.complete(cycle['dataCompleteness']) return self.product_amount != {} and self.product_amount > 0 and self.economicValueShare != {} and\ self.economicValueShare > 0 and self.functionalUnitMeasure == '1 ha'