def get_frame_data(nspec=10, objtype=None): """ Return basic test data for desispec.frame object: """ nwave = 100 wavemin, wavemax = 4000, 4100 wave, model_flux = get_models(nspec, nwave, wavemin=wavemin, wavemax=wavemax) resol_data = set_resolmatrix(nspec, nwave) calib = np.sin((wave - wavemin) * np.pi / np.max(wave)) flux = np.zeros((nspec, nwave)) for i in range(nspec): flux[i] = Resolution(resol_data[i]).dot(model_flux[i] * calib) sigma = 0.01 # flux += np.random.normal(scale=sigma, size=flux.shape) ivar = np.ones(flux.shape) / sigma**2 mask = np.zeros(flux.shape, dtype=int) fibermap = empty_fibermap(nspec, 1500) if objtype is None: fibermap['OBJTYPE'] = 'QSO' fibermap['OBJTYPE'][0:3] = 'STD' # For flux tests else: fibermap['OBJTYPE'] = objtype frame = Frame(wave, flux, ivar, mask, resol_data, fibermap=fibermap) frame.meta = {} frame.meta['EXPTIME'] = 1. # For flux tests return frame
def _make_frame(self, camera='b0', flavor='dark', night=None, expid=None): if night is None: night = self.night if expid is None: expid = self.expid nspec = 3 nwave = 10 wave = np.arange(nwave) flux = np.random.uniform(size=(nspec, nwave)) ivar = np.ones(flux.shape) frame = Frame(wave, flux, ivar, spectrograph=0) frame.meta = dict(CAMERA=camera, FLAVOR=flavor, NIGHT=night, EXPID=expid) return frame
def _make_frame(self, camera='b0', flavor='dark', night=None, expid=None): if night is None: night = self.night if expid is None: expid = self.expid nspec = 3 nwave = 10 wave = np.arange(nwave) flux = np.random.uniform(size=(nspec, nwave)) ivar = np.ones(flux.shape) frame = Frame(wave, flux, ivar, spectrograph=0) frame.meta = dict(CAMERA=camera, FLAVOR=flavor, NIGHT=night, EXPID=expid) return frame
def test_io_qa_frame(self): nspec = 3 nwave = 10 wave = np.arange(nwave) flux = np.random.uniform(size=(nspec, nwave)) ivar = np.ones(flux.shape) frame = Frame(wave, flux, ivar, spectrograph=0) frame.meta = dict(CAMERA='b0', FLAVOR='dark', NIGHT='20160607', EXPID=1) #- Init qaframe = QA_Frame(frame) qaframe.init_skysub() # Write desio_qa.write_qa_frame(self.testyfile, qaframe) # Read xqaframe = desio_qa.read_qa_frame(self.testyfile) # Check self.assertTrue(qaframe.qa_data['SKYSUB']['PARAM']['PCHI_RESID'] == xqaframe.qa_data['SKYSUB']['PARAM']['PCHI_RESID']) self.assertTrue(qaframe.flavor == xqaframe.flavor)