diff --git a/backend/src/main/java/com/mcmasterbaja/analyzer/SmoothStrictPrimAnalyzer.java b/backend/src/main/java/com/mcmasterbaja/analyzer/SmoothStrictPrimAnalyzer.java index e12d5758..936681e8 100644 --- a/backend/src/main/java/com/mcmasterbaja/analyzer/SmoothStrictPrimAnalyzer.java +++ b/backend/src/main/java/com/mcmasterbaja/analyzer/SmoothStrictPrimAnalyzer.java @@ -20,7 +20,7 @@ public class SmoothStrictPrimAnalyzer extends Analyzer { @SneakyThrows public void analyze(AnalyzerParams params) { extractParams(params); - logger.info("Running pipeline: StrictTimestamp -> sGolay (single file RPM)"); + logger.info("Running pipeline: StrictTimestamp -> Outlier Removal -> sGolay (PRIM RPM)"); // Single file and column String file = params.getInputFiles()[0]; @@ -37,14 +37,33 @@ public void analyze(AnalyzerParams params) { strict.analyze(sp); String strictOut = sp.getOutputFiles()[0]; - // 2) Savitzky-Golay for the strict timestamp output + // 2) Outlier removal for RPM > 20000 + Analyzer outlierRemoval = factory.getAnalyzer(AnalyzerType.DELETE_OUTLIER); + AnalyzerParams or = new AnalyzerParams(); + or.setInputFiles(new String[] {strictOut}); + or.setInputColumns(new String[] {"Timestamp (ms)", "RPM PRIM"}); + or.setType(AnalyzerType.DELETE_OUTLIER); + or.setOptions( + new String[] { + "0", // minX (minimum timestamp - keep all) + "999999999", // maxX (maximum timestamp - keep all) + "0", // minY (minimum RPM - keep all above 0) + "20000" // maxY (maximum RPM - remove above 20000) + }); + or.generateOutputFileNames(); + outlierRemoval.analyze(or); + String outlierOut = or.getOutputFiles()[0]; + + // 3) Savitzky-Golay for the outlier-removed output Analyzer sGolay = factory.getAnalyzer(AnalyzerType.SGOLAY); AnalyzerParams sg = new AnalyzerParams(); - sg.setInputFiles(new String[] {strictOut, strictOut}); + sg.setInputFiles(new String[] {outlierOut, outlierOut}); sg.setInputColumns(new String[] {"Timestamp (ms)", "RPM PRIM"}); sg.setType(AnalyzerType.SGOLAY); sg.setOptions(new String[] {"101", "3"}); sg.setOutputFiles(params.getOutputFiles()); sGolay.analyze(sg); + + logger.info("Completed pipeline: StrictTimestamp -> Outlier Removal -> sGolay for PRIM RPM"); } } diff --git a/backend/src/main/java/com/mcmasterbaja/analyzer/SmoothStrictSecAnalyzer.java b/backend/src/main/java/com/mcmasterbaja/analyzer/SmoothStrictSecAnalyzer.java index 221307c4..f40296a7 100644 --- a/backend/src/main/java/com/mcmasterbaja/analyzer/SmoothStrictSecAnalyzer.java +++ b/backend/src/main/java/com/mcmasterbaja/analyzer/SmoothStrictSecAnalyzer.java @@ -20,7 +20,7 @@ public class SmoothStrictSecAnalyzer extends Analyzer { @SneakyThrows public void analyze(AnalyzerParams params) { extractParams(params); - logger.info("Running pipeline: StrictTimestamp -> sGolay (single file RPM)"); + logger.info("Running pipeline: StrictTimestamp -> Outlier Removal -> sGolay (SEC RPM)"); // Single file and column String file = params.getInputFiles()[0]; @@ -37,14 +37,33 @@ public void analyze(AnalyzerParams params) { strict.analyze(sp); String strictOut = sp.getOutputFiles()[0]; - // 2) Savitzky-Golay for the strict timestamp output + // 2) Outlier removal for RPM > 20000 + Analyzer outlierRemoval = factory.getAnalyzer(AnalyzerType.DELETE_OUTLIER); + AnalyzerParams or = new AnalyzerParams(); + or.setInputFiles(new String[] {strictOut}); + or.setInputColumns(new String[] {"Timestamp (ms)", "RPM SEC"}); + or.setType(AnalyzerType.DELETE_OUTLIER); + or.setOptions( + new String[] { + "0", // minX (minimum timestamp - keep all) + "999999999", // maxX (maximum timestamp - keep all) + "0", // minY (minimum RPM - keep all above 0) + "20000" // maxY (maximum RPM - remove above 20000) + }); + or.generateOutputFileNames(); + outlierRemoval.analyze(or); + String outlierOut = or.getOutputFiles()[0]; + + // 3) Savitzky-Golay for the outlier-removed output Analyzer sGolay = factory.getAnalyzer(AnalyzerType.SGOLAY); AnalyzerParams sg = new AnalyzerParams(); - sg.setInputFiles(new String[] {strictOut, strictOut}); + sg.setInputFiles(new String[] {outlierOut, outlierOut}); sg.setInputColumns(new String[] {"Timestamp (ms)", "RPM SEC"}); sg.setType(AnalyzerType.SGOLAY); sg.setOptions(new String[] {"101", "3"}); sg.setOutputFiles(params.getOutputFiles()); sGolay.analyze(sg); + + logger.info("Completed pipeline: StrictTimestamp -> Outlier Removal -> sGolay for SEC RPM"); } } diff --git a/front-end/src/lib/subteamGraphPresets.ts b/front-end/src/lib/subteamGraphPresets.ts index 9d2d725a..43ec4f94 100644 --- a/front-end/src/lib/subteamGraphPresets.ts +++ b/front-end/src/lib/subteamGraphPresets.ts @@ -33,7 +33,7 @@ export const subteamGraphPresets: DataViewerPreset[] = [ }, { name: 'Smooth Strict RPM', - description: 'Primary and Secondary RPM vs Timestamp (ms) smoothened with strict timestamp outlier removal', + description: 'Primary and Secondary RPM vs Timestamp (ms) smoothened + outlier removal + strict timestamp', graphs: [ { axes: [ @@ -86,8 +86,8 @@ export const subteamGraphPresets: DataViewerPreset[] = [ ] }, { - name: 'Smooth Primary RPM with Strict Timestamp', - description: 'Smooths PRIM RPM with strict timestamp outlier removal', + name: 'Smooth Strict PRIM RPM', + description: 'Smooths PRIM RPM with strict timestamp + outlier removal', graphs: [ { axes: [ @@ -101,8 +101,8 @@ export const subteamGraphPresets: DataViewerPreset[] = [ ], }, { - name: 'Smooth Secondary RPM with Strict Timestamp', - description: 'Smooths SEC RPM with strict timestamp outlier removal', + name: 'Smooth Strict SEC RPM', + description: 'Smooths SEC RPM with strict timestamp + outlier removal', graphs: [ { axes: [ diff --git a/front-end/src/types/AnalyzerTypes.ts b/front-end/src/types/AnalyzerTypes.ts index 191f58a7..af3117c1 100644 --- a/front-end/src/types/AnalyzerTypes.ts +++ b/front-end/src/types/AnalyzerTypes.ts @@ -235,7 +235,7 @@ export const analyzerConfig: Record = { [AnalyzerType.SMOOTH_STRICT_PRIM]: { title: 'Smooth Strict PRIM', description: - 'Runs StrictTimstamp and Sgolay for RPM PRIM', + 'Runs StrictTimestamp and Sgolay for RPM PRIM', isJoinBased: false, image: { src: placeholderImage, @@ -247,7 +247,7 @@ export const analyzerConfig: Record = { [AnalyzerType.SMOOTH_STRICT_SEC]: { title: 'Smooth Strict SEC', description: - 'Runs StrictTimstamp and Sgolay for RPM SEC', + 'Runs StrictTimestamp and Sgolay for RPM SEC', isJoinBased: false, image: { src: placeholderImage, @@ -255,4 +255,4 @@ export const analyzerConfig: Record = { }, links: [{ title: 'Timestamp (Wiki)', url: 'https://en.wikipedia.org/wiki/Timestamp' }], }, -}; \ No newline at end of file +};