In [3]:
from astropy.io import fits
import math
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import os
import subprocess
from sklearn.cluster import DBSCAN
from analyzeImage import analyzeImage
import keras
from keras.models import load_model
from __future__ import print_function


Using TensorFlow backend.

In [1]:
gpu_code_path = "../code/gpu/"
real_image_name = "chip_7"
real_image_path = "../../bryce_samples" #gpu_code_path+"images/"+real_image_name
psi_image_path = gpu_code_path+"output-images/psi"
phi_image_path = gpu_code_path+"output-images/phi"

In [200]:
def execute(cmd):
    popen = subprocess.Popen(cmd, stdout=subprocess.PIPE, universal_newlines=True)
    for stdout_line in iter(popen.stdout.readline, ""):
        yield stdout_line 
    popen.stdout.close()
    return_code = popen.wait()
    if return_code:
        raise subprocess.CalledProcessError(return_code, cmd)

In [306]:
paramsFile = open('../code/gpu/debug/parameters.config', 'w')
paramsFile.write(
"""Debug ................ : 1
Image Count .......... : 5
Generate Images ...... : 0
Image Width .......... : 500
Image Height ......... : 500
PSF Sigma ............ : 1.0
Object Brightness .... : 360.0
Object Initial x ..... : 320.0
Object Initial y ..... : 180.0
Velocity x ........... : -1.3
Velocity y ........... : -0.2
Background Level ..... : 1024.0
Background Sigma ..... : 32.0
Mask Threshold ....... : 40.0
Mask Penalty ......... : 15.0
Angles to Search ..... : 80
Velocities to Search . : 20
Minimum Velocity ..... : 300
Maximum Velocity ..... : 450
Write to file ........ : 1
Source Images Path ... : ../../{source}/
Psi Images Path ...... : ../../{psi}/
Phi Images Path....... : ../../{phi}/
""".format( source=real_image_path, psi=psi_image_path, phi=phi_image_path ))
paramsFile.close()

In [202]:
popen = subprocess.Popen( "./clearImages.sh", stdout=subprocess.PIPE, 
                         stderr=subprocess.PIPE)
popen.wait()
output = popen.stderr.read()
output += popen.stdout.read()
print( output)




In [203]:
for path in execute("./search.sh"):
    print(path, end="")


Image Count ..........  : 5
Generate Images ......  : 0
Image Width ..........  : 500
Image Height .........  : 500
PSF Sigma ............  : 1.0
Object Brightness ....  : 360.0
Object Initial x .....  : 320.0
Object Initial y .....  : 180.0
Velocity x ...........  : -1.3
Velocity y ...........  : -0.2
Background Level .....  : 1024.0
Background Sigma .....  : 32.0
Mask Threshold .......  : 40.0
Mask Penalty .........  : -0.012
Angles to Search .....  : 120
Velocities to Search .  : 40
Minimum Velocity .....  : 320
Maximum Velocity .....  : 550
Write to file ........  : 1
Source Images Path ...  : ../../../code/gpu/images/chip_7/
Psi Images Path ......  : ../../../code/gpu/output-images/psi/
Phi Images Path.......  : ../../../code/gpu/output-images/phi/
Using Kernel Size 5X5
| 0.004 | 0.015 | 0.023 | 0.015 | 0.004 | 
 ---------------------------------------
| 0.015 | 0.058 | 0.093 | 0.058 | 0.015 | 
 ---------------------------------------
| 0.023 | 0.093 | 0.147 | 0.093 | 0.023 | 
 ---------------------------------------
| 0.015 | 0.058 | 0.093 | 0.058 | 0.015 | 
 ---------------------------------------
| 0.004 | 0.015 | 0.023 | 0.015 | 0.004 | 
 ---------------------------------------
97.532% of PSF contained within kernel
Reading 55 images from ../../../code/gpu/images/chip_7/

Image times: 0.000 0.003 0.006 0.009 0.012 0.015 0.018 0.021 0.024 0.027 0.030 0.033 0.036 0.040 0.043 0.046 0.049 0.052 0.055 0.058 0.061 0.064 0.067 0.070 0.073 0.076 0.079 0.082 0.085 0.088 0.091 0.094 0.097 0.100 0.103 0.106 0.109 0.112 0.115 0.118 0.122 0.125 0.128 0.131 0.134 0.137 0.140 0.143 0.146 0.149 0.152 0.155 0.158 0.161 0.164 
Masking images ... Done.
Creating Psi and Phi ... Done. Took 218.657 ms per image
Creating interleaved psi/phi buffer ... Done.
Padding 112 pixels around edges.
Searching 4800 possible trajectories starting from 7713024 pixels... 
 1. Likelihood: 6.584 at x: 682, y: 2016  and velocity x: -0.000, y: -320.000 Est. Flux: 607.221
 2. Likelihood: 6.521 at x: 1571, y: 599  and velocity x: 368.531, y: 141.466 Est. Flux: 552.856
 3. Likelihood: 6.350 at x: 1572, y: 600  and velocity x: 357.795, y: 137.345 Est. Flux: 538.770
 4. Likelihood: 6.348 at x: 682, y: 1234  and velocity x: -0.000, y: -463.750 Est. Flux: 586.430
 5. Likelihood: 6.312 at x: 1571, y: 600  and velocity x: 363.163, y: 139.405 Est. Flux: 535.053
 6. Likelihood: 6.308 at x: 682, y: 2015  and velocity x: -0.000, y: -320.000 Est. Flux: 583.276
 7. Likelihood: 6.254 at x: 682, y: 2018  and velocity x: -0.000, y: -331.500 Est. Flux: 578.023
 8. Likelihood: 6.250 at x: 1570, y: 599  and velocity x: 373.899, y: 143.526 Est. Flux: 529.489
 9. Likelihood: 6.250 at x: 682, y: 2017  and velocity x: -0.000, y: -331.500 Est. Flux: 578.646
10. Likelihood: 6.245 at x: 682, y: 1133  and velocity x: 0.000, y: 337.250 Est. Flux: 546.319
11. Likelihood: 6.225 at x: 682, y: 1132  and velocity x: 0.000, y: 343.000 Est. Flux: 545.832
12. Likelihood: 6.216 at x: 682, y: 1134  and velocity x: 0.000, y: 325.750 Est. Flux: 542.196
13. Likelihood: 6.210 at x: 682, y: 1129  and velocity x: 0.000, y: 320.000 Est. Flux: 534.128
14. Likelihood: 6.191 at x: 682, y: 1128  and velocity x: 0.000, y: 331.500 Est. Flux: 532.999
15. Likelihood: 6.175 at x: 682, y: 1130  and velocity x: 0.000, y: 320.000 Est. Flux: 532.029
Took 244.240 seconds to complete search.
Writing images to file... Done.

In [5]:
raw_results = np.genfromtxt('../data/results/bryce_images.txt', names=True)

In [262]:
image_mjd = []

for filename in sorted(os.listdir(real_image_path)):
    hdulist = fits.open(os.path.join(real_image_path, filename))
    image_mjd.append(hdulist[0].header['MJD'])

