def convolve(self, other):
     result = NDistanceFunction(self.dim)
     result.offsets = [
         so + oo for so, oo in zip(self.offsets, other.offsets)
     ]
     result.vector = Convolve.convolve(self.vector, other.vector)
     result.resetMaxDistance()
     return result
示例#2
0
def main(*args):
    resolution = 0.1
    fwhm = 0.5
    # get some (random) data, i.e. a stick-spectrum
    x = num.arange(-50, 50+resolution, resolution)
    y = num.zeros(x.shape, num.Float)
    for i in range(10):
        y[ran.randint(0, len(y)-1)] = ran.random()
    # create lineshape objects
    g = ls.GaussProfile(num.arange(-10*fwhm, 10*fwhm+resolution, resolution), 1.0)
    l = ls.LorentzProfile(num.arange(-10*fwhm, 10*fwhm+resolution, resolution), 1.0)
    v = ls.VoigtProfile(num.arange(-10*fwhm, 10*fwhm+resolution, resolution), (0.6, 0.6))
    # convolute data with profile
    res_g = Convolve.convolve(y, g(), Convolve.SAME)
    res_l = Convolve.convolve(y, l(), Convolve.SAME)
    res_v = Convolve.convolve(y, v(), Convolve.SAME)
    for i in zip(x, y, res_g, res_l, res_v):
        print "%12.6f %12.6f %12.6f %12.6f %12.6f" % i
示例#3
0
	print("Image is 160 Microns")
	kern = '../../Convolve_Regrid/Kernels/Kernel_LoRes_PACS_70_to_PACS_160.fits'	
	im = '../../Sky_Remove/Median_Removed/160um_medianRemoved.fits'
	conv_sname = '../../Convolve_Regrid/Convolutions/70Bkgd_ext_20_tstep_3000_to_160umRes.fits'
	regrid_sname = '../../Convolve_Regrid/Convolutions/70Bkgd_ext_20_tstep_3000_to_160umRes_Resampled.fits'
	sigma  = np.loadtxt('../../Sky_Remove/Sigma.txt')[3]
	sname = '160um/160um_70modeled'
	
	# Arbitrary stuff for plotting
	vmin=5;vmax=50 #bkgd
	vmin_=10; vmax_=50 #img
	vmin_sub = 0; vmax_sub= 10 # subtraction
	xdim = [110,150]; ydim = [100,135]

if convolve_regrid: # Note that this gave me a lot of problems on windows but not on linux
	Convolve.master_convolve(kern,bkgd,conv_sname)
	Regrid.resample(conv_sname,im,regrid_sname)	

bkgd = fits.open(regrid_sname)[0].data
bkgdhdr = fits.open(regrid_sname)[0].header
img = fits.open(im)[0].data
hdr = fits.open(im)[0].header
w = WCS(hdr)
# Region that is commonly over subtracted
# Used to just adjust median slope to a value
# That makes this region have a median of 0. 
ra = 16.014763979322012 
dec = -72.02709660389223 
c = SkyCoord(ra=ra*u.degree,dec=dec*u.degree,frame='icrs')
print("Null Region Center Coordinate: "+str(c.ra.hms)+str(c.dec))
SubRadius = 3.; # ArcSeconds
示例#4
0
# Kernels to Convolve with
k24 = '../Convolve_Regrid/Kernels/Kernel_LoRes_MIPS_24_to_PACS_160.fits'
k70 = '../Convolve_Regrid/Kernels/Kernel_LoRes_PACS_70_to_PACS_160.fits'
k100 = '../Convolve_Regrid/Kernels/Kernel_LoRes_PACS_100_to_PACS_160.fits'
Kernels = [k24, k70, k100]

# File Save Names
s24 = '../Final_Files/24/24_SNR_'
s70 = '../Final_Files/70/70_SNR_'
s100 = '../Final_Files/100/100_SNR_'
s160 = '../Final_Files/160/160_SNR_'
Save = [s24, s70, s100, s160]

for i in range(3):
    #Convolve
    Convolve.master_convolve(Kernels[i], Files[i], Save[i] + 'Convolve.fits')
    #Regrid
    Regrid.resample(Save[i] + 'Convolve.fits', f160,
                    Save[i] + 'Convolve_Regrid.fits')
    #Prune
    prune.SavePrune(Save[i] + 'Convolve_Regrid.fits',
                    Save[i] + 'Convolve_Regrid_Prune.fits')
prune.SavePrune(f160, Save[3] + 'Prune.fits')

if plot_ConvolveRegrid:
    f, axes = plt.subplots(1, 4, sharey=False)

    for i in range(4):
        if i == 3:
            file = f160
        else:
 def convolve(self, other):
     result = NDistanceFunction(self.dim)
     result.offsets = [so + oo for so, oo in zip(self.offsets, other.offsets)]
     result.vector = Convolve.convolve(self.vector, other.vector)
     result.resetMaxDistance()
     return result