Skip to content

Commit

Permalink
(#2887) Only interpolate if there are values before and after
Browse files Browse the repository at this point in the history
Also only interpolate good values
  • Loading branch information
squaregoldfish committed May 3, 2024
1 parent 2ca2beb commit cea1b86
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,48 +20,32 @@ GGBQBFQBQQQGG,17,12,22,17,17,G,12;22
GGBQBFBBQQQGG,17,12,22,17,17,G,12;22
GGBQBFNBQQQGG,17,12,22,17,17,G,12;22
QBQBFFGBQQQQQ,17,17,17,17,17,G,17
QBQBFFFBQQQQQ,17,13,19,17,17,Q,13;19
QBQBFFFBQQQQQ,17,,,,,,
QBQBFFQBQQQQQ,17,17,17,17,17,Q,17
QBQBFFBBQQQQQ,17,13,19,17,17,Q,13;19
QBQBFFNBQQQQQ,17,13,19,17,17,Q,13;19
QBQBFFBBQQQQQ,17,17,17,17,17,B,17
QBQBFFNBQQQQQ,17,,,,,,
BBBBFFGBBBBBB,17,17,17,17,17,G,17
BBBBFFFBBBBBB,17,14,18,17,17,B,14;18
BBBBFFFBBBBBB,17,,,,,,
BBBBFFQBBBBBB,17,17,17,17,17,Q,17
BBBBFFBBBBBBB,17,17,17,17,17,B,17
BBBBFFNBBBBBB,17,14,18,17,17,B,14;18
BBBBFFNBBBBBB,17,,,,,,
FFFFFFGFFFFFF,17,17,17,17,17,G,17
FFFFFFFFFFFFF,17,,,,,,
FFFFFFQFFFFFF,17,17,17,17,17,Q,17
FFFFFFBFFFFFF,17,17,17,17,17,B,17
FFFFFFNFFFFFF,17,,,,,,
GGGGGGGGGGGGG,1,,,,,,
GGGGGGGGGGGGG,10,11,11,10,11,G,11
GGGGGGGGGGGGG,24,23,23,24,23,G,23
GGGGGGGGGGGGG,10,,,,,,
GGGGGGGGGGGGG,24,,,,,,
FFFFFFFFFFFFF,10,,,,,,
FFFFFFFFFFFFF,24,,,,,,
QQQQQQQQQQQQQ,10,11,11,10,11,Q,11
QQQQQQQQQQQQQ,24,23,23,24,23,Q,23
BBBBBBBBBBBBB,10,11,11,10,11,B,11
BBBBBBBBBBBBB,24,23,23,24,23,B,23
FBQGGGGGGGQBF,9,14,14,9,14,G,14
FBQGGGGGGGQBF,8,13,13,8,13,Q,13
FBQGGGGGGGQBF,7,12,12,7,12,B,12
FBQGGGGGGGQBF,6,,,,,,
FBQGGGGGGGQBF,5,,,,,,
GGGGGGNBBBBBB,17,16,16,17,16,G,16
QQQQQQNGGGGGG,17,18,18,17,18,G,18
BBBBBBNQQQQQQ,17,18,18,17,18,Q,18
QQQQQQBGGGGGG,17,18,18,17,18,G,18
QQQQQQQGGGGGG,17,18,18,17,18,G,18
QQQQQQQQQBQQQ,20,19,21,20,20,Q,19;21
QQQBQQQQQQQQQ,14,13,15,14,14,Q,13;15
GGGGGGGGGGGGG,10,11,11,10,11,G,11
GGGGGGGGGGGGG,8,11,11,8,11,G,11
GGGGGGGGGGGGG,5,,,,,,
GGGGGGGGGGGGG,24,23,23,24,23,G,23
GGGGGGGGGGGGG,27,23,23,27,23,G,23
GGGGGGGGGGGGG,30,,,,,,
BGGGGGGGGGGGB,10,12,12,10,12,G,12
BGGGGGGGGGGGB,6,11,11,6,11,B,11
BGGGGGGGGGGGB,24,22,22,24,22,G,22
BGGGGGGGGGGGB,28,23,23,28,23,B,23
QQQQQQQQQQQQQ,10,,,,,,
QQQQQQQQQQQQQ,24,,,,,,
BBBBBBBBBBBBB,10,,,,,,
BBBBBBBBBBBBB,24,,,,,,
GGGGGGNBBBBBB,17,,,,,,
QQQQQQNGGGGGG,17,,,,,,
BBBBBBNQQQQQQ,17,,,,,,
QQQQQQBGGGGGG,17,17,17,17,17,B,17
QQQQQQQGGGGGG,17,17,17,17,17,Q,17
QQQQQQQQQBQQQ,20,20,20,20,20,B,20
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ GGGGG,GGGGGGG,GGGGG,16,11,27,16,16,G,11;12;13;14;15;21;22;23;24;25;26;27
GGQQG,GQQGGQQ,QQGQQ,18,11,27,18,17.515,G,11;12;15;21;24;25
GGQQG,GQQGGQQ,QQGQQ,30,21,39,30,29.641,G,21;24;25;37
GGQQG,GQQGGQQ,QQQQQ,30,21,27,24,23.333,G,21;24;25
GGQQG,QQQQQBB,QQQQQ,30,21,39,30,29.462,Q,21;22;23;24;25;35;36;37;38;39
GGQQG,QQQQQBB,QQQQQ,30,,,,,,
QQQQQ,BBBBBBB,QQQQQ,20,11,15,13,13,Q,11;12;13;14;15
QQQQQ,QQQQQQQ,BBBBB,38,35,39,38,37,B,35;36;37;38;39
BBGBG,BGBBQGG,GQGBB,5,11,15,5,14,G,13;15
Expand Down
30 changes: 12 additions & 18 deletions WebApp/src/uk/ac/exeter/QuinCe/data/Dataset/SensorValuesList.java
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,10 @@ private SensorValuesListValue makeDummyValue(LocalDateTime time) {
*
* <p>
* The value of the result will be the linear interpolation of the supplied
* values to the specified target time.
* values to the specified target time. If there is only a prior or post
* value, no interpolation will be performed and a {@code null} value will be
* returned. If the prior and post values have different flags, the
* interpolated value will be given the worst of those flags.
* </p>
*
* @param first
Expand All @@ -1085,24 +1088,14 @@ private SensorValuesListValue buildInterpolatedValue(

SensorValuesListValue result;

if (null == first && null == second) {
if (null == first || null == second) {
// Only 'interpolate' if we have values both before and after
result = null;
} else if (second == null) {
// Use prior value only
result = new SensorValuesListValue(first, targetTime);
} else if (first == null) {
// Use post value only
result = new SensorValuesListValue(second, targetTime);
} else {

if (second.getQCFlag().moreSignificantThan(first.getQCFlag())) {
result = new SensorValuesListValue(first, targetTime);
} else if (first.getQCFlag().moreSignificantThan(second.getQCFlag())) {
result = new SensorValuesListValue(second, targetTime);
if (!first.getQCFlag().isGood() || !second.getQCFlag().isGood()) {
// We only interpolate good values
result = null;
} else {

// Interpolate between the two

Double interpValue = Calculators.interpolate(first.getTime(),
first.getDoubleValue(), second.getTime(), second.getDoubleValue(),
targetTime);
Expand All @@ -1115,8 +1108,9 @@ private SensorValuesListValue buildInterpolatedValue(
result = new SensorValuesListValue(first.getStartTime(),
second.getEndTime(), targetTime, combinedSourceValues,
first.getSensorType(), interpValue,
Flag.getMostSignificantFlag(first.getQCFlag(), second.getQCFlag()), StringUtils
.combine(first.getQCMessage(), second.getQCMessage(), ";"));
Flag.getMostSignificantFlag(first.getQCFlag(), second.getQCFlag()),
StringUtils.combine(first.getQCMessage(), second.getQCMessage(),
";"));
}
}
return result;
Expand Down

0 comments on commit cea1b86

Please sign in to comment.