Skip to content

Commit

Permalink
Fix function being indented by one too many spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
DBerke committed Dec 13, 2023
1 parent 77baef5 commit bc08612
Showing 1 changed file with 110 additions and 110 deletions.
220 changes: 110 additions & 110 deletions geminidr/gnirs/primitives_gnirs_longslit.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,116 +185,116 @@ def addMDF(self, adinputs=None, suffix=None, mdf=None):
return adinputs


def determineDistortion(self, adinputs=None, **params):
"""
Maps the distortion on a detector by tracing lines perpendicular to the
dispersion direction. Then it fits a 2D Chebyshev polynomial to the
fitted coordinates in the dispersion direction. The distortion map does
not change the coordinates in the spatial direction.
The Chebyshev2D model is stored as part of a gWCS object in each
`nddata.wcs` attribute, which gets mapped to a FITS table extension
named `WCS` on disk.
This GNIRS-specific primitive sets default spectral order in case it's None
(since there are only few lines available in H and K-bands in high-res mode, which
requires setting order to 1), and minimum length of traced feature to be considered
as a useful line for each pixel scale.
It then calls the generic version of the primitive.
Parameters
----------
adinputs : list of :class:`~astrodata.AstroData`
Arc data as 2D spectral images with the distortion and wavelength
solutions encoded in the WCS.
suffix : str
Suffix to be added to output files.
spatial_order : int
Order of fit in spatial direction.
spectral_order : int
Order of fit in spectral direction.
id_only : bool
Trace using only those lines identified for wavelength calibration?
min_snr : float
Minimum signal-to-noise ratio for identifying lines (if
id_only=False).
nsum : int
Number of rows/columns to sum at each step.
step : int
Size of step in pixels when tracing.
max_shift : float
Maximum orthogonal shift (per pixel) for line-tracing (unbinned).
max_missed : int
Maximum number of steps to miss before a line is lost.
min_line_length: float
Minimum length of traced feature (as a fraction of the tracing dimension
length) to be considered as a useful line.
debug_reject_bad: bool
Reject lines with suspiciously high SNR (e.g. bad columns)? (Default: True)
debug: bool
plot arc line traces on image display window?
Returns
-------
list of :class:`~astrodata.AstroData`
The same input list is used as output but each object now has the
appropriate `nddata.wcs` defined for each of its extensions. This
provides details of the 2D Chebyshev fit which maps the distortion.
"""
adoutputs = []
for ad in adinputs:
these_params = params.copy()
disp = ad.disperser(pretty=True)
cam = ad.camera(pretty=True)
cenwave = ad.central_wavelength(asMicrometers=True)
if these_params["spectral_order"] is None:
if 'ARC' in ad.tags:
if disp.startswith('111') and cam.startswith('Long') and \
cenwave >= 1.65:
these_params["spectral_order"] = 1
else:
these_params["spectral_order"] = 2
else:
# sky line case
these_params["spectral_order"] = 3
self.log.stdinfo(f'Parameter "spectral_order" is set to None. '
f'Using spectral_order={these_params["spectral_order"]} for {ad.filename}')

if these_params["min_line_length"] is None:
if cam.startswith('Long'):
these_params["min_line_length"] = 0.8
else:
these_params["min_line_length"] = 0.6
self.log.stdinfo(f'Parameter "min_line_length" is set to None. '
f'Using min_line_length={these_params["min_line_length"]} for {ad.filename}')

