Skip to content

Commit 70724d0

Browse files
Merge pull request #45 from HamishBrownPFR/CropStageTests
put regional date setting back in workflow
2 parents b72b1d1 + edac1b4 commit 70724d0

File tree

231 files changed

+58447
-58182
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+58447
-58182
lines changed

Brians.xlsm

602 KB
Binary file not shown.

Darians.xlsm

636 KB
Binary file not shown.

Geralds.xlsm

600 KB
Binary file not shown.

Prototype_V3.4.xlsm

17 Bytes
Binary file not shown.

Prototype_V3.5.xlsm

582 KB
Binary file not shown.

SVSModel.Excel/ExcelInterface.cs

+10-16
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
using SVSModel.Models;
1111
using static SVSModel.Configuration.Constants;
1212
using static SVSModel.Configuration.InputCategories;
13+
using System.Runtime.InteropServices.ComTypes;
14+
using SVSModel;
1315

1416
namespace SVSModel.Excel
1517
{
@@ -63,31 +65,23 @@ public static class MyFunctions //: IMyFunctions
6365
/// <param name="testResults">2D array with dates in teh first column and soil N test results in the second</param>
6466
/// <returns>Dictionary with parameter names as keys and parameter values as values</returns>
6567
[ExcelFunction(Description = "Returns full N balance results")]
66-
public static object[,] GetDailyNBalance(object[,] met, object[,] config, object[,] testResults, object[,] nApplied)
68+
public static object[,] GetDailyNBalance(object[,] config, object[,] testResults, object[,] nApplied)
6769
{
6870
List<string> configErrors = Functions.ValidateConfig(config);
6971

70-
for (var r = 0; r < met.GetLength(0); r++)
72+
if (configErrors.Count == 0)
7173
{
72-
for (var c = 0; c < met.GetLength(1); c++)
73-
{
74-
if (met[r, c].GetType() == typeof(ExcelDna.Integration.ExcelEmpty) ||
75-
met[r, c].GetType() == typeof(ExcelDna.Integration.ExcelError))
76-
met[r, c] = null;
77-
}
78-
}
74+
var _config = new Config(Functions.dictMaker(config));
7975

76+
var startDate = _config.Prior.EstablishDate.AddDays(-1);
77+
var endDate = _config.Following.HarvestDate.AddDays(2);
78+
var weatherStation = _config.Field.WeatherStation;
79+
MetDataDictionaries metData = ModelInterface.BuildMetDataDictionaries(startDate, endDate, weatherStation, false);
8080

81-
if (configErrors.Count == 0)
82-
{
83-
Dictionary<DateTime, double> _tt = Functions.dictMaker(met, "MeanT");
84-
Dictionary<DateTime, double> _rain = Functions.dictMaker(met, "Rain");
85-
Dictionary<DateTime, double> _pet = Functions.dictMaker(met, "MeanPET");
8681
Dictionary<DateTime, double> _testResults = Functions.dictMaker(testResults, "Value");
8782
Dictionary<DateTime, double> _nApplied = Functions.dictMaker(nApplied, "Amount");
88-
var _config = new Config(Functions.dictMaker(config));
8983

90-
return Simulation.Simulation.SimulateField(_tt, _rain, _pet, _testResults, _nApplied, _config, Constants.InitialN);
84+
return Simulation.Simulation.SimulateField(metData.MeanT, metData.Rain, metData.MeanPET, _testResults, _nApplied, _config, Constants.InitialN);
9185
}
9286
else
9387
{

SVSModel/Data/CropCoefficientTableFull.csv

+23-23
Large diffs are not rendered by default.

SVSModel/Data/CropCoefficients.ipynb

+293-25
Large diffs are not rendered by default.
75.1 KB
Binary file not shown.

TestComponents/Test.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,9 @@ public static void runTestSet(string path, string set)
158158
{
159159
System.IO.Directory.CreateDirectory("OutputFiles");
160160
}
161-
161+
CultureInfo cult = new CultureInfo("en-NZ");
162162
DataFrame.SaveCsv(
163-
newDataframe, Path.Join(path, set, "Outputs", $"{test}.csv")
163+
newDataframe, Path.Join(path, set, "Outputs", $"{test}.csv"), cultureInfo: cult
164164
);
165165
}
166166
}

TestComponents/TestSets/CropStage/Outputs/Onion.csv

+362-362
Large diffs are not rendered by default.

TestComponents/TestSets/Location/Outputs/ashburton_Aut.csv

+31-31
Original file line numberDiff line numberDiff line change
@@ -218,34 +218,34 @@ Date,SoilMineralN,UptakeN,ResidueN,SoilOMN,FertiliserN,CropN,ProductN,LostN,RSWC
218218
29/08/2023 12:00:00 am,198.62619241421351,0,2.8057384024105403,0.50122957844414873,0,0,0,0,0.96675206611570252,0,0,0,0
219219
30/08/2023 12:00:00 am,201.74336498286061,0,2.6115086858255694,0.50566388282151364,0,0,0,0,0.98806338592536946,0,0,0,0
220220
31/08/2023 12:00:00 am,204.62695366417989,0,2.3872335557685034,0.49635512555077665,0,0,0,0,0.98409224836645959,0,0,0,0
221-
1/09/2023 12:00:00 am,207.34783723028369,0,2.2209014587173925,0.4999821073864007,0,1.531620091597147,1.4011487504610938,0,0.97393944036503077,0,0,0.010258361860937579,1.531620091597147
222-
2/09/2023 12:00:00 am,209.6951416913769,0.30335637448296215,2.1245951574914557,0.5260656780847297,0,1.8349764660801091,1.6786636560066184,0,0.97357814418361355,0,0,0.016085510208408746,1.8349764660801091
223-
3/09/2023 12:00:00 am,211.81792361880906,0.36213210288701014,1.9595993623894543,0.5253146679297056,0,2.1971085689671193,2.0099474686476984,0,0.97007724119139671,0,0,0.025121219147158948,2.1971085689671193
224-
4/09/2023 12:00:00 am,213.66772069815866,0.40964137030417769,1.7572719484566335,0.50216650119712725,0,2.6067499392712969,2.3846934629630017,0,0.97752880445414525,0,0,0.038205599944195527,2.6067499392712969
225-
5/09/2023 12:00:00 am,214.89908510915976,0.48113606510622686,1.62006149593212,0.4990996980511076,0,3.0878860043775238,2.8248438632638835,0.40666071787588326,1,0.32866843383935418,0,0.057538948741887454,3.0878860043775238
226-
6/09/2023 12:00:00 am,216.33066663702968,0.56889007802553682,1.5009048755458991,0.49956673034957039,0,3.6567760824030606,3.3452729346428001,0,0.98196969696969683,0,0,0.085818897964455659,3.6567760824030606
227-
7/09/2023 12:00:00 am,217.54317934974611,0.66598396236142987,1.3839645116672159,0.49453216341064271,0,4.3227600447644905,3.9545249298401086,0,0.95759885595276351,0,0,0.125791373849202,4.3227600447644905
228-
8/09/2023 12:00:00 am,218.52564393422867,0.78844602723241586,1.2857061205546785,0.48520449116028891,0,5.1112060719969064,4.6758070362342066,0,0.93870374683335445,0,0,0.18103290036840899,5.1112060719969064
229-
9/09/2023 12:00:00 am,219.26393672530907,0.90499809509752716,1.1756699498461245,0.46762093633182233,0,6.0162041670944335,5.5037127010086122,0,0.92518827504107304,0,0,0.25166847428831168,6.0162041670944335
230-
10/09/2023 12:00:00 am,219.76153437768667,1.0104991605906211,1.0646491825999647,0.44344763036826956,0,7.0267033276850546,6.4281323034748459,0,0.91260676958523068,0,0,0.33447271234251963,7.0267033276850546
231-
11/09/2023 12:00:00 am,219.99803892422287,1.2377563613006553,1.016179906418671,0.45808100141819025,0,8.2644596889857098,7.5604501599239642,0,0.90448377648059342,0,0,0.43396261330265906,8.2644596889857098
232-
12/09/2023 12:00:00 am,219.9041739833653,1.5310841727260343,0.97152123077857766,0.46569800108990439,0,9.7955438617117441,8.9611086438622252,0,0.87989198298073545,0,0,0.5448855398281659,9.7955438617117441
233-
13/09/2023 12:00:00 am,219.40534696508192,1.9160983943121064,0.93127818883651514,0.48599318719219592,0,11.71164225602385,10.71398384162182,0,0.8705941417351829,0,0,0.65767925708595032,11.71164225602385
234-
14/09/2023 12:00:00 am,218.45382559157295,2.3152991885492167,0.87056612312650827,0.49321169191373249,0,14.026941444573067,12.832053840035364,0,0.86634800615117202,0,0,0.75696597122082054,14.026941444573067
235-
15/09/2023 12:00:00 am,216.99161248848614,2.7462211002255099,0.80491645334143413,0.4790915437972656,0,16.773162544798577,15.344337587278696,0,0.83987697873723255,0,0,0.83504364221007077,16.773162544798577
236-
16/09/2023 12:00:00 am,214.81480061565557,3.4410232689718612,0.77156150959230274,0.49264988654897568,0,20.214185813770438,18.492236651856661,0,0.81609727784982755,0,0,0.89450886701683885,20.214185813770438
237-
17/09/2023 12:00:00 am,211.85950157394896,4.1575854958775302,0.72055886578016271,0.4817275883907432,0,24.371771309647968,22.295657457344625,0,0.78024075458446884,0,0,0.93500161371223844,24.371771309647968
238-
18/09/2023 12:00:00 am,208.46798265881893,4.4711130763905587,0.62716586901780147,0.4524282922427203,0,28.842884386038527,26.38589793833895,0,0.79177982843468131,0,0,0.95908614661236447,28.842884386038527
239-
19/09/2023 12:00:00 am,204.75891680746855,4.6770722650511942,0.54840987425940568,0.41959653944143926,0,33.519956651089721,30.664552936367262,0,0.79557522876854714,0,0,0.97346831189048688,33.519956651089721
240-
20/09/2023 12:00:00 am,200.38898008571692,5.2964884698029167,0.51011022111725879,0.41644152693403191,0,38.816445120892638,35.509859055038817,0,0.78477710588882987,0,0,0.98293960846111894,38.816445120892638
241-
21/09/2023 12:00:00 am,195.30635964861116,5.9662531161280512,0.47551254214367589,0.40812013687862153,0,44.782698237020689,40.967875794607806,0,0.76182130274563953,0,0,0.98912092956833275,44.782698237020689
242-
22/09/2023 12:00:00 am,189.27711407983372,6.8934908031273423,0.45258114321346454,0.4116640911364331,0,51.676189040148031,47.274143307098377,0,0.73672116380327135,0,0,0.99322071672438417,51.676189040148031
243-
23/09/2023 12:00:00 am,182.34412743118867,7.7706482315267991,0.42641504546821807,0.4112465374135289,0,59.446837271674831,54.382847430013641,0,0.71418520387180129,0,0,0.99584305660979977,59.446837271674831
244-
24/09/2023 12:00:00 am,174.1317209916655,9.0626078959253604,0.41422291635062436,0.43597854005160502,0,68.509445167600191,62.673455394063872,0,0.70163490562644604,0,0,0.99755040118444593,68.509445167600191
245-
25/09/2023 12:00:00 am,165.52494085152989,9.4085782113885443,0.37491939395735585,0.42687867729557322,0,77.918023378988735,71.280562128185991,0,0.70331477395222497,0,0,0.99853986019503005,77.918023378988735
246-
26/09/2023 12:00:00 am,156.87321932295907,9.5195003846193202,0.33913171512247686,0.52864714092604592,0,87.437523763608056,79.989142109671079,0,0.88832429331162233,0,13.200000000000005,0.99911764267161374,87.437523763608056
247-
27/09/2023 12:00:00 am,147.82083120637975,9.9034509174254453,0.31751756215886928,0.53354523868724013,0,97.340974681033501,89.048965726723253,0,0.8795385566110252,0,0,0.99947251374544777,97.340974681033501
248-
28/09/2023 12:00:00 am,139.07419125194949,9.5351913341950478,0.28606900629588949,0.50248237346888569,0,106.87616601522855,97.771900021338723,0,0.86044905417859741,0,0,0.99967887560410063,106.87616601522855
249-
29/09/2023 12:00:00 am,130.53991950290418,9.2814414889409278,0.26372864945875563,0.48344109043688954,0,116.15760750416948,106.26270019825874,0,0.83469243172098284,0,0,0.99980397435547286,116.15760750416948
250-
30/09/2023 12:00:00 am,121.65290876518293,9.650914363711081,0.25807973539345141,0.50582389059634913,0,125.80852186788056,115.09149963469073,0,0.80726905146127337,0,0,0.99988525861264388,125.80852186788056
251-
1/10/2023 12:00:00 am,113.20314500801096,9.1914781321194425,0.24100812480745049,0.50070625014003045,0,135,123.5,0,0.78620895067215124,0,0,0.99993345063478134,135
221+
1/09/2023 12:00:00 am,207.34783723028369,0,2.2209014587173925,0.4999821073864007,0,1.7471814378219308,1.6167100966858776,0,0.97393944036503077,0,0,0.010258361860937579,1.7471814378219308
222+
2/09/2023 12:00:00 am,209.65244709052376,0.34605097533611962,2.1245951574914557,0.5260656780847297,0,2.0932324131580504,1.9369196030845597,0,0.97357814418361355,0,0,0.016085510208408746,2.0932324131580504
223+
3/09/2023 12:00:00 am,211.72426227754957,0.41309884329333002,1.9595993623894543,0.5253146679297056,0,2.5063312564513804,2.3191701561319595,0,0.97007724119139671,0,0,0.025121219147158948,2.5063312564513804
224+
4/09/2023 12:00:00 am,213.5164061270045,0.46729460019883984,1.7572719484566335,0.50216650119712725,0,2.9736258566502203,2.7515693803419246,0,0.97752880445414525,0,0,0.038205599944195527,2.9736258566502203
225+
5/09/2023 12:00:00 am,214.68046878677563,0.54885151130636256,1.62006149593212,0.4990996980511076,0,3.5224773679565828,3.2594352268429421,0.40624702290573039,1,0.32866843383935418,0,0.057538948741887454,3.5224773679565828
226+
6/09/2023 12:00:00 am,216.03198430366419,0.64895608900690949,1.5009048755458991,0.49956673034957039,0,4.1714334569634923,3.8599303092032313,0,0.98196969696969683,0,0,0.085818897964455659,4.1714334569634923
227+
7/09/2023 12:00:00 am,217.15076594019641,0.75971503854563061,1.3839645116672159,0.49453216341064271,0,4.9311484955091229,4.5629133805847406,0,0.95759885595276351,0,0,0.125791373849202,4.9311484955091229
228+
8/09/2023 12:00:00 am,218.02226404677219,0.89941250513919968,1.2857061205546785,0.48520449116028891,0,5.8305610006483226,5.3951619648856228,0,0.93870374683335445,0,0,0.18103290036840899,5.8305610006483226
229+
9/09/2023 12:00:00 am,218.63318673557964,1.0323681973705128,1.1756699498461245,0.46762093633182233,0,6.8629291980188354,6.3504377319330132,0,0.92518827504107304,0,0,0.25166847428831168,6.8629291980188354
230+
10/09/2023 12:00:00 am,218.98856598757783,1.152717560970042,1.0646491825999647,0.44344763036826956,0,8.0156467589888774,7.4170757347786687,0,0.91260676958523068,0,0,0.33447271234251963,8.0156467589888774
231+
11/09/2023 12:00:00 am,219.05086778696801,1.4119591084466716,1.016179906418671,0.45808100141819025,0,9.427605867435549,8.7235963383738042,0,0.90448377648059342,0,0,0.43396261330265906,9.427605867435549
232+
12/09/2023 12:00:00 am,218.74151692550458,1.7465700933319219,0.97152123077857766,0.46569800108990439,0,11.174175960767471,10.339740742917952,0,0.87989198298073545,0,0,0.5448855398281659,11.174175960767471
233+
13/09/2023 12:00:00 am,217.97301679987359,2.1857715016597385,0.93127818883651514,0.48599318719219592,0,13.359947462427209,12.362289048025177,0,0.8705941417351829,0,0,0.65767925708595032,13.359947462427209
234+
14/09/2023 12:00:00 am,216.69563850353177,2.6411561113820685,0.87056612312650827,0.49321169191373249,0,16.001103573809278,14.806215969271573,0,0.86634800615117202,0,0,0.75696597122082054,16.001103573809278
235+
15/09/2023 12:00:00 am,214.84692020856136,3.1327262921090977,0.80491645334143413,0.4790915437972656,0,19.133829865918376,17.705004908398497,0,0.83987697873723255,0,0,0.83504364221007077,19.133829865918376
236+
16/09/2023 12:00:00 am,212.18581617194954,3.9253154327530879,0.77156150959230274,0.49264988654897568,0,23.059145298671464,21.337196136757687,0,0.81609727784982755,0,0,0.89450886701683885,23.059145298671464
237+
17/09/2023 12:00:00 am,208.64537546786016,4.7427271582602941,0.72055886578016271,0.4817275883907432,0,27.801872456931758,25.725758604628414,0,0.78024075458446884,0,0,0.93500161371223844,27.801872456931758
238+
18/09/2023 12:00:00 am,204.62458878642332,5.1003808426973798,0.62716586901780147,0.4524282922427203,0,32.902253299629137,30.445266851929556,0,0.79177982843468131,0,0,0.95908614661236447,32.902253299629137
239+
19/09/2023 12:00:00 am,200.25726831999168,5.3353268801324631,0.54840987425940568,0.41959653944143926,0,38.237580179761601,35.382176465039144,0,0.79557522876854714,0,0,0.97346831189048688,38.237580179761601
240+
20/09/2023 12:00:00 am,195.14189988767518,6.0419201803677751,0.51011022111725879,0.41644152693403191,0,44.279500360129376,40.972914294275562,0,0.78477710588882987,0,0,0.98293960846111894,44.279500360129376
241+
21/09/2023 12:00:00 am,189.2195845675588,6.8059479991386667,0.47551254214367589,0.40812013687862153,0,51.085448359268042,47.270625916855174,0,0.76182130274563953,0,0,0.98912092956833275,51.085448359268042
242+
22/09/2023 12:00:00 am,182.22014399685969,7.8636858050489735,0.45258114321346454,0.4116640911364331,0,58.949134164317016,54.547088431267362,0,0.73672116380327135,0,0,0.99322071672438417,58.949134164317016
243+
23/09/2023 12:00:00 am,174.19351056007383,8.864295019667594,0.42641504546821807,0.4112465374135289,0,67.81342918398461,62.749439342323434,0,0.71418520387180129,0,0,0.99584305660979977,67.81342918398461
244+
24/09/2023 12:00:00 am,164.70562597223525,10.338086044240782,0.41422291635062436,0.43597854005160502,0,78.151515228225392,72.31552545468908,0,0.70163490562644604,0,0,0.99755040118444593,78.151515228225392
245+
25/09/2023 12:00:00 am,154.77467556531161,10.732748478176575,0.37491939395735585,0.42687867729557322,0,88.884263706401967,82.246802455599223,0,0.70331477395222497,0,0,0.99853986019503005,88.884263706401967
246+
26/09/2023 12:00:00 am,144.78317250112772,10.859281920232405,0.33913171512247686,0.52864714092604592,0,99.743545626634372,92.295163972697381,0,0.88832429331162233,0,13.200000000000005,0.99911764267161374,99.743545626634372
247+
27/09/2023 12:00:00 am,134.33696536654037,11.297269935433476,0.31751756215886928,0.53354523868724013,0,111.04081556206785,102.7488066077576,0,0.8795385566110252,0,0,0.99947251374544777,111.04081556206785
248+
28/09/2023 12:00:00 am,124.24833552063079,10.877181225674363,0.28606900629588949,0.50248237346888569,0,121.91799678774221,112.81373079385236,0,0.86044905417859741,0,0,0.99967887560410063,121.91799678774221
249+
29/09/2023 12:00:00 am,114.40778682129013,10.587718439236298,0.26372864945875563,0.48344109043688954,0,132.50571522697851,122.61080792106779,0,0.83469243172098284,0,0,0.99980397435547286,132.50571522697851
250+
30/09/2023 12:00:00 am,104.16249924719469,11.00919120008524,0.25807973539345141,0.50582389059634913,0,143.51490642706375,132.79788419387393,0,0.80726905146127337,0,0,0.99988525861264388,143.51490642706375
251+
1/10/2023 12:00:00 am,94.419120049205887,10.485093572936279,0.24100812480745049,0.50070625014003045,0,154.00000000000003,142.5,0,0.78620895067215124,0,0,0.99993345063478134,154.00000000000003

0 commit comments

Comments
 (0)