-
Notifications
You must be signed in to change notification settings - Fork 34
ImageAnalysis Sketches
Michael Mommert edited this page Aug 28, 2017
·
5 revisions
Python implementation of the cometary enhancement filters by N. Samarasinha.
import matplotlib.pyplot as plt
from astropy.io import fits
from sbpy.image import CometaryEnhancement, PSFSubtraction, centroid
im = fits.open('comet.fits')
# cometary enhancement techniques typically need subpixel centering
gyx = 101, 99 # y, x guess
cyx = centroid(im[0].data, gyx, method='comet') # use the special comet centering method
ayx = centroid(im[0].data, gyz, method='psf') # use a simple weighted centering model for asteroids
# and other point sources
# One class to join them all?
enhance = CometaryEnhancement(im[0], cyx) # MM: added [0] to im, might help to avoid confusion in multi-ext fits
fig, axes = plt.subplots(2, 2)
axes[0, 0].imshow(enhance.azavg_norm()) # divide by azimuthal average, default parameters
axes[0, 1].imshow(enhance.azavg_norm(nth=360)) # use 1 deg steps for x, y to r, th conversion
axes[1, 0].imshow(enhance.rho_norm()) # 1/rho normalization
axes[1, 1].imshow(enhance.rvsf(a=1, b=1, n=0.1)) # radially variable spatial filter
# allow single line enhancements?
axes[1, 0].imshow(CometaryEnhancement.rho_norm(im=im[0].data, yx=cyx))
Wrappers for PSF subtraction techniques using the photutils affiliated package.
# create a model PSF from all point sources in the field
psfmodel = PSFSubtraction.create_psf(im[0])
# create a model PSF from an activity object
psfmodel = PSFSubtraction.create_psf(im.value, size=20) # with im_value from activity sketches
# subtract psfmodel from source
sub = psfmodel.subtract(im[0], ayx, scaling='peak') # scale psfmodel such that it fits the peak of the target
# create a radial average histogram
from utils import radavg
plt.bar(radavg(sub, ayx))