def setup_class(klass): import os klass.curdir = os.path.dirname(__file__) klass.datadir = os.path.join(klass.curdir, 'data') klass.config_file = \ os.path.abspath(os.path.join(klass.datadir, "calibrators.ini")) klass.config_file_empty = \ os.path.abspath(os.path.join(klass.datadir, "calibrators_nocal.ini")) klass.config = read_config(klass.config_file) klass.caldir = os.path.join(klass.datadir, 'sim', 'calibration') klass.caldir2 = os.path.join(klass.datadir, 'sim', 'calibration2') klass.caldir3 = os.path.join(klass.datadir, 'sim', 'calibration_bad') klass.crossdir = os.path.join(klass.datadir, 'sim', 'crossscans') if not os.path.exists(klass.caldir): print('Fake calibrators: DummyCal, 1 Jy.') mkdir_p(klass.caldir) sim_crossscans(5, klass.caldir) if not os.path.exists(klass.caldir2): print('Fake calibrators: DummyCal2, 1 Jy.') mkdir_p(klass.caldir2) sim_crossscans(5, klass.caldir2, srcname='DummyCal2') if not os.path.exists(klass.caldir3): print('Fake calibrators: DummyCal2, wrong flux 0.52 Jy.') mkdir_p(klass.caldir3) sim_crossscans(1, klass.caldir3, srcname='DummyCal2', scan_func=source_scan_func) if not os.path.exists(klass.crossdir): print('Fake cross scans: DummySrc, 0.52 Jy.') mkdir_p(klass.crossdir) sim_crossscans(5, klass.crossdir, srcname='DummySrc', scan_func=source_scan_func) klass.scan_list = \ list_scans(klass.caldir, ['./']) + \ list_scans(klass.caldir2, ['./']) + \ list_scans(klass.crossdir, ['./']) klass.scan_list.sort() caltable = CalibratorTable() caltable.from_scans(klass.scan_list) caltable.update() klass.calfile = os.path.join(klass.curdir, 'test_calibration.hdf5') caltable.write(klass.calfile, overwrite=True) caltable.write(klass.calfile.replace('hdf5', 'csv'))
def setup_class(klass): import os klass.curdir = os.path.dirname(__file__) klass.datadir = os.path.join(klass.curdir, 'data') klass.sim_dir = os.path.join(klass.datadir, 'sim') klass.obsdir_ra = os.path.join(klass.datadir, 'sim', 'gauss_ra') klass.obsdir_dec = os.path.join(klass.datadir, 'sim', 'gauss_dec') klass.config_file = \ os.path.abspath(os.path.join(klass.sim_dir, 'test_config_sim.ini')) klass.caldir = os.path.join(klass.datadir, 'sim', 'calibration') klass.simulated_flux = 0.25 # First off, simulate a beamed observation ------- sim_config_file(klass.config_file, add_garbage=True, prefix="./") if (not os.path.exists(klass.obsdir_ra)) or \ (not os.path.exists(klass.obsdir_dec)): mkdir_p(klass.obsdir_ra) mkdir_p(klass.obsdir_dec) print('Fake map: Point-like (but Gaussian beam shape), ' '{} Jy.'.format(klass.simulated_flux)) sim_map(klass.obsdir_ra, klass.obsdir_dec) defective_dir = os.path.join(klass.sim_dir, 'defective') if not os.path.exists(defective_dir): shutil.copytree(os.path.join(klass.datadir, 'calibrators'), defective_dir) # Copy skydip scan skydip_dir = os.path.join(klass.datadir, 'gauss_skydip') new_skydip_dir = os.path.join(klass.sim_dir, 'gauss_skydip') if os.path.exists(skydip_dir) and not os.path.exists(new_skydip_dir): shutil.copytree(skydip_dir, new_skydip_dir) caltable = CalibratorTable() caltable.from_scans(glob.glob(os.path.join(klass.caldir, '*.fits')), debug=True) caltable.update() klass.calfile = os.path.join(klass.datadir, 'calibrators.hdf5') caltable.write(klass.calfile, overwrite=True) klass.config = read_config(klass.config_file) klass.raonly = os.path.abspath( os.path.join(klass.datadir, 'test_raonly.ini')) klass.deconly = os.path.abspath( os.path.join(klass.datadir, 'test_deconly.ini')) if HAS_PYREGION: excluded_xy, excluded_radec = \ _excluded_regions_from_args([os.path.join(klass.datadir, "center.reg")]) else: excluded_xy, excluded_radec = None, None klass.scanset = ScanSet(klass.config_file, nosub=False, norefilt=False, debug=True, avoid_regions=excluded_radec) klass.scanset.write('test.hdf5', overwrite=True) klass.stdinfo = {} klass.stdinfo['FLAG'] = None klass.stdinfo['zap'] = intervals() klass.stdinfo['base'] = intervals() klass.stdinfo['fitpars'] = np.array([0, 0]) def scan_no(scan_str): basename = os.path.splitext(os.path.basename(scan_str))[0] return int(basename.replace('Dec', '').replace('Ra', '')) klass.dec_scans = \ dict([(scan_no(s), s) for s in klass.scanset.scan_list if 'Dec' in s]) klass.ra_scans = \ dict([(scan_no(s), s) for s in klass.scanset.scan_list if 'Ra' in s]) klass.n_ra_scans = max(list(klass.ra_scans.keys())) klass.n_dec_scans = max(list(klass.dec_scans.keys())) if HAS_MPL: plt.ioff()