Skip to content

Commit 39fc257

Browse files
committed
Merge branch 'bugfix/fitTelluric_infs_nans_crash' into release/4.x
2 parents d88b0e5 + e622db4 commit 39fc257

4 files changed

Lines changed: 17 additions & 4 deletions

File tree

geminidr/core/parameters_telluric.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ class fitTelluricConfig(config.core_1Dfitting_config):
3434
apply_shift = config.Field("Permanently apply pixel shift?", bool, True) # debug?
3535
debug_lsf_sampling = config.RangeField("Number of sample points for each LSF parameter",
3636
int, 5, min=3, optional=False)
37+
debug_stellar_mask_threshold = config.RangeField(
38+
"Absorption threshold for stellar mask", float, 0.9, min=0.5, max=1.0)
39+
debug_stellar_mask_max_extent = config.RangeField(
40+
"Maximum extent of a stellar mask region (nm)", float, 40., min=0.)
3741

3842
def setDefaults(self):
3943
self.niter = 1

geminidr/core/primitives_telluric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def fitTelluric(self, adinputs=None, **params):
256256
if (len(ext.shape) == 1 and
257257
ext.hdr.get('APERTURE') == aperture_to_use):
258258
tspek = tspek_list[result_index]
259-
absorption = tspek.data / m_final.models[result_index].continuum(tspek.waves)
259+
absorption = at.divide0(tspek.data, m_final.models[result_index].continuum(tspek.waves))
260260
goodpix = ~(tspek.mask | tcal.stellar_mask[result_index]).astype(bool)
261261
spline = make_interp_spline(tcal.spectra[result_index].waves[goodpix],
262262
absorption[goodpix], k=3)

geminidr/interactive/fit/telluric.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def model_change_handler(self, model):
376376

377377
good = get_good_pixels(model.x, model.aux_data.data['waves'])
378378

379-
absorption = model.y / model.aux_data.data['continuum'][good]
379+
absorption = at.divide0(model.y, model.aux_data.data['continuum'][good])
380380
goodpix = [m == 'good' for m in model.mask]
381381
spline = make_interp_spline(model.x[goodpix],
382382
absorption[goodpix], k=3)

gempy/library/calibrator.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,17 @@ def __init__(self, telluric_spectra, ui_params=None):
143143
# We store this as an attribute here since it's not handled fully
144144
# by TelluricSpectrum (you can make the mask but it's not applied)
145145
# and it needs to be accessed by the Visualizer
146-
self.stellar_mask = [tspek.make_stellar_mask(r=self.resolution)
147-
for tspek in self.spectra]
146+
if ui_params is None:
147+
stellar_mask_threshold = 1.0
148+
stellar_mask_max_extent = 0.
149+
else:
150+
stellar_mask_threshold = ui_params.debug_stellar_mask_threshold
151+
stellar_mask_max_extent = ui_params.debug_stellar_mask_max_extent
152+
self.stellar_mask = [tspek.make_stellar_mask(
153+
threshold=stellar_mask_threshold,
154+
max_contiguous=stellar_mask_max_extent,
155+
r=self.resolution)
156+
for tspek in self.spectra]
148157

149158
# Allow instantiation without this and can call later
150159
if ui_params is not None:

0 commit comments

Comments
 (0)