Contents:
Python script for various photometry tasks. See especially aperphot(), for basic aperture photometry. If you need something fancier, try PyRAF, DAOPHOT, etc.
Do aperture photometry on a specified file.
INPUTS: |
|
---|---|
OUTPUTS: | phot object. |
EXAMPLE: | import astropy.io.fits
from astropy import wcs
import numpy as np
from phot import aperphot
img='62_z_CDFs_goods_stamp_img.fits' #path to the image
RA = 52.9898239
DEC = -27.7143114
hdulist = astropy.io.fits.open(img)
w = wcs.WCS(hdulist['PRIMARY'].header)
world = np.array([[RA, DEC]])
pix = w.wcs_world2pix(world,1) # Pixel coordinates of (RA, DEC)
print "Pixel Coordinates: ", pix[0,0], pix[0,1]
#call aperture function
observation=aperphot(img, timekey=None, pos=[pix[0,0], pix[0,1]], dap=[4,8,12], resamp=2, retfull=False)
# Print outputs
print "Aperture flux:", observation.phot
print "Background: ", observation.bg
|
REQUIREMENTS: | scipy.interpolate, pyfits, numpy... |
Compute the centroid of an image with a specified binary mask projected upon it.
Convert degrees, minutes, seconds to decimal degrees, and back.
EXAMPLES:
dms(‘150:15:32.8’) dms([7, 49]) dms(18.235097)
Also works for negative values.
SEE ALSO: hms
Return the chi-squared error on a 2D gaussian fit. See gauss2d for more details on the input parameters.
z is the array of data to be fit ez is an optional array of one-sigma errors to the data in z.
Estimate the background value of a masked image via histogram fitting.
mask – numpy array. logical mask, False/0 in regions to ignore bins – sequence. edges of bins to pass to HIST plotalot – bool. Plot the histogram and fit. rout – 2-tuple of (nsigma, niter) for analysis.removeoutliers.
Set to (Inf, 0) to not cut any outliers.
badval – value returned when things go wrong.
Compute a gaussian distribution at the points x, y.
p is a three- or four-component array, list, or tuple:
z = [p4 +] p0/(p1*sqrt(4pi)) * exp(-r**2 / (2*p1**2))
where r = sqrt((x-p2)**2 + (y-p3)**2)
p[0] – Volume under the gaussian p[1] – one-sigma dispersion p[2] – X- offset of center p[3] – Y- offset of center p[4] – optional constant, vertical offset
x & y must be equal-sized arrays from numpy.meshgrid
NOTE: FWHM = 2*sqrt(2*ln(2)) * p1 ~ 2.3548*p1
SEE ALSO: egauss2d, numpy.meshgrid
Compute a hess diagram (surface-density CMD) on photometry data.
Convert hours, minutes, seconds to decimal degrees, and back.
EXAMPLES:
hms(‘15:15:32.8’) hms([7, 49]) hms(18.235097)
Also works for negative values.
SEE ALSO: dms
Use the Zaritsky & Harris (ZH) map to get A_V extinction in the LMC.
If their map returns null, interpolate from the surroundings.
Note that these calculations are definitely _not_ optimized.
Generate a binary (logical) mask with given shape and location.
x = x-coodinate system (made with meshgrid) y = y-coodinate system (made with meshgrid)
Conduct simple PRF model-fitting at a specified grid of positions
INPUTS: | psf – model PSF (or PRF), supersampled by factor ‘scale’ frame – science frame to which psf will be fit. best if it’s odd-sized |
---|---|
OPTIONS: | loc – (x,y) integers, star location in data frame (e.g., data[x,y]) w – [array] weights of pixels in data frame, (typ. 1/sigma^2) scale – supersampling level of PSF
xoffs – [int array] subpixel x offsets to test. yoffs – [int array] subpixel y offsets to test. |
RETURNS: | modelpsf, data, chisq, background, fluxscale, xoffset, yoffset, chisq[ii,jj],background[ii,jj], fluxscale[ii,jj] |
EXAMPLE: | import k2
import phot
import pylab as py
fn = 'kplr060018142-2014044044430_lpd-targ.fits'
f = pyfits.open('kplr060018142-2014044044430_lpd-targ.fits')
image = f[1].data['flux'][0]
prf = k2.loadPRF(fn)
out = phot.psffit(prf, image, (33, 23), scale=50, dframe=7, verbose=True)
py.figure()
py.subplot(132)
py.imshow(out[0])
py.title('Best-fit Model PRF')
py.colorbar()
py.subplot(131)
py.imshow(out[1])
py.title('Observed Data')
py.clim([out[0].min(), out[0].max()])
py.colorbar()
py.subplot(133)
py.imshow(out[1] - out[0])
py.title('Data - Model')
py.colorbar()
|
USAGE: |
---|
fit = optimize.fmin(psffiterr, [0,0], args=(psf, frame,weights,100,13, loc),xtol=0.5,ftol=1, full_output=True)
modelout = psffit(psf, frame, loc, weights, scale=100, dframe=13, xoffs=[fit[0][0]], yoffs=[fit[0][1]])
Read in an OGLE-II photometry map file and output the data.
If you like, use HMS and DMS to convert the RA and DEC values returned.
Calculate sensitiviy for various exposure times.
texp – 1D array of times mag – target magnitude npix – number of pixels read out
lin – linearity limit of the detector (ADU) tdead – detector dead time (reset + readout) between integrations rn – read noise, in ADU csky – sky background per second, in ADU zp – photometric zero point (magnitude for 1 ADU/sec) z – airmass h – observatory altitude, in meters d – telescope mirror diameter, in meters
TBD: Flat-field noise!
For now, I impose an artificial floor to the number of pixels needed – it won’t spread it out over less than 8.
Calculate SNR of a photometric CCD observation of given parameters.
The default keyword parameters are for the CTIO Blanco MOSAIC imager, operating in V band.
Load a subsection of a list of 2D FITS files.
NOTE: center can also be a list of tuples (1 per file), but dim cannot.
Load a subsection of a list of 2D FITS files.
center – (2-tuple) (x0,y0) center of region to load.
dim – (2-tuple) (dx,dy) sizes of region to load.
NOTE: center can also be a list of tuples (1 per file), but dim cannot.