image_mjd = np.array(image_mjd)
image_times = image_mjd - image_mjd[0]
#image_times*=24.

Load Psi Images


In [308]:
hdulist = fits.open(os.path.join(psi_image_path, os.listdir(psi_image_path)[0]))
num_images = len(os.listdir(psi_image_path))
image_shape = np.shape(hdulist[0].data)
im_psi_array = np.zeros((num_images, image_shape[0], image_shape[1]))

for idx, filename in list(enumerate(sorted(os.listdir(psi_image_path)))):

    #print (str('Loaded ' + filename))

    image_file = os.path.join(psi_image_path, filename)
    hdulist = fits.open(image_file)
    im_psi_array[idx] = hdulist[0].data#*mask

Load Phi Images (for potentially making psi/phi stamps)


In [264]:
hdulist = fits.open(os.path.join(phi_image_path, os.listdir(phi_image_path)[0]))
num_images = len(os.listdir(phi_image_path))
image_shape = np.shape(hdulist[0].data)
im_phi_array = np.zeros((num_images, image_shape[0], image_shape[1]))

for idx, filename in list(enumerate(sorted(os.listdir(phi_image_path)))):

   # print (str('Loaded ' + filename))

    image_file = os.path.join(phi_image_path, filename)
    hdulist = fits.open(image_file)
    im_phi_array[idx] = hdulist[0].data#*mask

In [265]:
hdulist = fits.open(os.path.join(real_image_path, os.listdir(real_image_path)[0]))
num_images = len(os.listdir(real_image_path))
image_shape = np.shape(hdulist[1].data)
im_array = np.zeros((num_images, image_shape[0], image_shape[1]))


for idx, filename in list(enumerate(sorted(os.listdir(real_image_path)))):

   # print( str('Loaded ' + filename))

    image_file = os.path.join(real_image_path, filename)
    hdulist = fits.open(image_file)
    im_array[idx] = hdulist[1].data#*mask

In [249]:
ai = analyzeImage()

In [250]:
model = load_model('../data/kbmod_model.h5')

In [314]:
results = raw_results[0:8000]
results


Out[314]:
array([(685.0, 2341.0, 0.0, 0.0, 24.126, 306.552, 3.246, 3025.267),
       (685.0, 2652.0, 0.0, 0.0, 24.126, 306.552, 3.326, 2937.714),
       (685.0, 2957.0, 0.0, 0.0, 23.538, -299.075, 3.339, 2920.109), ...,
       (1361.0, 1140.0, 0.0, 0.0, -326.135, 199.856, 4.307, 2148.091),
       (1355.0, 1172.0, 0.0, 0.0, 89.293, -371.932, 4.306, 2151.555),
       (716.0, 2003.0, 0.0, 0.0, 0.0, 315.0, 4.306, 2411.753)], 
      dtype=[('t0_x', '<f8'), ('t0_y', '<f8'), ('theta_par', '<f8'), ('theta_perp', '<f8'), ('v_x', '<f8'), ('v_y', '<f8'), ('likelihood', '<f8'), ('est_flux', '<f8')])

In [301]:
filtered_results = ai.filter_results(im_array, results, image_times, model, chunk_size=2000)


Finished chunk 1 of 1

In [302]:
print( len(filtered_results) )
filtered_results


