Skip to content

Commit 8a0eb4f

Browse files
authored
fix #7955 add tmap8 app (#7966)
1 parent 92e6661 commit 8a0eb4f

18 files changed

Lines changed: 1388 additions & 46 deletions

File tree

sirepo/feature_config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"radia",
3838
"shadow",
3939
"srw",
40+
"tmap8",
4041
)
4142
)
4243

sirepo/package_data/static/html/plot2d.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
<text class="main-title" ng-attr-x="{{ width / 2 }}" ng-attr-y="-{{ margin.top / 2 }}"></text>
3030
<text class="sub-title" ng-attr-x="{{ width / 2 }}" y="0" dy="-.5em"></text>
3131
<text class="x-base" text-anchor="end" ng-attr-x="{{ width + margin.right - 5 }}" ng-attr-y="{{ height + 40 }}"></text>
32-
<g ng-repeat="fp in focusPoints" class="focus" style="display: none;" data-focus-circle="" data-focus-point="fp"><circle r="6"></circle></g>
32+
<g ng-repeat="fp in focusPoints">
33+
<g ng-if="hasFocusPoint(plots[$index])" class="focus" style="display: none;" data-focus-circle="" data-focus-point="fp"><circle r="6"></circle></g>
34+
</g>
3335
<svg class="plot-viewport" ng-attr-width="{{ width }}" ng-attr-height="{{ height }}">
3436
<rect style="fill: none; pointer-events: all;" ng-attr-width="{{ width }}" ng-attr-height="{{ height }}"></rect>
3537
<path class="line line-0"></path>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<div class="container-fluid">
2+
<div class="row">
3+
<div class="col-lg-6 col-xxl-4">
4+
<div data-basic-editor-panel="" data-view-name="simulationSettings"></div>
5+
</div>
6+
<div class="col-lg-6 col-xxl-4" data-ng-if="appState.models.rpnVariables">
7+
<div data-simple-panel="simulationStatus">
8+
<div data-sim-status-panel="viz.simState" data-start-function="viz.startSimulation()"></div>
9+
</div>
10+
</div>
11+
<div class="col-lg-6 col-xxl-4" data-ng-if="viz.simState.getFrameCount() > 0">
12+
<div
13+
data-report-panel="parameter"
14+
data-model-name="plotAnimation"
15+
data-panel-title="{{ viz.reportTitle }}"
16+
></div>
17+
</div>
18+
</div>
19+
</div>

sirepo/package_data/static/js/sirepo-lattice.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,15 @@ SIREPO.app.service('rpnService', function(appState, requestSender, $rootScope) {
592592
});
593593
};
594594

595+
self.valueAsString = (value) => {
596+
if (! angular.isDefined(value)) {
597+
return value;
598+
}
599+
return value > 10**8
600+
? value.toExponential()
601+
: value.toString();
602+
};
603+
595604
$rootScope.$on('rpnVariables.changed', clearBooleanValues);
596605
appState.whenModelsLoaded($rootScope, clearBooleanValues);
597606
});
@@ -2806,7 +2815,7 @@ SIREPO.app.directive('rpnStatic', function(rpnService) {
28062815
}
28072816
return $scope.isError
28082817
? ''
2809-
: rpnService.getRpnValueForField($scope.model, $scope.field);
2818+
: rpnService.valueAsString(rpnService.getRpnValueForField($scope.model, $scope.field));
28102819
};
28112820
},
28122821
};
@@ -2896,7 +2905,7 @@ SIREPO.app.directive('rpnValue', function(appState, rpnService, $timeout) {
28962905
if (ngModel.$isEmpty(value)) {
28972906
return value;
28982907
}
2899-
return value.toString();
2908+
return rpnService.valueAsString(value);
29002909
});
29012910

29022911
// handle programmatic changes - don't step on current parsing

