def Terminate(self, args=None): self.logger.info('Terminate') self.gmt = ceo.GMT_MX() return "GMT deleted!"
def __init__(self, ops, satm, verbose=logging.INFO): self.logger = logging.getLogger(self.__class__.__name__) self.logger.setLevel(verbose) self.logger.info('Instantiate') self.gmt = ceo.GMT_MX() self.state0 = copy.deepcopy(self.gmt.state)
gs = ceo.Source(AGWS_photometric_band, zenith=zenith_angle, azimuth=azimuth_angle * math.pi / 180, rays_box_size=entrance_pupil_size_meter, rays_box_sampling=nPx, rays_origin=[0.0, 0.0, 25], fwhm=10.6) wfs = ceo.ShackHartmann(N_LENSLET, N_PX_LENLSET, lenslet_pitch_meter, N_PX_IMAGE=40, BIN_IMAGE=4, N_GS=N_GS) wfs.camera.photoelectron_gain = optics_throughtput gmt = ceo.GMT_MX(entrance_pupil_size_meter, nPx, M1_radial_order=M1_zernike_radial_order) # In[3]: gs.wavelength * ceo.constants.RAD2ARCSEC / 2 # In[4]: from scipy.optimize import brentq def ee80(_psf_, _px_scale_): n, m = _psf_.shape u = np.linspace(-1, 1, n) * (n / 2) v = np.linspace(-1, 1, m) * (m / 2)
def __init__(self, gmt_prms, gs_tt7_prms, gs_wfs_prms, wfs_prms, includeBM=True, filename=None): self.gmt = ceo.GMT_MX(**gmt_prms) if gs_tt7_prms is not None: self.tt7_gs = ceo.Source(**gs_tt7_prms) self.tt7 = ceo.GeometricTT7() self.wfs_gs = ceo.Source(**gs_wfs_prms) self.wfs_prms = wfs_prms self.wfs = ceo.GeometricShackHartmann(**wfs_prms) self.includeBM = includeBM self.N_MODE = 0 if includeBM: self.N_MODE = self.gmt.M1.modes.n_mode file_already_exists = False db = None if filename is not None: if os.path.isfile(filename + ".dir"): file_already_exists = True db = shelve.open(filename) print "@(AcO.LSQ)> WFS CALIBRATION ..." self.wfs_gs.reset() self.gmt.reset() self.gmt.propagate(self.wfs_gs) self.wfs.calibrate(self.wfs_gs, 0.) if file_already_exists: print " >> Loaded from %s" % filename self.C = db['C'] else: self.C = self.gmt.AGWS_calibrate(self.wfs, self.wfs_gs, decoupled=True, fluxThreshold=0.5, includeBM=self.includeBM, filterMirrorRotation=True, calibrationVaultKwargs={ 'nThreshold': [2] * 6 + [0], 'insertZeros': [None] * 6 + [[2, 7]] }) if filename is not None: print " >> Saved to %s" % filename db['C'] = self.C self.gs_tt7_prms = gs_tt7_prms if gs_tt7_prms is not None: print "@(AcO.LSQ)> TT7 CALIBRATION ..." self.gmt.reset() self.gmt.propagate(self.tt7_gs) self.tt7.calibrate(self.tt7_gs) if file_already_exists: print " >> Loaded from %s" % filename self.Dtt7 = db['Dtt7'] else: self.Dtt7 = self.gmt.calibrate(self.tt7, self.tt7_gs, mirror='M2', mode='segment tip-tilt', stroke=1e-6) if filename is not None: print " >> Saved to %s" % filename db['Dtt7'] = self.Dtt7 self.Mtt7 = LA.inv(self.Dtt7) if self.gs_tt7_prms is not None: print "@(AcO.LSQ)> TT7 calibration of observables ..." if file_already_exists: print " >> Loaded from %s" % filename D_s = db['D_s'] else: stroke = [1e-6] * 4 D = [] D.append( self.gmt.calibrate(self.tt7, self.tt7_gs, mirror='M1', mode='Rxyz', stroke=stroke[0])) D.append( self.gmt.calibrate(self.tt7, self.tt7_gs, mirror='M2', mode='Rxyz', stroke=stroke[1])) D.append( self.gmt.calibrate(self.tt7, self.tt7_gs, mirror='M1', mode='Txyz', stroke=stroke[2])) D.append( self.gmt.calibrate(self.tt7, self.tt7_gs, mirror='M2', mode='Txyz', stroke=stroke[3])) if includeBM: D.append( self.gmt.calibrate(self.tt7, self.tt7_gs, mirror='M1', mode='bending modes', stroke=1e-6)) if includeBM: D_s = [ np.concatenate([ D[0][:, k * 3:k * 3 + 3], D[2][:, k * 3:k * 3 + 3], D[1][:, k * 3:k * 3 + 3], D[3][:, k * 3:k * 3 + 3], D[4][:, k * self.N_MODE:(k + 1) * self.N_MODE] ], axis=1) for k in range(7) ] else: D_s = [ np.concatenate([ D[0][:, k * 3:k * 3 + 3], D[2][:, k * 3:k * 3 + 3], D[1][:, k * 3:k * 3 + 3], D[3][:, k * 3:k * 3 + 3] ], axis=1) for k in range(7) ] D_s[-1] = np.insert(D_s[-1], [2, 7], 0, axis=1) if filename is not None: print " >> Saved to %s" % filename db['D_s'] = D_s P2 = np.zeros((12 + self.N_MODE, 2)) P2[6, 0] = 1 P2[7, 1] = 1 self.Qbtt7 = [ np.eye(12 + self.N_MODE) - np.dot(P2, np.dot(self.Mtt7[k * 2:(k + 1) * 2, :], D_s[k])) for k in range(7) ] if filename is not None: db.close() self.observables(includeBM) self._piston_removed_ = False self._Osp_ = None self.D_orig = self.C.D self.N_MODE_orig = self.N_MODE self.Osp_orig = self.Osp self.Os_orig = self.Os self.set_aberrations(includeBM)
# In[2]: save_dir = sys.argv[1] print "Results will be saved in %s" % save_dir ## GENERIC STUFF: tid = ceo.StopWatch() CEO_git_commit = commands.getoutput("git rev-parse --verify --short HEAD") # In[3]: ## INITIALIZING CEO OBJECTS: # Telescope gmt = ceo.GMT_MX(D, nPx, M1_radial_order=M1_radial_order, M2_radial_order=M2_radial_order) # Turbulence parameters: if simul_turb == True: atm = ceo.JGmtAtmosphere(jsonfile=atm_fname) r0 = atm.r0 L0 = atm.L0 # In[4]: ## ON-AXIS AO SH WFS: p = D / (nPx - 1) if simul_SH == True: d = D / nLenslet if SHtype == 'diff':