-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from Stepania/TestingSystem
Testing system
- Loading branch information
Showing
782 changed files
with
276,185 additions
and
1,148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -350,3 +350,4 @@ MigrationBackup/ | |
|
||
# Ionide (cross platform F# VS Code tools) working folder | ||
.ionide/ | ||
.ipynb_checkpoints/ |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
[*.cs] | ||
|
||
# IDE0005: Using directive is unnecessary. | ||
dotnet_diagnostic.IDE0005.severity = none | ||
csharp_using_directive_placement = outside_namespace:silent | ||
csharp_prefer_simple_using_statement = true:suggestion | ||
csharp_prefer_braces = true:silent | ||
csharp_style_namespace_declarations = block_scoped:silent | ||
csharp_style_prefer_method_group_conversion = true:silent | ||
csharp_style_prefer_top_level_statements = true:silent | ||
csharp_style_prefer_primary_constructors = true:suggestion | ||
csharp_style_expression_bodied_methods = false:silent | ||
csharp_style_expression_bodied_constructors = false:silent | ||
csharp_style_expression_bodied_operators = false:silent | ||
csharp_style_expression_bodied_properties = true:silent | ||
csharp_style_expression_bodied_indexers = true:silent | ||
csharp_style_expression_bodied_accessors = true:silent | ||
csharp_style_expression_bodied_lambdas = true:silent | ||
csharp_style_expression_bodied_local_functions = false:silent | ||
csharp_indent_labels = one_less_than_current | ||
|
||
[*.{cs,vb}] | ||
#### Naming styles #### | ||
|
||
# Naming rules | ||
|
||
dotnet_naming_rule.interface_should_be_begins_with_i.severity = suggestion | ||
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface | ||
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i | ||
|
||
dotnet_naming_rule.types_should_be_pascal_case.severity = suggestion | ||
dotnet_naming_rule.types_should_be_pascal_case.symbols = types | ||
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case | ||
|
||
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = suggestion | ||
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members | ||
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case | ||
|
||
# Symbol specifications | ||
|
||
dotnet_naming_symbols.interface.applicable_kinds = interface | ||
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||
dotnet_naming_symbols.interface.required_modifiers = | ||
|
||
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum | ||
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||
dotnet_naming_symbols.types.required_modifiers = | ||
|
||
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method | ||
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected | ||
dotnet_naming_symbols.non_field_members.required_modifiers = | ||
|
||
# Naming styles | ||
|
||
dotnet_naming_style.begins_with_i.required_prefix = I | ||
dotnet_naming_style.begins_with_i.required_suffix = | ||
dotnet_naming_style.begins_with_i.word_separator = | ||
dotnet_naming_style.begins_with_i.capitalization = pascal_case | ||
|
||
dotnet_naming_style.pascal_case.required_prefix = | ||
dotnet_naming_style.pascal_case.required_suffix = | ||
dotnet_naming_style.pascal_case.word_separator = | ||
dotnet_naming_style.pascal_case.capitalization = pascal_case | ||
|
||
dotnet_naming_style.pascal_case.required_prefix = | ||
dotnet_naming_style.pascal_case.required_suffix = | ||
dotnet_naming_style.pascal_case.word_separator = | ||
dotnet_naming_style.pascal_case.capitalization = pascal_case | ||
dotnet_style_coalesce_expression = true:suggestion | ||
dotnet_style_null_propagation = true:suggestion | ||
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion | ||
dotnet_style_prefer_auto_properties = true:silent | ||
dotnet_style_object_initializer = true:suggestion | ||
dotnet_style_operator_placement_when_wrapping = beginning_of_line | ||
tab_width = 4 | ||
indent_size = 4 | ||
end_of_line = crlf | ||
dotnet_style_collection_initializer = true:suggestion |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
using System.Linq; | ||
using System.Diagnostics; | ||
using SVSModel.Configuration; | ||
using SVSModel; | ||
using System.ComponentModel; | ||
using SVSModel.Models; | ||
using System.Text.Json; | ||
using Microsoft.Data.Analysis; | ||
using System.Xml.Linq; | ||
using System.Reflection; | ||
using System.Data; | ||
using System; | ||
using static System.Net.Mime.MediaTypeNames; | ||
using System.Text.Json.Serialization; | ||
//using ServiceStack; | ||
//using ServiceStack.Text; | ||
using System.Collections.Generic; | ||
//using Nancy.Routing.Constraints; | ||
using IronPython.Hosting; | ||
using Microsoft.Scripting.Hosting; | ||
using Microsoft.Scripting; | ||
|
||
namespace TestModel | ||
{ | ||
public class Test | ||
{ | ||
private static void runPythonScript() | ||
{ | ||
////just checking | ||
string progToRun = @"C:\Users\1989s\source\repos\SVS\modelCsharp\TestModel\testGraph\testGraph\testGraph.py"; | ||
Process proc = new Process(); | ||
proc.StartInfo.FileName = "python.exe"; | ||
proc.StartInfo.RedirectStandardOutput = true; | ||
proc.StartInfo.UseShellExecute = false; | ||
proc.StartInfo.Arguments =progToRun; | ||
proc.Start(); | ||
StreamReader sReader = proc.StandardOutput; | ||
proc.WaitForExit(); | ||
Console.ReadLine(); | ||
|
||
} | ||
public static void RunTests(Dictionary<string, object> _configDict) | ||
|
||
{ | ||
|
||
//DataFrame testConfigs = Crop.LoadCoefficients("SVSModel.Data.TestConfig.csv"); | ||
|
||
string resourceName = "TestModel.TestConfig.csv"; | ||
var assembly = Assembly.GetExecutingAssembly(); | ||
Stream csv = assembly.GetManifestResourceStream(resourceName); | ||
DataFrame allTests = DataFrame.LoadCsv(csv); | ||
|
||
List<string> Tests = new List<string>(); | ||
|
||
foreach (DataFrameRow row in allTests.Rows) | ||
{ | ||
Tests.Add(row[0].ToString()); | ||
} | ||
|
||
foreach (string test in Tests) | ||
{ | ||
int testRow = getTestRow(test, allTests); | ||
|
||
SVSModel.Configuration.Config _config = SetConfigFromDataFrame(test, allTests); | ||
|
||
Dictionary<DateTime, double> testResults = new Dictionary<DateTime, double>(); | ||
Dictionary<DateTime, double> nApplied = new Dictionary<DateTime, double>(); | ||
|
||
string weatherStation = allTests["WeatherStation"][testRow].ToString(); | ||
|
||
MetDataDictionaries metData = ModelInterface.BuildMetDataDictionaries(_config.Prior.EstablishDate, _config.Following.HarvestDate.AddDays(1), weatherStation); | ||
|
||
object[,] output = Simulation.SimulateField(metData.MeanT, metData.Rain, metData.MeanPET, testResults, nApplied, _config); | ||
|
||
DataFrameColumn[] columns = new DataFrameColumn[13]; | ||
List<string> OutPutHeaders = new List<string>(); | ||
for (int i = 0; i< output.GetLength(1); i +=1) | ||
{ | ||
OutPutHeaders.Add(output[0, i].ToString()); | ||
if (i == 0) | ||
{ | ||
columns[i] = new PrimitiveDataFrameColumn<DateTime>(output[0, i].ToString()); | ||
} | ||
else | ||
{ | ||
columns[i] = new PrimitiveDataFrameColumn<double>(output[0, i].ToString()); | ||
} | ||
} | ||
|
||
var newDataframe= new DataFrame(columns); | ||
|
||
for (int r = 1; r < output.GetLength(0); r += 1) | ||
{ | ||
List<KeyValuePair<string, object>> nextRow = new List<KeyValuePair<string, object>>(); | ||
for (int c = 0; c < output.GetLength(1); c += 1) | ||
{ | ||
nextRow.Add(new KeyValuePair<string, object>(OutPutHeaders[c], output[r, c])); | ||
} | ||
newDataframe.Append(nextRow, true); | ||
} | ||
|
||
DataFrame.SaveCsv(newDataframe, @"C:\Users\1989s\source\repos\svs\modelCsharp\TestModel\testGraph\OutputFiles\" + test + ".csv"); | ||
|
||
} | ||
runPythonScript(); | ||
|
||
} | ||
|
||
public static SVSModel.Configuration.Config SetConfigFromDataFrame(string test, DataFrame allTests) | ||
{ | ||
int testRow = getTestRow(test, allTests); | ||
|
||
|
||
List<string> coeffs = new List<string> { "InitialN", | ||
"SoilOrder", | ||
"SampleDepth", | ||
"BulkDensity", | ||
"PMNtype", | ||
"PMN", | ||
"Trigger", | ||
"Efficiency", | ||
"Splits", | ||
"AWC", | ||
"PrePlantRain", | ||
"InCropRain", | ||
"Irrigation", | ||
"PriorCropNameFull", | ||
"PriorSaleableYield", | ||
"PriorFieldLoss", | ||
"PriorDressingLoss", | ||
"PriorMoistureContent", | ||
"PriorEstablishDate", | ||
"PriorEstablishStage", | ||
"PriorHarvestDate", | ||
"PriorHarvestStage", | ||
"PriorResidueRemoval", | ||
"PriorResidueIncorporation", | ||
"CurrentCropNameFull", | ||
"CurrentSaleableYield", | ||
"CurrentFieldLoss", | ||
"CurrentDressingLoss", | ||
"CurrentMoistureContent", | ||
"CurrentEstablishDate", | ||
"CurrentEstablishStage", | ||
"CurrentHarvestDate", | ||
"CurrentHarvestStage", | ||
"CurrentResidueRemoval", | ||
"CurrentResidueIncorporation", | ||
"FollowingCropNameFull", | ||
"FollowingSaleableYield", | ||
"FollowingFieldLoss", | ||
"FollowingDressingLoss", | ||
"FollowingMoistureContent", | ||
"FollowingEstablishDate", | ||
"FollowingEstablishStage", | ||
"FollowingHarvestDate", | ||
"FollowingHarvestStage", | ||
"FollowingResidueRemoval", | ||
"FollowingResidueIncorporation" | ||
}; | ||
|
||
Dictionary<string, object> testConfigDict = new Dictionary<string, object>(); | ||
foreach (string c in coeffs) | ||
{ | ||
testConfigDict.Add(c, allTests[c][testRow]); | ||
} | ||
|
||
List<string> datesNames = new List<string>(){ "PriorEstablishDate", "PriorHarvestDate", "CurrentEstablishDate", "CurrentHarvestDate", "FollowingEstablishDate", "FollowingHarvestDate" }; | ||
|
||
foreach (string dN in datesNames) | ||
{ | ||
float year = (float)allTests[dN.Replace("Date", "") + "Year"][testRow]; | ||
float month = (float)allTests[dN.Replace("Date", "") + "Month"][testRow]; | ||
float day = (float)allTests[dN.Replace("Date", "") + "Day"][testRow]; | ||
|
||
testConfigDict[dN] = new DateTime((int)year, (int)month, (int)day); | ||
} | ||
|
||
SVSModel.Configuration.Config ret = new SVSModel.Configuration.Config(testConfigDict); | ||
|
||
return ret; | ||
} | ||
|
||
private static int getTestRow(string test, DataFrame allTests) | ||
{ | ||
int testRow = 0; | ||
bool testNotFound = true; | ||
while (testNotFound) | ||
{ | ||
if (allTests[testRow, 0].ToString() == test) | ||
testNotFound = false; | ||
else | ||
testRow += 1; | ||
} | ||
return testRow; | ||
} | ||
|
||
} | ||
} | ||
|
Oops, something went wrong.