Esempio n. 1
0
 def status(self):
     text = f'\nCurrent temperature = {self.readback.get():.1f}, setpoint = {self.setpoint.get():.1f}\n\n'
     code = int(self.status_code.get())
     if code & 1:
         text += error_msg('Error        : yes') + '\n'
     else:
         text += 'Error        : no\n'
     if code & 2:
         text += go_msg('At setpoint  : yes') + '\n'
     else:
         text += 'At setpoint  : no\n'
     if code & 4:
         text += go_msg('Heater       : on') + '\n'
     else:
         text += 'Heater       : off\n'
     if code & 8:
         text += go_msg('Pump         : on') + '\n'
     else:
         text += 'Pump         : off\n'
     if code & 16:
         text += go_msg('Pump Auto    : yes') + '\n'
     else:
         text += 'Pump Auto    : no\n'
         
     boxedtext(f'Linkam {self.model}, stage {self.stage_model}', text, 'brown', width = 45)
Esempio n. 2
0
def show_edges():
    rois = user_ns['rois']
    if user_ns['with_xspress3'] is True:
        text = show_reference_wheel() + '\n' + user_ns['xs'].show_rois()
    else:
        text = show_reference_wheel() + '\n' + rois.show()
    boxedtext('Foils and ROIs configuration', text[:-1], 'brown', width=85)
Esempio n. 3
0
 def wh(self):
     stripe = ''
     if self.name.lower() == 'm3':
         if self.xu.user_readback.get() > 0:
             stripe = ' (Rh/Pt stripe)'
         else:
             stripe = ' (Si stripe)'
     boxedtext(self.name + stripe, self.where(), 'cyan')
Esempio n. 4
0
 def wh(self):
     if any(x.connected is False
            for x in (self.yu, self.ydi, self.ydo, self.xu, self.xd)):
         print(f'Some {self.name.capitalize()} motors are disconnected')
         print('Do check_for_synaxis() for more information.')
         return ()
     stripe = ''
     if self.name.lower() == 'm3':
         if self.xu.user_readback.get() > 0:
             stripe = ' (Rh/Pt stripe)'
         else:
             stripe = ' (Si stripe)'
     boxedtext(self.name + stripe, self.where(), 'cyan')
def show_vacuum():
    text = ' Vacuum section       pressure    current\n'
    text += '==================================================\n'
    for v in vac:
        if float(v.current.get()) > 5e-4:
            text += '%-20s  %s    %4s  mA\n' % (v.name, v._pressure(),
                                                v._current())
        else:
            text += '%-20s  %s    %4s μA\n' % (v.name, v._pressure(),
                                               v._current())
    text += '%-20s  %s\n' % (flight_path.name, flight_path._pressure())
    for i in range(1, 7):
        text += 'Front end section %d   %s\n' % (i, fev._pressure(i))
    boxedtext('BMM vacuum', text, 'brown', width=55)
Esempio n. 6
0
 def status(self):
     text = '\n  %s is %s\n\n' % (self.name, self.prefix)
     for signal in list(self.configuration_attrs):
         if signal.upper() not in status_list.keys():
             continue
         suffix = getattr(self, signal).pvname.replace(self.prefix, '')
         string = getattr(self, signal).enum_strs[getattr(self,
                                                          signal).get()]
         if signal != 'asscs':
             if getattr(self, signal).get() != status_list[signal.upper()]:
                 string = error_msg('%-19s' % string)
         text += '  %-26s : %-19s  %s   %s \n' % (
             getattr(self, signal + '_desc').get(), string,
             bold_msg(getattr(self, signal).get()), whisper(suffix))
     boxedtext('%s status signals' % self.name, text, 'green')
Esempio n. 7
0
 def status(self):
     text = '\n  %s is %s\n\n' % (self.name, self.prefix)
     for signal in status_list.keys():
         sig = signal.lower()
         try:
             suffix = getattr(self, sig).pvname.replace(self.prefix, '')
             string = getattr(self, sig).enum_strs[getattr(self, sig).get()]
             if signal != 'asscs':
                 if getattr(self, sig).get() != status_list[signal]:
                     string = verbosebold_msg('%-19s' % string)
             #text += '  %-26s : %-19s  %s   %s \n' % (getattr(self, sig+'_desc').get(),
             #                                         string,
             #                                         bold_msg(getattr(self, sig).get()),
             #                                         whisper(suffix))
             text += '  %-19s  %s   %s \n' % (
                 string, bold_msg(getattr(self,
                                          sig).get()), whisper(suffix))
         except:
             pass
     boxedtext('%s status signals' % self.name, text, 'green')
Esempio n. 8
0
def check_for_synaxis():
    '''A disconnected motor (due to IOC or controller not running) will be
    defined as a SynAxis. This does a test for that situation and
    reports about it at startup.  It also sets BMMuser.syns to True so
    things like motor_status() behave non-disastrously.
    '''
    BMMuser.syns = False
    syns = []
    for m in mcs8_motors:
        if 'SynAxis' in f'{m}':
            syns.append(m.name)
    if len(syns) > 0:
        BMMuser.syns = True
        text = 'The following are disconnected & defined as simulated motors:\n\n'
        text += '\n'.join(
            disconnected_msg(x)
            for x in textwrap.wrap(', '.join(syns))) + '\n\n'
        text += 'This allows bsui to operate normally, but do not expect anything\n'
        text += 'involving those motors to work correctly.\n'
        text += whisper(
            '(This likely means that an IOC or a motor controller (or both) are off.)'
        )
        boxedtext('Disconnected motors', text, 'red', width=74)
Esempio n. 9
0
def show_edges():
    if with_xspress3 is True:
        text = show_reference_wheel() + '\n' + xs.show_rois()
    else:
        text = show_reference_wheel() + '\n' + rois.show()
    boxedtext('Foils and ROIs configuration', text[:-1], 'brown', width=85)
