Skip to content

Commit

Permalink
Merge branch 'develop' into slitless_flats
Browse files Browse the repository at this point in the history
  • Loading branch information
debora-pe committed Aug 19, 2024
2 parents 60a2eac + 754cb17 commit 5d653a1
Show file tree
Hide file tree
Showing 12 changed files with 1,137 additions and 984 deletions.
681 changes: 681 additions & 0 deletions deprecated/old_ech_objfind.py

Large diffs are not rendered by default.

18 changes: 12 additions & 6 deletions doc/releases/1.16.1dev.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ Dependency Changes
Functionality/Performance Improvements and Additions
----------------------------------------------------

- Added the possibility to decide if the extracted standard star spectrum should be
used as a crutch for tracing the object in the science frame (before it was done as default).
This is done by setting the parameter ``use_std_trace`` in FindObjPar.
- Now PypeIt can handle the case where "Standard star trace does not match the number of orders in the echelle data"
both in `run_pypeit` and in `pypeit_coadd_1dspec`.
- Added the functionality to use slitless flats to create pixelflats. Note: new frametype
`slitless_pixflat` is added to the PypeIt frametype list.
- The created pixelflats are stored in the reduction directory and in the PypeIt cache directory
Expand Down Expand Up @@ -47,15 +52,12 @@ Script Changes
- The sensitivity function is now generated outside of datacube generation.
- The `grating_corr` column is now used to select the correct grating
correction file for each spec2d file when generating the datacube.
- Added the ``--extr`` parameter in the ``pypeit_sensfunc`` script (also as a SensFuncPar)
to allow the user to specify the extraction method to use when computing the sensitivity
function (before only optimal extraction was used).
- Added ``pypeit_show_pixflat`` script to inspect the (slitless) pixel flat
generated during the reduction and stored in ``data/pixelflats``.

- A new script, called `pypeit_extract_datacube`, allows 1D spectra of point
sources to be extracted from datacubes.
- The sensitivity function is now generated outside of datacube generation.
- The `grating_corr` column is now used to select the correct grating
correction file for each spec2d file when generating the datacube.

Datamodel Changes
-----------------

Expand All @@ -77,6 +79,10 @@ Bug Fixes
- Fix a MAJOR BUT SUBTLE bug in the use of ``numpy.argsort``. When using ``numpy.argsort``
the parameter kind='stable' should be used to ensure that a sorting algorithm more robust
than "quicksort" is used.
- Fix error "ValueError: setting an array element with a sequence. The requested
array has an inhomogeneous shape after 1 dimensions..." occurring when unpacking
the SpecObj spectrum but having an attribute of the SpecObj object that is None.




25 changes: 13 additions & 12 deletions pypeit/coadd1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ def __init__(self, spec1dfiles, objids, spectrograph=None, par=None, sensfuncfil
super().__init__(spec1dfiles, objids, spectrograph=spectrograph, par=par, sensfuncfile=sensfuncfile,
setup_id=setup_id, debug=debug, show=show, chk_version=chk_version)


def load(self):
"""
Load the arrays we need for performing coadds.
Expand Down Expand Up @@ -461,8 +460,7 @@ def coadd(self):
lower=self.par['lower'], upper=self.par['upper'],
maxrej=self.par['maxrej'], sn_clip=self.par['sn_clip'],
debug=self.debug, show=self.show, show_exp=self.show)



return wave_grid_mid, wave_coadd, flux_coadd, ivar_coadd, gpm_coadd, order_stacks

def load_ech_arrays(self, spec1dfiles, objids, sensfuncfiles):
Expand All @@ -474,7 +472,7 @@ def load_ech_arrays(self, spec1dfiles, objids, sensfuncfiles):
List of spec1d files for this setup.
objids (list):
List of objids. This is aligned with spec1dfiles
sensfuncfile (list):
sensfuncfiles (list):
List of sensfuncfiles. This is aligned with spec1dfiles and objids
Returns:
Expand All @@ -488,14 +486,15 @@ def load_ech_arrays(self, spec1dfiles, objids, sensfuncfiles):
indx = sobjs.name_indices(objids[iexp])
if not np.any(indx):
msgs.error("No matching objects for {:s}. Odds are you input the wrong OBJID".format(objids[iexp]))
wave_iexp, flux_iexp, ivar_iexp, gpm_iexp, _, _, _, header = \
wave_iexp, flux_iexp, ivar_iexp, gpm_iexp, _, _, meta_spec, header = \
sobjs[indx].unpack_object(ret_flam=self.par['flux_value'], extract_type=self.par['ex_value'])
# This np.atleast2d hack deals with the situation where we are wave_iexp is actually Multislit data, i.e. we are treating
# it like an echelle spectrograph with a single order. This usage case arises when we want to use the
# echelle coadding code to combine echelle and multislit data
if wave_iexp.ndim == 1:
wave_iexp, flux_iexp, ivar_iexp, gpm_iexp = np.atleast_2d(wave_iexp).T, np.atleast_2d(flux_iexp).T, np.atleast_2d(ivar_iexp).T, np.atleast_2d(gpm_iexp).T
weights_sens_iexp = sensfunc.SensFunc.sensfunc_weights(sensfuncfiles[iexp], wave_iexp,
ech_order_vec=meta_spec['ECH_ORDERS'],
debug=self.debug,
chk_version=self.chk_version)
# Allocate arrays on first iteration
Expand All @@ -511,14 +510,18 @@ def load_ech_arrays(self, spec1dfiles, objids, sensfuncfiles):
header_out['RA_OBJ'] = sobjs[indx][0]['RA']
header_out['DEC_OBJ'] = sobjs[indx][0]['DEC']

# Store the information
waves[...,iexp], fluxes[...,iexp], ivars[..., iexp], gpms[...,iexp], weights_sens[...,iexp] \
= wave_iexp, flux_iexp, ivar_iexp, gpm_iexp, weights_sens_iexp

# TODO :: The error below can be removed if we refactor to use a list of numpy arrays. But, if we do that,
# we need to make several changes to the ech_combspec function.
try:
# Store the information
waves[...,iexp], fluxes[...,iexp], ivars[..., iexp], gpms[...,iexp], weights_sens[...,iexp] \
= wave_iexp, flux_iexp, ivar_iexp, gpm_iexp, weights_sens_iexp
except ValueError:
msgs.error('The shape (Nspec,Norder) of spectra is not consistent between exposures. '
'These spec1ds cannot be coadded at this time.')

return waves, fluxes, ivars, gpms, weights_sens, header_out


def load(self):
"""
Load the arrays we need for performing echelle coadds.
Expand Down Expand Up @@ -563,8 +566,6 @@ def load(self):
for c, l in zip(combined, loaded):
c.append(l)



return waves, fluxes, ivars, gpms, weights_sens, headers


Expand Down
Loading

0 comments on commit 5d653a1

Please sign in to comment.