%matplotlib inline
import glob
import time
import os
import numpy as np
import matplotlib.pyplot as plt
import astropy.io.fits as pyfits
import drizzlepac
import grizli
from grizli import utils, multifit
print(grizli.__version__)
The following task in the stsci.skypac package can be run with TEAL: skymatch The following tasks in the drizzlepac package can be run with TEAL: astrodrizzle config_testbed imagefindpars mapreg photeq pixreplace pixtopix pixtosky refimagefindpars resetbits runastrodriz skytopix tweakback tweakreg updatenpol 1.2.dev124
NB: The example below uses the "ERS" exposures pre-processed as described in the WFC3IR_Reduction
notebook.
os.getcwd()
root = 'j033216m2743'
os.chdir('{0}/Extractions'.format(root))
grp = multifit.GroupFLT(grism_files=glob.glob('*GrismFLT.fits'),
catalog='{0}-ir.cat.fits'.format(root),
cpu_count=-1, sci_extn=1, pad=256)
Load ib6o23rsq.01.GrismFLT.fits! Load ib6o21qmq.01.GrismFLT.fits! Load ib6o23ruq.01.GrismFLT.fits! Load ib6o21r6q.01.GrismFLT.fits! Load ib6o21qoq.01.GrismFLT.fits! Load ib6o23ryq.01.GrismFLT.fits! Load ib6o21r8q.01.GrismFLT.fits! Load ib6o23s0q.01.GrismFLT.fits! Files loaded - 2.68 sec.
Now provide two ways of saving the extracted 2D spectra of a given object: "beams" cutouts from the FLT files and drizzled combinations of them, combined for the available grisms separately and for combinations of the available PAs.
# Fitting templates
# First is set with combined emission line complexes for the redshift fit
# (don't allow infinite freedom) of the line ratios / fluxes
templ0 = grizli.utils.load_templates(fwhm=1200, line_complexes=True, stars=False,
full_line_list=None, continuum_list=None,
fsps_templates=True)
# Second set has individual line templates for fitting the line fluxes
templ1 = grizli.utils.load_templates(fwhm=1200, line_complexes=False, stars=False,
full_line_list=None, continuum_list=None,
fsps_templates=True)
# Show the template names / dictionary keys
fmt = '{0:<36s} {1:<36s}'
print(fmt.format('templ0', 'templ1'))
print(fmt.format('------', '------'))
for i in range(len(templ1)):
if i > len(templ0)-1:
print(fmt.format('', list(templ1.keys())[i]))
else:
print(fmt.format(list(templ0.keys())[i], list(templ1.keys())[i]))
# Parameters for drizzled line maps
pline = {'kernel': 'point', 'pixfrac': 0.2, 'pixscale': 0.1, 'size': 8, 'wcs': None}
templ0 templ1 ------ ------ fsps/fsps_QSF_12_v3_nolines_001.dat fsps/fsps_QSF_12_v3_nolines_001.dat fsps/fsps_QSF_12_v3_nolines_002.dat fsps/fsps_QSF_12_v3_nolines_002.dat fsps/fsps_QSF_12_v3_nolines_003.dat fsps/fsps_QSF_12_v3_nolines_003.dat fsps/fsps_QSF_12_v3_nolines_004.dat fsps/fsps_QSF_12_v3_nolines_004.dat fsps/fsps_QSF_12_v3_nolines_005.dat fsps/fsps_QSF_12_v3_nolines_005.dat fsps/fsps_QSF_12_v3_nolines_006.dat fsps/fsps_QSF_12_v3_nolines_006.dat fsps/fsps_QSF_12_v3_nolines_007.dat fsps/fsps_QSF_12_v3_nolines_007.dat fsps/fsps_QSF_12_v3_nolines_008.dat fsps/fsps_QSF_12_v3_nolines_008.dat fsps/fsps_QSF_12_v3_nolines_009.dat fsps/fsps_QSF_12_v3_nolines_009.dat fsps/fsps_QSF_12_v3_nolines_010.dat fsps/fsps_QSF_12_v3_nolines_010.dat fsps/fsps_QSF_12_v3_nolines_011.dat fsps/fsps_QSF_12_v3_nolines_011.dat fsps/fsps_QSF_12_v3_nolines_012.dat fsps/fsps_QSF_12_v3_nolines_012.dat line Ha+NII+SII+SIII+He+PaB line PaB line OIII+Hb+Hg+Hd line HeI-1083 line OII+Ne line SIII line Gal-UV-lines line OII-7325 line ArIII-7138 line SII line Ha line OI-6302 line HeI-5877 line OIII line Hb line OIII-4363 line Hg line Hd line H7 line H8 line H9 line H10 line NeIII-3867 line OII line NeVI-3426 line NeV-3346 line MgII line CIV-1549 line CIII-1906 line CIII-1908 line OIII-1663 line HeII-1640 line NIII-1750 line NIV-1487 line NV-1240 line Lya
### Find IDs of specific objects to extract (2 galaxies and a star)
import astropy.units as u
tab = utils.GTable()
tab['ra'] = [53.0657456, 53.0624459, 53.077048]
tab['dec'] = [-27.720518, -27.707018, -27.705928]
idx, dr = grp.catalog.match_to_catalog_sky(tab)
source_ids = grp.catalog['NUMBER'][idx]
tab['id'] = source_ids
tab['dr'] = dr.to(u.mas)
tab['dr'].format='.1f'
id = source_ids[0]
# Pull out the 2D cutouts
beams = grp.get_beams(id, size=80)
mb = multifit.MultiBeam(beams, fcontam=0.2, group_name=root, psf=False)
# Save a FITS file with the 2D cutouts (beams) from the individual exposures
mb.write_master_fits()
# Fit polynomial model for initial continuum subtraction
wave = np.linspace(2000,2.5e4,100)
poly_templates = grizli.utils.polynomial_templates(wave, order=7)
pfit = mb.template_at_z(z=0, templates=poly_templates, fit_background=True,
fitter='lstsq', get_uncertainties=2)
# Drizzle grisms / PAs and make a figure
hdu, fig = mb.drizzle_grisms_and_PAs(fcontam=0.2, flambda=False, kernel='point',
size=32, zfit=pfit, diff=True)
# Save drizzle figure FITS file
fig.savefig('{0}_{1:05d}.stack.png'.format(root, id))
hdu.writeto('{0}_{1:05d}.stack.fits'.format(root, id), clobber=True)
j033216m2743_00151.beams.fits
# High-level wrapper script for doing everything (redshift fits, line fluxes, drizzled line
# maps). More explanation of the details of individual steps TBD.
#
# Needs to be able to find {root}_{id:05d}.beams.fits and {root}_{id:05d}.stack.fits
# generated above
from grizli import fitting
out = fitting.run_all_parallel(id, get_output_data=True, protect=False,
fit_beams=True, fit_only_beams=True,
argsfile='fit_args.npy')
Run id=151 with fit_args.npy j033216m2743_00151.full.fits
out
(<grizli.multifit.MultiBeam at 0x7fdbc0cb0d50>, None, <GTable length=400> zgrid chi2 ... risk float64 float64 ... float64 -------------------- ----------------- ... ------------------ 0.050000000000000044 9147.809115664842 ... 0.9441994858500709 0.05420841121120912 9129.64178812055 ... 0.9439364426179707 0.05843368977948726 9106.165683200523 ... 0.9436705068808653 0.06267590330938178 9065.020106475962 ... 0.9434016353764327 0.06693511967639965 9007.226245404385 ... 0.9431297840191433 0.07121140702809359 8970.568653051356 ... 0.9428549078813286 0.07550483378515271 9069.979451647347 ... 0.9425769611737413 0.07981546864249633 9147.342937756444 ... 0.942295897225591 0.0841433805703744 9152.9198184533 ... 0.9420116684640422 0.08848863881546998 9152.705126518784 ... 0.9417242263931509 ... ... ... ... 3.2409621436330305 9221.333299577711 ... 0.9300211437993922 3.257959965186914 9219.75181491373 ... 0.931474421402819 3.275025914191078 9216.046522634137 ... 0.9328895230003549 3.292160263701069 9210.537890949798 ... 0.934267666846817 3.3093632878668453 9205.012325367581 ... 0.9356100260315047 3.3266352619371604 9200.314590950215 ... 0.9369177303424789 3.343976462263969 9195.09651621712 ... 0.93819186804896 3.3613871663068444 9189.656101230987 ... 0.9394334876054349 3.3788676526374237 9184.028998713757 ... 0.9406435992809227 3.396418200943862 9179.586484917498 ... 0.9418231767167157, OrderedDict([('cont1d', <grizli.utils.SpectrumTemplate at 0x7fdc2312bb10>), ('line1d', <grizli.utils.SpectrumTemplate at 0x7fdc232ea9d0>), ('cfit', OrderedDict([('bg 000', (-0.0018567429816964648, 0.0012202118416740737)), ('bg 001', (-0.00467965958705463, 0.0012905825254275025)), ('bg 002', (-0.002806838872948164, 0.0012542467018404955)), ('bg 003', (-0.0009508463481857892, 0.0012729167040620715)), ('bg 004', (-0.0037981185049030886, 0.0010806211850964774)), ('bg 005', (-0.003992946984094812, 0.0011041359721475116)), ('bg 006', (-0.0035517478496280286, 0.0012515253065791536)), ('bg 007', (-1.703112254976721e-06, 0.001160400591093489)), ('fsps/fsps_QSF_12_v3_nolines_001.dat', (4.775217269547062e-16, 1.273429387877875e-15)), ('fsps/fsps_QSF_12_v3_nolines_002.dat', (0.0, 0.0)), ('fsps/fsps_QSF_12_v3_nolines_003.dat', (0.0, 0.0)), ('fsps/fsps_QSF_12_v3_nolines_004.dat', (0.0, 0.0)), ('fsps/fsps_QSF_12_v3_nolines_005.dat', (0.0, 0.0)), ('fsps/fsps_QSF_12_v3_nolines_006.dat', (0.0, 0.0)), ('fsps/fsps_QSF_12_v3_nolines_007.dat', (9.18940616516566e-16, 7.644748409332985e-16)), ('fsps/fsps_QSF_12_v3_nolines_008.dat', (1.849211944987381e-16, 2.310838109186711e-15)), ('fsps/fsps_QSF_12_v3_nolines_009.dat', (0.0, 0.0)), ('fsps/fsps_QSF_12_v3_nolines_010.dat', (0.0, 0.0)), ('fsps/fsps_QSF_12_v3_nolines_011.dat', (0.0, 0.0)), ('fsps/fsps_QSF_12_v3_nolines_012.dat', (0.0, 0.0)), ('alf_SSP.dat', (0.0, 0.0)), ('line PaB', (0.0, 0.0)), ('line HeI-1083', (0.0, 0.0)), ('line SIII', (0.0, 0.0)), ('line OII-7325', (0.0, 0.0)), ('line ArIII-7138', (0.0, 0.0)), ('line SII', (0.0, 0.0)), ('line Ha', (0.0, 0.0)), ('line OI-6302', (-1e-16, 3.955037980321617e-15)), ('line HeI-5877', (8.85687727537122e-18, 6.349506583805425e-18)), ('line OIII', (1.37476281838929e-16, 9.211848542012936e-18)), ('line Hb', (4.043658196052226e-17, 7.386733596666193e-18)), ('line OIII-4363', (-3.2161422259281906e-18, 1.2857304456026003e-17)), ('line Hg', (1.6716446526861707e-17, 1.3279368243180771e-17)), ('line Hd', (4.07758617162416e-18, 6.758993452828337e-18)), ('line H7', (6.133062985895207e-19, 7.556330419903564e-18)), ('line H8', (-3.332586167632501e-18, 8.962823617738327e-18)), ('line H9', (-6.129144619763036e-18, 8.780541077015039e-18)), ('line H10', (4.2263330303658475e-18, 8.904466534067189e-18)), ('line NeIII-3867', (1.000175633377396e-17, 9.351926171073645e-18)), ('line OII', (6.805071155082673e-17, 9.311446617128099e-18)), ('line NeVI-3426', (1.3744567540519463e-17, 1.2706672596586605e-17)), ('line NeV-3346', (-1.6067688591453754e-17, 1.3076544688413486e-17)), ('line MgII', (-1e-16, 2.4060511778318856e-12)), ('line CIV-1549', (0.0, 0.0)), ('line CIII-1906', (0.0, 0.0)), ('line CIII-1908', (0.0, 0.0)), ('line OIII-1663', (0.0, 0.0)), ('line HeII-1640', (0.0, 0.0)), ('line NIII-1750', (0.0, 0.0)), ('line NIV-1487', (0.0, 0.0)), ('line NV-1240', (0.0, 0.0)), ('line Lya', (0.0, 0.0))])), ('coeffs', array([-1.85674298e-03, -4.67965959e-03, -2.80683887e-03, -9.50846348e-04, -3.79811850e-03, -3.99294698e-03, -3.55174785e-03, -1.70311225e-06, 4.77521727e-16, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 9.18940617e-16, 1.84921194e-16, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, -1.00000000e-16, 8.85687728e-18, 1.37476282e-16, 4.04365820e-17, -3.21614223e-18, 1.67164465e-17, 4.07758617e-18, 6.13306299e-19, -3.33258617e-18, -6.12914462e-18, 4.22633303e-18, 1.00017563e-17, 6.80507116e-17, 1.37445675e-17, -1.60676886e-17, -1.00000000e-16, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00, 0.00000000e+00])), ('chi2', 8842.986398232446), ('covar', array([[1.48891694e-06, 3.87553712e-07, 4.10113535e-07, ..., 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [3.87553712e-07, 1.66560325e-06, 4.04790276e-07, ..., 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [4.10113535e-07, 4.04790276e-07, 1.57313479e-06, ..., 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], ..., [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ..., 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ..., 0.00000000e+00, 0.00000000e+00, 0.00000000e+00], [0.00000000e+00, 0.00000000e+00, 0.00000000e+00, ..., 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]])), ('z', 1.7417021486274922), ('templates', OrderedDict([('fsps/fsps_QSF_12_v3_nolines_001.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014ddad0>), ('fsps/fsps_QSF_12_v3_nolines_002.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf1d0>), ('fsps/fsps_QSF_12_v3_nolines_003.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf4d0>), ('fsps/fsps_QSF_12_v3_nolines_004.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bfad0>), ('fsps/fsps_QSF_12_v3_nolines_005.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf8d0>), ('fsps/fsps_QSF_12_v3_nolines_006.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bfcd0>), ('fsps/fsps_QSF_12_v3_nolines_007.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf210>), ('fsps/fsps_QSF_12_v3_nolines_008.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf6d0>), ('fsps/fsps_QSF_12_v3_nolines_009.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf490>), ('fsps/fsps_QSF_12_v3_nolines_010.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf110>), ('fsps/fsps_QSF_12_v3_nolines_011.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf610>), ('fsps/fsps_QSF_12_v3_nolines_012.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf410>), ('alf_SSP.dat', <grizli.utils.SpectrumTemplate at 0x7fdc014bf190>), ('line PaB', <grizli.utils.SpectrumTemplate at 0x7fdc014bf9d0>), ('line HeI-1083', <grizli.utils.SpectrumTemplate at 0x7fdc014bfdd0>), ('line SIII', <grizli.utils.SpectrumTemplate at 0x7fdc014bf5d0>), ('line OII-7325', <grizli.utils.SpectrumTemplate at 0x7fdc014bf2d0>), ('line ArIII-7138', <grizli.utils.SpectrumTemplate at 0x7fdc014bf650>), ('line SII', <grizli.utils.SpectrumTemplate at 0x7fdb8081d810>), ('line Ha', <grizli.utils.SpectrumTemplate at 0x7fdb8081d890>), ('line OI-6302', <grizli.utils.SpectrumTemplate at 0x7fdb8081dcd0>), ('line HeI-5877', <grizli.utils.SpectrumTemplate at 0x7fdb8081d410>), ('line OIII', <grizli.utils.SpectrumTemplate at 0x7fdb8081d190>), ('line Hb', <grizli.utils.SpectrumTemplate at 0x7fdb8081d850>), ('line OIII-4363', <grizli.utils.SpectrumTemplate at 0x7fdb8081d390>), ('line Hg', <grizli.utils.SpectrumTemplate at 0x7fdb8081de90>), ('line Hd', <grizli.utils.SpectrumTemplate at 0x7fdb8081d590>), ('line H7', <grizli.utils.SpectrumTemplate at 0x7fdb8081d2d0>), ('line H8', <grizli.utils.SpectrumTemplate at 0x7fdb8081dbd0>), ('line H9', <grizli.utils.SpectrumTemplate at 0x7fdb80849050>), ('line H10', <grizli.utils.SpectrumTemplate at 0x7fdb80831c90>), ('line NeIII-3867', <grizli.utils.SpectrumTemplate at 0x7fdb80831e50>), ('line OII', <grizli.utils.SpectrumTemplate at 0x7fdb80831f10>), ('line NeVI-3426', <grizli.utils.SpectrumTemplate at 0x7fdb80831610>), ('line NeV-3346', <grizli.utils.SpectrumTemplate at 0x7fdb808319d0>), ('line MgII', <grizli.utils.SpectrumTemplate at 0x7fdb8081bed0>), ('line CIV-1549', <grizli.utils.SpectrumTemplate at 0x7fdb8081b2d0>), ('line CIII-1906', <grizli.utils.SpectrumTemplate at 0x7fdb8081b350>), ('line CIII-1908', <grizli.utils.SpectrumTemplate at 0x7fdb8081bb10>), ('line OIII-1663', <grizli.utils.SpectrumTemplate at 0x7fdb8081be10>), ('line HeII-1640', <grizli.utils.SpectrumTemplate at 0x7fdb8081b1d0>), ('line NIII-1750', <grizli.utils.SpectrumTemplate at 0x7fdb8081b090>), ('line NIV-1487', <grizli.utils.SpectrumTemplate at 0x7fdb80814750>), ('line NV-1240', <grizli.utils.SpectrumTemplate at 0x7fdb808146d0>), ('line Lya', <grizli.utils.SpectrumTemplate at 0x7fdb80814050>)]))]), [<astropy.io.fits.hdu.image.PrimaryHDU object at 0x7fdc1168b190>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x7fdc230a8fd0>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x7fdc2312f5d0>, <astropy.io.fits.hdu.table.BinTableHDU object at 0x7fdbc10f3290>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc232eab50>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237a6550>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11de5750>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11de5fd0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11de3210>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11df2710>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc10f3310>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11dcb2d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11dcbf10>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11dcbf90>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11dd2690>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11df0190>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11df0f10>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11df0e50>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0c97a50>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbe2e54350>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f876d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f87710>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11dc6f10>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f923d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f92c10>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f92f90>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11dc6350>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f8d090>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f8ded0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f8df50>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc1169f610>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f87090>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11dc2990>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11dc29d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11df7550>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11cfc710>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11cfe0d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11cfe8d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11db9a50>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11d0c390>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11d0c590>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11d0c090>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11cfcb90>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc0291b650>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc0291b850>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc0291b790>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc1168b390>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11df28d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11df2ad0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11df2a10>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11ce2f90>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc0293a110>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc0293ad90>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc0293acd0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdbc0f8d6d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc02949050>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc02949f10>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc02949f90>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11d07990>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc23796150>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc23796350>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc23796110>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11ce97d0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237a6410>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237a6610>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237a6110>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc0292e110>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237ba050>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237bac10>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237bab50>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11d07dd0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237cb050>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237cbed0>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc237cbe10>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11d76610>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11d75590>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11d73810>, <astropy.io.fits.hdu.image.ImageHDU object at 0x7fdc11d69790>])
# Products
mb, st, fit, tfit, line_hdu = out
# Objects that are used for the fitting. They are
# both subclasses of grizli.fitting.GroupFitter,
# which provides the fitting methods.
print('mb: ', mb.__class__) # From "beams.fits"
print('st: ', st.__class__) # Drizzled spectra from "stack.fits" -- DEPRECATED
mb: <class 'grizli.multifit.MultiBeam'> st: <class 'NoneType'>
# Properties of the fit on the redshift grid
# stored in an astropy.table.Table
print('Fit table:', fit.colnames)
for k in fit.meta:
print(k, fit.meta[k])
Fit table: ['zgrid', 'chi2', 'coeffs', 'covar', 'pdf', 'risk'] N (8, 'Number of spectrum extensions') polyord (3, 'Order polynomial fit') chi2poly (9110.810483675881, 'Chi^2 of polynomial fit') chi2spl (8952.07641798737, 'Chi^2 of spline fit') Rspline (30, 'R=lam/dlam of spline fit') kspl (36, 'Parameters, k, of spline fit') huberdel (4, 'Huber delta parameter, see scipy.special.huber') splf01 (0.0, 'Spline flux at 0.61 um') sple01 (0.0, 'Spline flux err at 0.61 um') splf02 (8.709364219116736e-19, 'Spline flux at 0.81 um') sple02 (8.228081081620379e-19, 'Spline flux err at 0.81 um') splf03 (3.447047568901992e-19, 'Spline flux at 0.90 um') sple03 (1.912780771685985e-19, 'Spline flux err at 0.90 um') splf04 (3.422893039625516e-19, 'Spline flux at 1.27 um') sple04 (6.616727735097879e-20, 'Spline flux err at 1.27 um') splf05 (2.9097885262627317e-19, 'Spline flux at 1.40 um') sple05 (5.344124958449241e-20, 'Spline flux err at 1.40 um') NTEMP (17, 'Number of fitting templates') DoF (8366, 'Degrees of freedom (number of pixels)') ktempl (13, 'Parameters, k, of template fit') chimin (8850.12740526996, 'Minimum chi2 of template fit') chimax (9311.85063228819, 'Maximum chi2 of template fit') fitter ('nnls', 'Minimization algorithm') as_epsf (0, 'Object fit with effective PSF morphology') bic_poly (369.0662522299478, 'BIC of polynomial fit') bic_spl (427.09853418948757, 'BIC of spline fit') bic_temp (117.41510497602788, 'BIC of template fit') T001NAME ('fsps/fsps_QSF_12_v3_nolines_001.dat', 'Template name') T002NAME ('fsps/fsps_QSF_12_v3_nolines_002.dat', 'Template name') T003NAME ('fsps/fsps_QSF_12_v3_nolines_003.dat', 'Template name') T004NAME ('fsps/fsps_QSF_12_v3_nolines_004.dat', 'Template name') T005NAME ('fsps/fsps_QSF_12_v3_nolines_005.dat', 'Template name') T006NAME ('fsps/fsps_QSF_12_v3_nolines_006.dat', 'Template name') T007NAME ('fsps/fsps_QSF_12_v3_nolines_007.dat', 'Template name') T008NAME ('fsps/fsps_QSF_12_v3_nolines_008.dat', 'Template name') T009NAME ('fsps/fsps_QSF_12_v3_nolines_009.dat', 'Template name') T010NAME ('fsps/fsps_QSF_12_v3_nolines_010.dat', 'Template name') T011NAME ('fsps/fsps_QSF_12_v3_nolines_011.dat', 'Template name') T012NAME ('fsps/fsps_QSF_12_v3_nolines_012.dat', 'Template name') T013NAME ('alf_SSP.dat', 'Template name') T014NAME ('line Ha+NII+SII+SIII+He+PaB', 'Template name') T014FWHM (1000, 'FWHM, if emission line') T015NAME ('line OIII+Hb+Hg+Hd', 'Template name') T015FWHM (1000, 'FWHM, if emission line') T016NAME ('line OII+Ne', 'Template name') T016FWHM (1000, 'FWHM, if emission line') T017NAME ('line Gal-UV-lines', 'Template name') T017FWHM (1000, 'FWHM, if emission line') st_df (33.02518972012125, 'Student-t df of spline fit') st_loc (0.014438180338095958, 'Student-t loc of spline fit') st_scl (0.9934186519912005, 'Student-t scale of spline fit') hasprior (False, 'Prior applied to PDF') Z02 (1.7399866062975378, 'Integrated p(z) = 0.025') Z16 (1.7408441566800779, 'Integrated p(z) = 0.16') Z50 (1.7417042240614575, 'Integrated p(z) = 0.5') Z84 (1.7425584548011117, 'Integrated p(z) = 0.84') Z97 (1.7433940349887762, 'Integrated p(z) = 0.975') ZWIDTH1 (0.0017142981210338526, 'Width between the 16th and 84th p(z) percentiles') ZWIDTH2 (0.0034074286912384455, 'Width between the 2.5th and 97.5th p(z) percentiles') z_map (1.7417029804185848, 'Redshift at MAX(PDF)') zrmin (0.050000000000000044, 'z grid start') zrmax (3.396418200943862, 'z grid end') z_risk (1.7417062829253418, 'Redshift at minimum risk') min_risk (4.31191869125032e-06, 'Minimum risk') gam_loss (0.15, 'Gamma factor of the risk/loss function')
plt.plot(fit['zgrid'], fit['chi2'])
plt.xlabel('z'); plt.ylabel(r'$\chi^2$')
Text(0, 0.5, '$\\chi^2$')
# Results of the fit at the best determined redshift
print(tfit.keys())
print('z = {0}'.format(tfit['z']))
print('Continuum template, cont1d: ', tfit['cont1d'].__class__)
plt.plot(tfit['cont1d'].wave/1.e4, tfit['cont1d'].flux, label='continuum')
plt.plot(tfit['line1d'].wave/1.e4, tfit['line1d'].flux, label='total')
plt.xlim(0.8, 1.7); plt.ylim(0,1.e-18); plt.grid()
plt.xlabel(r'$\lambda$, microns'); plt.ylabel(r'$f_\lambda$, erg/s/cm2/A'); plt.legend()
# cfit, coeffs, covar are coefficients of the template fit
# and their covariance
odict_keys(['cont1d', 'line1d', 'cfit', 'coeffs', 'chi2', 'covar', 'z', 'templates']) z = 1.7417021486274922 Continuum template, cont1d: <class 'grizli.utils.SpectrumTemplate'>
<matplotlib.legend.Legend at 0x7fdbc125b110>
All of the information above is also stored in the *full.fits
file, so you don't have to
retrieve the outputs directly from the fitting script.
fit_hdu = pyfits.open('{0}_{1:05d}.full.fits'.format(root, id))
fit_hdu.info()
Filename: j033216m2743_00151.full.fits No. Name Ver Type Cards Dimensions Format 0 PRIMARY 1 PrimaryHDU 97 () 1 ZFIT_STACK 1 BinTableHDU 93 400R x 6C [D, D, 25D, 625D, D, D] 2 ZFIT_BEAM 1 BinTableHDU 88 62R x 6C [D, D, 25D, 625D, D, D] 3 TEMPL 1 BinTableHDU 177 9929R x 3C [D, D, D] 4 COVAR 1 ImageHDU 203 (53, 53) float64 5 SEG 1 ImageHDU 8 (80, 80) int32 6 DSCI F098M ImageHDU 28 (80, 80) float32 7 DWHT F098M ImageHDU 28 (80, 80) float32 8 DSCI F140W ImageHDU 28 (80, 80) float32 9 DWHT F140W ImageHDU 28 (80, 80) float32 10 LINE OI-6302 ImageHDU 31 (80, 80) float32 11 CONTINUUM OI-6302 ImageHDU 31 (80, 80) float32 12 CONTAM OI-6302 ImageHDU 31 (80, 80) float32 13 LINEWHT OI-6302 ImageHDU 31 (80, 80) float32 14 LINE HeI-5877 ImageHDU 31 (80, 80) float32 15 CONTINUUM HeI-5877 ImageHDU 31 (80, 80) float32 16 CONTAM HeI-5877 ImageHDU 31 (80, 80) float32 17 LINEWHT HeI-5877 ImageHDU 31 (80, 80) float32 18 LINE OIII ImageHDU 31 (80, 80) float32 19 CONTINUUM OIII ImageHDU 31 (80, 80) float32 20 CONTAM OIII ImageHDU 31 (80, 80) float32 21 LINEWHT OIII ImageHDU 31 (80, 80) float32 22 LINE Hb ImageHDU 31 (80, 80) float32 23 CONTINUUM Hb ImageHDU 31 (80, 80) float32 24 CONTAM Hb ImageHDU 31 (80, 80) float32 25 LINEWHT Hb ImageHDU 31 (80, 80) float32 26 LINE OIII-4363 ImageHDU 31 (80, 80) float32 27 CONTINUUM OIII-4363 ImageHDU 31 (80, 80) float32 28 CONTAM OIII-4363 ImageHDU 31 (80, 80) float32 29 LINEWHT OIII-4363 ImageHDU 31 (80, 80) float32 30 LINE Hg ImageHDU 31 (80, 80) float32 31 CONTINUUM Hg ImageHDU 31 (80, 80) float32 32 CONTAM Hg ImageHDU 31 (80, 80) float32 33 LINEWHT Hg ImageHDU 31 (80, 80) float32 34 LINE Hd ImageHDU 31 (80, 80) float32 35 CONTINUUM Hd ImageHDU 31 (80, 80) float32 36 CONTAM Hd ImageHDU 31 (80, 80) float32 37 LINEWHT Hd ImageHDU 31 (80, 80) float32 38 LINE H7 ImageHDU 31 (80, 80) float32 39 CONTINUUM H7 ImageHDU 31 (80, 80) float32 40 CONTAM H7 ImageHDU 31 (80, 80) float32 41 LINEWHT H7 ImageHDU 31 (80, 80) float32 42 LINE H8 ImageHDU 31 (80, 80) float32 43 CONTINUUM H8 ImageHDU 31 (80, 80) float32 44 CONTAM H8 ImageHDU 31 (80, 80) float32 45 LINEWHT H8 ImageHDU 31 (80, 80) float32 46 LINE H9 ImageHDU 31 (80, 80) float32 47 CONTINUUM H9 ImageHDU 31 (80, 80) float32 48 CONTAM H9 ImageHDU 31 (80, 80) float32 49 LINEWHT H9 ImageHDU 31 (80, 80) float32 50 LINE H10 ImageHDU 31 (80, 80) float32 51 CONTINUUM H10 ImageHDU 31 (80, 80) float32 52 CONTAM H10 ImageHDU 31 (80, 80) float32 53 LINEWHT H10 ImageHDU 31 (80, 80) float32 54 LINE NeIII-3867 ImageHDU 31 (80, 80) float32 55 CONTINUUM NeIII-3867 ImageHDU 31 (80, 80) float32 56 CONTAM NeIII-3867 ImageHDU 31 (80, 80) float32 57 LINEWHT NeIII-3867 ImageHDU 31 (80, 80) float32 58 LINE OII ImageHDU 31 (80, 80) float32 59 CONTINUUM OII ImageHDU 31 (80, 80) float32 60 CONTAM OII ImageHDU 31 (80, 80) float32 61 LINEWHT OII ImageHDU 31 (80, 80) float32 62 LINE NeVI-3426 ImageHDU 31 (80, 80) float32 63 CONTINUUM NeVI-3426 ImageHDU 31 (80, 80) float32 64 CONTAM NeVI-3426 ImageHDU 31 (80, 80) float32 65 LINEWHT NeVI-3426 ImageHDU 31 (80, 80) float32 66 LINE NeV-3346 ImageHDU 31 (80, 80) float32 67 CONTINUUM NeV-3346 ImageHDU 31 (80, 80) float32 68 CONTAM NeV-3346 ImageHDU 31 (80, 80) float32 69 LINEWHT NeV-3346 ImageHDU 31 (80, 80) float32 70 LINE MgII ImageHDU 31 (80, 80) float32 71 CONTINUUM MgII ImageHDU 31 (80, 80) float32 72 CONTAM MgII ImageHDU 31 (80, 80) float32 73 LINEWHT MgII ImageHDU 31 (80, 80) float32 74 DPSF F105W ImageHDU 26 (80, 80) float32 75 DPSF F125W ImageHDU 26 (80, 80) float32 76 DPSF F140W ImageHDU 26 (80, 80) float32 77 DPSF F160W ImageHDU 26 (80, 80) float32
# Basic properties of the input data
fit_hdu[0].header
SIMPLE = T / conforms to FITS standard BITPIX = 8 / array data type NAXIS = 0 / number of array dimensions EXTEND = T ID = 151 / Object ID RA = 53.0657384628246 / Central R.A. DEC = -27.72052066120356 / Central Decl. PIXFRAC = 0.2 / Drizzle PIXFRAC DRIZKRNL= 'point ' / Drizzle kernel NINPUT = 8 / Number of drizzled beams FILE0001= 'ib6o23rsq_flt.fits' / Parent filename GRIS0001= 'G141 ' / Beam grism element PA0001 = 74.0 / PA of dispersion axis FILE0002= 'ib6o23ruq_flt.fits' / Parent filename GRIS0002= 'G141 ' / Beam grism element PA0002 = 74.0 / PA of dispersion axis FILE0003= 'ib6o23ryq_flt.fits' / Parent filename GRIS0003= 'G141 ' / Beam grism element PA0003 = 74.0 / PA of dispersion axis FILE0004= 'ib6o23s0q_flt.fits' / Parent filename GRIS0004= 'G141 ' / Beam grism element PA0004 = 74.0 / PA of dispersion axis FILE0005= 'ib6o21qmq_flt.fits' / Parent filename GRIS0005= 'G102 ' / Beam grism element PA0005 = 75.0 / PA of dispersion axis FILE0006= 'ib6o21r6q_flt.fits' / Parent filename GRIS0006= 'G102 ' / Beam grism element PA0006 = 75.0 / PA of dispersion axis FILE0007= 'ib6o21qoq_flt.fits' / Parent filename GRIS0007= 'G102 ' / Beam grism element PA0007 = 75.0 / PA of dispersion axis FILE0008= 'ib6o21r8q_flt.fits' / Parent filename GRIS0008= 'G102 ' / Beam grism element PA0008 = 75.0 / PA of dispersion axis NDFILT = 2 / Number of direct image filters DFILT01 = 'F098M ' NFILT01 = 4 / Number of beams with this direct filter DFILT02 = 'F140W ' NFILT02 = 4 / Number of beams with this direct filter REDSHIFT= 1.741702148627492 / Redshift used NUMLINES= 16 / Number of lines in this file LINE001 = 'OI-6302 ' FLUX001 = -1E-16 / Line flux, 1e-17 erg/s/cm2 ERR001 = 3.95503798032161E-15 / Line flux err, 1e-17 erg/s/cm2 LINE002 = 'HeI-5877' FLUX002 = 8.85687727537122E-18 / Line flux, 1e-17 erg/s/cm2 ERR002 = 6.34950658380542E-18 / Line flux err, 1e-17 erg/s/cm2 LINE003 = 'OIII ' FLUX003 = 1.37476281838929E-16 / Line flux, 1e-17 erg/s/cm2 ERR003 = 9.21184854201293E-18 / Line flux err, 1e-17 erg/s/cm2 LINE004 = 'Hb ' FLUX004 = 4.04365819605222E-17 / Line flux, 1e-17 erg/s/cm2 ERR004 = 7.38673359666619E-18 / Line flux err, 1e-17 erg/s/cm2 LINE005 = 'OIII-4363' FLUX005 = -3.2161422259281E-18 / Line flux, 1e-17 erg/s/cm2 ERR005 = 1.2857304456026E-17 / Line flux err, 1e-17 erg/s/cm2 LINE006 = 'Hg ' FLUX006 = 1.67164465268617E-17 / Line flux, 1e-17 erg/s/cm2 ERR006 = 1.32793682431807E-17 / Line flux err, 1e-17 erg/s/cm2 LINE007 = 'Hd ' FLUX007 = 4.07758617162416E-18 / Line flux, 1e-17 erg/s/cm2 ERR007 = 6.75899345282833E-18 / Line flux err, 1e-17 erg/s/cm2 LINE008 = 'H7 ' FLUX008 = 6.13306298589520E-19 / Line flux, 1e-17 erg/s/cm2 ERR008 = 7.55633041990356E-18 / Line flux err, 1e-17 erg/s/cm2 LINE009 = 'H8 ' FLUX009 = -3.3325861676325E-18 / Line flux, 1e-17 erg/s/cm2 ERR009 = 8.96282361773832E-18 / Line flux err, 1e-17 erg/s/cm2 LINE010 = 'H9 ' FLUX010 = -6.1291446197630E-18 / Line flux, 1e-17 erg/s/cm2 ERR010 = 8.78054107701503E-18 / Line flux err, 1e-17 erg/s/cm2 LINE011 = 'H10 ' FLUX011 = 4.22633303036584E-18 / Line flux, 1e-17 erg/s/cm2 ERR011 = 8.90446653406718E-18 / Line flux err, 1e-17 erg/s/cm2 LINE012 = 'NeIII-3867' FLUX012 = 1.00017563337739E-17 / Line flux, 1e-17 erg/s/cm2 ERR012 = 9.35192617107364E-18 / Line flux err, 1e-17 erg/s/cm2 LINE013 = 'OII ' FLUX013 = 6.80507115508267E-17 / Line flux, 1e-17 erg/s/cm2 ERR013 = 9.31144661712809E-18 / Line flux err, 1e-17 erg/s/cm2 LINE014 = 'NeVI-3426' FLUX014 = 1.37445675405194E-17 / Line flux, 1e-17 erg/s/cm2 ERR014 = 1.27066725965866E-17 / Line flux err, 1e-17 erg/s/cm2 LINE015 = 'NeV-3346' FLUX015 = -1.6067688591453E-17 / Line flux, 1e-17 erg/s/cm2 ERR015 = 1.30765446884134E-17 / Line flux err, 1e-17 erg/s/cm2 LINE016 = 'MgII ' FLUX016 = -1E-16 / Line flux, 1e-17 erg/s/cm2 ERR016 = 2.40605117783188E-12 / Line flux err, 1e-17 erg/s/cm2 HASLINES= 'OI-6302 HeI-5877 OIII Hb OIII-4363 Hg Hd H7 H8 H9 H10 NeIII-3867 &' CONTINUE 'OII NeVI-3426 NeV-3346 MgII&' CONTINUE '' / Lines in this file GRIZLIV = '1.2-124-ge22d0b2' / Grizli version T_G141 = 4211.742066 / Total exposure time [s] N_G141 = 4 / Number of individual exposures T_G102 = 4211.742066 / Total exposure time [s] N_G102 = 4 / Number of individual exposures P_G141 = 1 / Number of PAs P_G102 = 1 / Number of PAs
from astropy.table import Table
# same as the fit table above, redshift fit to the stacked spectra
fit_stack = Table(fit_hdu['ZFIT_STACK'].data)
plt.plot(fit_stack['zgrid'], fit_stack['pdf'], label='Stacked')
# zoom in around the initial best-guess with the individual "beam" spectra
if 'ZFIT_BEAM' in fit_hdu:
fit_beam = Table(fit_hdu['ZFIT_BEAM'].data)
plt.plot(fit_beam['zgrid'], fit_beam['pdf'], label='Zoom, beams')
plt.xlim(0.6, 1.9); plt.semilogy(); plt.grid()
plt.ylim(1.e-80, 1e4)
plt.xlabel('z'); plt.ylabel('PDF(z)'); plt.legend()
<matplotlib.legend.Legend at 0x7fdbb1ab2b50>
# Best-fit templates, like `tfit` above
templ = Table(fit_hdu['TEMPL'].data)
print(templ.colnames)
['wave', 'continuum', 'full']
# Extensions 'DSCI', 'LINE', 'LINEWHT'... contain the drizzled line maps
print('{0} has lines [{1}]'.format(fit_hdu.filename(), fit_hdu[0].header['HASLINES']))
# Helper script for plotting them, not generated automatically
fig = grizli.fitting.show_drizzled_lines(fit_hdu, size_arcsec=1.6, cmap='plasma_r')
fig.savefig('{0}_{1:05d}.line.png'.format(root, id))
j033216m2743_00151.full.fits has lines [OI-6302 HeI-5877 OIII Hb OIII-4363 Hg Hd H7 H8 H9 H10 NeIII-3867 OII NeVI-3426 NeV-3346 MgII]
# Red star
id=source_ids[2]
from grizli.pipeline import auto_script
auto_script.extract(field_root=root, ids=[id], MW_EBV=0,
pline=pline, run_fit=False, grp=grp, diff=True)
from IPython.display import Image
Image(filename='{0}_{1:05d}.R30.png'.format(root, id))
mb = multifit.MultiBeam('{0}_{1:05d}.beams.fits'.format(root, id),
fcontam=0.2, group_name=root, psf=False, min_sens=0.05)
# Limited set of red stellar templates
tstar = grizli.utils.load_templates(fwhm=1200, line_complexes=True,
fsps_templates=True, stars=True)
# Fit spectral types. Just makes the plot now, outputs not saved
fig, result, tfit = mb.xfit_star(tstar=tstar, fit_background=False,
spline_correction=True, spline_args={'Rspline':5},
oned_args={'bin':2})
load_master_fits: j033216m2743_00429.beams.fits 1 ib6o23rsq_flt.fits G141 2 ib6o21qmq_flt.fits G102 3 ib6o23ruq_flt.fits G141 4 ib6o21r6q_flt.fits G102 5 ib6o21qoq_flt.fits G102 6 ib6o23ryq_flt.fits G141 7 ib6o21r8q_flt.fits G102 8 ib6o23s0q_flt.fits G141 stars/M6.5.txt stars/M8.0.txt stars/L1.0.txt stars/L3.5.txt stars/L6.0.txt stars/T2.0.txt stars/T6.0.txt stars/T7.5.txt # root id ra dec chi2 chi2_flat dof nk best_template as_epsf j033216m2743 429 53.077096 -27.706013 6284.132 6360.521 4822 7 stars/M8.0.txt 0
hdu, fig = mb.drizzle_grisms_and_PAs(fcontam=0.2, flambda=False, kernel='point',
size=32, zfit=tfit, diff=True)
# Fit for small shifts of the trace perpendicular to the dispersion
# All exposures in a given grism have the same offset
tr = mb.fit_trace_shift(verbose=False)
print('Trace offset: ', tr[0])
Trace offset: [-0.10094643 -0.10602606]
# Refit. Chi-squared is a bit improved
fig, result, tfit = mb.xfit_star(tstar=tstar, fit_background=False,
spline_correction=True, spline_args={'Rspline':6},
oned_args={'bin':2})
stars/M6.5.txt stars/M8.0.txt stars/L1.0.txt stars/L3.5.txt stars/L6.0.txt stars/T2.0.txt stars/T6.0.txt stars/T7.5.txt # root id ra dec chi2 chi2_flat dof nk best_template as_epsf j033216m2743 429 53.077096 -27.706013 6047.050 6113.969 4769 7 stars/M8.0.txt 0
hdu, fig = mb.drizzle_grisms_and_PAs(fcontam=0.2, flambda=False, kernel='point',
size=32, zfit=tfit, diff=True)
Can sometimes get an even better morphological model for point sources using effective PSF models in place of the observed drizzled direct image.
USE_EPSF = True
mb = multifit.MultiBeam('{0}_{1:05d}.beams.fits'.format(root, id),
fcontam=0.2, group_name=root, psf=USE_EPSF, min_sens=0.05)
# Trace offset
tr = mb.fit_trace_shift(verbose=False)
# Fit spectral types. Just makes the plot now, outputs not saved
fig, result, tfit = mb.xfit_star(tstar=tstar, fit_background=False,
spline_correction=True, spline_args={'Rspline':5},
oned_args={'bin':2})
load_master_fits: j033216m2743_00429.beams.fits 1 ib6o23rsq_flt.fits G141 2 ib6o21qmq_flt.fits G102 3 ib6o23ruq_flt.fits G141 4 ib6o21r6q_flt.fits G102 5 ib6o21qoq_flt.fits G102 6 ib6o23ryq_flt.fits G141 7 ib6o21r8q_flt.fits G102 8 ib6o23s0q_flt.fits G141 stars/M6.5.txt stars/M8.0.txt stars/L1.0.txt stars/L3.5.txt stars/L6.0.txt stars/T2.0.txt stars/T6.0.txt stars/T7.5.txt # root id ra dec chi2 chi2_flat dof nk best_template as_epsf j033216m2743 429 53.077096 -27.706013 4378.720 4460.211 3777 7 stars/M8.0.txt 1
hdu, fig = mb.drizzle_grisms_and_PAs(fcontam=0.2, flambda=False, kernel='point',
size=32, zfit=tfit, diff=True)