Skip to content

Commit

Permalink
Add loss test
Browse files Browse the repository at this point in the history
  • Loading branch information
HamishBrownPFR committed Apr 1, 2024
1 parent e2c2928 commit 5d169bb
Show file tree
Hide file tree
Showing 27 changed files with 9,769 additions and 6 deletions.
4 changes: 2 additions & 2 deletions SVSModel/Configuration/FieldConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace SVSModel.Configuration
public class FieldConfig
{
// Inputs
public string Location { get; init; }
public string WeatherStation { get; init; }
public string SoilCategory { get; init; }
public string SoilTexture { get; init; }
public double PMN { get; init; }
Expand Down Expand Up @@ -45,7 +45,7 @@ public FieldConfig() { }
public FieldConfig(Dictionary<string, object> c)
{
// Only raw input values should be set in here
Location = c["Location"].ToString();
WeatherStation = c["WeatherStation"].ToString();
SoilCategory = c["SoilCategory"].ToString();
SoilTexture = c["Texture"].ToString();
PMN = Functions.Num(c["PMN"]);
Expand Down
2 changes: 1 addition & 1 deletion SVSModel/Data/LossCoefficientTable.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Location,Month,langmuir
WeatherStation,Month,langmuirCoeff
Ashburton,1,0.4221956844236277
Ashburton,2,0.4040155222628269
Ashburton,3,0.41829435230252165
Expand Down
2 changes: 1 addition & 1 deletion SVSModel/Models/Losses.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static double DailyLoss(DateTime d, SimulationType thisSim)
double b = 0.38;
int month = d.Month;
if (month != currentMonth)
b = findLossCoefficient(month, thisSim.config.Field.Location);
b = findLossCoefficient(month, thisSim.config.Field.WeatherStation);
double PropDVol = thisSim.Drainage[d] / thisSim.config.Field.AWC;
double PropNLoss = (PropDVol * b) / (1 + PropDVol * b);
return PropNLoss * Math.Max(0, thisSim.SoilN[d]);
Expand Down
5 changes: 3 additions & 2 deletions TestComponents/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static void RunAllTests()
}


List<string> sets = new List<string> { "WS2", "Residues", "Location", "Moisture" };
List<string> sets = new List<string> { "WS2", "Residues", "Location", "Moisture", "Losses" };

//Delete graphs from previous test run
string graphFolder = Path.Join(Directory.GetCurrentDirectory(), "TestGraphs", "Outputs");
Expand Down Expand Up @@ -174,7 +174,8 @@ public static SVSModel.Configuration.Config SetConfigFromDataFrame(string test,
{
int testRow = getTestRow(test, allTests);

List<string> coeffs = new List<string> {"SoilCategory",
List<string> coeffs = new List<string> {"WeatherStation",
"SoilCategory",
"Texture",
"Rocks",
"SampleDepth",
Expand Down
2 changes: 2 additions & 0 deletions TestComponents/TestComponents.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<None Remove="observed.csv" />
<None Remove="TestSets\actualWS2DataConfig.csv" />
<None Remove="TestSets\Location\FieldConfigs.csv" />
<None Remove="TestSets\Losses\FieldConfigs.csv" />
<None Remove="TestSets\Moisture\FieldConfigs.csv" />
<None Remove="TestSets\Residues\FieldConfigs.csv" />
<None Remove="TestSets\SensibilityResidueCompConfig.csv" />
Expand All @@ -26,6 +27,7 @@

<ItemGroup>
<EmbeddedResource Include="TestSets\Location\FieldConfigs.csv" />
<EmbeddedResource Include="TestSets\Losses\FieldConfigs.csv" />
<EmbeddedResource Include="TestSets\Moisture\FieldConfigs.csv" />
<EmbeddedResource Include="TestSets\Residues\FieldConfigs.csv" />
<EmbeddedResource Include="TestSets\WS2\CropData.csv" />
Expand Down
16 changes: 16 additions & 0 deletions TestComponents/TestSets/Losses/FieldConfigs.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
,WeatherStation,SoilCategory,Texture,Rocks,SampleDepth,PMN,Splits,PrePlantRain,InCropRain,Irrigation,PriorCropNameFull,PriorFieldYield,PriorFieldLoss,PriorDressingLoss,PriorMoistureContent,PriorEstablishDate,PriorEstablishStage,PriorHarvestDate,PriorHarvestStage,PriorResidueRemoval,PriorResidueIncorporation,CurrentCropNameFull,CurrentFieldYield,CurrentFieldLoss,CurrentDressingLoss,CurrentMoistureContent,CurrentEstablishDate,CurrentEstablishStage,CurrentHarvestDate,CurrentHarvestStage,CurrentResidueRemoval,CurrentResidueIncorporation,FollowingCropNameFull,FollowingFieldYield,FollowingFieldLoss,FollowingDressingLoss,FollowingMoistureContent,FollowingEstablishDate,FollowingEstablishStage,FollowingHarvestDate,FollowingHarvestStage,FollowingResidueRemoval,FollowingResidueIncorporation
Lauder_Base,lauder,Sedimentary,Silt loam,0,0-30cm,20,3,Typical,Typical,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Lincoln_Base,lincoln,Sedimentary,Silt loam,0,0-30cm,20,3,Typical,Typical,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Levin_Base,levin,Sedimentary,Silt loam,0,0-30cm,20,3,Typical,Typical,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Lauder_Rocks,lauder,Sedimentary,Silt loam,50,0-30cm,20,3,Typical,Typical,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Lincoln_Rocks,lincoln,Sedimentary,Silt loam,50,0-30cm,20,3,Typical,Typical,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Levin_Rocks,levin,Sedimentary,Silt loam,50,0-30cm,20,3,Typical,Typical,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Lauder_VeryDry,lauder,Sedimentary,Silt loam,0,0-30cm,20,3,Typical,Very Dry,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Lincoln_VeryDry,lincoln,Sedimentary,Silt loam,0,0-30cm,20,3,Typical,Very Dry,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Levin_VeryDry,levin,Sedimentary,Silt loam,0,0-30cm,20,3,Typical,Very Dry,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Lauder_VeryWet,lauder,Sedimentary,Silt loam,0,0-30cm,20,3,Typical,Very Wet,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Lincoln_VeryWet,lincoln,Sedimentary,Silt loam,0,0-30cm,20,3,Typical,Very Wet,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Levin_VeryWet,levin,Sedimentary,Silt loam,0,0-30cm,20,3,Typical,Very Wet,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,12,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Lauder_LowYield,lauder,Sedimentary,Silt loam,0,0-30cm,20,1,Typical,Typical,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,6,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Lincoln_LowYield,lincoln,Sedimentary,Silt loam,0,0-30cm,20,1,Typical,Typical,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,6,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Levin_LowYield,levin,Sedimentary,Silt loam,0,0-30cm,20,1,Typical,Typical,Full,Pea Grain General,6,0,0,13,2022-09-27 00:00:00,Seed,2023-01-25 00:00:00,Maturity,All removed,Full (Plough),Wheat Grain Feed,6,0,0,15,2023-04-10 00:00:00,Seed,2024-02-10 00:00:00,Maturity,None removed,Full (Plough),Oat Fodder General,10,0,0,0,2024-03-01 00:00:00,Seed,2024-10-01 00:00:00,EarlyReproductive,None removed,Full (Plough)
Binary file added TestComponents/TestSets/Losses/FieldConfigs.pkl
Binary file not shown.
Binary file added TestComponents/TestSets/Losses/FieldConfigs.xlsx
Binary file not shown.
Loading

0 comments on commit 5d169bb

Please sign in to comment.