"""Launches a worker with the appropriate queue and database based on an index into a config file.""" from pathlib import Path from iris.data import PersistentQueue, Database from iris.rings import W2 from iris.worker import Worker # shield for multiprocessing if __name__ == '__main__': root = Path( __file__).parent / 'data' / 'arbitrary-spherical-coma-astigmatism' q = PersistentQueue(root / 'queue.pkl') db = Database(root, fields=[ 'truth_rmswfe', 'cost_first', 'cost_final', 'rrmswfe_final', 'time', 'nit' ]) w = Worker(q, db, optmode='global', simopts={ 'guess': [0] * 18, 'decoder_ring': W2, }, optopts={ 'parallel': True, 'nthreads': 7, 'ftol': 1e-7, }, work_time=60 * 17) w.start()
low_value, mid_value, high_value, x_factor, y_factor = make_mag_xy_random_values( ) xmag_low = low_value * x_factor ymag_low = low_value * y_factor xmag_mid = mid_value * x_factor ymag_mid = mid_value * y_factor xmag_high = high_value * x_factor ymag_high = high_value * y_factor z7 = xmag_low z8 = ymag_low z14 = xmag_mid z15 = ymag_mid z23 = xmag_high z24 = ymag_high # stack all truths together and split them into 5 chunks for 5 workers per datatype alltruth = np.stack( (z4, z5, z6, z7, z8, z9, z12, z13, z14, z15, z16, z21, z22, z23, z24, z25), axis=1) truths = list(alltruth) p = Path(__file__).parent #/ '..' / '..' / p = p / 'data' / 'arbitrary-spherical-coma-astigmatism' q = PersistentQueue(p / 'queue.pkl', overwrite=True) q.put_many(truths)
xcoef, ycoef = np.cos(angles), np.sin(angles) # flipped -- optics convention xcoef = (xcoef * coma_amounts_tiled.reshape((s, 1))).ravel() ycoef = (ycoef * coma_amounts_tiled.reshape((s, 1))).ravel() out_coma = np.zeros((sphcoef.shape[0], 16)) out_coma[:, 5] = sphcoef out_coma[:, 10] = sphcoef / -2 out_coma[:, 15] = sphcoef / 4 out_coma[:, 3] = xcoef out_coma[:, 4] = ycoef out_astig = np.zeros((sphcoef.shape[0], 16)) out_astig[:, 5] = sphcoef out_astig[:, 10] = sphcoef / -2 out_astig[:, 15] = sphcoef / 4 out_astig[:, 1] = xcoef out_astig[:, 2] = ycoef root = Path(__file__).parent / 'data' / 'coma-vs-angle' p = root / 'queue.pkl' q = PersistentQueue(p, overwrite=True) items = list(out_coma) q.put_many(items) root = Path(__file__).parent / 'data' / 'astigmatism-vs-angle' p = root / 'queue.pkl' q = PersistentQueue(p, overwrite=True) items = list(out_astig) q.put_many(items)
from iris.data import PersistentQueue # folders for each queue root = Path(__file__).parent / 'data' / 'cost-function-design' stem1 = root / 'diffraction_sumsquarediff' stem2 = root / '____________sumsquarediff' stem3 = root / 'diffraction_manhattan' stem4 = root / '____________manhattan' stems = (stem1, stem2, stem3, stem4) qs = [] for stem in stems: counter, local = 1, [] for i in range(5): p = stem / str(counter) p.mkdir(parents=True, exist_ok=True) local.append(PersistentQueue(p / 'queue.pkl', overwrite=True)) counter += 1 qs.append(local) # set the seed and generate 'fudge factor' arrays centered on 1 with stdev 1/2 and 500 samples e/a np.random.seed(1234) fudge1 = np.random.normal(loc=1, scale=0.5, size=500) fudge2 = np.random.normal(loc=1, scale=0.5, size=500) z16_factor, z25_factor = -0.5, 0.5**2 # no defocus # uniform normal distributions of size 500 and range [0, 0.25] truths_z4 = np.zeros(500) truths_z9 = np.random.random(truths_z4.shape) * .25 # Z16 and Z25 are derived from Z9 and have value -1/2 and +1/4 respectively
opt = _mtf_cost_core_manhattan ftol = 5e-4 else: opt = _mtf_cost_core_sumsquarediff ftol = 1e-7 if diff: optargs = ((_mtf_cost_core_diffractiondiv, opt), None) else: optargs = ((opt, ), None) # shield for multiprocessing if __name__ == '__main__': root = Path(cfg['root']).expanduser() base = root / target[0] / target[1] q = PersistentQueue(base / 'queue.pkl') db = Database(base, fields=[ 'truth_rmswfe', 'cost_first', 'cost_final', 'rrmswfe_final', 'time', 'nit' ]) w = Worker(q, db, optmode='global', optopts={ 'parallel': True, 'nthreads': 23, 'ftol': ftol, }, optcoreopts=optargs, work_time=60 * 7)