if these_params["max_missed"] is None:
if "ARC" in ad.tags:
# In arcs with few lines tracing strong horizontal noise pattern can
# affect distortion model.Using a lower max_missed value helps to
# filter out horizontal noise.
these_params["max_missed"] = 2
else:
# In science frames we want this parameter be set to a higher value, since
# otherwise the line might be abandoned when crossing a bright object spectrum.
these_params["max_missed"] = 5
self.log.stdinfo(f'Parameter "max_missed" is set to None. '
f'Using max_missed={these_params["max_missed"]} for {ad.filename}')
adoutputs.extend(super().determineDistortion([ad], **these_params))
return adoutputs
def determineDistortion(self, adinputs=None, **params):
"""
Maps the distortion on a detector by tracing lines perpendicular to the
dispersion direction. Then it fits a 2D Chebyshev polynomial to the
fitted coordinates in the dispersion direction. The distortion map does
not change the coordinates in the spatial direction.
The Chebyshev2D model is stored as part of a gWCS object in each
`nddata.wcs` attribute, which gets mapped to a FITS table extension
named `WCS` on disk.
This GNIRS-specific primitive sets default spectral order in case it's None
(since there are only few lines available in H and K-bands in high-res mode, which
requires setting order to 1), and minimum length of traced feature to be considered
as a useful line for each pixel scale.
It then calls the generic version of the primitive.
Parameters
----------
adinputs : list of :class:`~astrodata.AstroData`
Arc data as 2D spectral images with the distortion and wavelength
solutions encoded in the WCS.
suffix : str
Suffix to be added to output files.
spatial_order : int
Order of fit in spatial direction.
spectral_order : int
Order of fit in spectral direction.
id_only : bool
Trace using only those lines identified for wavelength calibration?
min_snr : float
Minimum signal-to-noise ratio for identifying lines (if
id_only=False).
nsum : int
Number of rows/columns to sum at each step.
step : int
Size of step in pixels when tracing.
max_shift : float
Maximum orthogonal shift (per pixel) for line-tracing (unbinned).
max_missed : int
Maximum number of steps to miss before a line is lost.
min_line_length: float
Minimum length of traced feature (as a fraction of the tracing dimension
length) to be considered as a useful line.
debug_reject_bad: bool
Reject lines with suspiciously high SNR (e.g. bad columns)? (Default: True)
debug: bool
plot arc line traces on image display window?
Returns
-------
list of :class:`~astrodata.AstroData`
The same input list is used as output but each object now has the
appropriate `nddata.wcs` defined for each of its extensions. This
provides details of the 2D Chebyshev fit which maps the distortion.
"""
adoutputs = []
for ad in adinputs:
these_params = params.copy()
disp = ad.disperser(pretty=True)
cam = ad.camera(pretty=True)
cenwave = ad.central_wavelength(asMicrometers=True)
if these_params["spectral_order"] is None:
if 'ARC' in ad.tags:
if disp.startswith('111') and cam.startswith('Long') and \
cenwave >= 1.65:
these_params["spectral_order"] = 1
else:
these_params["spectral_order"] = 2
else:
# sky line case
these_params["spectral_order"] = 3
self.log.stdinfo(f'Parameter "spectral_order" is set to None. '
f'Using spectral_order={these_params["spectral_order"]} for {ad.filename}')

if these_params["min_line_length"] is None:
if cam.startswith('Long'):
these_params["min_line_length"] = 0.8
else:
these_params["min_line_length"] = 0.6
self.log.stdinfo(f'Parameter "min_line_length" is set to None. '
f'Using min_line_length={these_params["min_line_length"]} for {ad.filename}')

if these_params["max_missed"] is None:
if "ARC" in ad.tags:
# In arcs with few lines tracing strong horizontal noise pattern can
# affect distortion model.Using a lower max_missed value helps to
# filter out horizontal noise.
these_params["max_missed"] = 2
else:
# In science frames we want this parameter be set to a higher value, since
# otherwise the line might be abandoned when crossing a bright object spectrum.
these_params["max_missed"] = 5
self.log.stdinfo(f'Parameter "max_missed" is set to None. '
f'Using max_missed={these_params["max_missed"]} for {ad.filename}')
adoutputs.extend(super().determineDistortion([ad], **these_params))
return adoutputs


def determineWavelengthSolution(self, adinputs=None, **params):
Expand Down

0 comments on commit bc08612

Please sign in to comment.