Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kbwestfall committed Aug 13, 2024
1 parent 320633c commit 717bd65
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 23 deletions.
6 changes: 3 additions & 3 deletions pypeit/core/findobj_skymask.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def ech_findobj_ineach_order(
Good-pixel mask for input image. Must have the same shape as
``image``. If None, all pixels in ``slitmask`` with non-negative
values are considered good.
std_trace (`astropy.table.Table`_:, optional):
std_trace (`astropy.table.Table`_, optional):
Table with the trace of the standard star on the input detector,
which is used as a crutch for tracing. The table has two columns:
`ECH_ORDER` and `TRACE_SPAT`. The shape of each row must be (nspec,).
Expand Down Expand Up @@ -489,7 +489,7 @@ def ech_fill_in_orders(sobjs:specobjs.SpecObjs,
``np.arange(norders)`` (but this is *not* recommended).
obj_id (`numpy.ndarray`_):
Object IDs of the objects linked together.
std_trace (`astropy.table.Table`_:, optional):
std_trace (`astropy.table.Table`_, optional):
Table with the trace of the standard star on the input detector,
which is used as a crutch for tracing. The table has two columns:
`ECH_ORDER` and `TRACE_SPAT`. The shape of each row must be (nspec,).
Expand Down Expand Up @@ -1136,7 +1136,7 @@ def ech_objfind(image, ivar, slitmask, slit_left, slit_righ, slit_spat_id, order
Plate scale in arcsec/pix. This can either be a single float for
every order, or an array with shape (norders,) providing the plate
scale of each order.
std_trace (`astropy.table.Table`_:, optional):
std_trace (`astropy.table.Table`_, optional):
Table with the trace of the standard star on the input detector,
which is used as a crutch for tracing. The table has two columns:
`ECH_ORDER` and `TRACE_SPAT`. The shape of each row must be (nspec,).
Expand Down
9 changes: 4 additions & 5 deletions pypeit/find_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

from pypeit import specobjs
from pypeit import msgs, utils
from pypeit import flatfield
from pypeit.display import display
from pypeit.core import skysub, qa, parse, flat, flexure
from pypeit.core import procimg
Expand Down Expand Up @@ -326,7 +325,7 @@ def run(self, std_trace=None, show_peaks=False, show_skysub_fit=False):
Parameters
----------
std_trace : `astropy.table.Table`_:, optional
std_trace : `astropy.table.Table`_, optional
Table with the trace of the standard star on the input detector,
which is used as a crutch for tracing. For MultiSlit reduction,
the table has a single column: `TRACE_SPAT`.
Expand Down Expand Up @@ -405,7 +404,7 @@ def find_objects(self, image, ivar, std_trace=None,
Image to search for objects from. This floating-point image has shape
(nspec, nspat) where the first dimension (nspec) is
spectral, and second dimension (nspat) is spatial.
std_trace : `astropy.table.Table`_:, optional
std_trace : `astropy.table.Table`_, optional
Table with the trace of the standard star on the input detector,
which is used as a crutch for tracing. For MultiSlit reduction,
the table has a single column: `TRACE_SPAT`.
Expand Down Expand Up @@ -731,7 +730,7 @@ def find_objects_pypeline(self, image, ivar, std_trace=None,
Image to search for objects from. This floating-point image has shape
(nspec, nspat) where the first dimension (nspec) is
spectral, and second dimension (nspat) is spatial.
std_trace : `astropy.table.Table`_:, optional
std_trace : `astropy.table.Table`_, optional
Table with the trace of the standard star on the input detector,
which is used as a crutch for tracing. For MultiSlit reduction,
the table has a single column: `TRACE_SPAT`.
Expand Down Expand Up @@ -886,7 +885,7 @@ def find_objects_pypeline(self, image, ivar, std_trace=None,
Image to search for objects from. This floating-point image has shape
(nspec, nspat) where the first dimension (nspec) is
spectral, and second dimension (nspat) is spatial.
std_trace : `astropy.table.Table`_:, optional
std_trace : `astropy.table.Table`_, optional
Table with the trace of the standard star on the input detector,
which is used as a crutch for tracing. For Echelle reduction,
the table has two columns: `ECH_ORDER` and `TRACE_SPAT`.
Expand Down
34 changes: 19 additions & 15 deletions pypeit/specobjs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1070,28 +1070,32 @@ def lst_to_array(lst, mask=None):
Allows for a list of Quantity objects
Args:
lst : list
lst (:obj:`list`):
Should be number or Quantities
mask (`numpy.ndarray`_, optional):
Boolean array used to limit to a subset of the list. True=good
Returns:
`numpy.ndarray`_, `astropy.units.Quantity`_: Converted list
"""
if mask is None:
mask = np.array([True]*len(lst))
_mask = np.ones(len(lst), dtype=bool) if mask is None else mask

# Return a Quantity array
if isinstance(lst[0], units.Quantity):
return units.Quantity(lst)[mask]
else:
# if all the elements of lst have the same type, np.array(lst)[mask] will work
if len(set(map(type, lst))) == 1:
return np.array(lst)[mask]
else:
# if not, we need to use dtype="object"
return np.array(lst, dtype="object")[mask]
# TODO: The dtype="object" is needed for the case where one element of lst is not a list but None.
# This would prevent the error "ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions..."
# However, this is may introduce other issues, where an array of objects creates problems in other parts of the code.
# I am using this workaround. Any suggestions/ideas?
return units.Quantity(lst)[_mask]

# If all the elements of lst have the same type, np.array(lst)[mask] will work
if len(set(map(type, lst))) == 1:
return np.array(lst)[_mask]

# Otherwise, we have to set the array type to object
return np.array(lst, dtype=object)[_mask]

# TODO: The dtype="object" is needed for the case where one element of lst
# is not a list but None. This would prevent the error "ValueError: setting
# an array element with a sequence. The requested array has an inhomogeneous
# shape after 1 dimensions..." However, this is may introduce other issues,
# where an array of objects creates problems in other parts of the code. I
# am using this workaround. Any suggestions/ideas?


0 comments on commit 717bd65

Please sign in to comment.