Exploring matching quad patterns in arc line spectra


In [16]:
# imports
import json
import pdb 

import arclines
from arclines import io as arcl_io
from arclines.holy import patterns as arch_patt

from pypit import pyputils
msgs = pyputils.get_dummy_logger()
from pypit import arutils

LRISr -- R600/7500

Idealized as the loaded spectrum is the one used to generate the current line lists

We assume that the wavelength of a given feature is known to +/- 200 Ang


In [6]:
swv_uncertainty = 200.

Load


In [4]:
lrisr_file = arclines.__path__[0]+'/data/sources/lrisr_600_7500_PYPIT.json'
with open(lrisr_file,'r') as f:
    lrisr = json.load(f)

In [5]:
npix = len(lrisr['spec'])

Setup


In [26]:
# Wavelengths
def get_wave(pypit_fit):
    npix = len(pypit_fit['spec'])
    wave = arutils.func_val(pypit_fit['fitc'],
                        np.array(pypit_fit['tcent'])/(npix-1),
                        pypit_fit['function'],
                        minv=pypit_fit['fmin'], maxv=pypit_fit['fmax'])
    return wave

In [27]:
wave = get_wave(lrisr)

In [14]:
# Line list
reload(arcl_io)
llist = arcl_io.load_line_lists(['ArI','HgI','KrI','NeI','XeI'], unknown=True)

In [15]:
# Cut
gdwv = (llist['wave'] > 5400.) & (llist['wave'] < 9000.)
cut_llist = llist[gdwv]

In [18]:
wvdata = cut_llist['wave'].data
wvdata.sort()

Match


In [22]:
reload(arch_patt)
tcent = np.array(pypit_fit['tcent'])
nlin = tcent.size
# init
final_idx = {}
for ii in range(nlin):
    final_idx[ii] = []
#
for idx in range(nlin-4):
    # Setup
    spec_lines = np.array(tcent[idx:idx+4])
    wvmnx = [wave[idx]-swv_uncertainty, wave[idx]+swv_uncertainty]
    # Run
    #pdb.set_trace()
    matches = arch_patt.match_quad_to_list(spec_lines, wvdata, wvmnx, 1.6, tol=1)
    # Save
    for match in matches:
        for ii in range(4):
            final_idx[idx+ii].append(match[ii])

In [23]:
final_idx


