Spitzer/MIPS 24 micron Analysis Routines

Contents:

A set of routines to assist reduction of Spitzer MIPS (24 micron) data.

To prepare a run (set AORs, frame numbers, etc.) edit initobs()

To generate empirical flat-fields, see mipsflat()

To extract photometry (aperture or PSF-fitting), see mipsphot()

To better array photometry, remove first-frames, etc., see binphot()

REQUIREMENTS:

pylab, numpy, os, NIRSPEC Data Analysis, pyfits,:doc:phot,:doc:tools, and maybe some others

HISTORY:

2009-08-24 15:55 IJC: Created

2011-06-15 09:37 IJMC: Better Sphinx documentation.

class spitzer.baseObject[source]

Empty object container.

spitzer.binphot(outputs, dumpframes=None, sigma=3, tbins=None, nbins=None, target=None, binfactor=None, returnstats=False)[source]

Bin down MIPSPHOT time-series photometry.

INPUT:

outputs – EITHER:

(list) outputs from MIPSPHOT, one element for

each dither position (a list of (dict) items)

OR:

(str) filename to a pickle containing such a list.

OPTIONAL INPUT:

dumpframes – (sequence) TBD – frames to throw away.

sigma – (float) value for sigma-clipping

tbins – (sequence) boundaries of time bins over which to

average the data. If tbins==’file’, taken from datafile; otherwise specified here, or overridden via ‘nbins’

nbins – (int) instead of using ‘tbins’ flag, automatically

subdivide the binned sequence into ‘nbins’ equally-spaced bins. Empty bins will be returned as ‘nan’

target – for datasets with a second calibrator star

(e.g. hd9712), specify that target – otherwise only main planetary data is used.

binfactor – see ANALYSIS.ERRXY

returnstats – print numbers about # of observations, and # of deleted frames

EXAMPLE:
import spitzer
outputs = []
for ii in range(14):
    outputs.append(spitzer.mipsphot(dataset='upsand1', dithernum=ii))
out2 = spitzer.binphot(outputs)
NOTES:

This calculates several different types of values, based partly

on values extracted from FITS headers and partly on calculations. If “out2” is the output object, “out2.keys” will contain a list of all the header keywords used. Each key values will be binned down by the appropriate factor, and the standard error on that measurement contained in a related keyword. For example, out2.AD24TMPA and out2.eAD24TMPA.

Other pertinent values calculated and returned are out2.flux.

out2.fitflux should NOT be used, since it does not properly

normalize for first-frame effects or dither position sensitivity variations. Similarly for out3.quadbg.

SEE ALSO:

mipsphot(), analysis.errxy()

spitzer.dither14(cparams)[source]

Returns: cparams[0:14] as an arra of shape (14,1)

spitzer.feps_flux_loss(offset, version='S18.18.0', order='SL1', path='~/proj/spitzer/data/irs/jeroen_20131121/', verbose=False)[source]

Compute flux throughput of the IRS instrument using a lookup table.

INPUTS:
offset: scalar

offset of target point source from the center of slit [units???]

version: string

order: string

path: string

Directory in which the lookup table is located. Alternatively, this can be the cal file in question, loaded by idlsave.read(‘IRSX_%s_%s_flcf.sav’)

EXAMPLE:
import tools
offset_sl1 = 0.0
wave, fraction = spitzer.feps_flux_loss(0, version="S18.18.0",order='SL1')
class spitzer.genericObject(**kw)[source]

Object generated with whatever attributes are passed to it.

Tested for object types of:
str list dict array <— _SMALL_ arrays of small values only... limited utility!
spitzer.initobs(obsname='upsand1', dce='all', expid='all', verbose=False)[source]

Initialize variables for SPITZER data analysis.

OPTIONAL INPUT:
obsname: (str) Current options are ‘upsand1’, ‘upsand2’,

‘hd209458_0’, ‘hd209458’, ‘hd189733_1’, ‘hd189733_2’

dce: (list) Which DCEs to load. Defaults to 0-35 inclusive.

