def calc_depreciation(scenario, lights, avg_photoperiod, years, days_in_year):

    """Calculate Depreciation Function to Compute Total Farm Depreciation each Year
       Typically accounts for 21 production costs

    Args:
       scenario (object): The farm scenario
       lights (object): The lights used on the farm
       avg_photoperiod (float): The average photoperiod of lights on the farm
       years (int): The no. of years the simulation will analyse
       days_in_year (float): The no. of days in the year

    Returns:
        depreciation (list): Depreciation as a timeseries of costs

    Notes:
    Construction - Depreciation over 15 years for building.
    Facilities   - Depreciation over 10 years for facilities.
    Lights - Depreciation over 5 years for LED (typically) but dependant for lifetime of LEDs
    """

    building_lifetime = 15
    facilities_lifetime = 10

    # Building
    building_depreciaiton_percent = 1/building_lifetime
    building_depreciation = scenario.capex_building * building_depreciaiton_percent

    # Facilities
    facilities_depreciation_percent = 1/facilities_lifetime
    facilities_depreciation = scenario.capex_facilities * facilities_depreciation_percent

    # Lights
    life_time_acceleration_factor = 0.8
    life_time = lights.life_time * life_time_acceleration_factor # Hours
    life_span = (life_time / avg_photoperiod)/days_in_year
    lights_depreciation_percent = 1/life_span
    lights_depreciation = lights_depreciation_percent * scenario.capex_lights

    # Pilot
    pilot_depreciation = (lights_depreciation+facilities_depreciation+building_depreciation)/scenario.growing_area_mulitplier

    depreciation = [0]

    for y in range(1, years+1):
        if y == 1:
            depreciation.append(pilot_depreciation)
        elif y > 1:
            depreciation.append(lights_depreciation + facilities_depreciation + building_depreciation)

    return depreciation, life_span