Пример #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 = arclines.__path__[0] + '/data/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']]
Пример #2
0
def init_line_list():
    """ Initialize a Table for a linelist
    Rigidly enforces table column formats
    Strings are the most annoying

    Returns
    -------
    init_tbl : Table
      One dummy row
    """
    # Get str lengths from defs
    len_line = defs.str_len()['ion']
    len_src = defs.str_len()['Source']
    # Load sources to check
    sources = arcl_io.load_source_table()
    src_files = sources['File'].data
    if len(src_files[0]) > len_src:
        raise ValueError(
            "Source filename now exceeds table.  Should fix source name")
    dummy_src = str('#') * len_src
    # Arc Line name
    dummy_line = str('#') * len_line
    #

    # Dict for Table
    idict = OrderedDict()
    idict['ion'] = dummy_line
    idict['wave'] = 0.
    idict['NIST'] = 0
    idict['Instr'] = 0  # Flag for instrument
    idict['amplitude'] = 0
    idict['Source'] = dummy_src

    # Table
    tkeys = idict.keys()
    lst = [[idict[tkey]] for tkey in tkeys]
    init_tbl = Table(lst, names=tkeys)

    # Return
    return init_tbl
Пример #3
0
def add_instr_source(line_tbl, instr, source_file):
    """
    Parameters
    ----------
    tbl
    instr
    source_file

    Returns
    -------
    Modified in place

    """
    str_len_dict = defs.str_len()
    # Add instrument flag
    line_tbl['Instr'] = defs.instruments()[instr]
    # Add source
    source = np.array([source_file] * len(line_tbl),
                      dtype='S{:d}'.format(str_len_dict['Source']))
    line_tbl['Source'] = source
Пример #4
0
import numpy as np
import json
import pdb

from astropy.table import Table

import arclines  # For path
src_path = arclines.__path__[0] + '/data/sources/'

from arclines import plots as arcl_plots
from arclines import utils as arcl_utils

# Hard-coded string lengths, and more
from arclines import defs
str_len_dict = defs.str_len()
instr_dict = defs.instruments()
line_dict = defs.lines()


def load(source, **kwargs):
    """
    Parameters
    ----------
    src_file
    format

    Returns
    -------

    """