Skip to content

Commit

Permalink
Merge pull request #1815 from pypeit/truncate_spec
Browse files Browse the repository at this point in the history
New EdgeTracePar to truncate slits in the spectral direction
  • Loading branch information
kbwestfall authored Jun 4, 2024
2 parents fbc378f + 75f1043 commit af8ed37
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
6 changes: 5 additions & 1 deletion pypeit/edgetrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -5352,7 +5352,11 @@ def get_slits(self):
right = self.edge_fit[:,gpm & self.is_right]
binspec, binspat = parse.parse_binning(self.traceimg.detector.binning)
ech_order = None if self.orderid is None else self.orderid[gpm][1::2]
if self.spectrograph.spec_min_max is None or ech_order is None:
if self.par['trim_spec'] is not None:
trim_low, trim_high = self.par['trim_spec']
specmin = np.asarray([trim_low]*nslit,dtype=np.float64)
specmax = np.asarray([self.nspec-trim_high]*nslit,dtype=np.float64)
elif self.spectrograph.spec_min_max is None or ech_order is None:
specmin = np.asarray([-np.inf]*nslit)
specmax = np.asarray([np.inf]*nslit)
else:
Expand Down
25 changes: 16 additions & 9 deletions pypeit/par/pypeitpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -3147,7 +3147,7 @@ class EdgeTracePar(ParSet):
"""
prefix = 'ETP' # Prefix for writing parameters to a header is a class attribute
def __init__(self, filt_iter=None, sobel_mode=None, edge_thresh=None, sobel_enhance=None,
exclude_regions=None, follow_span=None, det_min_spec_length=None,
exclude_regions=None, follow_span=None, det_min_spec_length=None, trim_spec=None,
max_shift_abs=None, max_shift_adj=None, max_spat_error=None, match_tol=None,
fit_function=None, fit_order=None, fit_maxdev=None, fit_maxiter=None,
fit_niter=None, fit_min_spec_length=None, auto_pca=None, left_right_pca=None,
Expand Down Expand Up @@ -3222,7 +3222,14 @@ def __init__(self, filt_iter=None, sobel_mode=None, edge_thresh=None, sobel_enha
'measurements of the detector data (as opposed to what ' \
'should be included in any modeling approach; see ' \
'fit_min_spec_length).'


defaults['trim_spec'] = None
dtypes['trim_spec'] = list
descr['trim_spec'] = 'User-defined truncation of all slits in the spectral direction.' \
'Should be two integers, e.g. 100,150 trims 100 pixels from the ' \
'short wavelength end and 150 pixels from the long wavelength ' \
'end of the spectral axis of the detector.'

defaults['max_shift_abs'] = 0.5
dtypes['max_shift_abs'] = [int, float]
descr['max_shift_abs'] = 'Maximum spatial shift in pixels between an input edge ' \
Expand Down Expand Up @@ -3668,13 +3675,13 @@ def from_dict(cls, cfg):
parkeys = ['filt_iter', 'sobel_mode', 'edge_thresh', 'sobel_enhance', 'exclude_regions',
'follow_span', 'det_min_spec_length', 'max_shift_abs', 'max_shift_adj',
'max_spat_error', 'match_tol', 'fit_function', 'fit_order', 'fit_maxdev',
'fit_maxiter', 'fit_niter', 'fit_min_spec_length', 'auto_pca', 'left_right_pca',
'pca_min_edges', 'pca_n', 'pca_var_percent', 'pca_function', 'pca_order',
'pca_sigrej', 'pca_maxrej', 'pca_maxiter', 'smash_range', 'edge_detect_clip',
'trace_median_frac', 'trace_thresh', 'trace_rms_tol', 'fwhm_uniform',
'niter_uniform', 'fwhm_gaussian', 'niter_gaussian', 'det_buffer', 'max_nudge',
'sync_predict', 'sync_center', 'gap_offset', 'sync_to_edge', 'bound_detector',
'minimum_slit_dlength', 'dlength_range', 'minimum_slit_length',
'fit_maxiter', 'fit_niter', 'fit_min_spec_length', 'trim_spec', 'auto_pca',
'left_right_pca', 'pca_min_edges', 'pca_n', 'pca_var_percent', 'pca_function',
'pca_order', 'pca_sigrej', 'pca_maxrej', 'pca_maxiter', 'smash_range',
'edge_detect_clip', 'trace_median_frac', 'trace_thresh', 'trace_rms_tol',
'fwhm_uniform', 'niter_uniform', 'fwhm_gaussian', 'niter_gaussian', 'det_buffer',
'max_nudge', 'sync_predict', 'sync_center', 'gap_offset', 'sync_to_edge',
'bound_detector', 'minimum_slit_dlength', 'dlength_range', 'minimum_slit_length',
'minimum_slit_length_sci', 'length_range', 'minimum_slit_gap', 'clip',
'order_match', 'order_offset', 'add_missed_orders', 'order_width_poly',
'order_gap_poly', 'order_spat_range', 'overlap', 'use_maskdesign',
Expand Down

0 comments on commit af8ed37

Please sign in to comment.