361
Out[302]:
array([(632.0, 1982.0, 0.0, 0.0, -27.628, -439.132, 3.274, 3490.778),
       (633.0, 1942.0, 0.0, 0.0, -37.6, -297.634, 3.277, 3525.271),
       (633.0, 2259.0, 0.0, 0.0, -48.253, -381.964, 3.28, 3492.125),
       (633.0, 2257.0, 0.0, 0.0, -46.373, -367.082, 3.281, 3849.504),
       (633.0, 2258.0, 0.0, 0.0, -46.373, -367.082, 3.289, 3814.398),
       (632.0, 2195.0, 0.0, 0.0, -37.6, 297.634, 3.298, 3341.125),
       (633.0, 2268.0, 0.0, 0.0, -45.747, -362.122, 3.299, 3533.769),
       (634.0, 2293.0, 0.0, 0.0, -55.147, -436.53, 3.307, 3490.382),
       (634.0, 2275.0, 0.0, 0.0, -55.773, -441.491, 3.308, 4010.713),
       (632.0, 1983.0, 0.0, 0.0, -27.628, -439.132, 3.313, 3593.826),
       (632.0, 1987.0, 0.0, 0.0, -27.628, -439.132, 3.314, 3860.664),
       (632.0, 1984.0, 0.0, 0.0, -27.628, -439.132, 3.314, 3645.711),
       (634.0, 2294.0, 0.0, 0.0, -55.773, -441.491, 3.316, 3482.873),
       (633.0, 2269.0, 0.0, 0.0, -45.747, -362.122, 3.32, 3511.671),
       (632.0, 1981.0, 0.0, 0.0, -27.628, -439.132, 3.327, 3486.206),
       (633.0, 2260.0, 0.0, 0.0, -48.253, -381.964, 3.329, 3493.777),
       (634.0, 2295.0, 0.0, 0.0, -55.773, -441.491, 3.336, 3481.197),
       (632.0, 2192.0, 0.0, 0.0, -38.227, 302.595, 3.337, 3335.307),
       (633.0, 1911.0, 0.0, 0.0, -42.613, 337.319, 3.344, 3576.434),
       (634.0, 2276.0, 0.0, 0.0, -55.773, -441.491, 3.346, 4011.501),
       (632.0, 2193.0, 0.0, 0.0, -38.227, 302.595, 3.347, 3318.477),
       (633.0, 2264.0, 0.0, 0.0, -48.253, -381.964, 3.348, 3465.219),
       (633.0, 2256.0, 0.0, 0.0, -46.373, -367.082, 3.352, 3977.911),
       (632.0, 1980.0, 0.0, 0.0, -27.942, -444.122, 3.359, 3478.743),
       (632.0, 1979.0, 0.0, 0.0, -26.372, -419.171, 3.36, 3788.672),
       (632.0, 1988.0, 0.0, 0.0, -27.942, -444.122, 3.362, 3976.134),
       (632.0, 2194.0, 0.0, 0.0, -38.227, 302.595, 3.362, 3313.285),
       (633.0, 2263.0, 0.0, 0.0, -48.253, -381.964, 3.362, 3476.691),
       (633.0, 2271.0, 0.0, 0.0, -45.747, -362.122, 3.362, 3501.434),
       (634.0, 2296.0, 0.0, 0.0, -55.773, -441.491, 3.366, 3485.651),
       (633.0, 2261.0, 0.0, 0.0, -48.253, -381.964, 3.368, 3494.965),
       (633.0, 2272.0, 0.0, 0.0, -45.747, -362.122, 3.369, 3497.645),
       (633.0, 1941.0, 0.0, 0.0, -37.6, -297.634, 3.369, 3645.911),
       (633.0, 2253.0, 0.0, 0.0, -48.253, -381.964, 3.37, 3813.514),
       (632.0, 1986.0, 0.0, 0.0, -27.628, -439.132, 3.371, 3831.709),
       (633.0, 2273.0, 0.0, 0.0, -45.747, -362.122, 3.372, 3492.135),
       (634.0, 2274.0, 0.0, 0.0, -55.773, -441.491, 3.374, 4127.276),
       (633.0, 1912.0, 0.0, 0.0, -42.613, 337.319, 3.374, 3606.897),
       (633.0, 2262.0, 0.0, 0.0, -48.253, -381.964, 3.377, 3487.989),
       (633.0, 2254.0, 0.0, 0.0, -48.253, -381.964, 3.379, 3801.585),
       (633.0, 2274.0, 0.0, 0.0, -45.747, -362.122, 3.382, 3489.81),
       (633.0, 1966.0, 0.0, 0.0, -38.227, -302.595, 3.387, 3875.453),
       (634.0, 2271.0, 0.0, 0.0, -57.151, -299.598, 3.387, 3552.636),
       (633.0, 2270.0, 0.0, 0.0, -46.373, -367.082, 3.388, 3486.061),
       (633.0, 2275.0, 0.0, 0.0, -45.747, -362.122, 3.389, 3478.866),
       (632.0, 2199.0, 0.0, 0.0, -37.6, 297.634, 3.39, 3340.842),
       (634.0, 2283.0, 0.0, 0.0, -57.151, -299.598, 3.391, 3443.67),
       (632.0, 2200.0, 0.0, 0.0, -37.6, 297.634, 3.393, 3317.987),
       (633.0, 2240.0, 0.0, 0.0, -42.613, 337.319, 3.393, 3337.007),
       (632.0, 2197.0, 0.0, 0.0, -37.6, 297.634, 3.394, 3396.314),
       (633.0, 2255.0, 0.0, 0.0, -48.253, -381.964, 3.394, 3788.221),
       (632.0, 1985.0, 0.0, 0.0, -27.628, -439.132, 3.395, 3786.579),
       (633.0, 1922.0, 0.0, 0.0, -43.867, 347.24, 3.397, 3722.569),
       (633.0, 1932.0, 0.0, 0.0, -47.0, 372.043, 3.398, 3702.685),
       (633.0, 2239.0, 0.0, 0.0, -42.613, 337.319, 3.4, 3361.098),
       (634.0, 2272.0, 0.0, 0.0, -57.151, -299.598, 3.402, 3539.193),
       (633.0, 1913.0, 0.0, 0.0, -42.613, 337.319, 3.403, 3633.694),
       (632.0, 1978.0, 0.0, 0.0, -26.372, -419.171, 3.403, 3772.206),
       (633.0, 2266.0, 0.0, 0.0, -45.747, -362.122, 3.403, 3769.927),
       (633.0, 2281.0, 0.0, 0.0, -44.493, -352.201, 3.404, 3606.549),
       (633.0, 2276.0, 0.0, 0.0, -45.747, -362.122, 3.405, 3469.743),
       (632.0, 2002.0, 0.0, 0.0, -37.6, -297.634, 3.406, 3661.243),
       (634.0, 2285.0, 0.0, 0.0, -55.773, -441.491, 3.406, 3784.047),
       (634.0, 2270.0, 0.0, 0.0, -56.214, -294.686, 3.406, 3729.104),
       (632.0, 2198.0, 0.0, 0.0, -37.6, 297.634, 3.406, 3383.234),
       (633.0, 1933.0, 0.0, 0.0, -45.747, 362.122, 3.407, 3843.431),
       (634.0, 2282.0, 0.0, 0.0, -57.151, -299.598, 3.407, 3463.073),
       (632.0, 2001.0, 0.0, 0.0, -37.6, -297.634, 3.408, 3676.639),
       (634.0, 2284.0, 0.0, 0.0, -55.147, -436.53, 3.408, 3789.204),
       (633.0, 2280.0, 0.0, 0.0, -44.493, -352.201, 3.409, 3612.066),
       (633.0, 2282.0, 0.0, 0.0, -44.493, -352.201, 3.41, 3607.155),
       (633.0, 2236.0, 0.0, 0.0, -42.613, 337.319, 3.412, 3477.335),
       (633.0, 1965.0, 0.0, 0.0, -38.227, -302.595, 3.415, 3831.646),
       (633.0, 1921.0, 0.0, 0.0, -43.867, 347.24, 3.416, 3694.24),
       (634.0, 2297.0, 0.0, 0.0, -55.773, -441.491, 3.418, 3507.46),
       (632.0, 2196.0, 0.0, 0.0, -37.6, 297.634, 3.42, 3445.118),
       (633.0, 2241.0, 0.0, 0.0, -42.613, 337.319, 3.42, 3340.636),
       (632.0, 2201.0, 0.0, 0.0, -37.6, 297.634, 3.421, 3318.589),
       (634.0, 2292.0, 0.0, 0.0, -55.147, -436.53, 3.422, 3628.873),
       (633.0, 2283.0, 0.0, 0.0, -44.493, -352.201, 3.422, 3606.456),
       (633.0, 2234.0, 0.0, 0.0, -44.493, 352.201, 3.423, 3268.425),
       (634.0, 2280.0, 0.0, 0.0, -57.151, -299.598, 3.424, 3499.397),
       (633.0, 2267.0, 0.0, 0.0, -45.747, -362.122, 3.428, 3729.624),
       (633.0, 2265.0, 0.0, 0.0, -48.88, -386.925, 3.43, 3459.001),
       (633.0, 2235.0, 0.0, 0.0, -43.867, 347.24, 3.431, 3382.787),
       (634.0, 2273.0, 0.0, 0.0, -59.025, -309.42, 3.431, 3316.065),
       (633.0, 2277.0, 0.0, 0.0, -45.747, -362.122, 3.432, 3466.61),
       (634.0, 2302.0, 0.0, 0.0, -53.267, -421.649, 3.432, 3811.01),
       (633.0, 1920.0, 0.0, 0.0, -44.493, 352.201, 3.433, 3549.915),
       (634.0, 2291.0, 0.0, 0.0, -55.147, -436.53, 3.433, 3657.793),
       (634.0, 2301.0, 0.0, 0.0, -53.267, -421.649, 3.433, 3832.708),
       (633.0, 2284.0, 0.0, 0.0, -44.493, -352.201, 3.436, 3596.53),
       (634.0, 2303.0, 0.0, 0.0, -53.267, -421.649, 3.437, 3788.257),
       (633.0, 1910.0, 0.0, 0.0, -42.613, 337.319, 3.44, 3657.826),
       (633.0, 2252.0, 0.0, 0.0, -48.253, -381.964, 3.44, 3912.062),
       (633.0, 2250.0, 0.0, 0.0, -48.253, -381.964, 3.441, 3937.282),
       (633.0, 2251.0, 0.0, 0.0, -48.253, -381.964, 3.441, 3928.058),
       (633.0, 1931.0, 0.0, 0.0, -47.0, 372.043, 3.442, 3750.854),
       (633.0, 1914.0, 0.0, 0.0, -41.36, 327.398, 3.443, 3775.72),
       (633.0, 1937.0, 0.0, 0.0, -47.627, 377.004, 3.445, 3659.614),
       (633.0, 2237.0, 0.0, 0.0, -42.613, 337.319, 3.445, 3467.31),
       (632.0, 2210.0, 0.0, 0.0, -37.6, 297.634, 3.446, 3244.574),
       (632.0, 2209.0, 0.0, 0.0, -37.6, 297.634, 3.447, 3259.527),
       (633.0, 1964.0, 0.0, 0.0, -38.227, -302.595, 3.449, 3804.673),
       (634.0, 2279.0, 0.0, 0.0, -56.214, -294.686, 3.449, 3663.346),
       (633.0, 1936.0, 0.0, 0.0, -47.627, 377.004, 3.45, 3645.195),
       (633.0, 2242.0, 0.0, 0.0, -42.613, 337.319, 3.451, 3341.51),
       (633.0, 2244.0, 0.0, 0.0, -42.613, 337.319, 3.451, 3296.862),
       (633.0, 2278.0, 0.0, 0.0, -45.747, -362.122, 3.452, 3460.272),
       (632.0, 2191.0, 0.0, 0.0, -39.48, 312.516, 3.453, 3271.81),
       (634.0, 2298.0, 0.0, 0.0, -55.773, -441.491, 3.453, 3512.187),
       (634.0, 2278.0, 0.0, 0.0, -57.151, -299.598, 3.453, 3545.31),
       (634.0, 2281.0, 0.0, 0.0, -57.151, -299.598, 3.455, 3519.387),
       (633.0, 2243.0, 0.0, 0.0, -42.613, 337.319, 3.457, 3321.545),
       (633.0, 2279.0, 0.0, 0.0, -45.747, -362.122, 3.459, 3449.094),
       (633.0, 1943.0, 0.0, 0.0, -38.227, -302.595, 3.461, 3647.636),
       (634.0, 2304.0, 0.0, 0.0, -53.267, -421.649, 3.46, 3767.963),
       (633.0, 2238.0, 0.0, 0.0, -43.867, 347.24, 3.461, 3309.117),
       (634.0, 2300.0, 0.0, 0.0, -55.147, -436.53, 3.461, 3465.532),
       (633.0, 2288.0, 0.0, 0.0, -44.493, -352.201, 3.462, 3567.843),
       (632.0, 2211.0, 0.0, 0.0, -37.6, 297.634, 3.462, 3240.676),
       (632.0, 1973.0, 0.0, 0.0, -27.942, -444.122, 3.463, 3562.898),
       (633.0, 2287.0, 0.0, 0.0, -44.493, -352.201, 3.464, 3572.321),
       (632.0, 2208.0, 0.0, 0.0, -37.6, 297.634, 3.464, 3284.274),
       (633.0, 2285.0, 0.0, 0.0, -44.493, -352.201, 3.465, 3597.352),
       (633.0, 2289.0, 0.0, 0.0, -44.493, -352.201, 3.465, 3557.033),
       (634.0, 2277.0, 0.0, 0.0, -55.773, -441.491, 3.466, 4101.749),
       (633.0, 1963.0, 0.0, 0.0, -38.227, -302.595, 3.467, 3773.466),
       (633.0, 1919.0, 0.0, 0.0, -42.613, 337.319, 3.468, 3860.296),
       (633.0, 1903.0, 0.0, 0.0, -40.107, 317.477, 3.469, 3864.227),
       (634.0, 2286.0, 0.0, 0.0, -55.773, -441.491, 3.469, 3847.412),
       (632.0, 1972.0, 0.0, 0.0, -27.628, -439.132, 3.47, 3539.931),
       (633.0, 1930.0, 0.0, 0.0, -47.0, 372.043, 3.47, 3744.086),
       (633.0, 1923.0, 0.0, 0.0, -42.613, 337.319, 3.471, 4028.829),
       (634.0, 2288.0, 0.0, 0.0, -55.147, -436.53, 3.473, 3776.617),
       (634.0, 2289.0, 0.0, 0.0, -55.773, -441.491, 3.473, 3767.949),
       (633.0, 2286.0, 0.0, 0.0, -44.493, -352.201, 3.474, 3588.012),
       (633.0, 1935.0, 0.0, 0.0, -47.627, 377.004, 3.478, 3644.081),
       (634.0, 2299.0, 0.0, 0.0, -53.267, -421.649, 3.481, 3936.967),
       (632.0, 2003.0, 0.0, 0.0, -38.227, -302.595, 3.481, 3604.846),
       (634.0, 2305.0, 0.0, 0.0, -55.147, -436.53, 3.482, 3401.736),
       (632.0, 1989.0, 0.0, 0.0, -27.628, -439.132, 3.484, 4246.086),
       (633.0, 1909.0, 0.0, 0.0, -42.613, 337.319, 3.486, 3661.309),
       (633.0, 1962.0, 0.0, 0.0, -38.227, -302.595, 3.486, 3763.982),
       (633.0, 1908.0, 0.0, 0.0, -41.987, 332.358, 3.487, 3708.311),
       (633.0, 1918.0, 0.0, 0.0, -42.613, 337.319, 3.487, 3862.65),
       (1571.0, 599.0, 0.0, 0.0, 367.262, 145.409, 3.489, 1835.07),
       (632.0, 1990.0, 0.0, 0.0, -27.942, -444.122, 3.491, 4262.83),
       (633.0, 2290.0, 0.0, 0.0, -44.493, -352.201, 3.492, 3553.757),
       (634.0, 2269.0, 0.0, 0.0, -57.151, -299.598, 3.492, 3725.103),
       (633.0, 1915.0, 0.0, 0.0, -44.493, 352.201, 3.493, 3501.877),
       (632.0, 2207.0, 0.0, 0.0, -37.6, 297.634, 3.493, 3312.427),
       (632.0, 1971.0, 0.0, 0.0, -27.314, -434.142, 3.494, 3697.267),
       (633.0, 2245.0, 0.0, 0.0, -50.133, -396.846, 3.497, 3936.469),
       (633.0, 1904.0, 0.0, 0.0, -39.48, 312.516, 3.498, 4011.264),
       (632.0, 1965.0, 0.0, 0.0, -27.314, -434.142, 3.499, 3547.122),
       (633.0, 1934.0, 0.0, 0.0, -47.627, 377.004, 3.5, 3635.209),
       (633.0, 2229.0, 0.0, 0.0, -42.613, 337.319, 3.5, 3893.819),
       (632.0, 2202.0, 0.0, 0.0, -37.6, 297.634, 3.505, 3372.485),
       (634.0, 2306.0, 0.0, 0.0, -55.773, -441.491, 3.507, 3405.038),
       (632.0, 1943.0, 0.0, 0.0, -38.227, 302.595, 3.511, 3389.989),
       (633.0, 1978.0, 0.0, 0.0, -41.36, -327.398, 3.511, 3920.552),
       (633.0, 1979.0, 0.0, 0.0, -41.987, -332.358, 3.512, 3925.057),
       (633.0, 2232.0, 0.0, 0.0, -42.613, 337.319, 3.514, 3749.655),
       (633.0, 1977.0, 0.0, 0.0, -41.36, -327.398, 3.515, 3905.243),
       (634.0, 2290.0, 0.0, 0.0, -53.267, -421.649, 3.515, 4272.812),
       (634.0, 2287.0, 0.0, 0.0, -55.773, -441.491, 3.516, 3882.687),
       (633.0, 2222.0, 0.0, 0.0, -42.613, 337.319, 3.518, 4093.697),
       (632.0, 2212.0, 0.0, 0.0, -37.6, 297.634, 3.52, 3270.925),
       (632.0, 1977.0, 0.0, 0.0, -26.372, -419.171, 3.522, 3861.988),
       (633.0, 2230.0, 0.0, 0.0, -41.36, 327.398, 3.523, 4079.721),
       (633.0, 2249.0, 0.0, 0.0, -48.253, -381.964, 3.524, 4039.326),
       (632.0, 1962.0, 0.0, 0.0, -27.0, -429.151, 3.525, 3627.897),
       (633.0, 2291.0, 0.0, 0.0, -44.493, -352.201, 3.527, 3547.056),
       (632.0, 1970.0, 0.0, 0.0, -27.0, -429.151, 3.528, 3695.686),
       (633.0, 1902.0, 0.0, 0.0, -41.987, 332.358, 3.529, 3652.026),
       (633.0, 2247.0, 0.0, 0.0, -48.253, -381.964, 3.529, 4075.531),
       (634.0, 2261.0, 0.0, 0.0, -59.025, -309.42, 3.53, 3749.972),
       (633.0, 2248.0, 0.0, 0.0, -48.253, -381.964, 3.531, 4056.46),
       (632.0, 1963.0, 0.0, 0.0, -27.0, -429.151, 3.531, 3596.312),
       (633.0, 2233.0, 0.0, 0.0, -42.613, 337.319, 3.531, 3726.349),
       (633.0, 1940.0, 0.0, 0.0, -47.627, 377.004, 3.532, 3780.36),
       (632.0, 1944.0, 0.0, 0.0, -38.227, 302.595, 3.532, 3415.696),
       (633.0, 2223.0, 0.0, 0.0, -42.613, 337.319, 3.532, 4088.523),
       (634.0, 2267.0, 0.0, 0.0, -55.773, -441.491, 3.533, 4585.292),
       (632.0, 2190.0, 0.0, 0.0, -40.733, 322.437, 3.534, 3221.041),
       (633.0, 1976.0, 0.0, 0.0, -40.107, -317.477, 3.534, 4272.863),
       (632.0, 1992.0, 0.0, 0.0, -37.6, -297.634, 3.535, 3412.92),
       (632.0, 1974.0, 0.0, 0.0, -27.942, -444.122, 3.54, 3658.903),
       (632.0, 1964.0, 0.0, 0.0, -27.314, -434.142, 3.541, 3599.284),
       (632.0, 2000.0, 0.0, 0.0, -37.6, -297.634, 3.542, 3822.844),
       (634.0, 2307.0, 0.0, 0.0, -53.267, -421.649, 3.544, 3713.608),
       (633.0, 2231.0, 0.0, 0.0, -41.36, 327.398, 3.546, 4041.864),
       (632.0, 1975.0, 0.0, 0.0, -25.116, -399.211, 3.546, 4224.086),
       (631.0, 2017.0, 0.0, 0.0, -27.942, -444.122, 3.546, 3415.846),
       (631.0, 2016.0, 0.0, 0.0, -27.942, -444.122, 3.549, 3405.44),
       (634.0, 2262.0, 0.0, 0.0, -57.151, -299.598, 3.55, 3932.635),
       (632.0, 1976.0, 0.0, 0.0, -25.744, -409.191, 3.551, 4053.905),
       (633.0, 2224.0, 0.0, 0.0, -42.613, 337.319, 3.552, 4089.058),
       (632.0, 2189.0, 0.0, 0.0, -38.227, 302.595, 3.552, 3624.978),
       (632.0, 1993.0, 0.0, 0.0, -27.942, -444.122, 3.553, 4437.167),
       (633.0, 1967.0, 0.0, 0.0, -38.853, -307.556, 3.555, 3898.142),
       (633.0, 1975.0, 0.0, 0.0, -40.107, -317.477, 3.555, 4267.003),
       (632.0, 2004.0, 0.0, 0.0, -38.853, -307.556, 3.556, 3544.193),
       (632.0, 2206.0, 0.0, 0.0, -38.227, 302.595, 3.558, 3283.755),
       (633.0, 1929.0, 0.0, 0.0, -45.747, 362.122, 3.558, 3795.41),
       (632.0, 1991.0, 0.0, 0.0, -27.628, -439.132, 3.558, 4421.205),
       (633.0, 2228.0, 0.0, 0.0, -42.613, 337.319, 3.559, 4007.064),
       (634.0, 2268.0, 0.0, 0.0, -57.151, -299.598, 3.559, 3832.518),
       (633.0, 1957.0, 0.0, 0.0, -38.227, -302.595, 3.561, 3812.298),
       (633.0, 2227.0, 0.0, 0.0, -42.613, 337.319, 3.562, 4042.455),
       (633.0, 1944.0, 0.0, 0.0, -37.6, -297.634, 3.564, 3843.796),
       (633.0, 2226.0, 0.0, 0.0, -42.613, 337.319, 3.564, 4065.828),
       (633.0, 2246.0, 0.0, 0.0, -50.133, -396.846, 3.566, 3933.983),
       (633.0, 2292.0, 0.0, 0.0, -44.493, -352.201, 3.565, 3543.352),
       (633.0, 1905.0, 0.0, 0.0, -41.36, 327.398, 3.566, 3661.284),
       (633.0, 2225.0, 0.0, 0.0, -42.613, 337.319, 3.566, 4084.697),
       (634.0, 2308.0, 0.0, 0.0, -53.267, -421.649, 3.566, 3705.047),
       (633.0, 1916.0, 0.0, 0.0, -43.867, 347.24, 3.568, 3752.072),
       (631.0, 2018.0, 0.0, 0.0, -27.942, -444.122, 3.57, 3444.83),
       (632.0, 2188.0, 0.0, 0.0, -38.227, 302.595, 3.574, 3650.796),
       (632.0, 2187.0, 0.0, 0.0, -38.227, 302.595, 3.575, 3660.013),
       (632.0, 1946.0, 0.0, 0.0, -38.853, 307.556, 3.576, 3363.666),
       (632.0, 1961.0, 0.0, 0.0, -26.372, -419.171, 3.577, 3738.796),
       (633.0, 2220.0, 0.0, 0.0, -44.493, 352.201, 3.577, 3826.673),
       (632.0, 2005.0, 0.0, 0.0, -40.107, -317.477, 3.578, 3427.55),
       (633.0, 1974.0, 0.0, 0.0, -40.107, -317.477, 3.578, 4250.278),
       (631.0, 2015.0, 0.0, 0.0, -27.942, -444.122, 3.578, 3409.985),
       (632.0, 1966.0, 0.0, 0.0, -27.942, -444.122, 3.582, 3477.436),
       (632.0, 2213.0, 0.0, 0.0, -37.6, 297.634, 3.585, 3308.686),
       (633.0, 2293.0, 0.0, 0.0, -44.493, -352.201, 3.585, 3526.679),
       (632.0, 1947.0, 0.0, 0.0, -38.853, 307.556, 3.585, 3373.959),
       (633.0, 1917.0, 0.0, 0.0, -42.613, 337.319, 3.586, 3945.964),
       (633.0, 1907.0, 0.0, 0.0, -41.987, 332.358, 3.587, 3771.817),
       (633.0, 1924.0, 0.0, 0.0, -43.867, 347.24, 3.587, 4056.734),
       (632.0, 1953.0, 0.0, 0.0, -24.488, -389.23, 3.587, 4441.529),
       (632.0, 1960.0, 0.0, 0.0, -26.372, -419.171, 3.588, 3805.264),
       (632.0, 1968.0, 0.0, 0.0, -27.0, -429.151, 3.588, 3676.997),
       (633.0, 1968.0, 0.0, 0.0, -42.613, -337.319, 3.589, 3291.01),
       (633.0, 2294.0, 0.0, 0.0, -44.493, -352.201, 3.589, 3498.175),
       (633.0, 2221.0, 0.0, 0.0, -42.613, 337.319, 3.59, 4200.21),
       (633.0, 2207.0, 0.0, 0.0, -47.0, 372.043, 3.59, 3713.442),
       (632.0, 1945.0, 0.0, 0.0, -38.853, 307.556, 3.591, 3365.548),
       (633.0, 1901.0, 0.0, 0.0, -41.987, 332.358, 3.592, 3739.94),
       (632.0, 1939.0, 0.0, 0.0, -37.6, 297.634, 3.596, 3394.671),
       (632.0, 1969.0, 0.0, 0.0, -26.372, -419.171, 3.596, 3832.064),
       (632.0, 1942.0, 0.0, 0.0, -38.853, 307.556, 3.6, 3345.821),
       (634.0, 2309.0, 0.0, 0.0, -53.267, -421.649, 3.601, 3711.13),
       (633.0, 2295.0, 0.0, 0.0, -44.493, -352.201, 3.602, 3473.078),
       (633.0, 1928.0, 0.0, 0.0, -43.867, 347.24, 3.603, 4136.862),
       (632.0, 1948.0, 0.0, 0.0, -38.853, 307.556, 3.604, 3383.368),
       (632.0, 1997.0, 0.0, 0.0, -37.6, -297.634, 3.604, 3746.375),
       (632.0, 2205.0, 0.0, 0.0, -37.6, 297.634, 3.604, 3413.689),
       (632.0, 1967.0, 0.0, 0.0, -27.0, -429.151, 3.605, 3667.759),
       (633.0, 1984.0, 0.0, 0.0, -40.733, -322.437, 3.605, 4458.06),
       (633.0, 1925.0, 0.0, 0.0, -42.613, 337.319, 3.606, 4294.451),
       (633.0, 1939.0, 0.0, 0.0, -47.627, 377.004, 3.607, 3851.103),
       (634.0, 2311.0, 0.0, 0.0, -53.267, -421.649, 3.607, 3680.818),
       (633.0, 1938.0, 0.0, 0.0, -47.627, 377.004, 3.608, 3843.962),
       (633.0, 1926.0, 0.0, 0.0, -42.613, 337.319, 3.608, 4315.052),
       (634.0, 2312.0, 0.0, 0.0, -53.267, -421.649, 3.61, 3672.525),
       (633.0, 1906.0, 0.0, 0.0, -41.987, 332.358, 3.613, 3763.768),
       (631.0, 2014.0, 0.0, 0.0, -27.628, -439.132, 3.613, 3419.509),
       (633.0, 2201.0, 0.0, 0.0, -45.747, 362.122, 3.613, 3998.071),
       (632.0, 1938.0, 0.0, 0.0, -37.6, 297.634, 3.614, 3378.214),
       (634.0, 2310.0, 0.0, 0.0, -53.267, -421.649, 3.615, 3702.539),
       (633.0, 1900.0, 0.0, 0.0, -40.107, 317.477, 3.619, 4083.024),
       (632.0, 1949.0, 0.0, 0.0, -38.853, 307.556, 3.619, 3388.166),
       (633.0, 1958.0, 0.0, 0.0, -38.227, -302.595, 3.619, 3886.023),
       (633.0, 2208.0, 0.0, 0.0, -45.747, 362.122, 3.62, 3860.17),
       (632.0, 2255.0, 0.0, 0.0, -38.227, -302.595, 3.62, 3535.437),
       (633.0, 1959.0, 0.0, 0.0, -38.227, -302.595, 3.622, 3905.876),
       (633.0, 2216.0, 0.0, 0.0, -42.613, 337.319, 3.622, 4418.437),
       (632.0, 1994.0, 0.0, 0.0, -27.942, -444.122, 3.624, 4546.962),
       (633.0, 1946.0, 0.0, 0.0, -47.0, 372.043, 3.624, 4282.106),
       (632.0, 2185.0, 0.0, 0.0, -38.227, 302.595, 3.624, 3763.148),
       (632.0, 1955.0, 0.0, 0.0, -25.116, -399.211, 3.625, 4399.791),
       (633.0, 1980.0, 0.0, 0.0, -41.36, -327.398, 3.626, 4117.447),
       (633.0, 1981.0, 0.0, 0.0, -41.987, -332.358, 3.626, 4122.94),
       (633.0, 1985.0, 0.0, 0.0, -42.613, -337.319, 3.626, 4026.5),
       (631.0, 2021.0, 0.0, 0.0, -27.942, -444.122, 3.627, 3559.283),
       (633.0, 2213.0, 0.0, 0.0, -47.0, 372.043, 3.628, 3659.386),
       (632.0, 1954.0, 0.0, 0.0, -24.802, -394.221, 3.628, 4433.314),
       (632.0, 2254.0, 0.0, 0.0, -38.227, -302.595, 3.629, 3548.443),
       (634.0, 2255.0, 0.0, 0.0, -59.025, -309.42, 3.631, 4084.146),
       (633.0, 2202.0, 0.0, 0.0, -44.493, 352.201, 3.632, 4295.291),
       (633.0, 1969.0, 0.0, 0.0, -41.987, -332.358, 3.633, 3510.702),
       (632.0, 2256.0, 0.0, 0.0, -38.227, -302.595, 3.634, 3526.078),
       (632.0, 2186.0, 0.0, 0.0, -38.227, 302.595, 3.637, 3745.216),
       (633.0, 2296.0, 0.0, 0.0, -44.493, -352.201, 3.637, 3462.476),
       (1326.0, 1145.0, 0.0, 0.0, 363.446, -69.331, 3.638, 1940.244),
       (632.0, 2006.0, 0.0, 0.0, -40.107, -317.477, 3.639, 3474.298),
       (633.0, 1945.0, 0.0, 0.0, -37.6, -297.634, 3.641, 3957.677),
       (633.0, 2217.0, 0.0, 0.0, -42.613, 337.319, 3.643, 4409.866),
       (633.0, 1947.0, 0.0, 0.0, -37.6, -297.634, 3.643, 4004.124),
       (632.0, 1940.0, 0.0, 0.0, -37.6, 297.634, 3.644, 3476.428),
       (632.0, 1937.0, 0.0, 0.0, -37.6, 297.634, 3.645, 3376.642),
       (634.0, 2256.0, 0.0, 0.0, -59.025, -309.42, 3.645, 4083.731),
       (633.0, 2210.0, 0.0, 0.0, -44.493, 352.201, 3.645, 4146.953),
       (632.0, 2219.0, 0.0, 0.0, -37.6, 297.634, 3.645, 3238.521),
       (632.0, 2257.0, 0.0, 0.0, -37.6, -297.634, 3.646, 3561.623),
       (633.0, 1983.0, 0.0, 0.0, -40.107, -317.477, 3.647, 4597.033),
       (632.0, 2182.0, 0.0, 0.0, -42.613, 337.319, 3.647, 3195.937),
       (633.0, 1950.0, 0.0, 0.0, -53.267, 421.649, 3.647, 3568.525),
       (633.0, 2214.0, 0.0, 0.0, -47.0, 372.043, 3.648, 3658.539),
       (631.0, 2213.0, 0.0, 0.0, -23.546, 374.26, 3.649, 3534.716),
       (631.0, 2020.0, 0.0, 0.0, -27.942, -444.122, 3.651, 3554.231),
       (633.0, 2206.0, 0.0, 0.0, -47.0, 372.043, 3.652, 3800.119),
       (633.0, 2215.0, 0.0, 0.0, -44.493, 352.201, 3.652, 4035.16),
       (633.0, 1927.0, 0.0, 0.0, -47.0, 372.043, 3.653, 3738.706),
       (632.0, 2253.0, 0.0, 0.0, -38.227, -302.595, 3.654, 3568.762),
       (631.0, 2019.0, 0.0, 0.0, -27.628, -439.132, 3.654, 3544.807),
       (631.0, 2198.0, 0.0, 0.0, -26.058, 414.181, 3.655, 3398.844),
       (631.0, 2212.0, 0.0, 0.0, -24.174, 384.24, 3.655, 3537.11),
       (633.0, 1956.0, 0.0, 0.0, -38.227, -302.595, 3.655, 3934.479),
       (633.0, 2218.0, 0.0, 0.0, -42.613, 337.319, 3.655, 4388.554),
       (632.0, 2252.0, 0.0, 0.0, -38.227, -302.595, 3.655, 3571.481),
       (633.0, 2204.0, 0.0, 0.0, -44.493, 352.201, 3.655, 4282.524),
       (632.0, 2221.0, 0.0, 0.0, -37.6, 297.634, 3.656, 3214.482),
       (631.0, 2214.0, 0.0, 0.0, -23.546, 374.26, 3.656, 3519.386),
       (633.0, 2219.0, 0.0, 0.0, -42.613, 337.319, 3.657, 4352.027),
       (631.0, 2197.0, 0.0, 0.0, -26.058, 414.181, 3.658, 3412.34),
       (633.0, 2200.0, 0.0, 0.0, -45.747, 362.122, 3.659, 4053.998),
       (632.0, 2183.0, 0.0, 0.0, -42.613, 337.319, 3.659, 3187.118),
       (633.0, 1949.0, 0.0, 0.0, -47.0, 372.043, 3.66, 4459.279),
       (632.0, 2220.0, 0.0, 0.0, -37.6, 297.634, 3.663, 3231.629),
       (632.0, 1958.0, 0.0, 0.0, -26.372, -419.171, 3.664, 4116.45),
       (633.0, 1989.0, 0.0, 0.0, -42.613, -337.319, 3.665, 4374.125),
       (632.0, 1936.0, 0.0, 0.0, -37.6, 297.634, 3.666, 3368.08),
       (631.0, 2199.0, 0.0, 0.0, -26.058, 414.181, 3.667, 3392.907),
       (634.0, 2257.0, 0.0, 0.0, -59.025, -309.42, 3.667, 4072.675),
       (633.0, 1951.0, 0.0, 0.0, -53.267, 421.649, 3.668, 3689.536),
       (632.0, 2184.0, 0.0, 0.0, -42.613, 337.319, 3.669, 3184.177),
       (632.0, 2222.0, 0.0, 0.0, -37.6, 297.634, 3.669, 3223.079),
       (633.0, 1973.0, 0.0, 0.0, -38.853, -307.556, 3.67, 4575.045),
       (634.0, 2259.0, 0.0, 0.0, -59.025, -309.42, 3.672, 3996.563),
       (633.0, 2297.0, 0.0, 0.0, -45.747, -362.122, 3.673, 3311.966),
       (631.0, 2215.0, 0.0, 0.0, -23.546, 374.26, 3.675, 3512.191),
       (632.0, 2204.0, 0.0, 0.0, -39.48, 312.516, 3.676, 3238.995),
       (632.0, 1959.0, 0.0, 0.0, -26.686, -424.161, 3.676, 4079.885),
       (633.0, 2203.0, 0.0, 0.0, -44.493, 352.201, 3.676, 4331.451),
       (634.0, 2260.0, 0.0, 0.0, -59.025, -309.42, 3.677, 3960.772),
       (631.0, 2200.0, 0.0, 0.0, -26.058, 414.181, 3.679, 3378.187),
       (632.0, 2223.0, 0.0, 0.0, -37.6, 297.634, 3.679, 3228.697),
       (633.0, 1952.0, 0.0, 0.0, -53.267, 421.649, 3.682, 3852.552),
       (633.0, 1972.0, 0.0, 0.0, -38.227, -302.595, 3.682, 4782.161),
       (632.0, 2267.0, 0.0, 0.0, -38.227, -302.595, 3.683, 3242.677),
       (633.0, 1986.0, 0.0, 0.0, -42.613, -337.319, 3.684, 4144.061),
       (632.0, 2266.0, 0.0, 0.0, -38.227, -302.595, 3.684, 3241.296),
       (631.0, 2004.0, 0.0, 0.0, -26.058, -414.181, 3.684, 3727.647),
       (633.0, 1970.0, 0.0, 0.0, -41.987, -332.358, 3.686, 3629.841),
       (631.0, 2022.0, 0.0, 0.0, -27.942, -444.122, 3.686, 3653.692),
       (633.0, 1988.0, 0.0, 0.0, -42.613, -337.319, 3.686, 4314.384),
       (632.0, 2258.0, 0.0, 0.0, -38.227, -302.595, 3.686, 3509.939),
       (631.0, 2216.0, 0.0, 0.0, -23.546, 374.26, 3.689, 3501.357),
       (632.0, 1935.0, 0.0, 0.0, -37.6, 297.634, 3.689, 3361.578),
       (632.0, 1996.0, 0.0, 0.0, -39.48, -312.516, 3.689, 3465.104),
       (633.0, 1982.0, 0.0, 0.0, -41.987, -332.358, 3.69, 4225.306),
       (633.0, 2298.0, 0.0, 0.0, -44.493, -352.201, 3.69, 3437.588),
       (632.0, 1950.0, 0.0, 0.0, -37.6, 297.634, 3.691, 3659.003),
       (633.0, 1971.0, 0.0, 0.0, -57.151, 299.598, 3.691, 3538.188)], 
      dtype=[('t0_x', '<f8'), ('t0_y', '<f8'), ('theta_par', '<f8'), ('theta_perp', '<f8'), ('v_x', '<f8'), ('v_y', '<f8'), ('likelihood', '<f8'), ('est_flux', '<f8')])

