Example #1
0
 def format_coord(self, ax, x, y):
     # TODO: in some cases, it might be necessary to adjust the
     # precision to the displayed xlim/ylim.
     coord_fmt = "{0:.6f}{1}".format
     parts = [coord_fmt(x, get_raw_label(ax.x_unit)),
              coord_fmt(y, get_raw_label(ax.y_unit))]
     elem = self.get_element_by_mouse_position(ax, x)
     if elem:
         name = strip_suffix(elem.node_name, '[0]')
         parts.insert(0, name.upper())
     return ', '.join(parts)
Example #2
0
 def format_coord(self, ax, x, y):
     # TODO: in some cases, it might be necessary to adjust the
     # precision to the displayed xlim/ylim.
     coord_fmt = "{0:.6f}{1}".format
     parts = [
         coord_fmt(x, get_raw_label(ax.x_unit)),
         coord_fmt(y, get_raw_label(ax.y_unit))
     ]
     elem = self.get_element_by_mouse_position(ax, x)
     if elem:
         name = strip_suffix(elem.node_name, '[0]')
         parts.insert(0, name.upper())
     return ', '.join(parts)
Example #3
0
 def on_mouse_move(self, event):
     """Update statusbar text."""
     xdata, ydata = event.xdata, event.ydata
     if xdata is None or ydata is None:
         # outside of axes:
         self._set_status_text("")
         return
     name = self._view.get_axes_name(event.inaxes)
     unit = self._view.unit
     elem = self._view.segment.element_by_position(xdata * unit['s'])
     # TODO: in some cases, it might be necessary to adjust the
     # precision to the displayed xlim/ylim.
     coord_fmt = "{0}={1:.6f}{2}".format
     parts = [coord_fmt('s', xdata, get_raw_label(unit['s'])),
              coord_fmt(name, ydata, get_raw_label(unit[name]))]
     if elem and 'name' in elem:
         parts.append('elem={0}'.format(elem['name']))
     self._set_status_text(', '.join(parts))
Example #4
0
    def _InitManualQP(self, index):
        qp_elem = self.ovm.get_qp(index)
        param_info = qp_elem.dvm_converter.param_info['kL']
        ui_unit = self.qp_ui_units[index] = param_info.ui_unit
        unit_label = get_raw_label(ui_unit)

        qp_value = qp_elem.dvm_backend.get()['kL']
        self.edit_qp[index].SetValue(self._fmt_kl(qp_value, index))

        param_name = param_info.name
        self.label_edit_qp[index].SetLabel(param_name + ':')
        self.label_disp_qp[index].SetLabel(param_name + ':')
        self.edit_qp_unit[index].SetLabel(unit_label)
        self.disp_qp_unit[index].SetLabel(unit_label)
Example #5
0
File: core.py Project: hibtc/madgui
 def get_steerer_row(self, i, v) -> ("Steerer", "Now", "To Be", "Unit"):
     initial = self.corrector.online_optic.get(v.lower())
     matched = self.corrector.saved_optics().get(v.lower())
     changed = matched is not None and not np.isclose(initial, matched)
     style = {
         # 'foreground': QColor(Qt.red),
         'font': bold(),
     } if changed else {}
     info = self.corrector._knobs[v.lower()]
     return [
         TableItem(v),
         TableItem(change_unit(initial, info.unit, info.ui_unit)),
         TableItem(change_unit(matched, info.unit, info.ui_unit),
                   set_value=self.set_steerer_value,
                   delegate=delegates[float], **style),
         TableItem(get_raw_label(info.ui_unit)),
     ]
Example #6
0
 def get_steerer_row(self, i, v) -> ("Steerer", "Now", "To Be", "Unit"):
     initial = self.corrector.online_optic.get(v.lower())
     matched = self.corrector.saved_optics().get(v.lower())
     changed = matched is not None and not np.isclose(initial, matched)
     style = {
         # 'foreground': QColor(Qt.red),
         'font': bold(),
     } if changed else {}
     info = self.corrector._knobs[v.lower()]
     return [
         TableItem(v),
         TableItem(change_unit(initial, info.unit, info.ui_unit)),
         TableItem(change_unit(matched, info.unit, info.ui_unit),
                   set_value=self.set_steerer_value,
                   delegate=delegates[float],
                   **style),
         TableItem(get_raw_label(info.ui_unit)),
     ]
Example #7
0
 def on_optics_updated(self, *_):
     self.opticsTable.model().titles[1:] = [
         "{}/{}".format(info.name, get_raw_label(info.ui_unit))
         for info in self.corrector.optic_params
     ]
Example #8
0
 def on_optics_updated(self, *_):
     self.opticsTable.model().titles[1:] = [
         "{}/{}".format(info.name, get_raw_label(info.ui_unit))
         for info in self.corrector.optic_params
     ]
Example #9
0
 def display(self, value):
     if value is None:
         return "" if self.unit is None else unit.get_raw_label(self.unit)
     if isinstance(value, (float, unit.units.Quantity)):
         return unit.format_quantity(value, self.fmtspec)
     return format(value)
Example #10
0
 def set_unit(self, unit):
     self._unit = unit
     self.suffix = "" if unit is None else " " + get_raw_label(unit)
     self.placeholder_text = self.suffix
     self.updateEdit()
Example #11
0
 def get_comp_unit(self, par, i):
     units = ui_units.get(par.name)
     if isinstance(units, list) and i < len(units):
         return get_raw_label(units[i])
Example #12
0
def ax_label(label, unit):
    if unit in (1, None):
        return label
    return "{} [{}]".format(label, get_raw_label(unit))
Example #13
0
 def __init__(self, param, acs_value, mad_value):
     self.param = param
     self.name = param.name
     self.unit = get_raw_label(param.ui_unit)
     self.acs_value = change_unit(acs_value, param.unit, param.ui_unit)
     self.mad_value = change_unit(mad_value, param.unit, param.ui_unit)
Example #14
0
 def UpdateBeam(self):
     data = self.ovm.get_monitor().dvm_backend.get()
     set_value(self.disp_mon[0], '{:5}'.format(data['posx'].magnitude))
     set_value(self.disp_mon[1], '{:5}'.format(data['posy'].magnitude))
     set_label(self.disp_mon_unit[0], get_raw_label(data['posx']))
     set_label(self.disp_mon_unit[1], get_raw_label(data['posy']))
Example #15
0
def ax_label(label, unit):
    if unit in (1, None):
        return label
    return "{} [{}]".format(label, get_raw_label(unit))