def _make_extension_fits(self, ext, filename, **kwargs): maps = { 'EXT_TOT_MAP': ext['ext_tot_map'], 'EXT_SRC_MAP': ext['ext_src_map'], 'EXT_BKG_MAP': ext['ext_bkg_map'], 'PTSRC_TOT_MAP': ext['ptsrc_tot_map'], 'PTSRC_SRC_MAP': ext['ptsrc_src_map'], 'PTSRC_BKG_MAP': ext['ptsrc_bkg_map'] } hdu_images = [] for k, v in sorted(maps.items()): if v is None: continue hdu_images += [v.make_hdu(k)] tab = fits_utils.dict_to_table(ext) hdu_data = fits.table_to_hdu(tab) hdu_data.name = 'EXT_DATA' if ext.get('tsmap'): hdus = [ext['tsmap'].make_hdu(hdu='PRIMARY')] else: hdus = [fits.PrimaryHDU()] hdus += [hdu_data] + hdu_images hdus[0].header['CONFIG'] = json.dumps(utils.tolist(ext['config'])) hdus[1].header['CONFIG'] = json.dumps(utils.tolist(ext['config'])) fits_utils.write_hdus(hdus, filename, keywords={'SRCNAME': ext['name']})
def _make_extension_fits(self, ext, filename, **kwargs): maps = {'EXT_TOT_MAP': ext['ext_tot_map'], 'EXT_SRC_MAP': ext['ext_src_map'], 'EXT_BKG_MAP': ext['ext_bkg_map'], 'PTSRC_TOT_MAP': ext['ptsrc_tot_map'], 'PTSRC_SRC_MAP': ext['ptsrc_src_map'], 'PTSRC_BKG_MAP': ext['ptsrc_bkg_map']} hdu_images = [] for k, v in sorted(maps.items()): if v is None: continue hdu_images += [v.make_hdu(k)] tab = fits_utils.dict_to_table(ext) hdu_data = fits.table_to_hdu(tab) hdu_data.name = 'EXT_DATA' if ext.get('tsmap'): hdus = [ext['tsmap'].make_hdu(hdu='PRIMARY')] else: hdus = [fits.PrimaryHDU()] hdus += [hdu_data] + hdu_images hdus[0].header['CONFIG'] = json.dumps(utils.tolist(ext['config'])) hdus[1].header['CONFIG'] = json.dumps(utils.tolist(ext['config'])) fits_utils.write_hdus(hdus, filename, keywords={'SRCNAME': ext['name']})
def _make_localize_fits(self, loc, filename, **kwargs): tab = fits_utils.dict_to_table(loc) hdu_data = fits.table_to_hdu(tab) hdu_data.name = 'LOC_DATA' hdus = [loc['tsmap_peak'].make_hdu(hdu='PRIMARY'), loc['tsmap'].make_hdu(hdu='TSMAP'), hdu_data] hdus[0].header['CONFIG'] = json.dumps(loc['config']) hdus[2].header['CONFIG'] = json.dumps(loc['config']) fits_utils.write_hdus(hdus, filename)
def _make_localize_fits(self, loc, filename, **kwargs): tab = fits_utils.dict_to_table(loc) hdu_data = fits.table_to_hdu(tab) hdu_data.name = 'LOC_DATA' hdus = [loc['tsmap_peak'].create_primary_hdu(), loc['tsmap'].create_image_hdu('TSMAP'), hdu_data] hdus[0].header['CONFIG'] = json.dumps(loc['config']) hdus[2].header['CONFIG'] = json.dumps(loc['config']) fits_utils.write_hdus(hdus, filename)
def _make_tsmap_fits(self, data, filename, **kwargs): maps = {'SQRT_TS_MAP': data['sqrt_ts'], 'NPRED_MAP': data['npred'], 'N_MAP': data['amplitude']} hdu_images = [] for k, v in sorted(maps.items()): if v is None: continue hdu_images += [v.create_image_hdu(k)] tab = fits_utils.dict_to_table(data) hdu_data = fits.table_to_hdu(tab) hdu_data.name = 'TSMAP_DATA' hdus = [data['ts'].create_primary_hdu(), hdu_data] + hdu_images hdus[0].header['CONFIG'] = json.dumps(data['config']) hdus[1].header['CONFIG'] = json.dumps(data['config']) fits_utils.write_hdus(hdus, filename)
def _make_tsmap_fits(self, data, filename, **kwargs): maps = {'SQRT_TS_MAP': data['sqrt_ts'], 'NPRED_MAP': data['npred'], 'N_MAP': data['amplitude']} hdu_images = [] for k, v in sorted(maps.items()): if v is None: continue hdu_images += [v.to_hdu(hdu=k)] tab = fits_utils.dict_to_table(data) hdu_data = fits.table_to_hdu(tab) hdu_data.name = 'TSMAP_DATA' hdus = [data['ts'].to_hdu(hdu='PRIMARY'), hdu_data] + hdu_images data['config'].pop('map_skydir', None) hdus[0].header['CONFIG'] = json.dumps(data['config']) hdus[1].header['CONFIG'] = json.dumps(data['config']) fits_utils.write_hdus(hdus, filename)