get_prism_bar_correction¶
- msaexp.utils.get_prism_bar_correction(scaled_yshutter, num_shutters=3, wrap='auto', wrap_pad=0.2, mask=True, bar_data=None)[source]¶
Generate the
msaexpprism bar-shadow correction- Parameters
- scaled_yshutterarray-like
Cross-dispersion pixel coordinates, scaled by a factor of 1/5 to roughly have units of the MSA shutters
- num_shutters[1,2,3]
Number of shutters in the slitlet
- wrapbool, str
If
auto, determine if the bounds ofscaled_yshutterare more than 0.5 shutters outside of the (-1.5, 1.5) range used to determine the correction. If so, or ifwrap=True, replicate the center shutter to all specified shutters.- wrap_padfloat
If
wrap, pad the outer edges that are unilluminated and won’t be properly calibrated- maskbool
Apply mask where the bar correction is within the shutter pixels of the calibration
- bar_dataNone, dict
Correction data. If not specified, read from
prism_{num_shutters}_bar_coeffs_wave.yaml
- Returns
- bararray-like
The estimated bar throughput. To correct, divide by
bar- is_wrappedbool
Was the bar profile wrapped using the single central shutter, e.g., from
wrap='auto'?
Examples
import numpy as np import matplotlib.pyplot as plt from msaexp.utils import get_prism_bar_correction scaled_yshutter = np.linspace(-1.6, 1.6, 512) fig, ax = plt.subplots(1,1,figsize=(6,4)) for n in [1,2,3]: bar, _wrapped = get_prism_bar_correction(scaled_yshutter, num_shutters=n, wrap=False) ax.plot(scaled_yshutter, bar, label=f'{n}-shutter', alpha=0.5) ax.legend(loc='lower right', fontsize=6) ax.grid() ax.set_xlabel('scaled_yshutter = cross-dispersion pixel / 5') ax.set_ylabel('bar shadow factor') fig.tight_layout(pad=1) fig.show()
(
Source code,png,hires.png,pdf)
import numpy as np import matplotlib.pyplot as plt import msaexp.utils # 5-shutter slitlet scaled_yshutter = np.linspace(-2.51, 2.51, 1024) fig, ax = plt.subplots(1,1,figsize=(6,4)) bar, _wrapped = msaexp.utils.get_prism_bar_correction(scaled_yshutter) ax.plot(scaled_yshutter, bar, label=f'wrapped: {_wrapped}') ax.grid() ax.legend() ax.set_xlabel('scaled_yshutter = cross-dispersion pixel / 5') ax.set_ylabel('bar shadow factor') fig.tight_layout(pad=1) fig.show()
(
Source code,png,hires.png,pdf)
slit_file = 'jw04233006001_03101_00002_nrs2_phot.076.4233_75646.fits' slit = jwst.datamodels.open(slit_file) # get the trace center _trace = msaexp.utils.slit_trace_center( slit, with_source_xpos=False, with_source_ypos=False ) # scaled coordinates yp, xp = np.indices(slit.data.shape) scaled_yshutter = (yp - _trace[1]) / 5 bar, _wrapped = msaexp.utils.get_prism_bar_correction(scaled_yshutter) plt.imshow(bar, aspect='auto')