def test_dwelltimes(dt, md=None): md = bmm_metadata(measurement='fluorescence') dets = [det] args = [ dets, ] start = list(0.5 * numpy.ones(len(dt))) stop = list(2.5 * numpy.ones(len(dt))) for q in zip(dt, start, stop): args.extend(q) args.append(5) # five steps from 0.5 to 2.5 yield from scan(*args, md=md)
def main_plan(inifile, force, **kwargs): ## --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- ## read and check INI content orig = inifile if not os.path.isfile(inifile): inifile = DATA + inifile if not os.path.isfile(inifile): print( warning_msg('\n%s does not exist! Bailing out....\n' % orig)) return (orig, -1) print(bold_msg('reading ini file: %s' % inifile)) (p, f) = scan_metadata(inifile=inifile, **kwargs) if not any( p): # scan_metadata returned having printed an error message return (yield from null()) #if not os.path.isdir(p['folder']): # print(error_msg('\n%s is not a folder\n' % p['folder'])) # return(yield from null()) detector = 'It' if 'trans' in p['mode']: detector = 'It' elif 'fluo' in p['mode']: detector = 'If' ## --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- ## verify output file name won't be overwritten outfile = '%s.%3.3d' % (os.path.join(p['folder'], p['filename']), p['start']) if os.path.isfile(outfile): print(error_msg('%s already exists! Bailing out....' % outfile)) return (yield from null()) ## --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- ## prompt user and verify that we are clear to start text = '\n' for k in ('folder', 'filename', 'experimenters', 'e0', 'npoints', 'dwell', 'delay', 'sample', 'prep', 'comment', 'mode', 'snapshots'): text = text + ' %-13s : %-50s\n' % (k, p[k]) if BMMuser.prompt: boxedtext('How does this look?', text + '\n %-13s : %-50s\n' % ('output file', outfile), 'green', width=len(outfile) + 25) # see 05-functions action = input("\nBegin time scan? [Y/n then Enter] ") if action.lower() == 'q' or action.lower() == 'n': return (yield from null()) (ok, ctstext) = BMM_clear_to_start() if force is False and ok is False: print(error_msg(ctstext)) yield from null() return ## --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- # organize metadata for injection into database and XDI output print(bold_msg('gathering metadata')) md = bmm_metadata( measurement=p['mode'], experimenters=p['experimenters'], edge=p['edge'], element=p['element'], edge_energy=p['e0'], direction=0, scantype='fixed', channelcut=p['channelcut'], mono='Si(%s)' % dcm._crystal, i0_gas='N2', #\ it_gas='N2', # > these three need to go into INI file ir_gas='N2', #/ sample=p['sample'], prep=p['prep'], stoichiometry=None, mode=p['mode'], comment=p['comment'], ) del (md['XDI']['Element']['edge']) del (md['XDI']['Element']['symbol']) md['XDI']['Column']['01'] = 'time seconds' md['XDI']['Column']['02'] = md.copy()['XDI']['Column']['03'] md['XDI']['Column']['03'] = md.copy()['XDI']['Column']['04'] md['XDI']['Column']['04'] = md['XDI']['Column']['05'] del (md['XDI']['Column']['05']) md['_kind'] = 'sead' rightnow = metadata_at_this_moment() # see 62-metadata.py for family in rightnow.keys(): # transfer rightnow to md if type(rightnow[family]) is dict: if family not in md: md[family] = dict() for k in rightnow[family].keys(): md[family][k] = rightnow[family][k] xdi = {'XDI': md} BMM_log_info( 'Starting single-energy absorption detection time scan using\n%s:\n%s\nCommand line arguments = %s\nMoving to measurement energy: %.1f eV' % (inifile, text, str(kwargs), p['e0'])) ## --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- ## move to the energy specified in the INI file print(bold_msg('Moving to measurement energy: %.1f eV' % p['e0'])) dcm.mode = 'fixed' yield from mv(dcm.energy, p['e0']) ## --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- ## snap photos if p['snapshots']: image = os.path.join( p['folder'], 'snapshots', "%s_XASwebcam_%s.jpg" % (p['filename'], now())) snap('XAS', filename=image) image = os.path.join(p['folder'], 'snapshots', "%s_analog_%s.jpg" % (p['filename'], now())) snap('analog', filename=image) ## --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- ## engage suspenders right before starting measurement if not force: BMM_suspenders() ## --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- ## perform the actual time scan uid = yield from timescan(detector, p['npoints'], p['dwell'], p['delay'], force=force, md={**xdi}) ## --*--*--*--*--*--*--*--*--*--*--*--*--*--*--*--*-- ## write the output file header = db[uid] write_XDI(outfile, header) # yield from ? report('wrote time scan to %s' % outfile)