From 7ad10d6ddc5633463315ff1f1f5e25a7ae0d61b4 Mon Sep 17 00:00:00 2001 From: James Kolpack Date: Fri, 3 Jul 2020 10:18:13 -0400 Subject: [PATCH] Add remaining fields for query --- WebCms/Models/LeafDataQuery.cs | 25 +++++++-- WebCms/Models/LeafInputDataCurveViewModel.cs | 9 +++- WebCms/Utility/QueryFilter.cs | 53 +++++++++++++++++++ WebCms/Views/Queue/Index.cshtml | 24 ++++++--- .../LeafInputDataViewModels.cshtml | 26 ++++++--- 5 files changed, 118 insertions(+), 19 deletions(-) diff --git a/WebCms/Models/LeafDataQuery.cs b/WebCms/Models/LeafDataQuery.cs index b2da7cc..0099725 100644 --- a/WebCms/Models/LeafDataQuery.cs +++ b/WebCms/Models/LeafDataQuery.cs @@ -6,6 +6,8 @@ namespace LeafWeb.WebCms.Models { public class LeafDataQuery { + private const string FloatingPointRegex = @"^([-+]?[0-9]*\.[0-9]+|[0-9]+)$"; + /// Query [Display(Name = "Search", Description = "General query")] public string q { get; set; } @@ -37,11 +39,25 @@ namespace LeafWeb.WebCms.Models public string lonr { get; set; } /// Sample CO2 concentration - //[ParseInfo(17, units: "umol/mol")] - [Display(Name = "CO2 response curves")] - [RegularExpression(@"^([0-9]*\.[0-9]+|[0-9]+)$", ErrorMessage = "Value is numeric")] + [Display(Name = "CO2 response curves (CO2S)")] + [RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")] public string co2s { get; set; } + /// PAR measured by the in-chamber quantum sensor + [Display(Name = "Light response curves (PARi)")] + [RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")] + public string pari { get; set; } + + /// temperature of leaf thermocouple + [Display(Name = "Temperature response curves (Tleaf)")] + [RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")] + public string tleaf { get; set; } + + /// DeltaF/Fm, the fraction of absorbed PSII photons that are used in photochemistry + [Display(Name = "Fluorometry measurements (PhiPS2)")] + [RegularExpression(FloatingPointRegex, ErrorMessage = "Must be numeric")] + public string phips2 { get; set; } + public bool HasExtendedParameters => !( string.IsNullOrEmpty(siteid) @@ -51,6 +67,9 @@ namespace LeafWeb.WebCms.Models && string.IsNullOrEmpty(lon) && string.IsNullOrEmpty(lonr) && string.IsNullOrEmpty(co2s) + && string.IsNullOrEmpty(pari) + && string.IsNullOrEmpty(tleaf) + && string.IsNullOrEmpty(phips2) ); } } \ No newline at end of file diff --git a/WebCms/Models/LeafInputDataCurveViewModel.cs b/WebCms/Models/LeafInputDataCurveViewModel.cs index e02c01c..9a35428 100644 --- a/WebCms/Models/LeafInputDataCurveViewModel.cs +++ b/WebCms/Models/LeafInputDataCurveViewModel.cs @@ -6,9 +6,16 @@ namespace LeafWeb.WebCms.Models public class LeafInputDataCurveViewModel { /// Sample CO2 concentration - //[ParseInfo(17, units: "umol/mol")] public double? CO2S { get; set; } + /// PAR measured by the in-chamber quantum sensor + public double? PARi { get; set; } + + /// temperature of leaf thermocouple + public double? Tleaf { get; set; } + + /// DeltaF/Fm, the fraction of absorbed PSII photons that are used in photochemistry + public double? PhiPS2 { get; set; } public LeafInputDataCurveViewModel() {} public LeafInputDataCurveViewModel(LeafInputDataCurve leafInputDataCurve) diff --git a/WebCms/Utility/QueryFilter.cs b/WebCms/Utility/QueryFilter.cs index 31b25bf..74d22e3 100644 --- a/WebCms/Utility/QueryFilter.cs +++ b/WebCms/Utility/QueryFilter.cs @@ -73,6 +73,7 @@ namespace LeafWeb.WebCms.Utility select li; } + // co2s if (!string.IsNullOrEmpty(query.co2s)) { @@ -90,6 +91,58 @@ namespace LeafWeb.WebCms.Utility select li; } + + // pari + if (!string.IsNullOrEmpty(query.pari)) + { + var p = double.Parse(query.pari); + + resultItems = + from li in resultItems + where + // maximum range inside LeafInputFiles + li.LeafInputData.Max(lid => + // range of LeafInputData + lid.Data.Max(d => d.PARi) + - lid.Data.Min(d => d.PARi)) + >= p + select li; + } + + // tleaf + if (!string.IsNullOrEmpty(query.tleaf)) + { + var p = double.Parse(query.tleaf); + + resultItems = + from li in resultItems + where + // maximum range inside LeafInputFiles + li.LeafInputData.Max(lid => + // range of LeafInputData + lid.Data.Max(d => d.Tleaf) + - lid.Data.Min(d => d.Tleaf)) + >= p + select li; + } + + // phips2 + if (!string.IsNullOrEmpty(query.phips2)) + { + var p = double.Parse(query.phips2); + + resultItems = + from li in resultItems + where + // maximum range inside LeafInputFiles + li.LeafInputData.Max(lid => + // range of LeafInputData + lid.Data.Max(d => d.PhiPS2) + - lid.Data.Min(d => d.PhiPS2)) + >= p + select li; + } + return resultItems; } } diff --git a/WebCms/Views/Queue/Index.cshtml b/WebCms/Views/Queue/Index.cshtml index 67873b1..02890e5 100644 --- a/WebCms/Views/Queue/Index.cshtml +++ b/WebCms/Views/Queue/Index.cshtml @@ -52,31 +52,39 @@
-
+
@Html.EditorFor(m => m.Q.lat, new { size = "small", append = "°" })
-
+
@Html.EditorFor(m => m.Q.latr, new { size = "small", prepend = "±", append = "°" })
-
+
@Html.EditorFor(m => m.Q.lon, new { size = "small", append = "°" })
-
+
@Html.EditorFor(m => m.Q.lonr, new { size = "small", prepend = "±", append = "°" })

+
Curve Variation range minimum
-
-
Curve Variation range minimum
- - @Html.EditorFor(m => m.Q.co2s, new { size = "small", append = "umol/m" }) +
+ @Html.EditorFor(m => m.Q.co2s, new { size = "small", append = "umol/m", prepend = ">" }) +
+
+ @Html.EditorFor(m => m.Q.pari, new { size = "small", append = "umol/m2/s", prepend = ">" }) +
+
+ @Html.EditorFor(m => m.Q.tleaf, new { size = "small", append = "oC", prepend = ">" }) +
+
+ @Html.EditorFor(m => m.Q.phips2, new { size = "small", prepend = ">" })
diff --git a/WebCms/Views/Shared/DisplayTemplates/LeafInputDataViewModels.cshtml b/WebCms/Views/Shared/DisplayTemplates/LeafInputDataViewModels.cshtml index 9e11507..f85738b 100644 --- a/WebCms/Views/Shared/DisplayTemplates/LeafInputDataViewModels.cshtml +++ b/WebCms/Views/Shared/DisplayTemplates/LeafInputDataViewModels.cshtml @@ -11,7 +11,7 @@ @RendDistinctValues("Latitude [°]", Model.Select(m => m.Site.Latitude?.ToString())) @RendDistinctValues("Longitude [°]", Model.Select(m => m.Site.Longitude?.ToString())) @RendDistinctValues("Elevation [m]", Model.Select(m => m.Site.Elevation?.ToString())) -@RendDistinctValues("CO2S", +@*@RendDistinctValues("CO2S", Model.Select(m => m.SiteName + " (" + m.Id + "): " + string.Join(", ", @@ -33,21 +33,33 @@ m.SiteName + " (" + m.Id + "): " + (m.Data?.Max(d => d.CO2S) - m.Data?.Min(d => d.CO2S))), "
") -@RendValue("CO2S Max Range", Model.Max(m => - m.Data?.Max(d => d.CO2S) - - m.Data?.Min(d => d.CO2S))?.ToString()) @RendValue("CO2S Min Range", Model.Min(m => + m.Data?.Max(d => d.CO2S) + - m.Data?.Min(d => d.CO2S))?.ToString())*@ + +@RendValue("CO2 response curves (CO2S) Max range", Model.Max(m => m.Data?.Max(d => d.CO2S) - m.Data?.Min(d => d.CO2S))?.ToString()) +@RendValue("Light response curves (PARi) Max range", Model.Max(m => + m.Data?.Max(d => d.PARi) + - m.Data?.Min(d => d.PARi))?.ToString()) + +@RendValue("Temperature response curves (Tleaf) Max Range", Model.Max(m => + m.Data?.Max(d => d.Tleaf) + - m.Data?.Min(d => d.Tleaf))?.ToString()) + +@RendValue("Fluorometry measurements (PhiPS2) Max Range", Model.Max(m => + m.Data?.Max(d => d.PhiPS2) + - m.Data?.Min(d => d.PhiPS2))?.ToString()) @helper RendValue(string label, string value) { -
-
+
+
@Html.Raw(label)
-
+
@Html.Raw(@value)