Esempio n. 1
0
 def draw_constraint(self, name, elem, envelope):
     """Draw one constraint representation in the graph."""
     view = self.view
     return view.axes[name].plot(
         strip_unit(elem['at'] + elem['l']/2, view.unit[view.sname]),
         strip_unit(envelope, view.unit[name]),
         **self._style)
Esempio n. 2
0
 def plot_ax(self, axes, name):
     """Plot the envelope into the figure."""
     if not self.visible:
         return
     self._remove_ax(name)
     view = self._view
     envdata = self.load_data(name)
     sname = view.sname
     self._lines[name] = axes.plot(
         unit.strip_unit(envdata[sname], view.unit[sname]),
         unit.strip_unit(envdata[name], view.unit[name]),
         'k-x')
Esempio n. 3
0
 def get_element_type(self, elem):
     """Return the element type name used for properties like coloring."""
     if 'type' not in elem or 'at' not in elem:
         return None
     type_name = elem['type'].lower()
     focussing = None
     if type_name == 'quadrupole':
         focussing = strip_unit(elem['k1']) > 0
     elif type_name == 'sbend':
         focussing = strip_unit(elem['angle']) > 0
     if focussing is not None:
         if focussing:
             type_name = 'f-' + type_name
         else:
             type_name = 'd-' + type_name
     return self._style.get(type_name)
Esempio n. 4
0
 def plot_ax(self, axes, name):
     """Draw the elements into the canvas."""
     line_view = self._line_view
     unit_s = line_view.unit[line_view.sname]
     line_style = line_view.config['select_style']
     patch_x = strip_unit(self.element['at'], unit_s)
     self._lines.append(axes.axvline(patch_x, **line_style))
Esempio n. 5
0
 def plot_ax(self, axes, name):
     """Draw the elements into the canvas."""
     view = self._view
     segment = view.segment
     if not segment.show_element_indicators:
         return
     unit_s = view.unit[view.sname]
     for elem in segment.elements:
         elem_type = self.get_element_type(elem)
         if elem_type is None:
             continue
         patch_x = strip_unit(elem['at'], unit_s)
         if strip_unit(elem['l']) != 0:
             patch_w = strip_unit(elem['l'], unit_s)
             axes.axvspan(patch_x, patch_x + patch_w, **elem_type)
         else:
             axes.vlines(patch_x, **elem_type)
Esempio n. 6
0
def _get_any_elem_param(elem, params):
    for param in params:
        try:
            return elem[param]._expression
        except KeyError:
            pass
        except AttributeError:
            if strip_unit(elem[param]) != 0.0:
                return elem['name'] + '->' + param
    raise ValueError()
Esempio n. 7
0
 def get_float_data(self, name):
     """Get a float data vector."""
     return strip_unit(self._segment.tw[name], self._unit[name])
Esempio n. 8
0
 def _fmt_kl(self, value, index):
     return '{:5}'.format(strip_unit(value, self.qp_ui_units[index]))
Esempio n. 9
0
 def _strip_sd_pair(self, sd_values, prefix='pos'):
     strip_unit = self.utool.strip_unit
     return (strip_unit('x', sd_values[prefix + 'x']),
             strip_unit('y', sd_values[prefix + 'y']))