Add parsing for LeafInputData after retrieving CleanedInput files

This commit is contained in:
2016-05-19 07:45:53 -04:00
parent 77ae03534e
commit cff6a0d96f
18 changed files with 433 additions and 8 deletions
+3
View File
@@ -70,6 +70,9 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="packages.config" />
<Content Include="Parsers\LeafInputData\LeafInput-cleaned.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Parsers\LeafInputData\LeafInput-tabSeparated.csv" />
<Content Include="Parsers\LeafOutputData\cntrlbestparameters_Wild Capsicum.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
+23 -1
View File
@@ -13,7 +13,29 @@ namespace LeafWeb.Core.Tests.Parsers
public class LeafInputCsvParserTests
{
private const string ContentDirectory = @"Parsers\LeafInputData\";
[Test]
public void Parse_Cleaned()
{
var fileInfo = FileUtility.GetContentFile(ContentDirectory, "LeafInput-cleaned.csv");
var leafInput = new LeafInputCsvParser(fileInfo);
var input = leafInput.Parse();
Assert.That(input.InvestigatorName, Is.EqualTo("Valid Cleaned"));
var site = input.Site;
Assert.That(site.SiteId, Is.Null);
Assert.That(site.Latitude, Is.EqualTo(-20.75d));
var photosynthetic = input.Photosynthetic;
Assert.That(photosynthetic.GammaStar, Is.EqualTo(0));
var data = input.Data;
Assert.That(data.Count(), Is.GreaterThan(2));
var dataItem = data.First();
Assert.That(dataItem.Obs, Is.EqualTo(10));
Assert.That(dataItem.Photo, Is.EqualTo(10.49195882));
}
[Test]
public void Parse_Valid()
{
@@ -0,0 +1,32 @@
Investigator name: Valid Cleaned
Contact information: validcleaned@yahoo.com.br
Site name in full: NA
Vegetation type: NA
Soil type: NA
Major species: NA
Sample leaf light environment: Full Sun
"Water_stress_assessment:_No_water_stress, plants_irrigated_every_day"
Instrument used: Licor-6400XT
Extra info:
SiteID,Latitude(Degrees),Longitude(Degrees),Elevation,SampleYear,SampleDayOfYear,GrowSeasonStart,GrowSeasonEnd,StandAge,CanopyHeight,LeafAreaIndex,SpeciesSampled,AveTimeResolution,SampleHeight,LeafAge,SpecificLeafArea,LfNitrogenContent,LfCarbonContent,LfPhosphContent
NoUnit,NorthPositive,EastPositive,m,NoUnit,DayOfYear,DayOfYear,DayOfYear,Year,m,m2/m2,NoBlankSpace,Minutes,m,days,cm2/g,%,%,%
-9999,-20.75,-42.88,648,2009,-9999,-9999,-9999,-9999,-9999,-9999,CoffeaArabica,-9999,-9999,-9999,140,3.48,-9999,-9999
Gamma*,Kc,Ko,Alpha,Rd,gi
Pa,Pa,Pa,NoUnit,umol/m2/s,umol/m2/s/Pa
-9999,-9999,-9999,-9999,-9999,-9999
Obs,HHMMSS,FTime,Photo,!AdjPhoto,!StomCond,!Ci,!Trmmol,!VpdL,Area,StmRat,BLCond,Tair,!Tleaf,TBlk,CO2R,CO2S,H2OR,H2OS,RH_R,RH_S,Flow,!PARi,PARo,Press,CsMch,HsMch,StableF,Status,PhiPS2,OxygenPress
NoUnit,HHMMSS,Second,umol/m2/s,umol/m2/s,mol/m2/s,umol/mol,mmol/m2/s,kPa,cm2,NA,mol/m2/s,oC,oC,oC,umol/mol,umol/mol,mmol/mol,mmol/mol,%,%,umol/s,umol/m2/s,umol/m2/s,Kpa,umol/mol,mmol/mol,NA,NA,NA,KPA
10,-9999,-9999,10.49195882,11.05941043,0.244883469,212.5041051,2.63076876,1.036135144,2,0,4.644859791,23.52121258,23.53769627,23.3545414,300.0483063,292.5618317,18.24994297,19.96389828,58.95560608,64.49247513,300.8535187,993.0888855,0.049617826,94.00339508,-2.052112579,-0.246214688,0.425,111115,0.180769687,21
10,-9999,-9999,6.613751647,7.414357534,0.200000749,130.8730299,2.24618742,1.072960558,2,0,4.644859791,23.57428112,23.68962097,23.40673904,200.1022598,195.4142136,18.39681854,19.86024399,59.23092155,63.94262123,300.8801514,992.5410278,0.049735996,93.98853455,-1.348773956,-0.243325055,0.475,111115,0.163288942,21
10,-9999,-9999,4.431079608,5.349146841,0.170652088,92.42684697,2.00393304,1.114947396,2,0,4.644859791,23.58453674,23.90329285,23.41538334,149.6127335,146.4719864,18.51102257,19.8167675,59.56615295,63.76787758,300.8583466,992.1625671,0.054449931,93.9954071,-1.367557526,-0.230450451,0.375,111115,0.147352806,21
10,-9999,-9999,1.523393138,2.556557599,0.159880602,70.4656295,1.965014975,1.163792845,2,0,4.644859791,23.59998169,24.21637478,23.43008366,99.656147,98.51480789,18.61892796,19.89914742,59.85464211,63.97018967,300.8723236,991.761908,0.039717828,93.9906868,-0.692935944,-0.232964337,0.575,111115,0.130597749,21
10,-9999,-9999,0.894293187,1.987936699,0.167650406,52.50296582,2.025541888,1.145843431,2,0,4.644859791,23.62822838,24.19524651,23.45776844,74.00842819,73.31520309,18.72938271,20.0488924,60.108358,64.34307251,300.8590363,991.5204651,0.045964496,93.99226608,-0.604091644,-0.238077939,0.575,111115,0.122154858,21
10,-9999,-9999,-0.495843139,0.655970767,0.176641615,42.05656346,2.078428704,1.118051438,2,0,4.644859791,23.63969841,24.11649742,23.46931267,48.81573753,49.07753906,18.83879395,20.19250221,60.41828194,64.75978699,300.871344,991.50896,0.042428688,93.99311447,-0.591835022,-0.238228619,0.7,111115,0.11011836,21
10,-9999,-9999,14.01214221,14.34608078,0.188886895,258.1956724,2.081065547,1.052338661,2,0,4.644859791,23.63486118,23.77918701,23.46806164,399.7125275,389.8589264,18.8980257,20.25335598,60.6206089,64.96820526,300.8738037,991.5494934,0.06246434,93.98490219,-3.991065979,-0.239916623,0.35,111115,0.183856114,21
10,-9999,-9999,19.20963114,19.06936549,0.167346311,390.2278007,1.923908779,1.090216329,2,0,4.644859791,23.6730854,23.97962074,23.50691929,600.9658813,587.4440186,18.97605591,20.22919121,60.72654266,64.73679276,300.8435883,990.6557251,0.06564644,93.97809906,-4.053321838,-0.263443768,0.6,111115,0.224674063,21
10,-9999,-9999,22.68315779,22.07166985,0.140898278,513.7169863,1.709378251,1.143940773,2,0,4.644859791,23.72432709,24.24497566,23.55486546,799.7560669,783.7866455,19.05482311,20.1682272,60.79165916,64.34382095,300.861908,990.5349609,0.044432433,93.97946396,-6.789344788,-0.258801281,0.625,111115,0.241833394,21
10,-9999,-9999,25.21838506,24.1313968,0.128254365,657.3239246,1.569373475,1.150702993,2,0,4.644859791,23.77119751,24.27973061,23.60147991,999.7003906,981.9117737,19.14113102,20.16335564,60.89594879,64.14807434,300.8594788,990.3832764,0.037125352,93.98093872,-10.22812653,-0.260886014,0.65,111115,0.250284039,21
10,-9999,-9999,27.03077557,25.46461001,0.120765245,816.0761447,1.52318325,1.183928533,2,0,4.644859791,23.80861893,24.49090347,23.63921146,1200.733826,1181.568982,19.23064556,20.22269268,61.04207878,64.19104309,300.8688538,990.2308533,0.058457612,93.97930527,-14.02487946,-0.262095273,0.575,111115,0.252074273,21
10,-9999,-9999,28.6322564,26.59017955,0.117258539,984.2999029,1.510964689,1.208454852,2,0,4.644859791,23.86426582,24.66598072,23.69386177,1400.285156,1379.865356,19.32225647,20.30630074,61.13061714,64.24388199,300.8569305,990.0950989,0.060696683,93.9834198,-17.98886871,-0.264069378,0.65,111115,0.25113703,21
10,-9999,-9999,29.59434444,27.07367747,0.111042426,1152.036476,1.451859088,1.224292598,2,0,4.644859791,23.92603722,24.77762184,23.75417137,1600.474329,1579.277905,19.41603336,20.36147785,61.19426117,64.17406006,300.8736847,989.9327454,0.052446734,93.97519684,-22.0407486,-0.271241009,0.65,111115,0.252735204,21
10,-9999,-9999,30.43679512,26.95968124,0.103627708,1515.947025,1.36954251,1.235421377,2,0,4.644859791,23.97047672,24.84818077,23.79694042,1999.831714,1977.797449,19.49336185,20.38523922,61.27052002,64.07382736,300.8539337,989.8097778,0.061404274,93.96966782,-31.06003571,-0.273886502,0.625,111115,0.248197252,21
1 Investigator name: Valid Cleaned
2 Contact information: validcleaned@yahoo.com.br
3 Site name in full: NA
4 Vegetation type: NA
5 Soil type: NA
6 Major species: NA
7 Sample leaf light environment: Full Sun
8 Water_stress_assessment:_No_water_stress, plants_irrigated_every_day
9 Instrument used: Licor-6400XT
10 Extra info:
11 SiteID Latitude(Degrees) Longitude(Degrees) Elevation SampleYear SampleDayOfYear GrowSeasonStart GrowSeasonEnd StandAge CanopyHeight LeafAreaIndex SpeciesSampled AveTimeResolution SampleHeight LeafAge SpecificLeafArea LfNitrogenContent LfCarbonContent LfPhosphContent
12 NoUnit NorthPositive EastPositive m NoUnit DayOfYear DayOfYear DayOfYear Year m m2/m2 NoBlankSpace Minutes m days cm2/g % % %
13 -9999 -20.75 -42.88 648 2009 -9999 -9999 -9999 -9999 -9999 -9999 CoffeaArabica -9999 -9999 -9999 140 3.48 -9999 -9999
14 Gamma* Kc Ko Alpha Rd gi
15 Pa Pa Pa NoUnit umol/m2/s umol/m2/s/Pa
16 -9999 -9999 -9999 -9999 -9999 -9999
17 Obs HHMMSS FTime Photo !AdjPhoto !StomCond !Ci !Trmmol !VpdL Area StmRat BLCond Tair !Tleaf TBlk CO2R CO2S H2OR H2OS RH_R RH_S Flow !PARi PARo Press CsMch HsMch StableF Status PhiPS2 OxygenPress
18 NoUnit HHMMSS Second umol/m2/s umol/m2/s mol/m2/s umol/mol mmol/m2/s kPa cm2 NA mol/m2/s oC oC oC umol/mol umol/mol mmol/mol mmol/mol % % umol/s umol/m2/s umol/m2/s Kpa umol/mol mmol/mol NA NA NA KPA
19 10 -9999 -9999 10.49195882 11.05941043 0.244883469 212.5041051 2.63076876 1.036135144 2 0 4.644859791 23.52121258 23.53769627 23.3545414 300.0483063 292.5618317 18.24994297 19.96389828 58.95560608 64.49247513 300.8535187 993.0888855 0.049617826 94.00339508 -2.052112579 -0.246214688 0.425 111115 0.180769687 21
20 10 -9999 -9999 6.613751647 7.414357534 0.200000749 130.8730299 2.24618742 1.072960558 2 0 4.644859791 23.57428112 23.68962097 23.40673904 200.1022598 195.4142136 18.39681854 19.86024399 59.23092155 63.94262123 300.8801514 992.5410278 0.049735996 93.98853455 -1.348773956 -0.243325055 0.475 111115 0.163288942 21
21 10 -9999 -9999 4.431079608 5.349146841 0.170652088 92.42684697 2.00393304 1.114947396 2 0 4.644859791 23.58453674 23.90329285 23.41538334 149.6127335 146.4719864 18.51102257 19.8167675 59.56615295 63.76787758 300.8583466 992.1625671 0.054449931 93.9954071 -1.367557526 -0.230450451 0.375 111115 0.147352806 21
22 10 -9999 -9999 1.523393138 2.556557599 0.159880602 70.4656295 1.965014975 1.163792845 2 0 4.644859791 23.59998169 24.21637478 23.43008366 99.656147 98.51480789 18.61892796 19.89914742 59.85464211 63.97018967 300.8723236 991.761908 0.039717828 93.9906868 -0.692935944 -0.232964337 0.575 111115 0.130597749 21
23 10 -9999 -9999 0.894293187 1.987936699 0.167650406 52.50296582 2.025541888 1.145843431 2 0 4.644859791 23.62822838 24.19524651 23.45776844 74.00842819 73.31520309 18.72938271 20.0488924 60.108358 64.34307251 300.8590363 991.5204651 0.045964496 93.99226608 -0.604091644 -0.238077939 0.575 111115 0.122154858 21
24 10 -9999 -9999 -0.495843139 0.655970767 0.176641615 42.05656346 2.078428704 1.118051438 2 0 4.644859791 23.63969841 24.11649742 23.46931267 48.81573753 49.07753906 18.83879395 20.19250221 60.41828194 64.75978699 300.871344 991.50896 0.042428688 93.99311447 -0.591835022 -0.238228619 0.7 111115 0.11011836 21
25 10 -9999 -9999 14.01214221 14.34608078 0.188886895 258.1956724 2.081065547 1.052338661 2 0 4.644859791 23.63486118 23.77918701 23.46806164 399.7125275 389.8589264 18.8980257 20.25335598 60.6206089 64.96820526 300.8738037 991.5494934 0.06246434 93.98490219 -3.991065979 -0.239916623 0.35 111115 0.183856114 21
26 10 -9999 -9999 19.20963114 19.06936549 0.167346311 390.2278007 1.923908779 1.090216329 2 0 4.644859791 23.6730854 23.97962074 23.50691929 600.9658813 587.4440186 18.97605591 20.22919121 60.72654266 64.73679276 300.8435883 990.6557251 0.06564644 93.97809906 -4.053321838 -0.263443768 0.6 111115 0.224674063 21
27 10 -9999 -9999 22.68315779 22.07166985 0.140898278 513.7169863 1.709378251 1.143940773 2 0 4.644859791 23.72432709 24.24497566 23.55486546 799.7560669 783.7866455 19.05482311 20.1682272 60.79165916 64.34382095 300.861908 990.5349609 0.044432433 93.97946396 -6.789344788 -0.258801281 0.625 111115 0.241833394 21
28 10 -9999 -9999 25.21838506 24.1313968 0.128254365 657.3239246 1.569373475 1.150702993 2 0 4.644859791 23.77119751 24.27973061 23.60147991 999.7003906 981.9117737 19.14113102 20.16335564 60.89594879 64.14807434 300.8594788 990.3832764 0.037125352 93.98093872 -10.22812653 -0.260886014 0.65 111115 0.250284039 21
29 10 -9999 -9999 27.03077557 25.46461001 0.120765245 816.0761447 1.52318325 1.183928533 2 0 4.644859791 23.80861893 24.49090347 23.63921146 1200.733826 1181.568982 19.23064556 20.22269268 61.04207878 64.19104309 300.8688538 990.2308533 0.058457612 93.97930527 -14.02487946 -0.262095273 0.575 111115 0.252074273 21
30 10 -9999 -9999 28.6322564 26.59017955 0.117258539 984.2999029 1.510964689 1.208454852 2 0 4.644859791 23.86426582 24.66598072 23.69386177 1400.285156 1379.865356 19.32225647 20.30630074 61.13061714 64.24388199 300.8569305 990.0950989 0.060696683 93.9834198 -17.98886871 -0.264069378 0.65 111115 0.25113703 21
31 10 -9999 -9999 29.59434444 27.07367747 0.111042426 1152.036476 1.451859088 1.224292598 2 0 4.644859791 23.92603722 24.77762184 23.75417137 1600.474329 1579.277905 19.41603336 20.36147785 61.19426117 64.17406006 300.8736847 989.9327454 0.052446734 93.97519684 -22.0407486 -0.271241009 0.65 111115 0.252735204 21
32 10 -9999 -9999 30.43679512 26.95968124 0.103627708 1515.947025 1.36954251 1.235421377 2 0 4.644859791 23.97047672 24.84818077 23.79694042 1999.831714 1977.797449 19.49336185 20.38523922 61.27052002 64.07382736 300.8539337 989.8097778 0.061404274 93.96966782 -31.06003571 -0.273886502 0.625 111115 0.248197252 21
+7
View File
@@ -99,6 +99,10 @@
<Compile Include="Migrations\201605161458209_LeafOutputFileType.Designer.cs">
<DependentUpon>201605161458209_LeafOutputFileType.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\201605191138068_LeafInputData.cs" />
<Compile Include="Migrations\201605191138068_LeafInputData.Designer.cs">
<DependentUpon>201605191138068_LeafInputData.cs</DependentUpon>
</Compile>
<Compile Include="Migrations\Configuration.cs" />
<Compile Include="Parsers\LeafGasComparisonParser.cs" />
<Compile Include="Remote\IPiscalClient.cs" />
@@ -152,6 +156,9 @@
<EmbeddedResource Include="Migrations\201605161458209_LeafOutputFileType.resx">
<DependentUpon>201605161458209_LeafOutputFileType.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Migrations\201605191138068_LeafInputData.resx">
<DependentUpon>201605191138068_LeafInputData.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
+4
View File
@@ -14,6 +14,10 @@ namespace LeafWeb.Core.DAL
public DbSet<FluxnetSite> FluxnetSites { get; set; }
public DbSet<PhotosynthesisType> PhotosynthesisTypes { get; set; }
public DbSet<LeafOutputFile> LeafOutputFiles { get; set; }
public DbSet<LeafInputData> LeafInputData { get; set; }
public DbSet<LeafInputDataCurve> LeafInputDataCurves { get; set; }
public DbSet<LeafInputDataPhotosynthetic> LeafInputDataPhotosynthetic { get; set; }
public DbSet<LeafInputDataSite> LeafInputDataSite { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
@@ -25,6 +25,12 @@ namespace LeafWeb.Core.Entities
/// </summary>
[ParseInfo(2, boolEncodedPosition: 1, alternateTitle: "FitRwp|Rch|ha?")] // formerly FitGi
public bool FitRwp {get; set;}
/// <summary>
/// TODO? : boolEncodedPosition only able to parse a single value from each cell currently
/// </summary>
//[ParseInfo(2, boolEncodedPosition: 2, alternateTitle: "FitRwp|Rch|ha?")] // formerly FitGi
//public bool FitRch {get; set;}
/// <summary>
/// whether or not the chloroplastic CO2 partial pressure photocompensation point is
+1
View File
@@ -16,6 +16,7 @@ namespace LeafWeb.Core.Entities
public virtual ICollection<LeafOutputFile> OutputFiles { get; set; }
public LeafOutputFile OutputErrorMessage => OutputFiles?.FirstOrDefault(f => f.IsErrorMessage);
public LeafOutputFile OutputWarningMessage => OutputFiles?.FirstOrDefault(f => f.IsWarningMessage);
public virtual ICollection<LeafInputData> LeafInputData { get; set; }
public LeafInputStatusType CurrentStatus { get; set; }
public virtual ICollection<LeafInputStatus> StatusHistory { get; set; }
+12
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using LeafWeb.Core.Utility;
namespace LeafWeb.Core.Entities
@@ -9,11 +10,22 @@ namespace LeafWeb.Core.Entities
/// </summary>
public class LeafInputData
{
[ForeignKey("LeafOutputFile")]
public int Id { get; set; }
public virtual LeafInputDataSite Site { get; set; }
public virtual LeafInputDataPhotosynthetic Photosynthetic { get; set; }
public virtual ICollection<LeafInputDataCurve> Data { get; set; }
/// <summary>
/// Leaf Input set this data belongs to
/// </summary>
public virtual LeafInput LeafInput { get; set; }
/// <summary>
/// Output file this data was parsed from
/// </summary>
public virtual LeafOutputFile LeafOutputFile { get; set; }
[ParseInfo(1, exampleValue: "First and last name")]
public string InvestigatorName { get; set; }
+1 -1
View File
@@ -10,7 +10,7 @@ namespace LeafWeb.Core.Entities
{
public int Id { get; set; }
public virtual LeafInputData LeafInputInfo { get; set; }
public virtual LeafInputData LeafInputData { get; set; }
public int ListOrder { get; set; }
+4 -2
View File
@@ -1,4 +1,5 @@
using LeafWeb.Core.Utility;
using System.ComponentModel.DataAnnotations.Schema;
using LeafWeb.Core.Utility;
namespace LeafWeb.Core.Entities
{
@@ -7,9 +8,10 @@ namespace LeafWeb.Core.Entities
/// </summary>
public class LeafInputDataPhotosynthetic
{
[ForeignKey("LeafInputData")]
public int Id { get; set; }
public virtual LeafInputData LeafInputInfo { get; set; }
public virtual LeafInputData LeafInputData { get; set; }
/// <summary>chloroplastic CO2 photocompensation point</summary>
/// <remarks>must be positive</remarks>
+4 -2
View File
@@ -1,4 +1,5 @@
using LeafWeb.Core.Utility;
using System.ComponentModel.DataAnnotations.Schema;
using LeafWeb.Core.Utility;
namespace LeafWeb.Core.Entities
{
@@ -7,9 +8,10 @@ namespace LeafWeb.Core.Entities
/// </summary>
public class LeafInputDataSite
{
[ForeignKey("LeafInputData")]
public int Id { get; set; }
public virtual LeafInputData LeafInputInfo { get; set; }
public virtual LeafInputData LeafInputData { get; set; }
/// <summary>Site identifier</summary>
/// <remarks>do not leave blank between letters</remarks>
+9 -1
View File
@@ -12,10 +12,18 @@ namespace LeafWeb.Core.Entities
public virtual LeafInput LeafInput { get; set; }
public string Filename { get; set; }
/// <summary>
/// CleanedInput files will be parsed and data stored here
/// </summary>
public virtual LeafInputData LeafInputData { get; set; }
/// <summary>
/// ToUser, NotToUser, CleanedInput
/// </summary>
public LeafOutputFileType FileType { get; set; }
public string Filename { get; set; }
public byte[] Contents { get; set; }
public bool IsLeafChartFile => Filename?.Contains(Filename_LeafChart) ?? false;
@@ -0,0 +1,29 @@
// <auto-generated />
namespace LeafWeb.Core.Migrations
{
using System.CodeDom.Compiler;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Resources;
[GeneratedCode("EntityFramework.Migrations", "6.1.3-40302")]
public sealed partial class LeafInputData : IMigrationMetadata
{
private readonly ResourceManager Resources = new ResourceManager(typeof(LeafInputData));
string IMigrationMetadata.Id
{
get { return "201605191138068_LeafInputData"; }
}
string IMigrationMetadata.Source
{
get { return null; }
}
string IMigrationMetadata.Target
{
get { return Resources.GetString("Target"); }
}
}
}
@@ -0,0 +1,141 @@
namespace LeafWeb.Core.Migrations
{
using System;
using System.Data.Entity.Migrations;
public partial class LeafInputData : DbMigration
{
public override void Up()
{
CreateTable(
"dbo.LeafInputData",
c => new
{
Id = c.Int(nullable: false),
InvestigatorName = c.String(),
ContactInformation = c.String(),
SiteName = c.String(),
VegetationType = c.String(),
SoilType = c.String(),
MajorSpecies = c.String(),
SampleLeafLightEnv = c.String(),
WaterStressAssessment = c.String(),
InstrumentUsed = c.String(),
ExtraInfo = c.String(),
LeafInput_Id = c.Int(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.LeafInput", t => t.LeafInput_Id)
.ForeignKey("dbo.LeafOutputFile", t => t.Id)
.Index(t => t.Id)
.Index(t => t.LeafInput_Id);
CreateTable(
"dbo.LeafInputDataCurve",
c => new
{
Id = c.Int(nullable: false, identity: true),
ListOrder = c.Int(nullable: false),
Obs = c.Double(),
HHMMSS = c.String(maxLength: 8),
FTime = c.Double(),
Photo = c.Double(),
AdjPhoto = c.Double(),
StomCond = c.Double(),
Ci = c.Double(),
Trmmol = c.Double(),
VpdL = c.Double(),
Area = c.Double(),
StmRat = c.Double(),
BLCond = c.Double(),
Tair = c.Double(),
Tleaf = c.Double(),
TBlk = c.Double(),
CO2R = c.Double(),
CO2S = c.Double(),
H2OR = c.Double(),
H2OS = c.Double(),
RH_R = c.Double(),
RH_S = c.Double(),
Flow = c.Double(),
PARi = c.Double(),
PARo = c.Double(),
Press = c.Double(),
CsMch = c.Double(),
HsMch = c.Double(),
StableF = c.Double(),
Status = c.String(),
PhiPS2 = c.Double(),
OxygenPress = c.Double(),
LeafInputData_Id = c.Int(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.LeafInputData", t => t.LeafInputData_Id)
.Index(t => t.LeafInputData_Id);
CreateTable(
"dbo.LeafInputDataPhotosynthetic",
c => new
{
Id = c.Int(nullable: false),
GammaStar = c.Double(nullable: false),
Kc = c.Double(nullable: false),
Ko = c.Double(nullable: false),
Alpha = c.Double(nullable: false),
Rd = c.Double(nullable: false),
gi = c.Double(nullable: false),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.LeafInputData", t => t.Id)
.Index(t => t.Id);
CreateTable(
"dbo.LeafInputDataSite",
c => new
{
Id = c.Int(nullable: false),
SiteId = c.String(),
Latitude = c.Double(),
Longitude = c.Double(),
Elevation = c.Double(),
SampleYear = c.Int(),
SampleDayOfYear = c.Int(),
GrowSeasonStart = c.Int(),
GrowSeasonEnd = c.Int(),
StandAge = c.Double(),
CanopyHeight = c.Double(),
LeafAreaIndex = c.Double(),
SpeciesSampled = c.String(),
AverageTimeResolution = c.Double(),
SampleHeight = c.Double(),
LeafAge = c.Int(),
SpecificLeafArea = c.Double(),
LfNitrogenContent = c.Double(),
LfCarbonContent = c.Double(),
LfPhosphContent = c.Double(),
})
.PrimaryKey(t => t.Id)
.ForeignKey("dbo.LeafInputData", t => t.Id)
.Index(t => t.Id);
}
public override void Down()
{
DropForeignKey("dbo.LeafInputDataSite", "Id", "dbo.LeafInputData");
DropForeignKey("dbo.LeafInputDataPhotosynthetic", "Id", "dbo.LeafInputData");
DropForeignKey("dbo.LeafInputData", "Id", "dbo.LeafOutputFile");
DropForeignKey("dbo.LeafInputData", "LeafInput_Id", "dbo.LeafInput");
DropForeignKey("dbo.LeafInputDataCurve", "LeafInputData_Id", "dbo.LeafInputData");
DropIndex("dbo.LeafInputDataSite", new[] { "Id" });
DropIndex("dbo.LeafInputDataPhotosynthetic", new[] { "Id" });
DropIndex("dbo.LeafInputDataCurve", new[] { "LeafInputData_Id" });
DropIndex("dbo.LeafInputData", new[] { "LeafInput_Id" });
DropIndex("dbo.LeafInputData", new[] { "Id" });
DropTable("dbo.LeafInputDataSite");
DropTable("dbo.LeafInputDataPhotosynthetic");
DropTable("dbo.LeafInputDataCurve");
DropTable("dbo.LeafInputData");
}
}
}
File diff suppressed because one or more lines are too long
+4
View File
@@ -13,6 +13,10 @@ namespace LeafWeb.Core.Parsers
{
}
public LeafInputCsvParser(byte[] fileContents) : base(fileContents)
{
}
public LeafInputData Parse()
{
// First 10 lines
+2 -1
View File
@@ -1,5 +1,6 @@
using System.Linq;
using System.Web.Mvc;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Utility;
using LeafWeb.Web.Attributes;
using LeafWeb.Web.ViewModels.Results;
@@ -26,7 +27,7 @@ namespace LeafWeb.Web.Controllers
if (leafInput == null)
return View("DownloadNotFound");
var zip = leafInput.GetOutputFileZip();
var zip = leafInput.GetOutputFileZip(LeafOutputFileType.ToUser);
var filename = leafInput.Identifier.FilterValidFilename() + ".zip";
@@ -1,5 +1,7 @@
using System;
using System.Linq;
using LeafWeb.Core.Entities;
using LeafWeb.Core.Parsers;
namespace LeafWeb.Web.Services.PiscalQueue
{
@@ -16,7 +18,13 @@ namespace LeafWeb.Web.Services.PiscalQueue
foreach (var outputFile in leafOutputFiles)
{
if (leafInput.OutputFiles.All(file => file.Filename != outputFile.Filename))
{
DataService.AddLeafOutputFile(outputFile);
// parse cleaned input file data
if (outputFile.FileType == LeafOutputFileType.CleanedInput)
AddLeafInputData(outputFile, leafInput);
}
else
Logger.Warn("LeafInput: {0}, RetrieveOutputFiles duplicate file name: {1}", leafInput.Id, outputFile.Filename);
}
@@ -34,5 +42,22 @@ namespace LeafWeb.Web.Services.PiscalQueue
HangfireStartup.TriggerPiscalProcessQueue();
}
private void AddLeafInputData(LeafOutputFile outputFile, LeafInput leafInput)
{
try
{
var parser = new LeafInputCsvParser(outputFile.Contents);
var data = parser.Parse();
data.LeafInput = leafInput;
data.LeafOutputFile = outputFile;
leafInput.LeafInputData.Add(data);
DataService.UpdateLeafInput(leafInput);
}
catch (Exception e)
{
Logger.Error(e, $"LeafInput: {leafInput.Id}, while parsing CleanedInput file: {outputFile.Filename}");
}
}
}
}