Commit aecc16e0 authored by LUSTIG Peter's avatar LUSTIG Peter

added file for detectons in real map

parent 02d0f213
import numpy as np
from nikamap import NikaMap, Jackknife, NikaBeam
import matplotlib.pyplot as plt
from pathlib import Path
import astropy.units as u
from astropy.io.fits import HDUList, PrimaryHDU, BinTableHDU
from picklesave import LoadObject
detection_threshold = 3.5
band = '2mm'
fwhm_beam = 11.2 * u.arcsec
if band == '2mm':
fwhm_beam = 17.7 * u.arcsec
fname = '../map_newrealisation_{}.pkl'.format(band)
realmap = LoadObject(fname)
# create new beam
newbeam = NikaBeam(fwhm=fwhm_beam, pixel_scale=realmap._pixel_scale)
realmap.beam = newbeam
std = realmap.check_SNR()
realmap.uncertainty.array *= std
nm_mf = realmap.match_filter(realmap.beam)
std = nm_mf.check_SNR()
nm_mf.uncertainty.array *= std
nm_mf.detect_sources(threshold=detection_threshold)
realmap.phot_sources(sources=nm_mf.sources, peak=False, psf=True)
hdul = HDUList([PrimaryHDU()])
hdu = BinTableHDU(data=realmap.sources, name='detected_sources')
hdu.header['band'] = band
hdu.header['fwhm_beam'] = '{}'.format(fwhm_beam)
hdu.header['detection_threshold'] = detection_threshold
# hdu.header['parity_threshold'] = parity_threshold
hdul.append(hdu)
hdul.writeto('NewrealisationSources_{}_threshold{}.fits'.format(band, detection_threshold), overwrite=True)
# realmap.sources.write()
#nm_mf.plot_SNR()
#plt.show(block=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment