def main(): args = get_args() pid = os.getpid() hostname = socket.gethostname() src['id'] = '{}/{}'.format(args.case_id, args.subcase_id) if not os.path.exists(files['src_dir'].abs): os.makedirs(files['src_dir'].abs) logfile = os.path.join(files['src_dir'].abs, '{}-{}.log'.format(hostname, pid)) logging.basicConfig(filename=logfile, level=logging.INFO) logging.info(str(args)) aoc = AdjOpticsCase(case_id=args.case_id, subcase_id=args.subcase_id, clip=args.clip, n_ss=args.ss, piston_tilt=bool(args.piston_tilt), displ_axes=['X'], corr_axes=['X'], n_proc=None, n_strips=args.n_strips) outfile = os.path.join(files['src_dir'].abs, 'act_fail-{}-{}.dat'.format(hostname, pid)) # Make an ordered list 0 .. n_acts-1 for shuffling later. ifuncs_x = aoc.ifuncs['X'].copy() ifuncs_ry = aoc.ifuncs['RY'].copy() n_acts = ifuncs_x.shape[0] i_acts = np.arange(n_acts) for i in range(args.max_sim): # Force some actuators to "fail" by taking them out of the optimization if args.max_fail > 0: n_fail = np.random.randint(args.max_fail) + 1 np.random.shuffle(i_acts) ok = np.ones(n_acts, dtype=bool) i_fail = i_acts[:n_fail] ok[i_fail] = False aoc.ifuncs['X'] = ifuncs_x[ok] aoc.ifuncs['RY'] = ifuncs_ry[ok] else: n_fail = 0 i_fail = [-1] aoc.calc_adj() aoc.calc_stats() aoc.calc_scatter(calc_input=False) hpd = aoc.scatter['corr']['X']['hpd'] rmsd = aoc.scatter['corr']['X']['rmsd'] resid_std = aoc.resid['X']['X']['std']['clip'] displ_std = aoc.displ['X']['std']['clip'] with open(outfile, 'a') as f: i_fail_str = ','.join(str(x) for x in i_fail) print >>f, ' '.join(str(x) for x in (n_fail, hpd, rmsd, displ_std, resid_std, i_fail_str))
def main(): args = get_args() pid = os.getpid() hostname = socket.gethostname() src['id'] = '{}/{}'.format(args.case_id, args.subcase_id) if not os.path.exists(files['src_dir'].abs): os.makedirs(files['src_dir'].abs) logfile = os.path.join(files['src_dir'].abs, '{}-{}.log'.format(hostname, pid)) logging.basicConfig(filename=logfile, level=logging.INFO) logging.info(str(args)) aoc = AdjOpticsCase(case_id=args.case_id, subcase_id=args.subcase_id, clip=args.clip, n_ss=args.ss, piston_tilt=bool(args.piston_tilt), displ_axes=['X'], corr_axes=['X'], n_proc=None, n_strips=args.n_strips) outfile = os.path.join(files['src_dir'].abs, 'act_fail-{}-{}.dat'.format(hostname, pid)) # Make an ordered list 0 .. n_acts-1 for shuffling later. ifuncs_x = aoc.ifuncs['X'].copy() ifuncs_ry = aoc.ifuncs['RY'].copy() n_acts = ifuncs_x.shape[0] i_acts = np.arange(n_acts) for i in range(args.max_sim): # Force some actuators to "fail" by taking them out of the optimization if args.max_fail > 0: n_fail = np.random.randint(args.max_fail) + 1 np.random.shuffle(i_acts) ok = np.ones(n_acts, dtype=bool) i_fail = i_acts[:n_fail] ok[i_fail] = False aoc.ifuncs['X'] = ifuncs_x[ok] aoc.ifuncs['RY'] = ifuncs_ry[ok] else: n_fail = 0 i_fail = [-1] aoc.calc_adj() aoc.calc_stats() aoc.calc_scatter(calc_input=False) hpd = aoc.scatter['corr']['X']['hpd'] rmsd = aoc.scatter['corr']['X']['rmsd'] resid_std = aoc.resid['X']['X']['std']['clip'] displ_std = aoc.displ['X']['std']['clip'] with open(outfile, 'a') as f: i_fail_str = ','.join(str(x) for x in i_fail) print >> f, ' '.join( str(x) for x in (n_fail, hpd, rmsd, displ_std, resid_std, i_fail_str))
aoc = AdjOpticsCase( case_id=args.case_id, subcase_id=args.subcase_id, clip=args.clip, n_ss=args.ss, piston_tilt=bool(args.piston_tilt), n_strips=args.n_strips, displ_axes=displ_axes, corr_axes=corr_axes, n_proc=0, ) # Compute stats for zero-noise case aoc.calc_adj() aoc.calc_stats() aoc.calc_scatter() coeffs = aoc.coeffs["X"] drive_ref = getattr(np, args.drive_ref)(abs(coeffs)) # noises = (0.00001, 0.001, 0.002, 0.005, 0.01, 0.02, # 0.05, 0.1, 0.15, 0.2) noises = np.random.uniform(0, 0.2, args.n_sim) noises[0] = 0 pid = os.getpid() hostname = socket.gethostname() outfile = os.path.join("drive_noise-{}-{}.dat".format(hostname, pid)) for noise in noises: print "Drive noise = {} (fraction of {} drive voltage)".format(noise, args.drive_ref) drive_noise = noise * drive_ref
displ_axes = args.displ_axes.split(',') corr_axes = args.corr_axes.split(',') aoc = AdjOpticsCase(case_id=args.case_id, subcase_id=args.subcase_id, clip=args.clip, n_ss=args.ss, piston_tilt=bool(args.piston_tilt), n_strips=args.n_strips, displ_axes=displ_axes, corr_axes=corr_axes, n_proc=0) # Compute stats for zero-noise case aoc.calc_adj() aoc.calc_stats() aoc.calc_scatter() coeffs = aoc.coeffs['X'] drive_ref = getattr(np, args.drive_ref)(abs(coeffs)) # noises = (0.00001, 0.001, 0.002, 0.005, 0.01, 0.02, # 0.05, 0.1, 0.15, 0.2) noises = np.random.uniform(0, 0.2, args.n_sim) noises[0] = 0 pid = os.getpid() hostname = socket.gethostname() outfile = os.path.join('drive_noise-{}-{}.dat'.format(hostname, pid)) for noise in noises: print 'Drive noise = {} (fraction of {} drive voltage)'.format( noise, args.drive_ref)