extract_spectra

msaexp.slit_combine.extract_spectra(target='1208_5110240', root='nirspec', path_to_files='./', files=None, do_gratings=['PRISM', 'G395H', 'G395M', 'G235M', 'G140M'], join=[0, 3, 5], exposure_groups=None, split_uncover=True, stuck_threshold=0.3, valid_frac_threshold=0.1, pad_border=2, sort_by_sn=False, position_key='y_index', mask_cross_dispersion=None, cross_dispersion_mask_type='trace', trace_from_yoffset=False, reference_exposure='auto', trace_niter=4, offset_degree=0, degree_kwargs={}, recenter_all=False, free_trace_offset=False, nod_offset=None, initial_sigma=7, fit_type=1, initial_theta=None, fix_params=False, input_fix_sigma=None, fit_params_kwargs=None, flag_2d_kwargs=None, diffs=True, undo_pathloss=True, undo_barshadow=False, sky_arrays=None, use_first_sky=False, drizzle_kws={'dkws': {'oversample': 16, 'pixfrac': 0.8}, 'ny': 13, 'step': 1, 'wave_sample': 1.05, 'with_pathloss': True}, get_xobj=False, trace_with_xpos=False, trace_with_ypos='auto', get_background=False, make_2d_plots=True, lookup_prf_type='merged', lookup_prf_version='001', include_full_pixtab=['PRISM'], plot_kws={}, protect_exception=True, **kwargs)[source]

Spectral combination workflow splitting by grating and multiple observations in a particular grating

Parameters
targetstr

Target name. If no files specified, will search for the 2D slit cutout files with names like *phot*{target}.fits

rootstr

Output file rootname

path_to_filesstr

Directory path containing the phot files

fileslist, None

Optional explicit list of phot files to combine

do_gratingslist

Gratings to consider

joinlist

Indices of files[i].split('[._]') + GRATING to join as a group

split_uncoverbool

Split sub-pixel dithers from UNCOVER (GO-2561) when defining exposure groups

sort_by_snbool

Try to process groups in order of decreasing S/N, i.e., to derive the trace offsets in the prism where it will be best defined and propagate to other groups with the gratings

mask_cross_dispersionNone or [int, int]

Optional cross-dispersion masking, e.g., for stuck-closed shutters or multiple sources within a slitlet. The specified values are integer indices of the pixel range to mask. See cross_dispersion_mask_type.

cross_dispersion_mask_typestr

Type of cross dispersion mask to apply. With 'trace', the masked pixels are calculated relative to the (expected) center of the trace, and, e.g., mask_cross_dispersion = [5,100] will mask all pixels 5 pixels “above” the center of the trace (100 is an arbitrarily large number to include all pixels). The mask will shift along with the nod offsets.

With fixed, the mask indices are relative to the trace in the first exposure and won’t shift with the nod offsets. So mask_cross_dispersion = [-3,3] would mask roughly the central shutter in all exposures that will contain the source in some exposures and not in others. This can be used to try to mitigate some stuck-closed shutters, though the how effective it is is still under investigation.

stuck_threshold, pad_border

See SlitGroup

trace_from_yoffset, trace_with_xpos, trace_with_ypos

See SlitGroup

position_key, reference_exposure, nod_offset, diffs

See SlitGroup

undo_pathloss, undo_barshadow

See SlitGroup

trace_niterint, optional

Number of iterations for the trace fit

offset_degreeint, optional

Polynomial offset degree

degree_kwargsdict, optional

Degree keyword arguments

recenter_allbool, optional

Refit for the trace center for all groups. If False, use the center from the first (usually highest S/N prism) trace.

free_trace_offsetbool

If True, recenter all traces within and across groups.

initial_sigmafloat, optional

Initial sigma value. This is 10 times the Gaussian sigma width, in pixels.

fit_typeint, optional

Fit type value

initial_thetaNone, optional

Initial parameter guesses

fix_paramsbool, optional

Fix parameters to initial_theta

input_fix_sigmaNone, optional

Input fix sigma value

fit_params_kwargsNone, optional

Fit parameters keyword arguments

drizzle_kwsdict, optional

Drizzle keyword arguments

get_xobjbool, optional

Return SlitGroup objects along with the HDU product

get_backgroundbool, optional

Get background value

make_2d_plotsbool, optional

Make 2D plots

include_full_pixtablist

List of dispersers to full pixel table in output

Returns
Nonenull

If no valid spectra are found

hdudict

Dict of HDUList objects for the separate gratings

xobjdict

Dictionary of SlitGroup objects if get_xobj=True