sirepo/package_data/static/js/sirepo-plotting.js

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,11 @@ SIREPO.app.factory('plotting', function(appState, frameCache, panelState, utilit
685685
return json.aspectRatio || defaultRatio || 1.0;
686686
},
687687

688+
hasFocusPoint: function(plot) {
689+
// a "band" plot has no single focus value
690+
return ! plot || plot.style !== 'band';
691+
},
692+
688693
initialHeight: function(scope) {
689694
return scope.isAnimation ? 1 : INITIAL_HEIGHT;
690695
},
@@ -1167,6 +1172,7 @@ SIREPO.app.service('plot2dService', function(appState, layoutService, panelState
11671172
$.extend($scope, attrs);
11681173
$scope.width = $scope.height = 0;
11691174
$scope.dataCleared = true;
1175+
$scope.hasFocusPoint = plotting.hasFocusPoint;
11701176
$scope.axes = {
11711177
x: layoutService.plotAxis($scope.margin, 'x', 'bottom', refresh),
11721178
y: layoutService.plotAxis($scope.margin, 'y', 'left', refresh),
@@ -2000,6 +2006,9 @@ SIREPO.app.directive('interactiveOverlay', function(focusPointService, keypressS
20002006
if (fpIndex === 0) {
20012007
fmtText = fmtText + fpt.xText + '\n';
20022008
}
2009+
if (! plotting.hasFocusPoint(plotScope.plots && plotScope.plots[fpIndex])) {
2010+
return;
2011+
}
20032012
fmtText = fmtText + fpt.yText;
20042013
if (fpt.fwhmText) {
20052014
fmtText = fmtText + ', ' + fpt.fwhmText;
@@ -2259,11 +2268,12 @@ SIREPO.app.directive('popupReport', function(focusPointService, plotting) {
22592268
<div style="padding: 4px; white-space: nowrap">
22602269
<div style="height: 20px"><span data-text-with-math="focusPoints[0].config.xAxis.label"
22612270
data-is-dynamic="1"></span> = {{ pointText(0, true) }} {{ focusPoints[0].config.xAxis.units }}</div>
2262-
<div data-ng-style="{ opacity: opacity($index) }" style="height: 20px"
2263-
data-ng-repeat="p in plots track by p._label + $index">
2264-
<div style="display:inline" data-color-circle="p"></div>
2265-
<span data-text-with-math="p._label"></span> = {{ pointText($index) }}
2266-
<span data-text-with-math="p._units"></span>
2271+
<div data-ng-repeat="p in plots track by p._label + $index">
2272+
<div data-ng-if="hasFocusPoint(p)" data-ng-style="{ opacity: opacity($index) }" style="height: 20px">
2273+
<div style="display:inline" data-color-circle="p"></div>
2274+
<span data-text-with-math="p._label"></span> = {{ pointText($index) }}
2275+
<span data-text-with-math="p._units"></span>
2276+
</div>
22672277
</div>
22682278
</div>
22692279
</div>
@@ -2274,6 +2284,7 @@ SIREPO.app.directive('popupReport', function(focusPointService, plotting) {
22742284

22752285
// prevent memory leak?
22762286
$scope.focusPoints.allowClone = true;
2287+
$scope.hasFocusPoint = plotting.hasFocusPoint;
22772288

22782289
function adjustBounds(bound, dim) {
22792290
if (bound < 1) {
@@ -3720,10 +3731,22 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
37203731
function setupPlots(json) {
37213732
const viewport = $scope.select('.plot-viewport');
37223733
viewport.selectAll('.line').remove();
3734+
viewport.selectAll('.band').remove();
37233735
viewport.selectAll('g.param-plot').remove();
37243736
json.plots.forEach(function(plot, ip) {
37253737
plot.strokeWidth = plot.strokeWidth || 2.0;
3726-
if (plot.style === 'scatter') {
3738+
if (plot.style === 'band') {
3739+
// a shaded region between plot.pointsLower and plot.pointsUpper,
3740+
// e.g. a confidence/uncertainty interval
3741+
viewport.append('path')
3742+
.attr('class', 'param-plot band')
3743+
.attr('data-sr-index', ip)
3744+
.style('fill', plot.color)
3745+
.style('stroke', 'none')
3746+
.style('opacity', plot.opacity || 0.25)
3747+
.datum(plot.pointsUpper);
3748+
}
3749+
else if (plot.style === 'scatter') {
37273750
let clusterInfo;
37283751
let circleRadius = plot.circleRadius || 2;
37293752
if (json.clusters) {
@@ -3896,6 +3919,24 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
38963919
return yaxis.scale(scaleFunction ? scaleFunction(d) : d);
38973920
});
38983921
};
3922+
// area generator for a "band" plot, filling between pointsLower and pointsUpper
3923+
$scope.plotGraphArea = function(plotIndex) {
3924+
const p = ($scope.plots || [])[plotIndex] || {};
3925+
const xPoints = p.x_points || $scope.axes.x.points;
3926+
const yaxis = p._yaxis == 'right' ? $scope.axes.y2 : $scope.axes.y;
3927+
return d3.svg.area()
3928+
.x(function(d, i) {
3929+
return $scope.axes.x.scale(xPoints[i]);
3930+
})
3931+
.y0(function(d, i) {
3932+
const v = p.pointsLower[i];
3933+
return yaxis.scale(scaleFunction ? scaleFunction(v) : v);
3934+
})
3935+
.y1(function(d, i) {
3936+
const v = p.pointsUpper[i];
3937+
return yaxis.scale(scaleFunction ? scaleFunction(v) : v);
3938+
});
3939+
};
38993940
$scope.graphLine = d3.svg.line()
39003941
.x(function(d, i) {
39013942
return $scope.axes.x.scale($scope.axes.x.points[i]);
@@ -3951,19 +3992,22 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
39513992
continue;
39523993
}
39533994
for (const p of plots) {
3954-
const y = p.points[i];
3995+
// a "band" plot has no single points[i] value -- use both edges
3996+
const ys = p.style === 'band' ? [p.pointsLower[i], p.pointsUpper[i]] : [p.points[i]];
39553997
const ia = p._yaxis == 'left' ? 0 : 1;
3956-
if (ydom[ia]) {
3957-
if (y < ydom[ia][0]) {
3958-
ydom[ia][0] = y;
3998+
for (const y of ys) {
3999+
if (ydom[ia]) {
4000+
if (y < ydom[ia][0]) {
4001+
ydom[ia][0] = y;
4002+
}
4003+
else if (y > ydom[ia][1]) {
4004+
ydom[ia][1] = y;
4005+
}
39594006
}
3960-
else if (y > ydom[ia][1]) {
3961-
ydom[ia][1] = y;
4007+
else {
4008+
ydom[ia] = [y, y];
39624009
}
39634010
}
3964-
else {
3965-
ydom[ia] = [y, y];
3966-
}
39674011
}
39684012
}
39694013
['left', 'right'].forEach((v, i) => {
@@ -4003,6 +4047,12 @@ SIREPO.app.directive('parameterPlot', function(appState, focusPointService, layo
40034047
d3.select(this).attr('d', $scope.plotGraphLine(ip));
40044048
});
40054049

4050+
$scope.select('.plot-viewport').selectAll('.band')
4051+
.each(function (d) {
4052+
var ip = parseInt(d3.select(this).attr('data-sr-index'));
4053+
d3.select(this).attr('d', $scope.plotGraphArea(ip));
4054+
});
4055+
40064056
$scope.select('.plot-viewport').selectAll('g.param-plot')
40074057
.each(function (d, ip) {
40084058
var sp = d3.select(this).selectAll('.scatter-point');

0 commit comments

Comments
 (0)