py/prospect/utilities.py
def frames2spectra(frames, nspec=None, startspec=None, with_scores=False, with_resolution_data=False):
    """Convert list of frames into DESI Spectra object

    Parameters
    ----------
    frames : :class:`list`
        A list of :class:`~desispec.frame.Frame`.
    nspec : :class:`int`, optional
        No description provided.
    startspec : :class:`int`, optional
        If nspec is set, only spectra in range [startspec:nspec+startspec] are kept
    with_scores : :class:`bool`, optional
        If `True`, include merged scores from input frames
    with_resolution_data : :class:`bool`, optional
        If `True`, include frames.resolution_data

    Returns
    -------
    :class:`~desispec.spectra.Spectra`
        No description provided.
    """

    bands = list()
    wave = dict()
    flux = dict()
    ivar = dict()
    mask = dict()
    res = dict()

    for fr in frames:
        fibermap = fr.fibermap
        band = fr.meta['CAMERA'][0]
        bands.append(band)
        wave[band] = fr.wave
        flux[band] = fr.flux
        ivar[band] = fr.ivar
        mask[band] = fr.mask
        res[band] = fr.resolution_data
        if nspec is not None :
            if startspec is None : startspec = 0
            flux[band] = flux[band][startspec:nspec+startspec]
            ivar[band] = ivar[band][startspec:nspec+startspec]
            mask[band] = mask[band][startspec:nspec+startspec]
            res[band] = res[band][startspec:nspec+startspec,:,:]
            fibermap = fr.fibermap[startspec:nspec+startspec]

    merged_scores = None
    if with_scores :
        list_scores = []
        for i in range(len(frames)):
            #- This works for both ndarray and fits_REC input scores
            list_scores.append(Table(frames[i].scores))
        merged_scores = hstack(list_scores)

    if not with_resolution_data : res = None

    spectra = desispec.spectra.Spectra(
        bands, wave, flux, ivar, mask, fibermap=fibermap, meta=dict(fr.meta), scores=merged_scores, resolution_data=res
    )
    return spectra
Convert list of frames into DESI Spectra object

    Parameters
    ----------
    frames : :class:`list`
        A list of :class:`~desispec.frame.Frame`.
    nspec : :class:`int`, optional
        No description provided.
    startspec : :class:`int`, optional
        If nspec is set, only spectra in range [startspec:nspec+startspec] are kept
    with_scores : :class:`bool`, optional
        If `True`, include merged scores from input frames
    with_resolution_data : :class:`bool`, optional
        If `True`, include frames.resolution_data

    Returns
    -------
    :class:`~desispec.spectra.Spectra`
        No description provided.
    
Convert list of frames into DESI Spectra object
Parameters



Returns
Convert list of frames into DESI Spectra object Parameters Returns
def frames2spectra(frames, nspec=None, startspec=None, with_scores=False, with_resolution_data=False):
    bands = list()
    wave = dict()
    flux = dict()
    ivar = dict()
    mask = dict()
    res = dict()
    for fr in frames:
        fibermap = fr.fibermap
        band = fr.meta['CAMERA'][0]
        bands.append(band)
        wave[band] = fr.wave
        flux[band] = fr.flux
        ivar[band] = fr.ivar
        mask[band] = fr.mask
        res[band] = fr.resolution_data
        if nspec is not None :
            if startspec is None : startspec = 0
            flux[band] = flux[band][startspec:nspec+startspec]
            ivar[band] = ivar[band][startspec:nspec+startspec]
            mask[band] = mask[band][startspec:nspec+startspec]
            res[band] = res[band][startspec:nspec+startspec,:,:]
            fibermap = fr.fibermap[startspec:nspec+startspec]
    merged_scores = None
    if with_scores :
        list_scores = []
        for i in range(len(frames)):
            list_scores.append(Table(frames[i].scores))
        merged_scores = hstack(list_scores)
    if not with_resolution_data : res = None
    spectra = desispec.spectra.Spectra(
        bands, wave, flux, ivar, mask, fibermap=fibermap, meta=dict(fr.meta), scores=merged_scores, resolution_data=res
    )
    return spectra
def frames2spectra ( frames , nspec = None , startspec = None , with_scores = False , with_resolution_data = False ) : bands = list ( ) wave = dict ( ) flux = dict ( ) ivar = dict ( ) mask = dict ( ) res = dict ( ) for fr in frames : fibermap = fr . fibermap band = fr . meta [ 'CAMERA' ] [ 0 ] bands . append ( band ) wave [ band ] = fr . wave flux [ band ] = fr . flux ivar [ band ] = fr . ivar mask [ band ] = fr . mask res [ band ] = fr . resolution_data if nspec is not None : if startspec is None : startspec = 0 flux [ band ] = flux [ band ] [ startspec : nspec + startspec ] ivar [ band ] = ivar [ band ] [ startspec : nspec + startspec ] mask [ band ] = mask [ band ] [ startspec : nspec + startspec ] res [ band ] = res [ band ] [ startspec : nspec + startspec , : , : ] fibermap = fr . fibermap [ startspec : nspec + startspec ] merged_scores = None if with_scores : list_scores = [ ] for i in range ( len ( frames ) ) : list_scores . append ( Table ( frames [ i ] . scores ) ) merged_scores = hstack ( list_scores ) if not with_resolution_data : res = None spectra = desispec . spectra . Spectra ( bands , wave , flux , ivar , mask , fibermap = fibermap , meta = dict ( fr . meta ) , scores = merged_scores , resolution_data = res ) return spectra
Convert list of frames into DESI Spectra object
Parameters
Convert list of frames into DESI Spectra object Parameters
"""Convert list of frames into DESI Spectra object

    Parameters
    ----------
    frames : :class:`list`
        A list of :class:`~desispec.frame.Frame`.
    nspec : :class:`int`, optional
        No description provided.
    startspec : :class:`int`, optional
        If nspec is set, only spectra in range [startspec:nspec+startspec] are kept
    with_scores : :class:`bool`, optional
        If `True`, include merged scores from input frames
    with_resolution_data : :class:`bool`, optional
        If `True`, include frames.resolution_data

    Returns
    -------
    :class:`~desispec.spectra.Spectra`
        No description provided.
    """ #- This works for both ndarray and fits_REC input scores
frames
nspec
startspec
with_scores
with_resolution_data
class
`~desispec.spectra.Spectra`
No description provided.
` ~desispec . spectra . Spectra ` No description provided .