Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
debora-pe committed Aug 29, 2024
1 parent 25c7e35 commit 97c5950
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions pypeit/scripts/chk_flexure.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ def main(args):
# What kind of file are we??
hdul = fits.open(in_file)
head0 = hdul[0].header
file_type = None

if 'PYP_CLS' in head0.keys() and head0['PYP_CLS'].strip() == 'AllSpec2DObj':
# load the spec2d file
allspec2D = spec2dobj.AllSpec2DObj.from_fits(file, chk_version=chk_version)
allspec2D = spec2dobj.AllSpec2DObj.from_fits(in_file, chk_version=chk_version)
allspec2D.flexure_diagnostics(flexure_type=flexure_type)
elif 'DMODCLS' in head0.keys() and head0['DMODCLS'].strip() == 'SpecObjs':
if flexure_type == 'spat':
msgs.error("Spat flexure not available in the spec1d file, try with a "
"spec2d file")
# load the spec1d file
sobjs = specobjs.SpecObjs.from_fitsfile(file, chk_version=chk_version)
sobjs = specobjs.SpecObjs.from_fitsfile(in_file, chk_version=chk_version)
sobjs.flexure_diagnostics()
else:
msgs.error("Bad file type input!")
Expand Down
15 changes: 8 additions & 7 deletions pypeit/spec2dobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,20 +730,22 @@ def __repr__(self):

def flexure_diagnostics(self, flexure_type='spat'):
"""
Print the spectral or spatial flexure of a spec2d or spec1d file.
Print and return the spectral or spatial flexure of a spec2d file.
Args:
flexure_type (:obj:`str`, optional):
Type of flexure to check. Options are 'spec' or 'spat'. Default
is 'spec'.
Returns:
:obj:`astropy.table.Table`, :obj:`float`: If flexure_type is
'spec', return a table with the spectral flexure. If flexure_type is
'spat', return the spatial flexure
:obj:`dict`: Dictionary with the flexure values for each detector. If
flexure_type is 'spec', the spectral flexure is stored in an astropy table.
If flexure_type is 'spat', the spatial flexure is stored in a float.
"""
if flexure_type not in ['spat', 'spec']:
msgs.error(f'flexure_type must be spat or spec, not {flexure_type}')
return_flex = {}
# Loop on Detectors
for det in self.detectors:
print('')
Expand All @@ -757,15 +759,14 @@ def flexure_diagnostics(self, flexure_type='spat'):
# print the table
spec_flex.pprint_all()
# return the table
return_flex = spec_flex
return_flex[det] = spec_flex
# get and print the spatial flexure
if flexure_type == 'spat':
spat_flex = self[det].sci_spat_flexure
# print the value
print(f'Spat shift: {spat_flex}')
# return the value
return_flex = spat_flex
return_flex[det] = spat_flex

# TODO: Was this supposed to be a list for all detectors, or just the last detector?
return return_flex

2 changes: 1 addition & 1 deletion pypeit/specobjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ def get_extraction_groups(self, model_full_slit=False) -> List[List[int]]:

def flexure_diagnostics(self):
"""
Print the spectral or spatial flexure of a spec2d or spec1d file.
Print and return the spectral flexure of a spec1d file.
Returns:
:obj:`astropy.table.Table`: Table with the spectral flexure.
Expand Down

0 comments on commit 97c5950

Please sign in to comment.