OUTPUT:
a DICT containing the following values, in order:

datalist – list of BCD data file names to analyse _bcd – BCD (processed data) directory

spitzer.mipsaperphot(fn, dap=(11, 13, 41), mask=None, fix=False, verbose=False, center=None)[source]

Perform aperture photometry on a MIPS file or list of MIPS files.

INPUT:

fn – (str) filename, or (list) list of filenames

OPTIONAL INPUT:

dap – (3-sequence) pixel diameters: target aperture, inner sky, outer sky

mask – (array) mask to pass to phot.aperphot. Otherwise, generate one from dap.

NOTES:
** if no center location is passed, target positions will be taken

from Table 8.7 of the S.O.M. based on the MIPS filename.

** this works if you pass in an array or a filename, but

passing a filename enables the function to do a more complete job (grabbing object name,RA/DEC, HJD fields, etc.)

spitzer.mipsfile(*args)[source]

Generate a MIPS data file name according to the standard in the MIPS Data Handbook v3.2:

SPITZER_M+chnlnum_aorkey_expid_dcenum_version_type.suffix
INPUT:

separate values, or a list, or lists of lists, representing the quantities:

chnlnum, aor, expid, dce, ver, type, suffix

ALTERNATIVELY, input can be a (str) filename

OUTPUT:
either:
  1. list of strings or
  2. string corresponding to all combinations of the input paramters.

ALTERNATIVELY, output is a tuple of type (ch,aor,exp,dce,ver,type,suff)

EXAMPLES:
inp = (1, 26598144, 7, range(3), 1, ['bunc', 'bcd'], 'fits')
spitzer.mipsfile(inp)
# OR
spitzer.mipsfile(1, 26598144, 7, range(3), 1, ['bunc', 'bcd'], 'fits')
# OR
spitzer.mipsfile('SPITZER_M1_26598144_0007_0000_1_bunc.fits')
spitzer.mipsflat(files, norm=True, nmax=99999, retall=False)[source]

Make a flat field from a set of MIPS filenames. Use a stack median. In creating the flat only use the half-side of the detector that the target star is not falling on.

If nmax is too large, you may run out of memory. Set it lower!

INPUTS:

norm=True – whether to normalize the final flat by the chip-wide median.

nmax – the number of files to use, per

EXAMPLE:
init = spitzer.initobs('upsand2')
files = [init.path+f for f in init.files[0]]
flat = spitzer.mipsflat(files)
spitzer.mipsphot(dataset, dithernum=0, dce='all', expid='all', aper=[13, 23, 41], sigma=5, verbose=False, plotalot=False, psffile='/Users/ianc/proj/spitzer/psf/psfx100_6200K_sm.fits', pmask='/Users/ianc/proj/spitzer/psf/mips24_pmask.fits', scale=100.0, fileind='all', dflatfield=None, sflatfield=None, offset=[0, 0])[source]

Analyze a Spitzer/MIPS 24um photometric dataset.

INPUTS:

dataset – (str) ‘upsand1’, ‘upsand2’, ‘upsand2cal’, ‘hd209458_0’, ‘hd209458’, ‘hd189733_1’, ‘hd189733_2’

dce & expid – if ‘all’, use all dce & expid values valid for the specified dithernum.

aper – (tuple) [targ, sky_inner, sky_outer]

aperture diameters for photometry, in pixels. For PSF-fitting, this must be _odd_.

sigma – sigma-clipping value when computing means

psffile – model PSF to use for PSF-fitting photometry (from TinyTim).

pmask – filename for MIPS bad pixel mask

scale – scaling of model PSF relative to physical MIPS detector.

fileind – either set to ‘all’, or a sequence of which files to extract

dflatfield – filename of a FITS flat-field by which to divide all frames before photometry.

sflatfield – filename of a FITS flat-field by which to subtract all frames before photometry.

dithernum – should be any value from 0 to 13, inclusive.

offset – pixel offset from nominal MIPS 14-dither position

