Skip to content

Commit

Permalink
Merge branch 'main' into patch-16
Browse files Browse the repository at this point in the history
  • Loading branch information
holos-aafc authored Apr 19, 2024
2 parents 2447fc0 + e230eb7 commit ff1c7b6
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Small-grain cereals,Small-grain cereals,0.38,0.015,0.248,0.0083,0.073,12
,Barley,0.373 (3),0.028 (3),0.21,0.009,0.046,12,267,0.44,90,880,6.1
,Oats,0.357 (3),0.029 (3),0.419,0.0073,0.047,12,287,0.52,90,880,6
,Triticale,0.344,0.015,0.229,0.007,0.053,12,195,0.6,90,880,6
,Sorghum (4),-9,-9,-9,0.0065,0.06,0,,,,,
,Sorghum (4),-9,-9,-9,0.0065,0.06,12,,,,,
,Canary Seed,0.171,0.11,0.193,0.008,0.073,8,,,,,
,Buckwheat,0.344,0.015,0.229,0.007,0.053,12,,,,,
,Mixed Grains,0.357,0.029,0.419,0.0073,0.047,12,,,,,
Expand All @@ -20,7 +20,7 @@ Silage,Corn Silage,0.369 (3),0.015 (3),0.25,0.0063,0.11,70,304,0.45,95,640,13
,Triticale Silage,0.344,0.015,0.229,0.007,0.053,60,,,,,
,Wheat Silage,0.344 (3),0.015 (3),0.229,0.007,0.053,57,,,,,
,,,,,,,
Oilseeds,Oilseeds,0.197,0.078,0.246,0.008,0.073,2,,,,,
Oilseeds,Oilseeds,0.197,0.078,0.246,0.008,0.073,9,,,,,
,Canola,0.18 (3),0.046 (3),0.375,0.0083,0.073,9,,,,,
,Mustard,0.18,0.046,0.375,0.0083,0.073,9,,,,,
,Flax,0.171 (3),0.11 (3),0.193,0.0063,0.15,8,,,,,
Expand All @@ -30,7 +30,6 @@ Pulse crops,Pulse crops,0.279,0.046,0.223,0.008,0.075,13
,Beans (dry field),0.2,0.099,0.224,0.008,0.085,13,,,,,
,Chickpea,0.301 (3),0.063 (3),0.219,0.008,0.075,13,,,,,
,Dry Pea,0.163 (3),0.071 (3),0.215,0.008,0.075,13,,,,,
,Field Pea,0.163,0.071,0.215,0.008,0.075,13,,,,,
,Lentil,0.305 (3),0.059 (3),0.239,0.008,0.075,13,,,,,
,Fababean,0.2,0.099,0.224,0.008,0.085,13,,,,,
,White Beans,0.279,0.046,0.223,0.008,0.075,13,,,,,
Expand All @@ -39,24 +38,24 @@ Pulse crops,Pulse crops,0.279,0.046,0.223,0.008,0.075,13
Root crops,Potatos,0.795,0,0.097,0.0169,0.073,75,,,,,
,Sugar Beets,0.925,0,0.097,0.0169,0.073,80,,,,,
,,,,,,,
Other field crops,SAFFLoWeR,0.197,0.078,0.246,0.008,0.073,2,,,,,
,SUNFLowerSeeds,0.197,0.078,0.246,0.0169,0.073,2,200,0.6,90,891,10
,TOBACCO,0.5,0,0.2,0.008,0.073,13,,,,,
Other field crops,Safflower,0.197,0.078,0.246,0.008,0.073,2,,,,,
,Sunflower seeds,0.197,0.078,0.246,0.0169,0.073,2,200,0.6,90,891,10
,Tobacco,0.5,0,0.2,0.008,0.073,13,,,,,
,Vegetables,-9,-9,-9,-9,-9,-9,,,,,
,Berries and Grapes,-9,-9,-9,-9,-9,-9,,,,,
,Other field crops,-9,-9,-9,-9,-9,-9,,,,,
,,,,,,,
Cover/Winter crops,Winter wheat,0.344 (3),0.015 (3),0.229,0.007,0.053,12
,Rye,0.344,0.015,0.229,0.007,0.053,12,241,0.44,94,880,6
,(Fall) Rye,0.344,0.015,0.229,0.007,0.053,12,241,0.44,94,880,6
,,,,,,,
Perennials,Rangeland (native),-9,-9,-9,0.0134,0.049,0,,,,,
,Perennial forages,-9,-9,-9,0.0126,0.049,0,,,,,
,Tame grass,-9,-9,-9,0.0134,0.057,0,332,0.54,82,870,15
,Tame legume,-9,-9,-9,0.025,0.072,0,,,,,
,Tame mixed,-9,-9,-9,0.0178,0.061,0,,,,,
,Seeded grassland,-9,-9,-9,-9,-9,-9,,,,,
,Forage for seed,-9,-9,-9,-9,-9,-9,,,,,
,Alfalfa,-9,-9,-9,0.0238,0.072,0,,,,,
Perennials,Rangeland (native),-9,-9,-9,0.0134,0.049,13,,,,,
,Perennial forages,-9,-9,-9,0.0126,0.049,13,,,,,
,Tame grass,-9,-9,-9,0.0134,0.057,13,332,0.54,82,870,15
,Tame legume,-9,-9,-9,0.025,0.072,13,,,,,
,Tame mixed,-9,-9,-9,0.0178,0.061,13,,,,,
,Seeded grassland,-9,-9,-9,-9,0.049,13,,,,,
,Forage for seed,-9,-9,-9,-9,0.049,13,,,,,
,Alfalfa,-9,-9,-9,0.0238,0.072,13,,,,,
,,,,,,,
,,,,,,,
,,,,,,,"1 Values for the N content of residues from IPCC (2019), Table 5.5B. The estimates are in units of g N (g residue)-1 on dry weight basis from a biomass-weighted average of aboveground and belowground for each crop based on data in IPCC (2019), Table 11.1a."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void TestCleanup()
public void GetData()
{
var result = _sut.GetData().ToList();
Assert.AreEqual(91, result.Count);
Assert.AreEqual(90, result.Count);
}

