Skip to content

Commit b9935bb

Browse files
committed
sort out min_line_length in determineDistortion() to be the fraction of the illuminated slit length
1 parent 6a14628 commit b9935bb

6 files changed

Lines changed: 25 additions & 19 deletions

File tree

geminidr/core/parameters_spect.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ class determineDistortionConfig(config.Config):
145145
max_shift = config.RangeField("Maximum shift per pixel in line position",
146146
float, 0.05, min=0.001, max=0.1)
147147
max_missed = config.RangeField("Maximum number of steps to miss before a line is lost", int, 5, min=0)
148-
min_line_length = config.RangeField("Exclude line traces shorter than this fraction of spatial dimension",
149-
float, 0., min=0., max=1.)
148+
min_line_length = config.RangeField("Exclude line traces shorter than this fraction of slit length",
149+
float, 0.8, min=0., max=1.)
150150
debug_reject_bad = config.Field("Reject lines with suspiciously high SNR (e.g. bad columns)?", bool, True)
151151
debug = config.Field("Display line traces on image display?", bool, False)
152152

geminidr/core/primitives_spect.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1473,11 +1473,23 @@ def determineDistortion(self, adinputs=None, **params):
14731473
initial_peaks, _ = peak_finding.find_wavelet_peaks(
14741474
data, widths=widths, mask=mask & DQ.not_signal,
14751475
variance=variance, min_snr=min_snr, reject_bad=debug_reject_bad)
1476-
log.stdinfo(f"Found {len(initial_peaks)} peaks")
1477-
print(initial_peaks)
1476+
#log.stdinfo(f"Found {len(initial_peaks)} peaks")
1477+
14781478
# The coordinates are always returned as (x-coords, y-coords)
14791479
rwidth = 0.42466 * fwidth
14801480

1481+
# The slit length may be smaller than the width of the slice,
1482+
# so we need to estimate the slit length and
1483+
# "min_line_length" is the fraction of that, not the fraction
1484+
# of the slice width.
1485+
loc = int(np.median(initial_peaks))
1486+
if dispaxis == 0:
1487+
_slice = ext.mask[loc] & DQ.unilluminated
1488+
else:
1489+
_slice = ext.mask[:, loc] & DQ.unilluminated
1490+
slit_length_frac = 1 - ((_slice.argmin() +
1491+
_slice[::-1].argmin()) / _slice.size)
1492+
14811493
# Straight slits, such as in longslit, can have all the lines
14821494
# traced simultaneously since they all have the same starting
14831495
# point. "Curved" slits need to be handled one-by-one. This is
@@ -1492,7 +1504,7 @@ def determineDistortion(self, adinputs=None, **params):
14921504
nsum=nsum, max_missed=max_missed,
14931505
max_shift=max_shift * ybin / xbin,
14941506
viewer=self.viewer if debug else None,
1495-
min_line_length=min_line_length)
1507+
min_line_length=min_line_length*slit_length_frac)
14961508

14971509
else:
14981510
traces = []
@@ -1501,14 +1513,20 @@ def determineDistortion(self, adinputs=None, **params):
15011513
# along the dispersion axis. `extract_info` here is the
15021514
# polynomial describing that midway line.
15031515
start = extract_info(peak)
1516+
print("peak, start:", peak, start)
15041517
traces.extend(tracing.trace_lines(
15051518
ext, axis=1 - dispaxis,
15061519
start=start, initial=[peak],
15071520
rwidth=rwidth, cwidth=max(int(fwidth), 5), step=step,
15081521
nsum=nsum, max_missed=max_missed,
15091522
max_shift=max_shift * ybin / xbin,
15101523
viewer=self.viewer if debug else None,
1511-
min_line_length=0.1))
1524+
min_line_length=min_line_length*slit_length_frac))
1525+
1526+
log.stdinfo(f"Traced {len(traces)} lines")
1527+
if ext.id == 6 and ad.filename.startswith("S20060311S0321"):
1528+
for trace in traces:
1529+
print(trace.input_coordinates())
15121530

15131531
# List of traced peak positions
15141532
in_coords = np.array([coord for trace in traces for

geminidr/f2/parameters_f2_spect.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class determineDistortionConfig(parameters_spect.determineDistortionConfig):
3131
def setDefaults(self):
3232
self.spectral_order = 3
3333
self.min_snr = 10.
34-
self.min_line_length = 0.3
3534
self.debug_reject_bad = False
3635

3736

geminidr/gnirs/parameters_gnirs_crossdispersed.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ def setDefaults(self):
1919

2020
class determineDistortionConfig(parameters_spect.determineDistortionConfig):
2121
spectral_order = config.RangeField("Fitting order in spectral direction", int, None, min=1, optional=True)
22-
min_line_length = config.RangeField("Exclude line traces shorter than this fraction of spatial dimension",
23-
float, None, min=0., max=1., optional=True)
2422
max_missed = config.RangeField("Maximum number of steps to miss before a line is lost",
2523
int, None, min=0, optional=True)
2624
def setDefaults(self):
2725
self.min_snr = 10
2826
self.spatial_order = 2
27+
self.step = 5
2928
self.debug_reject_bad = False
3029

3130

geminidr/gnirs/parameters_gnirs_longslit.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ def list_of_ints_check(value):
1313

1414
class determineDistortionConfig(parameters_spect.determineDistortionConfig):
1515
spectral_order = config.RangeField("Fitting order in spectral direction", int, None, min=1, optional=True)
16-
min_line_length = config.RangeField("Exclude line traces shorter than this fraction of spatial dimension",
17-
float, None, min=0., max=1., optional=True)
1816
max_missed = config.RangeField("Maximum number of steps to miss before a line is lost",
1917
int, None, min=0, optional=True)
2018
def setDefaults(self):

geminidr/gnirs/primitives_gnirs_spect.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,6 @@ def determineDistortion(self, adinputs=None, **params):
121121
self.log.stdinfo(f'Parameter "spectral_order" is set to None. '
122122
f'Using spectral_order={these_params["spectral_order"]} for {ad.filename}')
123123

124-
if these_params["min_line_length"] is None:
125-
if cam.startswith('Long'):
126-
these_params["min_line_length"] = 0.8
127-
else:
128-
these_params["min_line_length"] = 0.6
129-
self.log.stdinfo(f'Parameter "min_line_length" is set to None. '
130-
f'Using min_line_length={these_params["min_line_length"]} for {ad.filename}')
131-
132124
if these_params["max_missed"] is None:
133125
if "ARC" in ad.tags:
134126
# In arcs with few lines tracing strong horizontal noise pattern can

0 commit comments

Comments
 (0)