Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mass balance bug if test and fert event added on the same day #66

Merged
merged 2 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions SVSModel/Models/SoilNitrogen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,25 @@ public static void TestsAndActualFertiliser(Dictionary<DateTime, double> testRes
{
List<DateTime> UpdateDates = testResults.Keys.ToList();
UpdateDates.AddRange(nApplied.Keys.ToList());
UpdateDates = UpdateDates.Distinct().ToList();
UpdateDates.Sort((a, b) => a.CompareTo(b));


foreach (DateTime d in UpdateDates)
{
if (nApplied.ContainsKey(d))
{
SoilNitrogen.UpdateBalance(d, nApplied[d], thisSim.SoilN[d], thisSim.NLost[d], ref thisSim, true, nApplied, true);
thisSim.NFertiliser[d] = nApplied[d];
}
if (testResults.ContainsKey(d))
{
double dCorrection = testResults[d] - thisSim.SoilN[d];
SoilNitrogen.UpdateBalance(d, dCorrection, thisSim.SoilN[d], thisSim.NLost[d], ref thisSim, true, nApplied, true);
}
if (nApplied.ContainsKey(d))
{
if (!testResults.ContainsKey(d)) // Dont after fertiliser if soil test was entered on the same day
{
SoilNitrogen.UpdateBalance(d, nApplied[d], thisSim.SoilN[d], thisSim.NLost[d], ref thisSim, true, nApplied, true);
}
thisSim.NFertiliser[d] = nApplied[d];
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion SVSModel/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ $ dotnet pack SVSModel/SVSModel.csproj
```

```bash
$ dotnet nuget push SVSModel/bin/Release/SVSModel.1.2.0.nupkg --source "https://pkgs.dev.azure.com/rezaresystems/48ae16c6-5f20-44a0-ad41-e047c311de0a/_packaging/svs-model-calculator/nuget/v3/index.json" --api-key az --interactive
$ dotnet nuget push SVSModel/bin/Release/SVSModel.1.2.1.nupkg --source "https://pkgs.dev.azure.com/rezaresystems/48ae16c6-5f20-44a0-ad41-e047c311de0a/_packaging/svs-model-calculator/nuget/v3/index.json" --api-key az --interactive
```
2 changes: 1 addition & 1 deletion SVSModel/SVSModel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<id>SVSModel</id>
<version>1.2.0</version>
<version>1.2.1</version>
<authors>PotatoesNZ</authors>
<description>A wrapper of the SVS Model code</description>
<LangVersion>12</LangVersion>
Expand Down
Loading