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

Ws1 tests #7

Closed
Closed
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
3 changes: 3 additions & 0 deletions SVSModel/Data/CropCoefficientTableFull.csv
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,6 @@ TestResidue10,24,Grain,Cereal,Wheat,Feed,Poaceae ,Triticum,astevium,,Triticum as
TestResidue15,24,Grain,Cereal,Wheat,Feed,Poaceae ,Triticum,astevium,,Triticum astevium ,astevium ,Seed,Apr,Maturity,Feb,12,t/ha,Saleable grain ,50000,Total,0,0,0.5,0,15,0.1,1.5,1,1,1.5,1.5,1.5
TestResidue30,24,Grain,Cereal,Wheat,Feed,Poaceae ,Triticum,astevium,,Triticum astevium ,astevium ,Seed,Apr,Maturity,Feb,12,t/ha,Saleable grain ,50000,Total,0,0,0.5,0,15,0.1,1.5,1,1,3,3,3
TestResidue45,24,Grain,Cereal,Wheat,Feed,Poaceae ,Triticum,astevium,,Triticum astevium ,astevium ,Seed,Apr,Maturity,Feb,12,t/ha,Saleable grain ,50000,Total,0,0,0.5,0,15,0.1,1.5,1,1,4.5,4.5,4.5
Parsley Vegetable General,76,Vegetable,Green,Parsley,General,Apiaceae,Petroselinum,crispum,,Petroselinum crispum,crispum,Seed,May,Vegetative,Sep,10,t/ha,Saleable product ,50000,Total,0,0,0.7,0,92,0.1,1.5,0.8,1,0.8,4,4.5
Pumpkin Seed General,77,Seed,Fruit,Pumpkin,General,Cucurbitaceae,Cucurbita,pepo,,Cucurbita pepo ,pepo ,Seed,Oct,LateReproductive,Mar,40,t/ha,Saleable product ,50000,Total,0,0,0.8,0,88,0.1,0.8,1,1,1,1.4,2
Tall fescue Seed Turf,78,Seed,Forage,Tall fescue,Turf,Tall fescue Seed Turf,Poaceae,Festuca,arundinacea,x,Festuca arundinacea,Seed,May,LateReproductive,Jan,1.8,t/ha,Saleable seed,1000000,Total,15,5,0.15,0.04,15,0.1,0.6,1,0.7,0.9,1.2,2
29 changes: 20 additions & 9 deletions TestComponents/Test.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,17 @@
{
public static void RunAllTests()
{
string path = Path.Join(Directory.GetCurrentDirectory(), "TestComponents", "TestSets");
string fullroot = AppDomain.CurrentDomain.BaseDirectory;
List<string> rootFrags = fullroot.Split('\\').ToList();
string root = "";
foreach (string d in rootFrags)
{
if (d == "FieldNBalance")
break;
else
root += d + "\\";
}
string path = Path.Join(root, "FieldNBalance", "TestComponents", "TestSets");
List<string> sets = new List<string> { "WS2", "Residues", "Location", "Moisture" };

//Delete graphs from previous test run
Expand All @@ -31,15 +41,14 @@
foreach (string graphPath in graphPaths)
File.Delete(graphPath);

string basePath = Directory.GetCurrentDirectory();
foreach (string s in sets)
{
//Make config file in format that .NET DataTable is able to import
runPythonScript(basePath, Path.Join("TestGraphs", "MakeConfigs", $"{s}.py"));
runPythonScript(root, Path.Join("FieldNBalance","TestGraphs", "MakeConfigs", $"{s}.py"));
//Run each test
runTestSet(path, s);
//Make graphs associated with each test
runPythonScript(basePath, Path.Join("TestGraphs", "MakeGraphs", $"{s}.py"));
runPythonScript(root, Path.Join("FieldNBalance", "TestGraphs", "MakeGraphs", $"{s}.py"));
}
}

Expand All @@ -57,11 +66,11 @@

var assembly = Assembly.GetExecutingAssembly();
string testConfig = "TestComponents.TestSets." + set + ".FieldConfigs.csv";
Stream configcsv = assembly.GetManifestResourceStream(testConfig);

Check warning on line 69 in TestComponents/Test.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.
DataFrame allTests = DataFrame.LoadCsv(configcsv);

string fertData = "TestComponents.TestSets." + set + ".FertiliserData.csv";
Stream fertcsv = assembly.GetManifestResourceStream(fertData);

Check warning on line 73 in TestComponents/Test.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.
DataFrame allFert = new DataFrame();
if (fertcsv != null)
{
Expand All @@ -72,7 +81,7 @@

foreach (DataFrameRow row in allTests.Rows)
{
Tests.Add(row[0].ToString());

Check warning on line 84 in TestComponents/Test.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'item' in 'void List<string>.Add(string item)'.
}

foreach (string test in Tests)
Expand All @@ -84,7 +93,7 @@
Dictionary<System.DateTime, double> testResults = new Dictionary<System.DateTime, double>();
Dictionary<System.DateTime, double> nApplied = fertDict(test, allFert);

string weatherStation = allTests["WeatherStation"][testRow].ToString();

Check warning on line 96 in TestComponents/Test.cs

View workflow job for this annotation

GitHub Actions / build

Converting null literal or possible null value to non-nullable type.

MetDataDictionaries metData = ModelInterface.BuildMetDataDictionaries(_config.Prior.EstablishDate, _config.Following.HarvestDate.AddDays(1), weatherStation);

Expand All @@ -94,7 +103,7 @@
List<string> OutPutHeaders = new List<string>();
for (int i = 0; i < output.GetLength(1); i += 1)
{
OutPutHeaders.Add(output[0, i].ToString());

Check warning on line 106 in TestComponents/Test.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'item' in 'void List<string>.Add(string item)'.
if (i == 0)
{
columns[i] = new PrimitiveDataFrameColumn<System.DateTime>(output[0, i].ToString());
Expand Down Expand Up @@ -132,10 +141,10 @@

private static void runPythonScript(string path, string pyProg)
{
string newPath = Path.GetFullPath(Path.Combine(path, @"..\..\"));
string progToRun = pyProg;
string progToRun = Path.Join(path,pyProg);

Process proc = new Process();
//proc.StartInfo.FileName = "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\Python39_64\\python.exe";
proc.StartInfo.FileName = "python";
proc.StartInfo.RedirectStandardOutput = true;
proc.StartInfo.UseShellExecute = false;
Expand Down Expand Up @@ -232,9 +241,11 @@
{
if (row[0].ToString() == site) //if this date row holds data for current site
{
DateTime date = DateTime.ParseExact(
row[1].ToString(), "d/M/yyyy", CultureInfo.InvariantCulture
);

//DateTime date = DateTime.ParseExact(
// row[1].ToString(), "d/M/yyyy", CultureInfo.InvariantCulture);
DateTime date = (DateTime)row[1];

DateTime last = new DateTime();
if (fert.Keys.Count > 0)
{
Expand All @@ -242,11 +253,11 @@
}
if (date == last) //If alread fertiliser added for that date add it to existing total
{
fert[last] += Double.Parse(row[2].ToString());

Check warning on line 256 in TestComponents/Test.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 's' in 'double double.Parse(string s)'.
}
else //add it to a new date
{
fert.Add(date, Double.Parse(row[2].ToString()));

Check warning on line 260 in TestComponents/Test.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 's' in 'double double.Parse(string s)'.
}
}
}
Expand Down
502 changes: 251 additions & 251 deletions TestComponents/TestSets/Location/Outputs/ashburton_Aut.csv

Large diffs are not rendered by default.

424 changes: 212 additions & 212 deletions TestComponents/TestSets/Location/Outputs/ashburton_Spr.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Location/Outputs/blenheim_Aut.csv

Large diffs are not rendered by default.

424 changes: 212 additions & 212 deletions TestComponents/TestSets/Location/Outputs/blenheim_Spr.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Location/Outputs/hastings_Aut.csv

Large diffs are not rendered by default.

424 changes: 212 additions & 212 deletions TestComponents/TestSets/Location/Outputs/hastings_Spr.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Location/Outputs/invercargill_Aut.csv

Large diffs are not rendered by default.

424 changes: 212 additions & 212 deletions TestComponents/TestSets/Location/Outputs/invercargill_Spr.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Location/Outputs/kerikeri_Aut.csv

Large diffs are not rendered by default.

424 changes: 212 additions & 212 deletions TestComponents/TestSets/Location/Outputs/kerikeri_Spr.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Location/Outputs/levin_Aut.csv

Large diffs are not rendered by default.

424 changes: 212 additions & 212 deletions TestComponents/TestSets/Location/Outputs/levin_Spr.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/Dry_Full.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/Dry_None.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/Dry_Some.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/Typical_Full.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/Typical_None.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/Typical_Some.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/VeryDry_Full.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/VeryDry_None.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/VeryDry_Some.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/VeryWet_Full.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/VeryWet_None.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/VeryWet_Some.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/Wet_Full.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/Wet_None.csv

Large diffs are not rendered by default.

828 changes: 414 additions & 414 deletions TestComponents/TestSets/Moisture/Outputs/Wet_Some.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN0.5High.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN0.5Low.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN1.0High.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN1.0Low.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN1.5High.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN1.5Low.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN3.0High.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN3.0Low.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN4.5High.csv

Large diffs are not rendered by default.

502 changes: 251 additions & 251 deletions TestComponents/TestSets/Residues/Outputs/StovN4.5Low.csv

Large diffs are not rendered by default.

Binary file added TestComponents/TestSets/WS1/FieldConfigs.xlsx
Binary file not shown.
Loading
Loading