[TestMethod]
Expand Down Expand Up @@ -139,13 +139,12 @@ public void GetOats()
public void GetLigninContentValue()
{
Table_7_Relative_Biomass_Information_Data data = _sut.GetResidueData(IrrigationType.RainFed, 0, CropType.SmallGrainCereals, SoilFunctionalCategory.Black, Province.Alberta);
Assert.AreEqual(0.074, data.LigninContent);
Assert.AreEqual(0.073, data.LigninContent);

data = _sut.GetResidueData(IrrigationType.RainFed, 0, CropType.AlfalfaMedicagoSativaL, SoilFunctionalCategory.DarkBrown, Province.Alberta);
Assert.AreEqual(0.133, data.LigninContent);
}


#endregion
}
}
14 changes: 4 additions & 10 deletions H.Core.Test/Services/Animals/ScaleUpServiceTest.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
using H.Core.Calculators.Infrastructure;
using H.Core.Emissions.Results;

using H.Core.Enumerations;
using H.Core.Models.Animals.Sheep;
using H.Core.Models.Animals;
using H.Core.Models;
using H.Core.Providers.Animals.Table_28;
using H.Core.Services.Animals;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
using System;
using System.Collections.Generic;
using H.Core.Providers.Animals.Table_28;

namespace H.Core.Test.Services.Animals
{
Expand Down Expand Up @@ -54,15 +48,15 @@ public void TestCleanup()
[TestMethod]
public void ShouldScaleUpReturnsTrue()
{
var result = _scaleUpService.ShouldScaleUp(true, AnimalType.BeefBackgrounderHeifer, ProductionStages.GrowingAndFinishing, ComponentType.Backgrounding);
var result = _scaleUpService.ShouldScaleUp(true, AnimalType.BeefBackgrounderHeifer, ProductionStages.GrowingAndFinishing, ComponentType.Backgrounding, new Farm() { Defaults = new Defaults() { ScaleUpEmissionsEnabled = true } });

Assert.IsTrue(result);
}

[TestMethod]
public void ShouldScaleUpReturnsFalse()
{
var result = _scaleUpService.ShouldScaleUp(true, AnimalType.BeefCowLactating, ProductionStages.Lactating, ComponentType.CowCalf);
var result = _scaleUpService.ShouldScaleUp(true, AnimalType.BeefCowLactating, ProductionStages.Lactating, ComponentType.CowCalf, new Farm() {Defaults = new Defaults() {ScaleUpEmissionsEnabled = true}});

Assert.IsFalse(result);
}
Expand Down
1 change: 1 addition & 0 deletions H.Core/Calculators/Carbon/CarbonCalculatorBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public double CalculateDigestateCarbonInputPerHectare(

/// <summary>
/// Equation 2.1.2-34
/// Equation 2.1.2-2
///
/// (kg C ha^-1)
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions H.Core/Models/Defaults.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ public class Defaults : ModelBase
private PumpType _defaulPumpType;
private double _pumpEmissionsFactor;

private bool _scaleUpEmissionsEnabled;

#endregion

#region Constructors
Expand Down Expand Up @@ -991,6 +993,12 @@ public TillageType RunInPeriodTillageType
set => SetProperty(ref _runInPeriodTillageType, value);
}

public bool ScaleUpEmissionsEnabled
{
get => _scaleUpEmissionsEnabled;
set => SetProperty(ref _scaleUpEmissionsEnabled, value);
}

#endregion

#region Public Methods
Expand Down
2 changes: 1 addition & 1 deletion H.Core/Services/Animals/IScaleUpService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public interface IScaleUpService
#region Public Methods

bool ShouldScaleUp(bool isAnnualReport, AnimalType animalType, ProductionStages productionStage,
ComponentType? componentType);
ComponentType? componentType, Farm farm);
double ScaleUpEmissions(double emissions, double numberOfDaysRest, double numberOfDaysInCycle);

#endregion
Expand Down
7 changes: 6 additions & 1 deletion H.Core/Services/Animals/ScaleUpService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ public ScaleUpService(ITable_28_Production_Days_Provider table28ProductionDaysPr
#region Public Methods

public bool ShouldScaleUp(bool isAnnualReport, AnimalType animalType, ProductionStages productionStage,
ComponentType? componentType)
ComponentType? componentType, Farm farm)
{
if (farm.Defaults.ScaleUpEmissionsEnabled == false)
{
return false;
}

if (isAnnualReport == false)
{
// Emissions are only scaled up when reporting annually
Expand Down

0 comments on commit ff1c7b6

Please sign in to comment.