JWSTNirspec_cal

class breads.instruments.JWSTNirspec_cal(filename=None, utils_dir=None, save_utils=True, load_utils=True, preproc_task_list=None, verbose=True)[source]

Bases: JWST_IFUs

JWST NIRSpec 2D calibrated data class.

Parameters:
utils_dir: str or None

Path to the folder saving the intermediate products of each preprocessing step.

save_utils: bool (default=True)

Whether to save intermediate products.

load_utils: bool (default=True)

Whether to load intermediate products.

preproc_task_list: list or None

List of preprocessing tasks to run.

verbose: bool (default=True)

If True, the code is returning more printing.

wv_reffloat

Reference wavelength. If not set, the shortest wavelength will be used by default.

About the “preproc_task_list” parameter. Each task should be a list containing:

task[0] = the name of the class method task[1] = a dictionary with any relevant method arguments (but not including save_utils, see task[2])

If not defined, it assumes no parameters are needed (task[1] = {}).

task[2] = a boolean saying if the outputs should be saved in the utils folder.

Default to class save_utils if not defined for the task. If it is a string instead, it will be saved with the string as the filename.

task[3] = a boolean saying if we should attempt to load the data from the utils folder.

Default to class load_utils if not defined for the task.

Methods Summary

compute_charge_bleeding_mask([save_utils, ...])

Compute charge bleeding bar mask

compute_med_filt_badpix([save_utils, ...])

Quick bad pixel identification.

compute_starspectrum_contnorm_2dspline([...])

Compute star spectrum continuum normalized by 2d spline

compute_starsubtraction_2dspline([...])

Compute Star Subtraction with 2D Spline

mask_interp_elements_too_far_from_bin_edges(...)

Mask interpolated elements too far from the edge bins

reload_charge_bleeding_mask([load_filename])

Reload charge bleeding bar mask

reload_starspectrum_contnorm_2dspline([...])

Reload star spectrum continuum normalized by 2d spline

reload_starsubtraction_2dspline([load_filename])

Reload Star Subtraction with 2D spline

save_charge_bleeding_mask(save_utils, bar_mask)

Save charge bleeding bar mask

Methods Documentation

compute_charge_bleeding_mask(save_utils=False, threshold2mask=0.15)[source]

Compute charge bleeding bar mask

Parameters:
save_utils: bool (default is False)

if True, save the computed charge bleeding mask.

threshold2mask: float (default is 0.15) in arcsec

Separation threshold to mask the traces sitting in the charge bleeding region.

Returns:
compute_med_filt_badpix(save_utils=False, window_size=50, mad_threshold=50, crop_Npix_from_trace_edges=0)[source]

Quick bad pixel identification.

The data is first high-pass filtered row by row with a median filter with a window size of 50 (window_size) pixels. The median absolute deviation (MAP) is then calculated row by row, and any pixel deviating by more than 50x the MAP are identified as bad.

Only returns (or save) the newly identified bad pixels, the ones already included in self.bad_pixels won’t be in new_badpix. But this map is automatically applied to self.bad_pixels: self.bad_pixels *= new_badpix

Parameters:
crop_Npix_from_trace_edges
mad_threshold
window_size
save_utilsbool or string

Save the computed bad pixel map (nans=bad) into the utils directory Default filename (set save_utils as a string instead of bool to override filename): os.path.join(self.utils_dir, os.path.basename(self.filename).replace(“.fits”, “_med_filt_badpix.fits”))

Returns:
new_badpixnp.array

nans = bad.

compute_starspectrum_contnorm_2dspline(save_utils=False, im=None, im_wvs=None, err=None, mppool=None, spec_R_sampling=None, threshold_badpix=10, wv_nodes=None, N_wvs_nodes=20, ifuy_nodes=None, delta_ifuy=0.05, apply_new_bad_pixels=False, iterative=True, independent_trace=True)[source]

Compute star spectrum continuum normalized by 2d spline

Parameters:
save_utils
im
im_wvs
err
mppool
spec_R_sampling
threshold_badpix
wv_nodes
N_wvs_nodes
ifuy_nodes
delta_ifuy
apply_new_bad_pixels
iterative
independent_trace
Returns:
compute_starsubtraction_2dspline(save_utils=False, im=None, im_wvs=None, err=None, threshold_badpix=10, mppool=None, starsub_dir='starsub2d', iterative=True, independent_trace=True)[source]

Compute Star Subtraction with 2D Spline

Parameters:
save_utils
im
im_wvs
err
threshold_badpix
mppool
starsub_dir
iterative
independent_trace
Returns:
subtracted_im, star_model, spline_paras0, self.wv_nodes, self.ifuy_nodes
mask_interp_elements_too_far_from_bin_edges(dwv_threshold)[source]

Mask interpolated elements too far from the edge bins

Parameters:
dwv_threshold
Returns:
maskndarray

Mask of which pixels are masked

Also modifies self.bad_pixels
reload_charge_bleeding_mask(load_filename=None)[source]

Reload charge bleeding bar mask

Parameters:
load_filenamestr or None

Filename to load mask data from, or leave None to use default filename

Returns:
bar_maskndarray
Also modifies self.badpixels, by multiplying that times the bar_mask
reload_starspectrum_contnorm_2dspline(load_filename=None, apply_new_bad_pixels=False)[source]

Reload star spectrum continuum normalized by 2d spline

Parameters:
load_filenamestr or None

Filename to load spectrum data from, or leave None to use default filename

apply_new_bad_pixelsbool

If set, multiply self.badpixels times the NEW_BADPIX extension of the spectrum

Returns:
new_wavelengths,combined_fluxes,combined_errors,spline_cont0,spline_paras0,wv_nodes,ifuy_nodes
reload_starsubtraction_2dspline(load_filename=None)[source]

Reload Star Subtraction with 2D spline

Parameters:
load_filenamestr or None

Filename to load PSF subtracted data from, or leave None to use default filename

Returns:
subtracted_im, star_model, spline_paras0, wv_nodes, ifuy_nodes
save_charge_bleeding_mask(save_utils, bar_mask)[source]

Save charge bleeding bar mask