Esempio n. 10
0
 def wh(self):
     boxedtext('goniometer table', self.where(), 'cyan')
Esempio n. 11
0
 def wh(self):
     boxedtext('XAFS table', self.where(), 'cyan')
Esempio n. 12
0
 def wh(self):
     boxedtext('DCM', self.where(), 'cyan', width=74)
Esempio n. 13
0
def show_edges():
    rois = user_ns['rois']
    xs = user_ns['xs']
    text = show_reference_wheel() + '\n' + rois.show() + '\n' + xs.show_rois()
    boxedtext('Foils and ROIs configuration', text[:-1], 'brown', width=85)
Esempio n. 14
0
def calibrate_mono(mono='111'):
    BMMuser, shb, dcm, dcm_pitch = user_ns['BMMuser'], user_ns['shb'], user_ns[
        'dcm'], user_ns['dcm_pitch']
    BMM_dcm = dcm_parameters()

    # read content from INI file
    datafile = os.path.join(BMMuser.DATA, 'edges%s.ini' % mono)
    print(f'reading {datafile}')
    config.read_file(open(datafile))
    DSPACING = float(config.get('config', 'DSPACING'))
    thistitle = 'Si(%s) calibration curve' % mono

    edges = dict()
    for i in config.items('edges'):
        el = i[0]
        vals = [float(j) for j in i[1].split(',')
                ]  # convert CSV string -> list of strings -> list of floats
        edges[el] = vals

    # organize the data from the INI file
    ordered = [y[1] for y in sorted([(edges[x][1], x) for x in edges.keys()])]

    tabulated = list()
    ee = list()
    tt = list()
    for el in ordered:
        ee.append(edges[el][1])
        tt.append(edges[el][2])

    # working arrays
    e = array(ee)
    th = array(tt)
    energy = e.copy(),
    theta = th.copy()

    # limfit parameters
    params = lmfit.Parameters()
    params.add('d', value=DSPACING, vary=True)
    params.add('offset', value=0, vary=True)

    def match(pars, x, data=None):
        vals = pars.valuesdict()
        d_spacing = vals['d']
        offset = vals['offset']
        model = (2 * pi * HBARC) / (2 * d_spacing * sin(
            (x + offset) * pi / 180))  # HBARC defined in 20-dcm.py
        func = model - data
        if data is None:
            return model
        return func

    fit = lmfit.minimize(match, params, args=(th, ), kws={'data': e})
    boxedtext('fit results', lmfit.fit_report(fit), 'green')

    d_spacing = fit.params.get('d').value
    derr = fit.params.get('d').stderr
    offset = fit.params.get('offset').value
    oerr = fit.params.get('offset').stderr
    energy = (2 * pi * HBARC) / (2 * d_spacing * sin(
        (theta + offset) * pi / 180))

    i = 0
    text = '\n #  El.  tabulated    found        diff\n'
    found = list()
    for el in ordered:
        val = (2 * pi * HBARC) / (2 * d_spacing * sin(
            (tt[i] + offset) * pi / 180))
        found.append(val)
        text = text + "    %-2s  %9.3f  %9.3f  %9.3f\n" % (
            el.capitalize(), ee[i], found[i], found[i] - ee[i])
        i = i + 1
    boxedtext('comparison with tabulated values', text, 'lightgray')
    text = ' self.dspacing_%s = %.7f\n' % (dcm._crystal, d_spacing)
    if dcm._crystal == '111':
        text += ' self.offset_111 = %.7f' % (BMM_dcm.offset_111 + offset)
        boxedtext('new values for 19-dcm-parameters.py', text, 'lightgray')
    else:
        text += ' self.offset_311 = %.7f' % (BMM_dcm.offset_311 + offset)
        boxedtext('new values for BMM/dcm-parameters.py', text, 'lightgray')

    y1 = 13.5
    y2 = 12.9
    if mono == '311':
        (y1, y2) = (2 * y1, 2 * y2)

    ## cubic interpolation of tabulated edge energies ... eye candy
    xnew = linspace(min(ee), max(ee), 100)
    f = interp1d(ee, tt, kind='cubic')

    plt.cla()
    #fig, ax = plt.subplots()
    plt.plot(xnew, f(xnew), label='tabulated')
    plt.plot(found, tt, 'ro', label='measured')
    plt.xlabel('energy (eV)')
    plt.ylabel('angle (degrees)')
    plt.title(thistitle)
    plt.text(12000,
             y1,
             'd-spacing = %.8f ± %.8f Å' % (d_spacing, derr),
             fontsize='small')
    plt.text(12000,
             y2,
             'offset = %.5f ± %.5f degrees' % (offset, oerr),
             fontsize='small')
    legend = plt.legend(loc='upper right', shadow=True)
    plt.show()

    plottheta = arange(20.0, 5.0, -0.1)
    if mono == '311':
        plottheta = arange(36.0, 10.0, -0.1)
def xrdm():
    boxedtext('XRD motor status', xrd_motors(), 'cyan', width=60)
def ms():
    boxedtext('BMM motor status', motor_status(), 'cyan', width=84)
def su():
    boxedtext('BMM utilities', show_utilities(), 'brown', width=124)
def sw():
    boxedtext('BMM water', show_water(), 'lightblue', width=55)
Esempio n. 19
0
 def wh(self):
     boxedtext(self.name, self.where(), 'cyan')
Esempio n. 20
0
def ms():
    if user_ns['BMMuser'].syns is True:
        print('Some motors are disconnected and represented as a SynAxis.')
        print('Do check_for_synaxis() for more information.')
        return
    boxedtext('BMM motor status', motor_status(), 'cyan', width=84)