Simplify CurveData data structures
This commit is contained in:
@@ -28,18 +28,6 @@ namespace LeafWeb.Core.Charter
|
||||
|
||||
foreach (var comparisonGroup in comparisonGroups)
|
||||
{
|
||||
if (comparisonGroup.FitType.Count() != 4)
|
||||
{
|
||||
var missing =
|
||||
from rwp in new[] {true, false}
|
||||
from gamma in new [] {true, false}
|
||||
where !comparisonGroup.FitType.Any(ft => ft.FitRwp == rwp && ft.FitGammaStar == gamma)
|
||||
select $"(FitRwp: {(rwp ? "yes" : "no")}, FitGamma*: {(gamma ? "yes" : "no")})";
|
||||
throw new ParseException(
|
||||
$"Curve data in '{comparisonGroup.CurveID}' requires data sets representing all combinations of FitRwp and FitGamma."
|
||||
+ " Combinations missing are: " + string.Join(", ", missing));
|
||||
}
|
||||
|
||||
var curveData = new CurveData {CurveId = comparisonGroup.CurveID};
|
||||
|
||||
foreach (var fitType in comparisonGroup.FitType)
|
||||
@@ -52,29 +40,18 @@ namespace LeafWeb.Core.Charter
|
||||
// gammastar = chloroplastic CO2 partial pressure photocompensation point = "Cmp"
|
||||
|
||||
// put each comparison into the correct curve location
|
||||
if (!fitType.FitRwp && !fitType.FitGammaStar)
|
||||
curveData.FixedCndFixedCmp = paramSet;
|
||||
else if (!fitType.FitRwp && fitType.FitGammaStar)
|
||||
curveData.FixedCndEstimatedCmp = paramSet;
|
||||
else if (fitType.FitRwp && !fitType.FitGammaStar)
|
||||
curveData.EstimatedCndFixedCmp = paramSet;
|
||||
else if (fitType.FitRwp && fitType.FitGammaStar)
|
||||
curveData.EstimatedCndEstimatedCmp = paramSet;
|
||||
if (!fitType.FitRwp && !fitType.FitGammaStar)
|
||||
paramSet.CurveType = CurveType.FixedCndFixedCmp;
|
||||
else if (!fitType.FitRwp && fitType.FitGammaStar)
|
||||
paramSet.CurveType = CurveType.FixedCndEstimatedCmp;
|
||||
else if ( fitType.FitRwp && !fitType.FitGammaStar)
|
||||
paramSet.CurveType = CurveType.EstimatedCndFixedCmp;
|
||||
else if ( fitType.FitRwp && fitType.FitGammaStar)
|
||||
paramSet.CurveType = CurveType.EstimatedCndEstimatedCmp;
|
||||
|
||||
curveData.ParamSets.Add(paramSet);
|
||||
}
|
||||
|
||||
// guarantee all data is present
|
||||
if (curveData.FixedCndFixedCmp == null)
|
||||
throw new ArgumentException(
|
||||
$"{comparisonGroup.CurveID} missing data for {ReflectionExtensions.GetPropertyDisplayName<CurveData>(c=>c.FixedCndFixedCmp)}");
|
||||
if (curveData.FixedCndEstimatedCmp == null)
|
||||
throw new ArgumentException(
|
||||
$"{comparisonGroup.CurveID} missing data for {ReflectionExtensions.GetPropertyDisplayName<CurveData>(c=>c.FixedCndEstimatedCmp)}");
|
||||
if (curveData.EstimatedCndFixedCmp == null)
|
||||
throw new ArgumentException(
|
||||
$"{comparisonGroup.CurveID} missing data for {ReflectionExtensions.GetPropertyDisplayName<CurveData>(c=>c.EstimatedCndFixedCmp)}");
|
||||
if (curveData.EstimatedCndEstimatedCmp == null)
|
||||
throw new ArgumentException(
|
||||
$"{comparisonGroup.CurveID} missing data for {ReflectionExtensions.GetPropertyDisplayName<CurveData>(c=>c.EstimatedCndEstimatedCmp)}");
|
||||
yield return curveData;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user