Out[23]:
{0: [1],
 1: [2, 2],
 2: [3, 3, 3],
 3: [4, 4, 4, 4],
 4: [5, 5, 5, 5],
 5: [6, 6, 6, 6],
 6: [7, 7, 7, 7],
 7: [8, 8, 8, 8],
 8: [9, 9, 9, 9],
 9: [10, 10, 10, 10],
 10: [11, 11, 11, 11],
 11: [12, 12, 12, 12],
 12: [13, 13, 13, 13],
 13: [14, 14, 14, 14],
 14: [15, 15, 15, 15],
 15: [16, 16, 16, 16],
 16: [17, 17, 17, 17],
 17: [18, 18, 18, 18],
 18: [19, 19, 19, 19, 20, 21],
 19: [20, 20, 20, 21, 22, 19, 20, 21],
 20: [21, 21, 22, 23, 20, 21, 22, 19, 20, 21],
 21: [22, 23, 24, 21, 22, 23, 20, 21, 22, 22],
 22: [22, 23, 24, 21, 22, 23, 23, 23],
 23: [22, 23, 24, 24, 24, 24],
 24: [25, 25, 25, 25],
 25: [26, 26, 26, 26],
 26: [27, 27, 27, 27],
 27: [28, 28, 28, 28],
 28: [29, 29, 29, 29],
 29: [30, 30, 30, 30],
 30: [31, 31, 31, 31],
 31: [32, 32, 32, 32],
 32: [33, 33, 33, 33],
 33: [34, 34, 34, 34],
 34: [35, 35, 35, 35],
 35: [36, 36, 36, 36],
 36: [37, 37, 37, 37],
 37: [38, 38, 38, 38],
 38: [39, 39, 39, 39],
 39: [40, 40, 40, 40],
 40: [41, 41, 41, 41, 44],
 41: [42, 42, 42, 45, 42],
 42: [43, 43, 51, 43, 43],
 43: [44, 53, 44, 44, 44],
 44: [45, 45, 45, 45],
 45: [46, 46, 46, 46],
 46: [47, 47, 47, 47],
 47: [48, 48, 48, 48],
 48: [49, 49, 49, 44, 49],
 49: [50, 50, 46, 50, 50],
 50: [51, 47, 51, 51, 51],
 51: [49, 52, 52, 52, 52],
 52: [53, 53, 53, 53],
 53: [54, 54, 54, 54],
 54: [55, 55, 55, 55],
 55: [56, 56, 56, 56],
 56: [57, 57, 57, 57],
 57: [58, 58, 58, 58],
 58: [59, 59, 59, 59],
 59: [60, 60, 60, 60],
 60: [61, 61, 61, 61],
 61: [62, 62, 62, 62],
 62: [63, 63, 63, 63],
 63: [64, 64, 64, 64],
 64: [65, 65, 65, 65],
 65: [66, 66, 66, 66],
 66: [67, 67, 67, 67],
 67: [68, 68, 68, 68],
 68: [69, 69, 69, 69],
 69: [70, 70, 70, 70],
 70: [71, 71, 71, 71],
 71: [72, 72, 72, 64, 72],
 72: [73, 73, 66, 73, 73],
 73: [74, 67, 74, 74, 74],
 74: [68, 75, 75, 75, 75],
 75: [76, 76, 76, 76],
 76: [77, 77, 77, 77, 83],
 77: [78, 78, 78, 84, 78],
 78: [79, 79, 86, 79, 79],
 79: [80, 87, 80, 80, 80],
 80: [81, 81, 81, 81],
 81: [82, 82, 82, 82],
 82: [83, 83, 83, 78, 83],
 83: [84, 84, 80, 84, 84],
 84: [85, 81, 85, 85, 85],
 85: [82, 86, 86, 86, 86],
 86: [87, 87, 87, 87],
 87: [88, 88, 88, 88],
 88: [89, 89, 89],
 89: [90, 90],
 90: [91],
 91: []}

LRISb -- B600

Load


In [24]:
lrisb_file = arclines.__path__[0]+'/data/sources/lrisb_600_4000_PYPIT.json'
with open(lrisb_file,'r') as f:
    lrisb = json.load(f)

In [25]:
npix = len(lrisb['spec'])

Setup


In [28]:
wave = get_wave(lrisb)

In [30]:
# Line list
reload(arcl_io)
llist = arcl_io.load_line_lists(['CdI','HgI','ZnI'], unknown=True)

In [31]:
# Cut
gdwv = (llist['wave'] > 3000.) & (llist['wave'] < 5600.)
cut_llist = llist[gdwv]

In [32]:
wvdata = cut_llist['wave'].data
wvdata.sort()

Run


In [36]:
reload(arch_patt)
pypit_fit = lrisb
tcent = np.array(pypit_fit['tcent'])
nlin = tcent.size
# init
final_idx = {}
for ii in range(nlin):
    final_idx[ii] = []
#
for idx in range(nlin-4):
    # Setup
    spec_lines = np.array(tcent[idx:idx+4])
    wvmnx = [wave[idx]-swv_uncertainty, wave[idx]+swv_uncertainty]
    # Run
    #pdb.set_trace()
    matches = arch_patt.match_quad_to_list(spec_lines, wvdata, wvmnx, 1.26, tol=1)
    # Save
    for match in matches:
        for ii in range(4):
            final_idx[idx+ii].append(match[ii])

In [37]:
final_idx


Out[37]:
{0: [0],
 1: [1, 1],
 2: [2, 2],
 3: [3, 3],
 4: [4, 4],
 5: [5, 5],
 6: [6, 6, 6],
 7: [7, 7, 7],
 8: [8, 8, 8],
 9: [9, 9, 9],
 10: [10, 10, 10],
 11: [11, 11, 11, 11],
 12: [12, 12, 12, 12],
 13: [13, 13, 13],
 14: [14, 14],
 15: [15],
 16: []}

In [ ]: