Пример #1
0
def single_deconvolve(filelist, krn_size, psf_width, vb):

	## Deconvolve all FITS images in list
	for infile in filelist:
	
		## Run SExtractor to generate source-catalogue
		catfile = SD.SEx(infile, vb)
		## Run PSFEx to generate model image of PSF
		psf_obs = SD.PSFEx(catfile, "snap", vb)
		
		##--------------------------------------------------------------------
		
		## Intermediate step: convert PSF image to an array
		psf_obs = IM.pngcropwhite(IM.fits_pix(psf_obs))
		
		##--------------------------------------------------------------------		
		
		## Make target psf array
		gaussparams = DT.moments(psf_obs)
		if type(psf_width) is float:			
			gaussparams[1]=gaussparams[2]=psf_width#AsecToPix(psf_width,infile)
		psf_ref = DT.Gauss_2D(*gaussparams)
		#scipy.misc.imsave("./ref_"+str(psf_width)+".png",psf_ref)
		
		##--------------------------------------------------------------------		
		
		## Calculate deconvolution-kernel array
			## Kernel size = psf width -- assume this is ~ correlation length-scale
		krn_size = 3*int(max(gaussparams[1:3]))	### ONLY APPROPRIATE when using simdec
		kernarr = DT.get_kernel(psf_obs, psf_ref,[krn_size,krn_size],vb)	
		## Deconvolve image
		DT.deconvolve_image(infile, kernarr, vb)
	
	return
Пример #2
0
def simultaneous_deconvolve(filelist, krn_size, vb):
	
	s2_max = 0.0
	
	## Find largest PSF in ensemble
	for infile in filelist:
	
		## Run SExtractor to generate source-catalogue
		catfile = SD.SEx(infile, vb)
		## Run PSFEx to generate model image of PSF
		psf_obs = SD.PSFEx(catfile, "snap", vb)
		
		### NEED to find FWHM from images without going through the
		### following rigmarole:
		
		## Convert PSF image to an array
		psf_obs = IM.pngcropwhite(IM.fits_pix(psf_obs))
		
		## Here is how we decide what PSF to use
		## Product of the two widths = s2
		m=DT.moments(psf_obs)
		s2 = m[1]*m[2]
		## Which image has largest s2? Call this psf_OBS.
		if s2 > s2_max:
			s2_max = s2
			psf_OBS = psf_obs

##------------------------------------------------------------
	
	## Make target psf array
	psf_ref = DT.Gauss_2D(*DT.moments(psf_OBS))
	## Calculate kernel array for obs->ref
	kernarr = DT.get_kernel(psf_OBS, psf_ref, [krn_size,krn_size],vb)

##------------------------------------------------------------	

	## Deconvolve to the target	PSF
	for infile in filelist:
		DT.deconvolve_image(infile, kernarr, vb)	
	
	return