From bb2b5e3939dabee2c38433133ea7e84189d6eb41 Mon Sep 17 00:00:00 2001 From: mloppie Date: Wed, 9 Oct 2024 14:59:40 -0400 Subject: [PATCH 01/15] show intervention marker on chart, improve label position --- .../calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue | 6 +++++- packages/client/hmi-client/src/services/charts.ts | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index 69ef6bfede..c0c5b71ea1 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -792,7 +792,11 @@ const preparedCharts = computed(() => { annotations ); - charts[variable].layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[variable])); + Object.entries(groupedInterventionOutputs.value).forEach((item) => { + item[1].forEach((intervention) => { + charts[variable].layer.push(...createInterventionChartMarkers(intervention, false, -180)); + }); + }); }); return charts; }); diff --git a/packages/client/hmi-client/src/services/charts.ts b/packages/client/hmi-client/src/services/charts.ts index c681c96490..132fa06f4c 100644 --- a/packages/client/hmi-client/src/services/charts.ts +++ b/packages/client/hmi-client/src/services/charts.ts @@ -733,7 +733,8 @@ export function createSuccessCriteriaChart( export function createInterventionChartMarkers( data: ReturnType, - hideLabels = false + hideLabels = false, + labelXOffset = 5 ): any[] { const markerSpec = { data: { values: data }, @@ -749,7 +750,7 @@ export function createInterventionChartMarkers( type: 'text', align: 'left', angle: 90, - dx: 5, + dx: labelXOffset, dy: -10 }, encoding: { From 7b5e1b7af265a95b10296df3db3011bb21d2dbfd Mon Sep 17 00:00:00 2001 From: mloppie Date: Wed, 9 Oct 2024 15:09:09 -0400 Subject: [PATCH 02/15] show intervention on calibrate node graph, improve label position --- .../ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue index 07a0703007..0b6804be53 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue @@ -210,8 +210,11 @@ const preparedCharts = computed(() => { } ); applyForecastChartAnnotations(chart, annotations); - chart.layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[variable])); - + Object.entries(groupedInterventionOutputs.value).forEach((item) => { + item[1].forEach((intervention) => { + chart.layer.push(...createInterventionChartMarkers(intervention, false, -80)); + }); + }); return chart; }); }); From 63ca70f95d73af276c268d42d7db2918f8baf7d7 Mon Sep 17 00:00:00 2001 From: mloppie Date: Wed, 9 Oct 2024 15:28:29 -0400 Subject: [PATCH 03/15] lint --- .../ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue | 2 +- .../ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index c0c5b71ea1..9261e9c7fa 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -794,7 +794,7 @@ const preparedCharts = computed(() => { Object.entries(groupedInterventionOutputs.value).forEach((item) => { item[1].forEach((intervention) => { - charts[variable].layer.push(...createInterventionChartMarkers(intervention, false, -180)); + charts[variable].layer.push(...createInterventionChartMarkers([intervention], false, -180)); }); }); }); diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue index 0b6804be53..b34b5b62d3 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue @@ -212,7 +212,7 @@ const preparedCharts = computed(() => { applyForecastChartAnnotations(chart, annotations); Object.entries(groupedInterventionOutputs.value).forEach((item) => { item[1].forEach((intervention) => { - chart.layer.push(...createInterventionChartMarkers(intervention, false, -80)); + chart.layer.push(...createInterventionChartMarkers([intervention], false, -80)); }); }); return chart; From 364cd677926777fe8779043f15633fabfeb82a3a Mon Sep 17 00:00:00 2001 From: mloppie Date: Wed, 16 Oct 2024 13:24:34 -0400 Subject: [PATCH 04/15] add intervention charts to calibrate dd --- .../tera-calibrate-ciemss-drilldown.vue | 32 ++++++++++++++++--- .../tera-calibrate-node-ciemss.vue | 2 +- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index 2f45e3769e..b986e11465 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -288,6 +288,15 @@ /> + + + { annotations ); - Object.entries(groupedInterventionOutputs.value).forEach((item) => { - item[1].forEach((intervention) => { - charts[variable].layer.push(...createInterventionChartMarkers([intervention], false, -180)); + if (groupedInterventionOutputs.value) { + Object.entries(groupedInterventionOutputs.value).forEach((item) => { + item[1].forEach((intervention) => { + charts[variable].layer.push(...createInterventionChartMarkers([intervention], false)); + }); }); - }); + } }); + + if (groupedInterventionOutputs.value) { + _.forEach(Object.keys(groupedInterventionOutputs.value), (key) => { + charts[key] = createInterventionChart(groupedInterventionOutputs.value[key], { + title: key, + width: chartSize.value.width, + height: chartSize.value.height, + xAxisTitle: 'Time', + yAxisTitle: 'Value' + }); + }); + } return charts; }); diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue index b34b5b62d3..b3799067ae 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue @@ -212,7 +212,7 @@ const preparedCharts = computed(() => { applyForecastChartAnnotations(chart, annotations); Object.entries(groupedInterventionOutputs.value).forEach((item) => { item[1].forEach((intervention) => { - chart.layer.push(...createInterventionChartMarkers([intervention], false, -80)); + chart.layer.push(...createInterventionChartMarkers([intervention], false)); }); }); return chart; From a14f149508d23553686f26d0c93008ddcaff53bb Mon Sep 17 00:00:00 2001 From: mloppie Date: Fri, 18 Oct 2024 10:55:41 -0400 Subject: [PATCH 05/15] partial --- .../tera-calibrate-ciemss-drilldown.vue | 53 +++++++++++++++---- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index b986e11465..291f853aa9 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -293,7 +293,7 @@ @@ -464,6 +464,7 @@ import { ClientEventType, CsvAsset, DatasetColumn, + Model, ModelConfiguration, ChartAnnotation, InterventionPolicy, @@ -490,7 +491,6 @@ import { WorkflowNode } from '@/types/workflow'; import { createForecastChart, createHistogramChart, - createInterventionChart, createErrorChart, applyForecastChartAnnotations, createInterventionChartMarkers @@ -499,6 +499,7 @@ import VegaChart from '@/components/widgets/VegaChart.vue'; import TeraChartControl from '@/components/workflow/tera-chart-control.vue'; import TeraInputText from '@/components/widgets/tera-input-text.vue'; import { displayNumber } from '@/utils/number'; +import { getUnitsFromModelParts } from '@/services/model'; import TeraPyciemssCancelButton from '@/components/pyciemss/tera-pyciemss-cancel-button.vue'; import TeraSaveSimulationModal from '@/components/project/tera-save-simulation-modal.vue'; import { useClientEvent } from '@/composables/useClientEvent'; @@ -743,6 +744,15 @@ const groupedInterventionOutputs = computed(() => _.groupBy(flattenInterventionData(interventionPolicy.value?.interventions ?? []), 'appliedTo') ); +const translationMap = (variable: string) => ({ + [`${pyciemssMap[variable]}_mean:pre`]: `${variable} before optimization`, + [`${pyciemssMap[variable]}_mean`]: `${variable} after optimization` +}); +const modelref = ref(null); +const getUnit = (paramId: string) => { + if (!modelref.value) return ''; + return getUnitsFromModelParts(modelref.value)[paramId] || ''; +}; const preparedCharts = computed(() => { if (!preparedChartInputs.value) return {}; const { result, resultSummary, reverseMap } = preparedChartInputs.value; @@ -751,7 +761,7 @@ const preparedCharts = computed(() => { // Need to get the dataset's time field const datasetTimeField = knobs.value.timestampColName; - const charts = {}; + const charts = { interventions: {} }; selectedVariableSettings.value.forEach((settings) => { const variable = settings.selectedVariables[0]; const annotations = chartAnnotations.value.filter((annotation) => annotation.chartId === settings.id); @@ -803,14 +813,35 @@ const preparedCharts = computed(() => { }); if (groupedInterventionOutputs.value) { - _.forEach(Object.keys(groupedInterventionOutputs.value), (key) => { - charts[key] = createInterventionChart(groupedInterventionOutputs.value[key], { - title: key, - width: chartSize.value.width, - height: chartSize.value.height, - xAxisTitle: 'Time', - yAxisTitle: 'Value' - }); + Object.entries(groupedInterventionOutputs.value).forEach((variable) => { + if (!variable) return; + + charts.interventions[variable[0]] = createForecastChart( + { + data: result, + variables: [`${pyciemssMap[variable[0]]}:pre`, pyciemssMap[variable[0]]], + timeField: 'timepoint_id', + groupField: 'sample_id' + }, + { + data: resultSummary, + variables: [`${pyciemssMap[variable[0]]}_mean:pre`, `${pyciemssMap[variable[0]]}_mean`], + timeField: 'timepoint_id' + }, + null, + { + width: chartSize.value.width, + height: chartSize.value.height, + legend: true, + xAxisTitle: getUnit('_time') || 'Time', + yAxisTitle: getUnit(variable[0]), + title: '', + colorscheme: ['#AAB3C6', '#1B8073'], + translationMap: translationMap(variable[0]) + } + ); + // add intervention annotations (rules and text) + // forecastChart.layer.push(...createInterventionChartMarkers(preProcessedInterventionsData.value[variable])); }); } return charts; From bc249fddea9acc155192cf3f1a7930c1276e0f61 Mon Sep 17 00:00:00 2001 From: Tom Szendrey Date: Fri, 18 Oct 2024 12:00:44 -0400 Subject: [PATCH 06/15] hope this is what youre looking for --- .../tera-calibrate-ciemss-drilldown.vue | 78 +++++++++---------- 1 file changed, 38 insertions(+), 40 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index 291f853aa9..f916e4239f 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -284,7 +284,7 @@ @@ -293,7 +293,7 @@ @@ -464,7 +464,6 @@ import { ClientEventType, CsvAsset, DatasetColumn, - Model, ModelConfiguration, ChartAnnotation, InterventionPolicy, @@ -492,14 +491,13 @@ import { createForecastChart, createHistogramChart, createErrorChart, - applyForecastChartAnnotations, - createInterventionChartMarkers + applyForecastChartAnnotations + // ,createInterventionChartMarkers } from '@/services/charts'; import VegaChart from '@/components/widgets/VegaChart.vue'; import TeraChartControl from '@/components/workflow/tera-chart-control.vue'; import TeraInputText from '@/components/widgets/tera-input-text.vue'; import { displayNumber } from '@/utils/number'; -import { getUnitsFromModelParts } from '@/services/model'; import TeraPyciemssCancelButton from '@/components/pyciemss/tera-pyciemss-cancel-button.vue'; import TeraSaveSimulationModal from '@/components/project/tera-save-simulation-modal.vue'; import { useClientEvent } from '@/composables/useClientEvent'; @@ -744,24 +742,20 @@ const groupedInterventionOutputs = computed(() => _.groupBy(flattenInterventionData(interventionPolicy.value?.interventions ?? []), 'appliedTo') ); -const translationMap = (variable: string) => ({ - [`${pyciemssMap[variable]}_mean:pre`]: `${variable} before optimization`, - [`${pyciemssMap[variable]}_mean`]: `${variable} after optimization` -}); -const modelref = ref(null); -const getUnit = (paramId: string) => { - if (!modelref.value) return ''; - return getUnitsFromModelParts(modelref.value)[paramId] || ''; -}; const preparedCharts = computed(() => { - if (!preparedChartInputs.value) return {}; + const charts: { interventionCharts: any[]; simulationCharts: any[] } = { + interventionCharts: [], + simulationCharts: [] + }; + + if (!preparedChartInputs.value) return charts; const { result, resultSummary, reverseMap } = preparedChartInputs.value; const state = props.node.state; // Need to get the dataset's time field const datasetTimeField = knobs.value.timestampColName; - const charts = { interventions: {} }; + // Simulate Charts: selectedVariableSettings.value.forEach((settings) => { const variable = settings.selectedVariables[0]; const annotations = chartAnnotations.value.filter((annotation) => annotation.chartId === settings.id); @@ -770,7 +764,7 @@ const preparedCharts = computed(() => { if (mapObj) { datasetVariables.push(mapObj.datasetVariable); } - charts[variable] = applyForecastChartAnnotations( + charts.simulationCharts[variable] = applyForecastChartAnnotations( createForecastChart( { data: result, @@ -803,50 +797,54 @@ const preparedCharts = computed(() => { annotations ); - if (groupedInterventionOutputs.value) { - Object.entries(groupedInterventionOutputs.value).forEach((item) => { - item[1].forEach((intervention) => { - charts[variable].layer.push(...createInterventionChartMarkers([intervention], false)); - }); - }); - } + // if (groupedInterventionOutputs.value) { + // Object.entries(groupedInterventionOutputs.value).forEach((item) => { + // item[1].forEach((intervention) => { + // charts.simulationCharts[variable].layer.push(...createInterventionChartMarkers([intervention], false)); + // }); + // }); + // } }); if (groupedInterventionOutputs.value) { - Object.entries(groupedInterventionOutputs.value).forEach((variable) => { - if (!variable) return; - - charts.interventions[variable[0]] = createForecastChart( + Object.keys(groupedInterventionOutputs.value).forEach((key) => { + console.log(key); + charts.interventionCharts[key] = createForecastChart( { data: result, - variables: [`${pyciemssMap[variable[0]]}:pre`, pyciemssMap[variable[0]]], + variables: [pyciemssMap.value[key]], timeField: 'timepoint_id', groupField: 'sample_id' }, + null, { - data: resultSummary, - variables: [`${pyciemssMap[variable[0]]}_mean:pre`, `${pyciemssMap[variable[0]]}_mean`], - timeField: 'timepoint_id' + data: groundTruthData.value, + variables: [key], + timeField: datasetTimeField as string, + groupField: 'sample_id' }, - null, { + title: key, width: chartSize.value.width, height: chartSize.value.height, legend: true, - xAxisTitle: getUnit('_time') || 'Time', - yAxisTitle: getUnit(variable[0]), - title: '', - colorscheme: ['#AAB3C6', '#1B8073'], - translationMap: translationMap(variable[0]) + translationMap: reverseMap, + xAxisTitle: modelVarUnits.value._time || 'Time', + yAxisTitle: modelVarUnits.value[key] || '', + colorscheme: ['#AAB3C6', '#1B8073'] } ); + // add intervention annotations (rules and text) - // forecastChart.layer.push(...createInterventionChartMarkers(preProcessedInterventionsData.value[variable])); + // charts.interventionCharts[key].layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[key])); }); } return charts; }); +console.log(preparedCharts); +console.log(preparedCharts.value); + const preparedDistributionCharts = computed(() => { if (!preparedChartInputs.value || _.isEmpty(pyciemssMap.value)) return {}; const { result } = preparedChartInputs.value; From 0aa4e209fddb7c2100032ac5db50566a8ff9bd1b Mon Sep 17 00:00:00 2001 From: mloppie Date: Fri, 18 Oct 2024 13:27:55 -0400 Subject: [PATCH 07/15] add intervention chart marker --- .../tera-calibrate-ciemss-drilldown.vue | 20 +++++-------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index f916e4239f..1ac1343ff7 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -491,8 +491,8 @@ import { createForecastChart, createHistogramChart, createErrorChart, - applyForecastChartAnnotations - // ,createInterventionChartMarkers + applyForecastChartAnnotations, + createInterventionChartMarkers } from '@/services/charts'; import VegaChart from '@/components/widgets/VegaChart.vue'; import TeraChartControl from '@/components/workflow/tera-chart-control.vue'; @@ -796,19 +796,10 @@ const preparedCharts = computed(() => { ), annotations ); - - // if (groupedInterventionOutputs.value) { - // Object.entries(groupedInterventionOutputs.value).forEach((item) => { - // item[1].forEach((intervention) => { - // charts.simulationCharts[variable].layer.push(...createInterventionChartMarkers([intervention], false)); - // }); - // }); - // } }); if (groupedInterventionOutputs.value) { Object.keys(groupedInterventionOutputs.value).forEach((key) => { - console.log(key); charts.interventionCharts[key] = createForecastChart( { data: result, @@ -836,15 +827,14 @@ const preparedCharts = computed(() => { ); // add intervention annotations (rules and text) - // charts.interventionCharts[key].layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[key])); + charts.interventionCharts[key].layer.push( + ...createInterventionChartMarkers(groupedInterventionOutputs.value[key]) + ); }); } return charts; }); -console.log(preparedCharts); -console.log(preparedCharts.value); - const preparedDistributionCharts = computed(() => { if (!preparedChartInputs.value || _.isEmpty(pyciemssMap.value)) return {}; const { result } = preparedChartInputs.value; From bb7865640e0031ccbbaa46ef0acc9d91bd66125e Mon Sep 17 00:00:00 2001 From: mloppie Date: Mon, 21 Oct 2024 12:11:43 -0400 Subject: [PATCH 08/15] restore intervention marker on variable charts --- .../calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue | 2 ++ .../ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue | 6 +----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index 1ac1343ff7..c4966d03ef 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -796,6 +796,8 @@ const preparedCharts = computed(() => { ), annotations ); + + charts[variable].layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[variable])); }); if (groupedInterventionOutputs.value) { diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue index b3799067ae..69460592b5 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue @@ -210,11 +210,7 @@ const preparedCharts = computed(() => { } ); applyForecastChartAnnotations(chart, annotations); - Object.entries(groupedInterventionOutputs.value).forEach((item) => { - item[1].forEach((intervention) => { - chart.layer.push(...createInterventionChartMarkers([intervention], false)); - }); - }); + chart.layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[variable])); return chart; }); }); From d8eff7ccc5cfea8cdb8129f0b9fd60257ebb45db Mon Sep 17 00:00:00 2001 From: mloppie Date: Mon, 21 Oct 2024 12:12:19 -0400 Subject: [PATCH 09/15] Update packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue Co-authored-by: Tom Szendrey --- .../ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index 37ac1d76de..553c53ef21 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -824,7 +824,7 @@ const preparedCharts = computed(() => { charts[variable].layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[variable])); }); - +// Intervention Charts: if (groupedInterventionOutputs.value) { Object.keys(groupedInterventionOutputs.value).forEach((key) => { charts.interventionCharts[key] = createForecastChart( From f655a9c92d2c4d56e1a1639e794cf2f97d8c1f1d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 21 Oct 2024 16:15:10 +0000 Subject: [PATCH 10/15] chore: lint and format client codebase --- .../ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index 553c53ef21..2576e0d549 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -824,7 +824,7 @@ const preparedCharts = computed(() => { charts[variable].layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[variable])); }); -// Intervention Charts: + // Intervention Charts: if (groupedInterventionOutputs.value) { Object.keys(groupedInterventionOutputs.value).forEach((key) => { charts.interventionCharts[key] = createForecastChart( From c64c0adefee86a2e7084ce4fff91a01a0681a717 Mon Sep 17 00:00:00 2001 From: mloppie Date: Mon, 21 Oct 2024 12:15:16 -0400 Subject: [PATCH 11/15] typo --- .../ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue index c4966d03ef..3d51849cc0 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-ciemss-drilldown.vue @@ -797,7 +797,9 @@ const preparedCharts = computed(() => { annotations ); - charts[variable].layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[variable])); + charts.simulationCharts[variable].layer.push( + ...createInterventionChartMarkers(groupedInterventionOutputs.value[variable]) + ); }); if (groupedInterventionOutputs.value) { From a224055e626f9ce64758be5c16ef0c841a13951c Mon Sep 17 00:00:00 2001 From: mloppie Date: Mon, 21 Oct 2024 16:33:43 -0400 Subject: [PATCH 12/15] add intervention charts to calibrate node --- .../tera-calibrate-node-ciemss.vue | 43 ++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue index bb3c828595..fad2577a81 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue @@ -7,7 +7,13 @@ v-for="(_var, index) of selectedVariableSettings" :key="index" :are-embed-actions-visible="false" - :visualization-spec="preparedCharts[index]" + :visualization-spec="preparedCharts.variableCharts[index]" + /> + @@ -173,7 +179,7 @@ const preparedCharts = computed(() => { // Need to get the dataset's time field const datasetTimeField = state.timestampColName; - return selectedVariableSettings.value.map((setting) => { + const variableCharts = selectedVariableSettings.value.map((setting) => { const variable = setting.selectedVariables[0]; const datasetVariables: string[] = []; const mapObj = state.mapping.find((d) => d.modelVariable === variable); @@ -182,6 +188,7 @@ const preparedCharts = computed(() => { } const annotations = chartAnnotations.value.filter((annotation) => annotation.chartId === setting.id); + // variable chart const chart = createForecastChart( { data: result, @@ -211,8 +218,40 @@ const preparedCharts = computed(() => { ); applyForecastChartAnnotations(chart, annotations); chart.layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[variable])); + + return chart; + }); + + // intervention charts + const interventionCharts = Object.keys(groupedInterventionOutputs.value).map((key) => { + const chart = createForecastChart( + { + data: result, + variables: [pyciemssMap[key]], + timeField: 'timepoint_id', + groupField: 'sample_id' + }, + null, + { + data: groundTruth, + variables: [key], + timeField: datasetTimeField as string + }, + { + title: key, + legend: true, + translationMap: reverseMap, + xAxisTitle: modelVarUnits.value._time || 'Time', + yAxisTitle: modelVarUnits.value[key] || '', + colorscheme: ['#AAB3C6', '#1B8073'], + ...chartSize + } + ); + chart.layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[key])); return chart; }); + + return { variableCharts, interventionCharts }; }); // --- Handle chart annotations From c43fe0460757933bac221ac5d031cbc461b832d3 Mon Sep 17 00:00:00 2001 From: mloppie Date: Mon, 21 Oct 2024 16:33:56 -0400 Subject: [PATCH 13/15] fix chart marker position on simulate node --- .../workflow/ops/simulate-ciemss/tera-simulate-node-ciemss.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/simulate-ciemss/tera-simulate-node-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/simulate-ciemss/tera-simulate-node-ciemss.vue index 11a7ec9458..426b0a931e 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/simulate-ciemss/tera-simulate-node-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/simulate-ciemss/tera-simulate-node-ciemss.vue @@ -204,7 +204,7 @@ const preparedCharts = computed(() => { if (interventionPolicy.value) { _.keys(groupedInterventionOutputs.value).forEach((key) => { if (config.includes(key)) { - chart.layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[key])); + chart.layer.push(...createInterventionChartMarkers(groupedInterventionOutputs.value[key], false, -115)); } }); } From 48a845f5b15252ef4894b4f8a5e73016c1283d76 Mon Sep 17 00:00:00 2001 From: mloppie Date: Tue, 22 Oct 2024 09:31:47 -0400 Subject: [PATCH 14/15] lint --- .../ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue index fad2577a81..36462eaf5f 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue @@ -149,6 +149,10 @@ const groupedInterventionOutputs = computed(() => const preparedCharts = computed(() => { const state = props.node.state; + if (!runResult.value || !csvAsset.value || !runResultPre.value) return []; + if (!runResult.value || !csvAsset.value || !runResultPre.value) { + return { variableCharts: [], interventionCharts: [] }; + } if (!runResult.value || !csvAsset.value || !runResultPre.value) return []; From 3645a362002aaac7930d87dc8c7dfaf7c207ee25 Mon Sep 17 00:00:00 2001 From: Daniel Chang Date: Tue, 22 Oct 2024 09:43:53 -0400 Subject: [PATCH 15/15] linter fixes --- .../ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue index 36462eaf5f..15619ede4f 100644 --- a/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue +++ b/packages/client/hmi-client/src/components/workflow/ops/calibrate-ciemss/tera-calibrate-node-ciemss.vue @@ -10,7 +10,7 @@ :visualization-spec="preparedCharts.variableCharts[index]" /> const preparedCharts = computed(() => { const state = props.node.state; - if (!runResult.value || !csvAsset.value || !runResultPre.value) return []; if (!runResult.value || !csvAsset.value || !runResultPre.value) { return { variableCharts: [], interventionCharts: [] }; } - if (!runResult.value || !csvAsset.value || !runResultPre.value) return []; - // Merge before/after for chart const { result, resultSummary } = mergeResults( runResult.value,