diff --git a/dashboard-react/app/api/data/route.js b/dashboard-react/app/api/data/route.js index 1d37a23..66f6f8d 100644 --- a/dashboard-react/app/api/data/route.js +++ b/dashboard-react/app/api/data/route.js @@ -98,7 +98,7 @@ const getIntersectingTrialIDs = (...sets) => { }; const prepareData = async (searchParams) => { - console.log("searchParams", searchParams); + // console.log("searchParams", searchParams); // Display params const aggCol = searchParams.get("aggcol") || "Material Class I"; const displayCol = searchParams.get("displaycol") || "% Residuals (Mass)"; @@ -175,6 +175,18 @@ const prepareData = async (searchParams) => { // filter data based on selected filters filteredData = filterData(filteredData, "Test Method", [testMethod]); filteredData = filterData(filteredData, "Technology", technologies); + // Return empty object to preserve privacy if not enough trials (Except for Bulk Dose) + const technologyTrialIDs = new Set(filteredData.map((d) => d["Trial ID"])); + // console.log("technologyTrialIDs", technologyTrialIDs); + // console.log(technologies); + const trialThreshold = testMethod === "Bulk Dose" ? 1 : 3; + if (technologyTrialIDs.size < trialThreshold && testMethod !== "Bulk Dose") { + return { + message: + "There are not enough trials for the selected technology. Please select more options.", + }; + } + filteredData = filterData(filteredData, "Material Class II", materials); filteredData = filterData( filteredData, @@ -242,8 +254,8 @@ const prepareData = async (searchParams) => { console.log("filteredData.length", filteredData.length); - // Not enough data - return empty object (ignore for bulk dose since methodology is different) - const dataThreshold = testMethod === "Bulk Dose" ? 1 : 5; + // Not enough data - return empty object + const dataThreshold = 1; if (filteredData.length < dataThreshold) { return { message: @@ -283,7 +295,7 @@ const prepareData = async (searchParams) => { ); }); - console.log("sortedGrouped", sortedGrouped); + // console.log("sortedGrouped", sortedGrouped); return { data: sortedGrouped, diff --git a/dashboard-react/components/CheckboxMenu.js b/dashboard-react/components/CheckboxMenu.js index f282218..094dd5e 100644 --- a/dashboard-react/components/CheckboxMenu.js +++ b/dashboard-react/components/CheckboxMenu.js @@ -12,6 +12,7 @@ export default function CheckboxMenu({ filterKey, title, infoText, + showInfoIcon = false, }) { const snap = useSnapshot(state); @@ -97,7 +98,7 @@ export default function CheckboxMenu({
)}
@@ -105,7 +106,19 @@ export default function CheckboxMenu({ {options?.map((option) => (
  • ) : ( - ${title}`, - x: 0.5, - xanchor: "center", - yanchor: "top", - }, - showlegend: true, - yaxis: { + <> +
    + +
    + ${yAxisTitle}`, + text: `${title}`, + x: 0.5, + xanchor: "center", + yanchor: "top", + }, + showlegend: true, + yaxis: { + title: { + text: `${yAxisTitle}`, + }, + range: [0, yMax], + }, + xaxis: { + title: { + text: "Days", + }, + tickangle: xTickAngle, + ticklen: 10, + automargin: true, + range: [0, maxDays], // Cap x-axis at maxDays + showline: true, }, - range: [0, yMax], - linewidth: 2, // Set y-axis line thickness - }, - xaxis: { - tickangle: xTickAngle, - ticklen: 10, - automargin: true, - range: [0, maxDays], // Cap x-axis at maxDays - linewidth: 2, // Set x-axis line thickness - }, - hovermode: "x", - }} - config={{ - displayModeBar: false, - }} - /> + hovermode: "x", + }} + config={{ + displayModeBar: false, + }} + /> + )} ); diff --git a/dashboard-react/public/data/operating_conditions.csv b/dashboard-react/public/data/operating_conditions.csv index 0b1449a..fa7d292 100644 --- a/dashboard-react/public/data/operating_conditions.csv +++ b/dashboard-react/public/data/operating_conditions.csv @@ -1,15 +1,126 @@ -Trial ID,Trial Duration,Average Temperature (F),Average % Moisture (In Field) -CASP004-01,,, -WR004-01,67.0,127.30833333333328,0.49000000000000005 -CASP005-01,71.0,158.52903225806455,0.425 -EASP002-01,93.0,148.755376344086,0.49857142857142855 -CASP006-01,90.0,147.7457692307692,0.5471768113666667 -CASP004-02,68.0,134.8616417910448,0.5700000000000001 -ASP001-01,90.0,147.71428571428572,0.50495 -EASP003-01,90.0,159.26666666666668,0.4555555555555556 -WR005-01,95.0,140.15151515151518,0.5458333333333333 -EASP001-01,72.0,145.55940476190477,0.43916666666666665 -IV002-01,49.0,136.83468253968257,0.4583333333333333 -AD001-01,,, -CASP001-01,,, -CASP003-01,,, +Time Step,WR004-01,CASP005-01,EASP001-01,IV002-01,EASP002-01,CASP006-01,CASP004-02,ASP001-01,EASP003-01,WR005-01,Operating Condition,Time Unit +1.0,112.8,128.8,92.16333333333334,103.625,89.16666666666667,103.0,172.352,127.8,120.4,146.5,Temperature,Day +2.0,117.0,137.6,133.09,118.25,114.66666666666667,,169.172,133.8,116.2,136.0,Temperature,Day +3.0,125.2,140.8,116.84666666666668,117.875,129.66666666666666,109.0,164.956,136.4,124.2,141.0,Temperature,Day +4.0,128.0,,156.8,118.42857142857143,,,161.138,,,142.0,Temperature,Day +5.0,,,161.97,118.0,,,144.674,,,142.33333333333334,Temperature,Day +6.0,,142.6,140.29999999999998,117.66666666666667,143.66666666666666,137.33333333333334,137.366,142.0,165.4,,Temperature,Day +7.0,134.0,143.4,162.1,118.85714285714286,148.66666666666666,138.0,132.35000000000002,144.4,162.0,,Temperature,Day +8.0,135.8,144.6,166.95,119.28571428571429,149.66666666666666,141.33333333333334,157.474,146.4,167.2,108.0,Temperature,Day +9.0,136.4,131.2,170.01,121.88888888888889,158.66666666666666,146.66666666666666,155.116,148.0,170.0,107.33333333333333,Temperature,Day +10.0,139.2,156.6,143.47375,120.14285714285714,162.0,151.33333333333334,156.818,148.2,170.4,109.33333333333333,Temperature,Day +11.0,135.8,,169.03,119.57142857142857,,,128.574,,,110.33333333333333,Temperature,Day +12.0,,,169.77,119.14285714285714,,,115.68199999999999,,,108.0,Temperature,Day +13.0,,163.0,140.04375,118.57142857142857,160.0,,122.04,140.2,165.4,109.0,Temperature,Day +14.0,138.2,164.6,171.12,117.85714285714286,161.66666666666666,133.0,127.976,141.0,164.8,,Temperature,Day +15.0,135.8,166.0,134.94375,117.57142857142857,162.66666666666666,132.33333333333334,118.00199999999998,142.6,166.6,126.0,Temperature,Day +16.0,136.6,166.2,172.48,117.57142857142857,161.66666666666666,136.66666666666666,127.91400000000002,,165.2,129.0,Temperature,Day +17.0,135.8,168.2,138.24625,119.0,161.66666666666666,,117.50600000000001,142.2,160.2,144.83333333333334,Temperature,Day +18.0,136.6,,167.4,117.28571428571429,,,126.46400000000001,,,133.66666666666666,Temperature,Day +19.0,,,166.56,118.14285714285714,,,117.556,,,148.16666666666666,Temperature,Day +20.0,,,127.5975,117.71428571428571,160.83333333333334,133.33333333333334,122.648,142.6,153.8,,Temperature,Day +21.0,136.4,150.6,170.6,118.57142857142857,159.0,137.5,131.92999999999998,155.2,,,Temperature,Day +22.0,137.2,150.8,127.2025,141.85714285714286,157.33333333333334,129.4,117.75,155.4,152.8,,Temperature,Day +23.0,139.6,153.6,168.09,141.14285714285714,135.0,131.8,122.6,156.8,,,Temperature,Day +24.0,138.8,155.6,123.42857142857143,143.57142857142858,140.33333333333334,,136.218,155.8,148.2,140.33333333333334,Temperature,Day +25.0,136.0,,165.61,144.14285714285714,,,117.458,,,,Temperature,Day +26.0,,,164.11,145.28571428571428,,,119.94200000000001,,,,Temperature,Day +27.0,,160.8,162.11,146.85714285714286,157.33333333333334,156.33333333333334,124.796,156.2,159.2,,Temperature,Day +28.0,136.6,163.4,118.28571428571429,148.57142857142858,158.66666666666666,154.0,134.12199999999999,157.0,156.6,,Temperature,Day +29.0,136.0,165.6,118.57142857142857,148.71428571428572,158.33333333333334,154.66666666666666,123.418,,156.0,140.0,Temperature,Day +30.0,135.6,167.8,130.28571428571428,151.0,156.66666666666666,153.33333333333334,116.53600000000002,162.0,,147.0,Temperature,Day +31.0,133.8,169.0,130.28571428571428,149.85714285714286,157.66666666666666,157.0,117.93800000000002,,155.8,153.16666666666666,Temperature,Day +32.0,135.0,,158.16,135.14285714285714,,,119.39000000000001,,,,Temperature,Day +33.0,,,157.88,137.85714285714286,,,121.502,,,148.83333333333334,Temperature,Day +34.0,,169.6,129.42857142857142,142.42857142857142,157.0,,124.15599999999999,154.8,,,Temperature,Day +35.0,,169.8,130.57142857142858,151.85714285714286,158.0,153.0,127.25399999999999,151.6,,,Temperature,Day +36.0,135.3,169.8,131.14285714285714,148.28571428571428,157.0,145.5,141.254,151.6,149.2,,Temperature,Day +37.0,135.1,168.0,154.04,150.0,160.33333333333334,151.66666666666666,127.704,151.6,,,Temperature,Day +38.0,135.2,169.2,126.85714285714286,157.14285714285714,158.33333333333334,,117.78000000000002,,,151.83333333333334,Temperature,Day +39.0,135.2,,153.07,151.14285714285714,,,117.09400000000001,,,,Temperature,Day +40.0,,,152.23,150.0,,,116.36800000000001,,,,Temperature,Day +41.0,,,126.85714285714286,150.71428571428572,157.33333333333334,148.66666666666666,116.23799999999999,149.0,141.2,,Temperature,Day +42.0,135.0,168.4,149.89,158.42857142857142,159.0,144.0,116.96,145.2,,,Temperature,Day +43.0,134.9,169.0,125.42857142857143,158.28571428571428,153.66666666666666,152.0,110.06199999999998,,135.8,142.66666666666666,Temperature,Day +44.0,136.2,170.2,150.0,157.85714285714286,150.33333333333334,150.66666666666666,110.828,147.2,167.4,,Temperature,Day +45.0,136.8,169.6,125.14285714285714,159.0,153.0,,113.33599999999998,151.0,166.6,148.16666666666666,Temperature,Day +46.0,128.4,,,158.42857142857142,,,117.98400000000001,,,153.33333333333334,Temperature,Day +47.0,,,,159.28571428571428,,166.0,119.974,,,,Temperature,Day +48.0,,,,160.85714285714286,148.66666666666666,164.0,121.99600000000001,,167.6,,Temperature,Day +49.0,124.4,,,159.28571428571428,154.33333333333334,160.66666666666666,130.964,,167.6,,Temperature,Day +50.0,124.9,,,159.71428571428572,118.33333333333333,,148.8,,171.8,,Temperature,Day +51.0,123.7,,,,128.66666666666666,,140.8,,167.6,143.16666666666666,Temperature,Day +52.0,122.2,,,,131.0,,149.0,,168.0,,Temperature,Day +53.0,117.8,,,,,,145.6,,,,Temperature,Day +54.0,,,,,,,148.0,,,,Temperature,Day +55.0,,,,,150.66666666666666,160.33333333333334,149.2,,168.0,,Temperature,Day +56.0,114.3,,,,154.0,151.66666666666666,144.0,,,,Temperature,Day +57.0,110.7,,,,156.0,157.0,155.8,,168.2,151.33333333333334,Temperature,Day +58.0,114.4,,,,158.33333333333334,157.33333333333334,156.8,,169.0,148.66666666666666,Temperature,Day +59.0,112.4,,,,160.33333333333334,,160.2,,168.2,146.83333333333334,Temperature,Day +60.0,109.4,,,,,,159.8,,,146.5,Temperature,Day +61.0,,,,,,157.33333333333334,159.8,,,144.83333333333334,Temperature,Day +62.0,,,,,161.0,158.0,161.0,,165.6,,Temperature,Day +63.0,105.1,,,,160.33333333333334,163.0,152.8,,,,Temperature,Day +64.0,106.9,,,,156.33333333333334,,148.4,,167.8,146.66666666666666,Temperature,Day +65.0,102.3,,,,157.0,,148.0,,168.4,,Temperature,Day +66.0,101.7,,,,156.33333333333334,,152.8,,166.4,154.0,Temperature,Day +67.0,96.3,,,,,,145.6,,,153.33333333333334,Temperature,Day +68.0,,,,,,154.66666666666666,,,,,Temperature,Day +69.0,,,,,156.66666666666666,154.0,,,166.6,,Temperature,Day +70.0,,,,,130.33333333333334,153.0,,,,,Temperature,Day +71.0,,,,,133.0,153.0,,,,148.33333333333334,Temperature,Day +72.0,,,,,137.0,,,,,,Temperature,Day +73.0,,,,,142.0,,,,,151.16666666666666,Temperature,Day +74.0,,,,,,,,,,,Temperature,Day +75.0,,,,,,150.0,,,,144.66666666666666,Temperature,Day +76.0,,,,,,149.33333333333334,,,,,Temperature,Day +77.0,,,,,,150.5,,,,,Temperature,Day +78.0,,,,,140.83333333333334,149.52666666666667,,,,,Temperature,Day +79.0,,,,,141.33333333333334,151.21,,,,,Temperature,Day +80.0,,,,,141.33333333333334,149.6,,,,150.66666666666666,Temperature,Day +81.0,,,,,,150.24,,,,,Temperature,Day +82.0,,,,,,148.51333333333332,,,,,Temperature,Day +83.0,,,,,140.33333333333334,147.95000000000002,,,,,Temperature,Day +84.0,,,,,140.0,149.41333333333333,,,,,Temperature,Day +85.0,,,,,139.66666666666666,147.42333333333332,,,,143.33333333333334,Temperature,Day +86.0,,,,,140.33333333333334,147.53666666666666,,,,,Temperature,Day +87.0,,,,,139.66666666666666,,,,,140.66666666666666,Temperature,Day +88.0,,,,,,,,,,,Temperature,Day +89.0,,,,,,,,,,141.66666666666666,Temperature,Day +90.0,,,,,140.0,,,,,,Temperature,Day +91.0,,,,,,,,,,,Temperature,Day +92.0,,,,,,,,,,,Temperature,Day +93.0,,,,,,,,,,143.66666666666666,Temperature,Day +94.0,,,,,,,,,,150.33333333333334,Temperature,Day +95.0,,,,,,,,,,150.0,Temperature,Day +96.0,,,,,,,,,,,Temperature,Day +97.0,,,,,,,,,,,Temperature,Day +1.0,0.5,0.5,0.6,0.55,0.6,,0.57,,,0.6,Moisture,Week +2.0,0.5,0.4,0.6,0.5,0.6,0.6690518113666666,0.57,0.5068,0.45,,Moisture,Week +3.0,0.5,0.4,0.5,0.5,0.5,,0.57,0.5001,0.5,0.55,Moisture,Week +4.0,0.5,0.4,0.48,0.4,0.5,0.5440518113666666,0.57,0.6226,0.5,0.55,Moisture,Week +5.0,0.5,0.4,0.42,0.4,0.45,0.6190518113666668,0.57,0.5664,0.5,0.55,Moisture,Week +6.0,0.5,0.4,0.41,0.4,0.45,0.5190518113666667,0.57,0.4647,0.5,0.55,Moisture,Week +7.0,0.5,0.4,0.36,,0.4,0.5690518113666669,0.57,0.5388,,0.55,Moisture,Week +8.0,0.5,0.5,0.36,,0.4,,0.57,0.48,0.45,0.5,Moisture,Week +9.0,0.45,,0.43,,0.4,0.5690518113666669,0.57,,0.4,0.5,Moisture,Week +10.0,0.45,,0.4,,0.38,,0.57,0.46,0.4,0.55,Moisture,Week +11.0,,,0.36,,0.6,0.5190518113666667,,0.51,0.4,0.55,Moisture,Week +12.0,,,0.35,,0.6,,,0.47,,0.55,Moisture,Week +13.0,,,,,0.6,0.3690518113666666,,0.45,,0.55,Moisture,Week +14.0,,,,,0.5,,,0.49,,,Moisture,Week +1.0,0.075,0.11,0.18,,0.1,,0.208,0.16,,0.0275,Oxygen,Week +2.0,0.06,0.11,0.1775,0.19,0.1,,,,0.12,0.014848484848484849,Oxygen,Week +3.0,0.07,0.1,0.1725,,0.1,,0.212,0.1517,,0.020588235294117643,Oxygen,Week +4.0,0.06,0.1,0.195,0.08,0.12,0.1198,,,0.15,0.0183,Oxygen,Week +5.0,0.07,0.1,0.178,,0.03,,0.212,0.1117,,0.016666666666666666,Oxygen,Week +6.0,0.06,0.1,0.178,0.03,0.04,,,0.155,0.14,0.028333333333333335,Oxygen,Week +7.0,0.06,0.1,0.176,,0.06,,0.225,,,0.015,Oxygen,Week +8.0,0.06,0.1,0.18,,0.07,,,0.148,0.11,0.02,Oxygen,Week +9.0,0.08,,0.173,,0.04,,0.22,,0.1,0.0175,Oxygen,Week +10.0,0.08,,0.16,,0.02,,,0.12,,,Oxygen,Week +11.0,,,0.13,,0.0,,,,0.02,0.013333333333333332,Oxygen,Week +12.0,,,0.12,,0.1,,,0.09,,,Oxygen,Week +13.0,,,,,0.01,,,,,0.05428571428571429,Oxygen,Week +14.0,,,,,,,,,,,Oxygen,Week diff --git a/scripts/pipeline-template.py b/scripts/pipeline-template.py index cb4231a..cd564da 100644 --- a/scripts/pipeline-template.py +++ b/scripts/pipeline-template.py @@ -104,6 +104,8 @@ def map_technology(trial_id: str) -> str: df_temps = pd.read_excel(OPERATING_CONDITIONS_PATH, sheet_name=3, skiprows=1, index_col="Day #") df_temps.columns = [trial2id[col.replace("*", "")] for col in df_temps.columns] df_temps_avg = df_temps.mean().to_frame("Average Temperature (F)") +df_temps["Operating Condition"] = "Temperature" +df_temps["Time Unit"] = "Day" df_trial_duration = pd.read_excel( OPERATING_CONDITIONS_PATH, @@ -123,8 +125,22 @@ def map_technology(trial_id: str) -> str: df_trial_duration = df_trial_duration.set_index("Trial ID") df_moisture = pd.read_excel(OPERATING_CONDITIONS_PATH, sheet_name=4, skiprows=1, index_col="Week") +# Filter out rows with non-numeric week values +df_moisture = df_moisture.reset_index() +df_moisture = df_moisture[pd.to_numeric(df_moisture["Week"], errors="coerce").notna()] +df_moisture = df_moisture.set_index("Week") df_moisture.columns = [trial2id[col.replace("*", "")] for col in df_moisture.columns] df_moisture_avg = df_moisture.mean().to_frame("Average % Moisture (In Field)") +df_moisture["Operating Condition"] = "Moisture" +df_moisture["Time Unit"] = "Week" + +df_o2 = pd.read_excel(OPERATING_CONDITIONS_PATH, sheet_name=6, skiprows=1, index_col="Week") +df_o2 = df_o2.reset_index() +df_o2 = df_o2[pd.to_numeric(df_o2["Week"], errors="coerce").notna()] +df_o2 = df_o2.set_index("Week") +df_o2.columns = [trial2id[col.replace("*", "")] for col in df_o2.columns] +df_o2["Operating Condition"] = "Oxygen" +df_o2["Time Unit"] = "Week" df_operating_conditions_avg = pd.concat([df_trial_duration, df_temps_avg, df_moisture_avg], axis=1) @@ -588,11 +604,12 @@ def preprocess_data(self, data: pd.DataFrame) -> pd.DataFrame: df_operating_conditions_avg, left_index=True, right_index=True, how="left" ) -operating_conditions_output_path = DATA_DIR / "operating_conditions_avg.csv" -df_operating_conditions_avg.to_csv(operating_conditions_output_path, index_label="Trial ID") +operating_conditions_avg_output_path = DATA_DIR / "operating_conditions_avg.csv" +df_operating_conditions_avg.to_csv(operating_conditions_avg_output_path, index_label="Trial ID") -# Save full temperature data (TODO: Currently testing this...) -temperature_output_path = DATA_DIR / "temperature_data.csv" -df_temps.to_csv(temperature_output_path, index=True) +# Save full operating conditions data (TODO: Currently testing this...) +operating_conditions_output_path = DATA_DIR / "operating_conditions.csv" +df_operating_conditions = pd.concat([df_temps, df_moisture, df_o2], axis=0) +df_operating_conditions.to_csv(operating_conditions_output_path, index=True, index_label="Time Step") print("Complete!")