Skip to content

Commit

Permalink
docstrings and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
rcooke-ast committed Oct 4, 2023
1 parent 3e43070 commit 8c53a1f
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 117 deletions.
229 changes: 126 additions & 103 deletions pypeit/coadd3d.py

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pypeit/core/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ def extract_hist_spectrum(waveimg, frame, gpm=None, bins=1000):
if waveimg.shape != _gpm.shape:
msgs.error("Wavelength image is not the same shape as the GPM")
# Set the bins
if type(bins) is int:
if isinstance(bins, int):
_bins = np.linspace(np.min(waveimg[_gpm]), np.max(waveimg[_gpm]), bins)
elif type(bins) is np.ndarray:
elif isinstance(bins, np.ndarray):
_bins = bins
else:
msgs.error("Argument 'bins' should be an integer or a numpy array")
Expand Down
6 changes: 3 additions & 3 deletions pypeit/inputfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,16 +796,16 @@ def options(self):
Dictionary containing cube options.
"""
# Define the list of allowed parameters
opts = dict(scale_corr=None, skysub_frame=None)
opts = dict(scale_corr=None, skysub_frame=None, ra_offset=None, dec_offset=None)

# Get the scale correction files
scale_corr = self.path_and_files('scale_corr', skip_blank=True)
scale_corr = self.path_and_files('scale_corr', skip_blank=False, check_exists=False)
if scale_corr is None:
opts['scale_corr'] = [None]*len(self.filenames)
elif len(scale_corr) == 1 and len(self.filenames) > 1:
opts['scale_corr'] = scale_corr.lower()*len(self.filenames)
elif len(scale_corr) != 0:
opts['scale_corr'] = scale_corr.lower()
opts['scale_corr'] = scale_corr

# Get the skysub files
skysub_frame = self.path_and_files('skysub_frame', skip_blank=False, check_exists=False)
Expand Down
10 changes: 2 additions & 8 deletions pypeit/par/pypeitpar.py
Original file line number Diff line number Diff line change
Expand Up @@ -1456,6 +1456,7 @@ def __init__(self, slit_spec=None, relative_weights=None, align=None, combine=No
'line map to register two frames.' \

defaults['method'] = "subpixel"
options['method'] = ["subpixel", "ngp"]
dtypes['method'] = str
descr['method'] = 'What method should be used to generate the datacube. There are currently two options: ' \
'(1) "subpixel" (default) - this algorithm divides each pixel in the spec2d frames ' \
Expand Down Expand Up @@ -1588,19 +1589,12 @@ def from_dict(cls, cfg):
return cls(**kwargs)

def validate(self):
# Check the method options
allowed_methods = ["subpixel", "ngp"]
if self.data['method'] not in allowed_methods:
# Check if the supplied name exists
if not os.path.exists(self.data['method']):
raise ValueError("The 'method' must be one of:\n"+", ".join(allowed_methods) +
"\nor, the relative path to a spec2d file.")
# Check the skysub options
allowed_skysub_options = ["none", "image", ""] # Note, "None" is treated as None which gets assigned to the default value "image".
if self.data['skysub_frame'] not in allowed_skysub_options:
# Check if the supplied name exists
if not os.path.exists(self.data['method']):
raise ValueError("The 'skysub_frame' must be one of:\n" + ", ".join(allowed_methods) +
raise ValueError("The 'skysub_frame' must be one of:\n" + ", ".join(allowed_skysub_options) +
"\nor, the relative path to a spec2d file.")
if len(self.data['whitelight_range']) != 2:
raise ValueError("The 'whitelight_range' must be a two element list of either NoneType or float")
Expand Down
9 changes: 8 additions & 1 deletion pypeit/scripts/coadd_datacube.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,16 @@ def main(args):
msgs.info("Restricting to detector={}".format(args.det))
parset['rdx']['detnum'] = int(args.det)

# Extract the options
ra_offsets = coadd3dfile.options['ra_offset']
dec_offsets = coadd3dfile.options['dec_offset']
skysub_frame = coadd3dfile.options['skysub_frame']
scale_corr = coadd3dfile.options['scale_corr']

# Instantiate CoAdd3d
tstart = time.time()
coadd = CoAdd3D.get_instance(coadd3dfile.filenames, coadd3dfile.options, spectrograph=spectrograph, par=parset,
coadd = CoAdd3D.get_instance(coadd3dfile.filenames, parset, skysub_frame=skysub_frame, scale_corr=scale_corr,
ra_offsets=ra_offsets, dec_offsets=dec_offsets, spectrograph=spectrograph,
det=args.det, overwrite=args.overwrite)

# Coadd the files
Expand Down
1 change: 1 addition & 0 deletions pypeit/slittrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ def get_radec_image(self, wcs, alignSplines, tilts, initial=True, flexure=None):
reference (usually the centre of the slit) and the edges of the
slits. Shape is (nslits, 2).
"""
msgs.info("Generating an RA/DEC image")
# Initialise the output
raimg = np.zeros((self.nspec, self.nspat))
decimg = np.zeros((self.nspec, self.nspat))
Expand Down

0 comments on commit 8c53a1f

Please sign in to comment.