In [316]:
results_to_cluster = results#filtered_results
arg = dict(eps=0.05, min_samples=1, n_jobs=-1)
clustered_results = ai.clusterResults(results_to_cluster, dbscan_args=arg)#, im_array, image_times)
clustered_results =  results_to_cluster[np.array(clustered_results[1], dtype=np.int)]
#best_targets = range(stamp_count)
#best_targets

In [317]:
print( len(clustered_results) )
clustered_results


42
Out[317]:
array([(685.0, 2341.0, 0.0, 0.0, 24.126, 306.552, 3.246, 3025.267),
       (685.0, 2957.0, 0.0, 0.0, 23.538, -299.075, 3.339, 2920.109),
       (685.0, 3930.0, 0.0, 0.0, 24.126, -306.552, 3.345, 2928.102),
       (685.0, 1331.0, 0.0, 0.0, 23.538, 299.075, 3.452, 3000.064),
       (1308.0, 1173.0, 0.0, 0.0, 345.855, -251.278, 3.502, 1745.545),
       (1360.0, 1134.0, 0.0, 0.0, -268.582, 164.587, 3.557, 1772.089),
       (685.0, 2447.0, 0.0, 0.0, 24.714, -314.029, 3.662, 2857.432),
       (1390.0, 1535.0, 0.0, 0.0, -0.0, -442.5, 3.859, 2033.062),
       (1184.0, 2884.0, 0.0, 0.0, 306.716, -99.658, 3.928, 2088.633),
       (1338.0, 1105.0, 0.0, 0.0, 194.834, 228.122, 3.974, 2264.375),
       (1334.0, 1123.0, 0.0, 0.0, 277.164, 114.805, 3.988, 2141.792),
       (1293.0, 1143.0, 0.0, 0.0, 426.182, 33.541, 4.023, 2166.134),
       (1384.0, 1134.0, 0.0, 0.0, -189.561, -260.908, 4.073, 2085.057),
       (1457.0, 2677.0, 0.0, 0.0, -268.043, 228.93, 4.085, 2485.041),
       (1131.0, 2044.0, 0.0, 0.0, 299.583, -97.34, 4.096, 3317.548),
       (1339.0, 1107.0, 0.0, 0.0, 249.255, 249.255, 4.099, 2270.833),
       (770.0, 3563.0, 0.0, 0.0, 193.969, 266.976, 4.102, 2828.018),
       (1343.0, 1105.0, 0.0, 0.0, 95.023, 292.45, 4.105, 2311.74),
       (225.0, 3305.0, 0.0, 0.0, -24.715, 314.029, 4.135, 2711.158),
       (323.0, 2914.0, 0.0, 0.0, 32.953, -418.705, 4.139, 2427.706),
       (1303.0, 1143.0, 0.0, 0.0, 441.136, -34.718, 4.164, 2207.069),
       (1385.0, 1343.0, 0.0, 0.0, -328.115, -106.611, 4.174, 2295.246),
       (1456.0, 2679.0, 0.0, 0.0, -233.825, 199.705, 4.175, 2407.481),
       (155.0, 397.0, 0.0, 0.0, -255.687, 351.922, 4.176, 2361.858),
       (1456.0, 1265.0, 0.0, 0.0, -176.343, 287.766, 4.184, 2484.179),
       (388.0, 2889.0, 0.0, 0.0, -265.165, -265.165, 4.19, 2469.986),
       (337.0, 2932.0, 0.0, 0.0, -212.132, -212.132, 4.209, 2800.858),
       (557.0, 2268.0, 0.0, 0.0, -233.345, 233.345, 4.21, 2666.092),
       (152.0, 400.0, 0.0, 0.0, -224.06, 262.34, 4.211, 2603.685),
       (126.0, 2014.0, 0.0, 0.0, -25.891, 328.983, 4.213, 2358.572),
       (1455.0, 1269.0, 0.0, 0.0, -307.591, 307.592, 4.219, 2544.001),
       (605.0, 2167.0, 0.0, 0.0, -297.951, -123.415, 4.223, 2332.714),
       (920.0, 692.0, 0.0, 0.0, -371.931, 89.293, 4.236, 2400.932),
       (478.0, 2380.0, 0.0, 0.0, -214.318, -250.934, 4.248, 2637.911),
       (1878.0, 2148.0, 0.0, 0.0, -163.437, -320.762, 4.251, 2508.236),
       (1652.0, 877.0, 0.0, 0.0, -233.801, -273.746, 4.256, 2756.609),
       (245.0, 3342.0, 0.0, 0.0, 48.103, -303.714, 4.266, 2769.566),
       (686.0, 2044.0, 0.0, 0.0, 336.48, -287.381, 4.272, 2451.223),
       (1382.0, 1342.0, 0.0, 0.0, -285.317, -92.705, 4.275, 2380.948),
       (1386.0, 1332.0, 0.0, 0.0, -336.46, -26.48, 4.276, 2520.964),
       (1385.0, 1369.0, 0.0, 0.0, -204.576, -239.528, 4.28, 2155.67),
       (1347.0, 1110.0, 0.0, 0.0, 23.538, 299.075, 4.281, 2342.468)], 
      dtype=[('t0_x', '<f8'), ('t0_y', '<f8'), ('theta_par', '<f8'), ('theta_perp', '<f8'), ('v_x', '<f8'), ('v_y', '<f8'), ('likelihood', '<f8'), ('est_flux', '<f8')])

In [319]:
f_results = clustered_results
for imNum in range(min(len(f_results),50)):
    current = imNum#best_targets[imNum]    
    plt.imshow(ai.createPostageStamp(im_array,
                                         list(f_results[['t0_x', 't0_y']][current]),
                                         np.array(list(f_results[['v_x', 'v_y']][current])),
                                         image_times, [25., 25.])[0],
                    origin='lower',
               #cmap=plt.cm.Greys_r,
               interpolation='None')
    plt.title(str('#' + str(imNum+1) + ' [x,y] = ' + str(list(f_results[['t0_x', 't0_y']][current])))
                  + ' v = ' + str(list(f_results[['v_x', 'v_y']][current])))
 #   plt.savefig("stamps/stamp"+str(imNum+1)+".png")
    plt.show()



In [ ]:


In [ ]: