In [11]:
from kbmodpy import kbmod as kb
import numpy as np
import matplotlib.pyplot as plt
import os
%matplotlib inline

In [12]:
def run_search(file_list, psf, flags, flag_except, master_flags,
               min_lh, min_obs, vel_x, vel_y, radius):
    
    stack = kb.image_stack([kb.layered_image(f) for f in file_list])
    stack.apply_mask_flags(flags, flag_except)
    stack.apply_master_mask(master_flags, 15)
    search = kb.stack_search(stack, psf)
    del(stack)
    search.set_debug(True)
    return search.region_search(vel_x, vel_y, radius, min_lh, min_obs)

In [13]:
def plot(img, lx, ux, ly, uy):
    fig = plt.figure(figsize=(12,12))
    plt.imshow(img[lx:ux,ly:uy], origin='lower',  vmin=-50, vmax=200)#cmap=plt.cm.Greys_r,
    plt.xlabel('X Pixels')
    plt.ylabel('Y Pixels')
    plt.colorbar()

In [14]:
path = '../../fraser/'

In [15]:
max_imgs = 35

In [16]:
files = os.listdir(path)
files = [f for f in files if 'chip' in f]
files.sort()
chip_list = []
for chip in files:
    current = []
    current = [path+chip+'/'+img for img
               in os.listdir(path+chip)][:max_imgs]
    current.sort()
    chip_list.append(current)

In [17]:
m_flags = ~0 # mask pixels with any flags
flag_exceptions = [32] # unless it has one of these special combinations of flags
mastr_flags = int('100111', 2)

In [18]:
x_v, y_v = 230, 90
rad = 50
minlh = 60.0
minobs = 22

In [19]:
res = run_search(chip_list[5], kb.psf(1.2),
    m_flags, flag_exceptions, mastr_flags, minlh, minobs,
    x_v, y_v, rad)

In [20]:
res


Out[20]:
[ix: 123.000000 iy: 167.000000 fx: 122.000000 fy: 199.000000 depth: 0 obs_count: 23 lh: 88.671425 flux 3590.856934,
 ix: 135.000000 iy: 1980.000000 fx: 141.000000 fy: 1954.000000 depth: 0 obs_count: 22 lh: 68.053940 flux 2869.772461,
 ix: 109.000000 iy: 1951.000000 fx: 107.000000 fy: 1954.000000 depth: 0 obs_count: 35 lh: 65.078461 flux 2133.612549,
 ix: 76.000000 iy: 1918.000000 fx: 121.000000 fy: 1958.000000 depth: 0 obs_count: 22 lh: 65.248146 flux 2684.584473,
 ix: 67.000000 iy: 1903.000000 fx: 134.000000 fy: 1959.000000 depth: 0 obs_count: 22 lh: 65.116035 flux 2744.058105,
 ix: 182.000000 iy: 1952.000000 fx: 178.000000 fy: 1957.000000 depth: 0 obs_count: 35 lh: 63.749146 flux 2086.584961]

In [ ]:


In [ ]: