Skip to content

Commit

Permalink
Merge branch 'master' into 7361-plot-grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
moellep authored Nov 18, 2024
2 parents 9ce9acd + d587811 commit 1dbc394
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
44 changes: 22 additions & 22 deletions sirepo/package_data/static/js/sirepo-lattice.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,17 +645,17 @@ SIREPO.app.directive('beamlineEditor', function(appState, latticeService, panelS
<div style="display:none">
<div data-ng-class="::popoverInfo.modifyBeamline.class">
<div class="text-center">
<button class="btn btn-default" data-ng-click="unpackBeamline()">Unpack</button>
<button class="btn btn-default" data-ng-if=":: canReverseBeamline()" data-ng-click="reverseBeamline()">Reverse</button>
<button class="btn btn-default" data-ng-click="clearPopover()">Cancel</button>
<button type="button" class="btn btn-default" data-ng-click="unpackBeamline()">Unpack</button>
<button type="button" class="btn btn-default" data-ng-if=":: canReverseBeamline()" data-ng-click="reverseBeamline()">Reverse</button>
<button type="button" class="btn btn-default" data-ng-click="clearPopover()">Cancel</button>
</div>
</div>
<div data-ng-class="::popoverInfo.elementPosition.class">
<input data-rpn-value="" data-ng-model="popoverInfo.elementPosition.elemedge" class="form-control" data-lpignore="true" required />
<div data-rpn-static="" field="\'elemedge\'" data-model="popoverInfo.elementPosition" style="margin-left: 2em;"></div>
<div class="text-center">
<button class="btn btn-primary sr-button-save-cancel" data-ng-click="setElementPosition()">Save</button>
<button class="btn btn-default sr-button-save-cancel" data-ng-click="clearPopover()">Cancel</button>
<button type="button" class="btn btn-primary sr-button-save-cancel" data-ng-click="setElementPosition()">Save</button>
<button type="button" class="btn btn-default sr-button-save-cancel" data-ng-click="clearPopover()">Cancel</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -1217,23 +1217,23 @@ SIREPO.app.directive('elementPicker', function(latticeService) {
<br />
<div data-ng-if="activeTab == \'basic\'" class="row">
<div data-ng-repeat="name in controller.basicNames" class="col-sm-4">
<button style="width: 100%; margin-bottom: 1ex;" class="btn btn-default" type="button" data-ng-click="createElement(name)" data-ng-attr-title="{{ controller.titleForName(name) }}">{{ name }}</button>
<button type="button" style="width: 100%; margin-bottom: 1ex;" class="btn btn-default" type="button" data-ng-click="createElement(name)" data-ng-attr-title="{{ controller.titleForName(name) }}">{{ name }}</button>
</div>
</div>
<div data-ng-if="activeTab == \'advanced\'" class="row">
<div data-ng-repeat="name in controller.advancedNames" class="{{ smallElementClass }}">
<button style="width: 100%; margin-bottom: 1ex; overflow: hidden;" class="btn btn-default btn-sm" type="button" data-ng-click="createElement(name)" data-ng-attr-title="{{ controller.titleForName(name) }}">{{ name }}</button>
<button type="button" style="width: 100%; margin-bottom: 1ex; overflow: hidden;" class="btn btn-default btn-sm" type="button" data-ng-click="createElement(name)" data-ng-attr-title="{{ controller.titleForName(name) }}">{{ name }}</button>
</div>
</div>
<div data-ng-if="activeTab == \'all\'" class="row">
<div data-ng-repeat="name in allNames" class="{{ smallElementClass }}">
<button style="width: 100%; margin-bottom: 1ex; overflow: hidden" class="btn btn-default btn-sm" type="button" data-ng-click="createElement(name)" data-ng-attr-title="{{ controller.titleForName(name) }}">{{ name }}</button>
<button type="button" style="width: 100%; margin-bottom: 1ex; overflow: hidden" class="btn btn-default btn-sm" type="button" data-ng-click="createElement(name)" data-ng-attr-title="{{ controller.titleForName(name) }}">{{ name }}</button>
</div>
</div>
<br />
<div class="row">
<div class="col-sm-offset-6 col-sm-3">
<button data-dismiss="modal" class="btn btn-primary" style="width:100%">Close</button>
<button type="button" data-dismiss="modal" class="btn btn-primary" style="width:100%">Close</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -2251,11 +2251,11 @@ SIREPO.app.directive('latticeBeamlineTable', function(appState, latticeService,
<span data-ng-if="beamlineBend(beamline)">&deg;</span>
<div class="sr-button-bar-parent">
<div class="sr-button-bar" data-ng-class="{\'sr-button-bar-active\': isActiveBeamline(beamline)}" >
<button class="btn btn-info btn-xs sr-hover-button" data-ng-click="copyBeamline(beamline)">Copy</button>
<button type="button" class="btn btn-info btn-xs sr-hover-button" data-ng-click="copyBeamline(beamline)">Copy</button>
<span data-ng-show="! isActiveBeamline(beamline)" >
<button class="btn btn-info btn-xs sr-hover-button" data-ng-disabled="wouldBeamlineSelfNest(beamline)" data-ng-click="latticeService.addToBeamline(beamline)">Add to Beamline</button>
<button data-ng-click="latticeService.editBeamline(beamline)" class="btn btn-info btn-xs sr-hover-button">Edit</button>
<button data-ng-show="! isActiveBeamline(beamline)" data-ng-click="deleteBeamline(beamline)" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span></button>
<button type="button" class="btn btn-info btn-xs sr-hover-button" data-ng-disabled="wouldBeamlineSelfNest(beamline)" data-ng-click="latticeService.addToBeamline(beamline)">Add to Beamline</button>
<button type="button" data-ng-click="latticeService.editBeamline(beamline)" class="btn btn-info btn-xs sr-hover-button">Edit</button>
<button type="button" data-ng-show="! isActiveBeamline(beamline)" data-ng-click="deleteBeamline(beamline)" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span></button>
</span>
</div>
<div>
Expand Down Expand Up @@ -2406,7 +2406,7 @@ SIREPO.app.directive('latticeElementPanels', function(latticeService) {
<div class="panel panel-info" style="margin-bottom: 0">
<div class="panel-heading"><span class="sr-panel-heading">Beamlines</span></div>
<div class="panel-body" style="padding-bottom: 0">
<button class="btn btn-info btn-xs pull-right" accesskey="b" data-ng-click="latticeService.newBeamline()"><span class="glyphicon glyphicon-plus"></span> New <u>B</u>eamline</button>
<button type="button" class="btn btn-info btn-xs pull-right" accesskey="b" data-ng-click="latticeService.newBeamline()"><span class="glyphicon glyphicon-plus"></span> New <u>B</u>eamline</button>
<div data-lattice-beamline-table=""></div>
</div>
</div>
Expand Down Expand Up @@ -2434,11 +2434,11 @@ SIREPO.app.directive('latticeElementTable', function(appState, latticeService, p
scope: {},
template: `
<div class="sr-sticky-heading">
<button style="min-width: 7em" data-ng-click="toggleCollapseElems()" class="btn btn-info btn-xs">{{ areAllExpanded ? 'Collapse' : 'Expand'}} All</button>
<button type="button" style="min-width: 7em" data-ng-click="toggleCollapseElems()" class="btn btn-info btn-xs">{{ areAllExpanded ? 'Collapse' : 'Expand'}} All</button>
<input style="display: inline; width: 15em" class="form-control input-sm" data-ng-change="findElement(searchVar)" data-ng-model="searchVar" placeholder="Search Elements" />
<div class="pull-right" style="padding-top: 4px">
<button data-ng-if=":: latticeService.wantRpnVariables" class="btn btn-info btn-xs" data-ng-click="latticeService.showRpnVariables()"><span class="glyphicon glyphicon-list-alt"></span> Variables</button>
<button class="btn btn-info btn-xs" data-ng-click="latticeService.newElement()" accesskey="e"><span class="glyphicon glyphicon-plus"></span> New <u>E</u>lement</button>
<button type="button" data-ng-if=":: latticeService.wantRpnVariables" class="btn btn-info btn-xs" data-ng-click="latticeService.showRpnVariables()"><span class="glyphicon glyphicon-list-alt"></span> Variables</button>
<button type="button" class="btn btn-info btn-xs" data-ng-click="latticeService.newElement()" accesskey="e"><span class="glyphicon glyphicon-plus"></span> New <u>E</u>lement</button>
</div>
</div>
<table style="width: 100%; table-layout: fixed; margin-bottom: 0" class="table table-hover">
Expand Down Expand Up @@ -2470,7 +2470,7 @@ SIREPO.app.directive('latticeElementTable', function(appState, latticeService, p
</td>
<td style="overflow: hidden"><span style="color: #777; white-space: nowrap">{{ element.description }}</span></td>
<td style="text-align: right">{{ elementLength(element) }}</td>
<td style="text-align: right">{{ element.bend || \'&nbsp;\' }}<span data-ng-if="element.isBend">&deg;</span><div class="sr-button-bar-parent"><div class="sr-button-bar"><button class="btn btn-info btn-xs sr-hover-button" data-ng-click="copyElement(element)">Copy</button> <button data-ng-show="latticeService.activeBeamlineId" class="btn btn-info btn-xs sr-hover-button" data-ng-click="latticeService.addToBeamline(element)">Add to Beamline</button> <button data-ng-click="editElement(category.name, element)" class="btn btn-info btn-xs sr-hover-button">Edit</button> <button data-ng-click="deleteElement(element)" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span></button></div><div></td>
<td style="text-align: right">{{ element.bend || \'&nbsp;\' }}<span data-ng-if="element.isBend">&deg;</span><div class="sr-button-bar-parent"><div class="sr-button-bar"><button type="button" class="btn btn-info btn-xs sr-hover-button" data-ng-click="copyElement(element)">Copy</button> <button type="button" data-ng-show="latticeService.activeBeamlineId" class="btn btn-info btn-xs sr-hover-button" data-ng-click="latticeService.addToBeamline(element)">Add to Beamline</button> <button type="button" data-ng-click="editElement(category.name, element)" class="btn btn-info btn-xs sr-hover-button">Edit</button> <button type="button" data-ng-click="deleteElement(element)" class="btn btn-danger btn-xs"><span class="glyphicon glyphicon-remove"></span></button></div><div></td>
</tr>
</tbody>
</table>
Expand Down Expand Up @@ -2712,7 +2712,7 @@ SIREPO.app.directive('latticeTab', function(latticeService, panelState, utilitie
<br />
<div class="row">
<div class="col-sm-offset-6 col-sm-3">
<button data-dismiss="modal" class="btn btn-primary" style="width:100%">Close</button>
<button type="button" data-dismiss="modal" class="btn btn-primary" style="width:100%">Close</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -2942,7 +2942,7 @@ SIREPO.app.directive('varEditor', function(appState, latticeService, requestSend
<td><div class="col-sm-12" data-rpn-static="" data-model="var" data-field="\'value\'"></div></td>
<td style="vertical-align: middle">
<div data-disable-after-click="">
<button class="btn btn-danger btn-xs" data-ng-click="deleteVar($index)" title="Delete Variable"><span class="glyphicon glyphicon-remove"></span></button>
<button type="button" class="btn btn-danger btn-xs" data-ng-click="deleteVar($index)" title="Delete Variable"><span class="glyphicon glyphicon-remove"></span></button>
</div>
</td>
</tr>
Expand All @@ -2957,15 +2957,15 @@ SIREPO.app.directive('varEditor', function(appState, latticeService, requestSend
</td>
<td><div class="col-sm-12" data-rpn-static="" data-model="newVar" data-field="\'value\'"></div></td>
<td>
<button class="btn btn-primary btn-xs" data-ng-disabled="! hasNewVar()" data-ng-click="addVar()" title="Add Variable"><span class="glyphicon glyphicon-plus"></span></button>
<button type="button" class="btn btn-primary btn-xs" data-ng-disabled="! hasNewVar()" data-ng-click="addVar()" title="Add Variable"><span class="glyphicon glyphicon-plus"></span></button>
</td>
</tr>
</tbody>
</table>
</div>
<div class="row">
<div class="col-sm-6 pull-right">
<button data-ng-click="saveChanges()" class="btn btn-primary sr-button-save-cancel" data-ng-disabled="! form.$valid">Save</button>
<button type="submit" data-ng-click="saveChanges()" class="btn btn-primary sr-button-save-cancel" data-ng-disabled="! form.$valid">Save</button>
<button data-ng-click="cancelChanges()" class="btn btn-default">Cancel</button>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions sirepo/template/elegant.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ def from_madx(self, madx):
)
self.__combine_dipedge(data)
eb = LatticeUtil.find_first_command(data, "bunched_beam")
mb = LatticeUtil.find_first_command(madx, "beam")
mb = self.beam
for f in self._BEAM_VARS:
v = self._find_var(madx, f)
if v:
Expand Down Expand Up @@ -555,8 +555,8 @@ def _fixup_element(self, element_in, element_out):
if element_in.type == "COLLIMATOR":
m = re.search(r"^\{?\s*(.*?),\s*(.*?)\s*\}?$", element_in.aperture)
if m:
element_out.x_max = float(m.group(1))
element_out.y_max = float(m.group(2))
element_out.x_max = self.__val(m.group(1))
element_out.y_max = self.__val(m.group(2))
if element_in.apertype == "rectangle":
element_out.type = "RCOL"
elif element_in.type == "RFCAVITY":
Expand Down
5 changes: 2 additions & 3 deletions sirepo/template/impactx.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def __init__(self, qcall=None, nslice=1, **kwargs):
self.nslice = nslice

def from_madx(self, madx):
self.beam = sirepo.template.lattice.LatticeUtil.find_first_command(madx, "beam")
data = self.fill_in_missing_constants(super().from_madx(madx), PKDict())
self._remove_zero_drifts(data)
return data
Expand All @@ -144,8 +143,8 @@ def _fixup_element(self, element_in, element_out):
elif element_in.type == "COLLIMATOR":
m = re.search(r"^\{?\s*(.*?),\s*(.*?)\s*\}?$", element_in.aperture)
if m:
element_out.xmax = float(m.group(1))
element_out.ymax = float(m.group(2))
element_out.xmax = self.__val(m.group(1))
element_out.ymax = self.__val(m.group(2))
element_out.shape = (
"rectangular"
if element_in.apertype == "rectangle"
Expand Down
5 changes: 3 additions & 2 deletions sirepo/template/madx_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _copy_beamlines(self, data):
self.result.models.simulation[f] = data.models.simulation[f]

def _copy_code_variables(self, data):
res = data.models.rpnVariables
res = copy.deepcopy(data.models.rpnVariables)
if self.to_class.sim_type() in ("madx", "opal"):
res = list(filter(lambda x: x.name not in self._MADX_VARIABLES, res))
else:
Expand All @@ -138,6 +138,7 @@ def _copy_code_variables(self, data):

def _copy_elements(self, data):
for el in data.models.elements:
el = copy.deepcopy(el)
if el.type not in self.field_map:
pkdlog("Unhandled element type: {}", el.type)
el.type = self.drift_type
Expand Down Expand Up @@ -196,7 +197,7 @@ def __init_direction(self, data, from_class, to_class):
def __normalize_madx_beam(self, data):
from sirepo.template import madx

self.beam = LatticeUtil.find_first_command(data, "beam")
self.beam = copy.deepcopy(LatticeUtil.find_first_command(data, "beam"))
cv = madx.code_var(data.models.rpnVariables)
for f in ParticleEnergy.ENERGY_PRIORITY.madx:
self.beam[f] = cv.eval_var_with_assert(self.beam[f])
Expand Down

0 comments on commit 1dbc394

Please sign in to comment.