Esempio n. 1
0
def load_by_hand():
    """ By-hand line list
    Parameters
    ----------
    line_file
    add_path

    Returns
    -------
    byhand : Table

    """
    str_len_dict = defs.str_len()

    src_file = resource_filename('pypeit', '/data/arc_lines/sources/by_hand_list.ascii')
    # Read
    line_list = Table.read(src_file, format='ascii.fixed_width', comment='#')
    # Add
    line_list['NIST'] = 1
    # Deal with Instr and Source
    ilist, slist = [], []
    for row in line_list:
        ilist.append(defs.instruments()[row['sInstr']])  # May need to split
        slist.append(row['sSource'])
    line_list['Instr'] = ilist
    line_list['Source'] = np.array(slist, dtype='S{:d}'.format(str_len_dict['Source']))
    # Trim
    return line_list[['ion', 'wave', 'NIST', 'Instr', 'amplitude', 'Source']]
Esempio n. 2
0
def load_line_lists(lamps,
                    unknown=False,
                    skip=False,
                    all=False,
                    NIST=False,
                    restrict_on_instr=None):
    """
    Loads a series of line list files

    Parameters
    ----------
    lamps : list
        List of arc lamps to be used for wavelength calibration.
        E.g., ['ArI','NeI','KrI','XeI']
    unknown : bool, optional
    skip : bool, optional
        Skip missing line lists (mainly for building)
    NIST : bool, optional
        Load the full NIST linelists
    restrict_on_instr : str, optional
        Restrict according to the input spectrograph

    Returns
    -------
    line_list : Table

    """
    # All?
    if all:
        line_files = glob.glob(os.path.join(data.Paths.linelist,
                                            '*_lines.dat'))
        lamps = []
        for line_file in line_files:
            i0 = line_file.rfind('/')
            i1 = line_file.rfind('_')
            lamps.append(line_file[i0 + 1:i1])

    msgs.info(f"Arc lamps used: {', '.join(lamps)}")
    # Read standard files
    lists = []
    for lamp in lamps:
        if NIST:
            line_file = os.path.join(data.Paths.nist, f'{lamp}_vacuum.ascii')
        else:
            line_file = os.path.join(data.Paths.linelist, f'{lamp}_lines.dat')
        if not os.path.isfile(line_file):
            if not skip:
                line_files = glob.glob(
                    os.path.join(data.Paths.linelist, '*_lines.dat'))
                all_list = [
                    os.path.split(ll)[1].replace("_lines.dat", "")
                    for ll in line_files
                ]
                msgs.warn(
                    "Input line {:s} is not included in arclines".format(lamp))
                msgs.info("Please choose from the following list:" +
                          msgs.newline() + ",".join(all_list))
                import pdb
                pdb.set_trace()
                raise IOError("Cannot continue without list")
        else:
            lists.append(load_line_list(line_file, NIST=NIST))
    # Stack
    if len(lists) == 0:
        return None
    line_lists = vstack(lists, join_type='exact')

    # Restrict on the spectrograph?
    if restrict_on_instr is not None:
        instr_dict = defs.instruments()
        gdI = (line_lists['Instr'] & instr_dict[restrict_on_instr]) > 0
        line_lists = line_lists[gdI]

    # Unknown
    if unknown:
        unkn_lines = load_unknown_list(lamps)
        unkn_lines.remove_column('line_flag')  # may wish to have this info
        # Stack
        line_lists = vstack([line_lists, unkn_lines])

    # Return
    return line_lists