Skip to content

Commit

Permalink
Merged over pressure data transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Dec 26, 2024
1 parent a5508f1 commit 3056563
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@
'plot-hidden': !profilesCalculated
}">
</div>
<div id="heatmapplotA" class="diff-heatmap-plot"
<div id="heatmapPlotA" class="diff-heatmap-plot"
[ngClass]="{
'plot-display': profilesCalculated,
'plot-hidden': !profilesCalculated
}">
<div id="heatmapplotB" class="diff-heatmap-plot"
</div>
<div id="heatmapPlotB" class="diff-heatmap-plot"
[ngClass]="{
'plot-display': profilesCalculated,
'plot-hidden': !profilesCalculated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { ResamplingService } from '../../shared/ResamplingService';
import { ReloadDispatcher } from '../../shared/reloadDispatcher';
import { HeatMapPlotter } from '../../shared/heatMapPlotter';
import { FeatureFlags } from 'scuba-physics';
import * as _ from "lodash";

@Component({
selector: 'app-diff-profilechart',
Expand Down Expand Up @@ -48,8 +47,8 @@ export class ProfileDifferenceChartComponent extends Streamed implements OnInit
.create(() => this.profileB);

this.plotter = new ChartPlotter('diveplotdiff', chartPlotterFactory, profileBTraces, profileATraces);
this.heatMapPlotterA = new HeatMapPlotter('heatmapplotA');
this.heatMapPlotterB = new HeatMapPlotter('heatmapplotB');
this.heatMapPlotterA = new HeatMapPlotter('heatmapPlotA');
this.heatMapPlotterB = new HeatMapPlotter('heatmapPlotB');

this.profileComparatorService.selectionChanged$.pipe(takeUntil(this.unsubscribe$))
.subscribe(() => {
Expand Down Expand Up @@ -117,15 +116,11 @@ export class ProfileDifferenceChartComponent extends Streamed implements OnInit

if(this.heatMapEnabled) {
// TODO rescale different profile duration to the same max. duration (add surface tissues offgasing to shorter dive)
const profileAoverPressuresA = this.profileA.tissueOverPressures;
let transponedA = _.zip.apply(_, profileAoverPressuresA) as number[][];
transponedA = transponedA.reverse();
this.heatMapPlotterA.plotHeatMap(transponedA);

const profileAoverPressuresB = this.profileB.tissueOverPressures;
let transponedB = _.zip.apply(_, profileAoverPressuresB) as number[][];
transponedB = transponedB.reverse();
this.heatMapPlotterB.plotHeatMap(transponedB);
const overPressuresA = this.profileA.tissueOverPressures;
this.heatMapPlotterA.plotHeatMap(overPressuresA);

const overPressuresB = this.profileB.tissueOverPressures;
this.heatMapPlotterB.plotHeatMap(overPressuresB);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { takeUntil } from 'rxjs';
import * as Plotly from 'plotly.js-dist';
import * as _ from 'lodash';
import { faChartArea, faFire } from '@fortawesome/free-solid-svg-icons';
import { DiveResults } from '../shared/diveresults';
import { SelectedWaypoint } from '../shared/selectedwaypointService';
Expand Down Expand Up @@ -94,9 +93,8 @@ export class ProfileChartComponent extends Streamed implements OnInit {
this.plotter.plotCharts(this.dive.totalDuration);

if (this.showHeatMap) {
let transponed = _.zip.apply(_, this.dive.tissueOverPressures) as number[][];
transponed = transponed.reverse();
this.heatmapPlotter.plotHeatMap(transponed);
const overPressures = this.dive.tissueOverPressures;
this.heatmapPlotter.plotHeatMap(overPressures);
}
}

Expand Down
6 changes: 5 additions & 1 deletion projects/planner/src/app/shared/heatMapPlotter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as Plotly from 'plotly.js-dist';
import * as _ from "lodash";

export class HeatMapPlotter {
private readonly colorScale = [
Expand Down Expand Up @@ -58,9 +59,12 @@ export class HeatMapPlotter {
* +1: is 100% speed of ongasing.
*/
public plotHeatMap(dataValues: number[][]): void {
let transponed = _.zip.apply(_, dataValues) as number[][];
transponed = transponed.reverse();

const data: Plotly.Data[] = [
{
z: dataValues,
z: transponed,
type: <Plotly.PlotType>'heatmap',
colorscale: this.colorScale as Plotly.ColorScale,
showscale: false,
Expand Down

0 comments on commit 3056563

Please sign in to comment.