EXAMPLE:
import spitzer
outputs = []
for ii in range(14):
    outputs.append(spitzer.mipsphot(dataset='upsand1', dithernum=ii))

# OR use different model PSFs for each position:
psfs = ['/Users/ianc/proj/spitzer/psf/psfx100_6200K_%s_sm.fits' %s \
            for s in ['39.0x87.6','39.0x38.1','89.5x87.6','89.5x38.1']]

dnum = [[0,2,4,6],[1,3,5],[7,9,11,13],[8,10,12]]
outputs = []
for ii in range(4):
    for jj in dnum[ii]:
        outputs.append(spitzer.mipsphot(dataset='upsand1',dithernum=jj,psffile=psfs[ii]))
spitzer.mipspos(dcenum, expid, retfnum=False)[source]

Return the approximate x,y location of a star on the MIPS detector.

INPUT:

expid – (int) exposure ID number.

dcenum – (int or list of ints) DCE, 0-35 inclusive.

OPTIONAL INPUT:
retfnum – (bool). Whether to return the frame position number

(from 0-13), as listed in Table 8.7 of the Spitzer Observer’s Manual.

OUTPUT:

(xpos, ypos) – tuple of floats, if retfnum==False

( (xpos, ypos), fnum) – tuple of (tuple, floats)

EXAMPLE:
mipspos(0,0) 
mipspos(35,1, retfnum=True)
[mipspos(range(36), expid) for expid in [0,1]]
NOTE:

Based on the prescription of even DCE on the LHS, odd DCE on the RHS, and per Table 8.7 in the Spitzer Observer’s Manual.

spitzer.model_irs_eclipse(params, nobs, nchan, rampfunc, npar_ramp, tparams, time, phase, normalize=False, cal_file=None)[source]

Generate a full spectrophotometric model of an IRS-observed eclipse.

INPUTS:
offset: 1D NumPy array

offset of target point source from the center of slit [units???]

nobs: int

number of obesrvations

nchan: int

number of wavelength channels

rampfunc: function

Ramp function: e.g., phasecurves.ramp5n(), et al.

npar_ramp: int

Number of parameters required for rampfunc.

tparams: sequence

Transiting planet parameters, to be passed to transit.modeleclipse_simple()

time: 1D NumPy array

Time of observations, to be passed to transit.modeleclipse_simple()

phase: 1D NumPy array

Orbital phase of observations, to be passed to ‘rampfunc.’

normalize: bool

Whether to normalize result by stack median.

cal_file: None or IDLSave object

pass calibration file in directly, to model_irs_slitloss()

EXAMPLE:
test = model_irs_eclipse(params, nobs, nchan, rampfunc, npar_ramp, transit_params, this_mbjd, phase, )
spitzer.model_irs_slitloss(offsets, nobs, nchan, normalize=False, version='S18.18.0', order='SL1', path='~/proj/spitzer/data/irs/jeroen_20131121/', verbose=False, cal_file=None)[source]

Compute flux throughput of the IRS instrument using a lookup table.

INPUTS:
offset: 1D NumPy array

offset of target point source from the center of slit [units???]

nobs: int

number of obesrvations

nchan: int

number of wavelength channels

normalize: bool

Whether to divide result by stack median

cal_file: None, 2-tuple, or IDLSave object

pass calibration file in directly (or tuple [offset, flcf]), to save time in a highly repetitive analysis.

EXAMPLE:
import spitzer
slitloss = spitzer.model_irs_slitloss(y_offset_pu_a, nobs, nchan, False)
spitzer.pxsize(fn, key1='PXSCAL1', key2='PXSCAL2')[source]

Compute size of pixels (in steradians) for a given FITS image.

INPUT:

fn – str. filename

OPTIONAL INPUT:

key1 – str. FITS Header Key of first pixel scale value, in arcsec/pix

key2 – str. FITS Header Key of second pixel scale value, in arcsec/pix

OUTPUT:

a – float. area of a pixel, in steradians.

Previous topic

Compute azimuthal statistics

Next topic

“Kernel density estimate” statistics

This Page