def beam_recons(led_names, ref_slot='11', ref_amp=4, ref_pix_x=1000, ref_pix_y=256, npix_for_avg=30, npix_beam_image=300): mean_bias_file = ref_slot + '_mean_bias_image_RTM-006.fits' recons = {} for led in led_names: config = u.load_ccob_config( '/home/combet/ccob-wb/ccob_config_RTM-006.yaml') config['led_name'] = led config['path'] = os.path.join(config['path'], config['led_name']) flist = sorted(u.find_files(config, slot=ref_slot)) ccd_dict = sensorTest.MaskedCCD(flist[0], bias_frame=os.path.join( config['tmp_dir'], mean_bias_file)) eotest_results_file = os.path.join( config['eo_data_path'], '{}_eotest_results.fits'.format(ccd_dict.md('LSST_NUM'))) gains_dict = u.gains(eotest_results_file) nodes = {} nodes['xarr'] = [] nodes['yarr'] = [] nodes['val'] = [] for i, f in enumerate(sorted(flist)): nodes['xarr'].append( float(os.path.basename(f).split('_')[3].split('x')[1])) nodes['yarr'].append( float(os.path.basename(f).split('_')[4].split('y')[1])) ccd_dict = sensorTest.MaskedCCD(f, bias_frame=os.path.join( config['tmp_dir'], mean_bias_file)) image = ccd_dict.unbiased_and_trimmed_image(ref_amp) image *= gains_dict[ref_amp] arr = image.getArrays() nodes['val'].append( np.mean( (arr[0][ref_pix_x - npix_for_avg / 2:ref_pix_x + npix_for_avg / 2, ref_pix_y - npix_for_avg / 2:ref_pix_y + npix_for_avg / 2]))) f_interp = interpolate.interp2d(np.unique(nodes['xarr']), np.unique(nodes['yarr']), nodes['val'], kind='cubic') xarr2 = np.linspace(min(nodes['xarr']), max(nodes['xarr']), npix_beam_image) yarr2 = np.linspace(min(nodes['yarr']), max(nodes['yarr']), npix_beam_image) tmp = f_inerp(xarr2, yarr2) recons[led] = tmp / max(tmp.flatten()) return recons
def main(): # print command line arguments config = sys.argv[0] print(config) config = u.load_ccob_config("beam_config.yaml") dirlist = [] for d in config['rundir']: dirlist += glob.glob(config['rootdir'] + d + 'ccob_' + config['led_name'] + '*') print(len(dirlist)) assert (len(dirlist) / config['scan_size']).is_integer, 'Wrong number of scan locations' print(f'Scan over {len(dirlist)} locations') b = beam.CcobBeam(config) for i in np.arange(config['scan_size']): # that's just to allow saving the data at every line of the scan in case # the job is interrupted. start = i * config['scan_size'] end = (i + 1) * config['scan_size'] b.read_multibunch(config, dirlist=dirlist[start:end]) b.save( os.path.join( config['tmpdir'], 'beam_object_' + config['ref_raft'] + '_' + config['ref_slot'] + '_' + config['led_name'] + '.pkl'))
def main(): """ First, finds the list of files relevant to a CCOB scan, given the paths available in the configuration file. Then,generates a CcobBeam object containing the raw data, the interpolated model of the beam, the 2D beam array, and the location of the beam maximum. """ configfile = sys.argv[1] config = u.load_ccob_config(configfile) dirlist = [] for d in config['rundir']: dirlist += glob.glob(config['rootdir'] + d + 'ccob_' + config['led_name'] + '*') outfile = os.path.join( config['tmpdir'], 'beam_object_' + config['ref_raft'] + '_' + config['ref_slot'] + '_' + config['led_name'] + '.pkl') assert (len(dirlist) / config['scan_size'] ).is_integer, f'{len(dirlsit)} = Wrong number of scan locations' print(f'Scan over {len(dirlist)} locations') b = CcobBeam(config) print(outfile) if os.path.isfile(outfile): b = pickle.load(open(outfile, 'rb')) if b.config == config: print( "Configuration matches - continuing from existing partial file" ) else: sys.exit( "Configuration does not match that of existing file - Exit") for i in np.arange(config['scan_size']): # that's just to allow saving the data at every line of the scan in case # the job is interrupted. print(f'Loading row {i}') start = i * config['scan_size'] end = (i + 1) * config['scan_size'] b.read_multibunch(config, dirlist=dirlist[start:end], silent=True) b.save(outfile) b.interp_beam_BOT(amp=config['ref_amps'][0], pd_corr=True) im = b.make_image_BOT() b.find_max_from_avg() b.save(outfile)
def main(): config_file = 'ccob_config.yaml' config = ccob_utils.load_ccob_config(config_file) slot_names = ['00', '01', '02', '10', '11', '12', '20', '21', '22'] led_names = ['uv', 'blue', 'nm750', 'nm850', 'red', 'nm960'] currents = ['0.012A', '0.012A', '0.012A', '0.012A', '0.012A', '0.012A'] exp_times = ['0.6s', '0.03s', '0.06s', '0.12s', '0.06s', '0.18s'] led_names = ['red'] currents = ['0.012A'] exp_times = ['0.06s'] xpos = ['258', '300', '342'] ypos = ['234', '192', '150'] # for slot in slot_names: # ccob_utils.build_mean_bias_frame(config, slot) for i, led in enumerate(led_names): config['led_name'] = led config['current'] = currents[i] config['exp_time'] = exp_times[i] for x in xpos: for y in ypos: print "Working on led = " + led + ", x = " + x + ", y = " + y config['xpos'] = x config['ypos'] = y im_raw, im_corr, im_corr_wbias = ccob_utils.make_image( config, slot_names) fig_raw = im_raw.plot(nsig=2, title=config['led_name']) fig_corr = im_corr.plot(nsig=2, title=config['led_name']) fig_corr_wbias = im_corr_wbias.plot(nsig=2, title=config['led_name']) filename = 'raft_image_raw_ccob_X' + config[ 'xpos'] + '_Y' + config['ypos'] + '_' + config[ 'led_name'] + '.png' fig_raw.savefig(os.path.join(config['tmp_dir'], filename)) filename = 'raft_image_corr_ccob_X' + config[ 'xpos'] + '_Y' + config['ypos'] + '_' + config[ 'led_name'] + '.png' fig_corr.savefig(os.path.join(config['tmp_dir'], filename)) filename = 'raft_image_corr_wbias_ccob_X' + config[ 'xpos'] + '_Y' + config['ypos'] + '_' + config[ 'led_name'] + '.png' fig_corr_wbias.savefig( os.path.join(config['tmp_dir'], filename))
def __init__(self, config_file_beam, config_file_data): # self.config_file_beam = config_file_beam # self.config_file_data = config_file_data self.config_beam = u.load_ccob_config(config_file_beam) self.config_data = u.load_ccob_config(config_file_data)