In [1]:
%load_ext autoreload
%autoreload 2
# System modules
import os
import warnings
import pickle
import glob
import sys
import logging
import datetime as dt
import time
from copy import deepcopy

# External modules
import numpy as np
import scipy.misc
import scipy.ndimage.filters
import matplotlib.pyplot as plt
from matplotlib import gridspec
from matplotlib.backends.backend_pdf import PdfPages
import pandas as pd
import dateutil.parser
import typhon.plots
import scipy.ndimage

import PIL

from skimage.segmentation import slic
from skimage.filters import threshold_otsu
from skimage import exposure

# Internal modules
import pyclamster
from pyclamster.clustering.preprocess import LCN
from pyclamster.functions import rbDetection
from pyclamster.positioning import Projection

plt.style.use('ggplot')

warnings.catch_warnings()
warnings.filterwarnings('ignore')

#logging.basicConfig(level=logging.INFO)

In [2]:
FILE_DIR = %pwd
BASE_DIR = os.path.dirname(FILE_DIR)
#image_directory = os.path.join(BASE_DIR, "examples", "images", "lex")
image_dir = '/home/tfinn/Data/example/'
trained_models = os.path.join(BASE_DIR, "data")
plot_dir = os.path.join(BASE_DIR, 'plots')
debug = False

In [3]:
predictor = pickle.load(open(os.path.join(trained_models, "kmeans.pk"), "rb"))
global_thres = np.mean(predictor.algorithm.cluster_centers_)
cams = []
cams.append(pickle.load(open(os.path.join(trained_models, 'sessions', 'FE3_session_new_600.pk'), mode='rb')))
cams.append(pickle.load(open(os.path.join(trained_models, 'sessions', 'FE4_session_new_600.pk'), mode='rb')))
cams[0].set_images(os.path.join(image_dir, 'cam3'))
cams[1].set_images(os.path.join(image_dir, 'cam4'))
matching = pyclamster.matching.Matching(greyscale=True)
dist = np.sqrt((cams[0].position.x-cams[1].position.x)**2+(cams[0].position.y-cams[1].position.y)**2)

height = {}

In [4]:
def save_heights(path):
    max_len = np.max([len(height[i]) for i in height.keys()])
    df_height = pd.DataFrame(columns=range(max_len), index=height.keys())
    for i in df_height.index:
        for k, j in enumerate(height[i]):
            if not j is None:
                if 200<j<15000:
                    df_height.ix[i, k] = j
    df_height = df_height.sort()
    df_height.to_json(path)

In [5]:
def generate_doppel(images):
    start_time = time.time()
    k = 0
    clouds = []
    height[images[0].time] = []
    for img in images:
        image_lcn = pyclamster.Image(img)
        image_lcn.data = LCN((50,50,3)).fit_transform(image_lcn.data)
        #image_lcn.data = image_lcn.data-scipy.ndimage.filters.uniform_filter(image_lcn.data, size=(50,50,3), mode='constant')
        #image_lcn.save(os.path.join(plot_dir, "lcn_{0:s}_{1:d}.png".format(img.time.strftime('%Y%m%d%H%M'), k)))
        #image_lcn = image_lcn.cut([50, 50, 350, 350])
        #w, h, _ = original_shape = image_lcn.data.shape
        rb_image = rbDetection(image_lcn.data)
        thres = 0.25*threshold_otsu(rb_image)+0.75*global_thres
        label = pyclamster.Labels(rb_image<thres)
        #label = predictor.predict(raw_image_lcn)
        #label.reshape((w, h), replace=True)
        #masks = label.getMaskStore()
        #cloud_mask_num = [1] # cloud - sky choose right number (0 or 1)
        #masks.denoise(cloud_mask_num, 1000)
        #cloud_labels_object, numLabels = masks.labelMask(cloud_mask_num)
        #cloud_labels_object, numLabels = masks.wsMask(cloud_mask_num, np.ones((14,14)))
        #cloud_labels_object, numLabels = masks.slicMask(img.cut([50,50,350,350]), cloud_mask_num, 30)
        #cloud_labels_object, numLabels = masks.regionMask(cloud_mask_num, (30, 30))
        segmented_image = slic(img.data, n_segments=30, sigma=1)+1
        #rb_image = img.data[:,:,0]-img.data[:,:,2]
        #thres = global_thres = threshold_otsu(rb_image[rb_image>10])
        #threshold_array = np.zeros_like(rb_image)
        #threshold_array[:] = global_thres
        #label = pyclamster.Labels(rb_image>threshold_array)
        masks = label.getMaskStore()
        masks.denoise([1], 960)
        cloud_labels_object, _ = masks.givenLabelMask(segmented_image, [1,])
        #cloud_labels_object, _ = masks.labelMask([1,])
        cloud_store = cloud_labels_object.getMaskStore()
        cloud_labels = np.unique(cloud_labels_object.labels)[1:]
        #cloud_rb_image_data = pyclamster.Image(PIL.Image.fromarray(rb_image[:,:]))
        clouds.append([cloud_store.getCloud(img, labels=[k, ]) for k in cloud_labels])
        if debug:
            j = 0
            fig = plt.figure()
            gs = gridspec.GridSpec(2,3)
            ax = plt.subplot(gs[0, 0])
            ax.imshow(img.data)
            ax = plt.subplot(gs[0, 1])
            ax.imshow(rb_image)
            ax = plt.subplot(gs[1, :])
            ax.hist(rb_image.reshape((-1)), bins=256)
            ax.axvline(x=thres)
            ax = plt.subplot(gs[0, 2])
            ax.imshow(cloud_labels_object.labels)
            plt.axis('off')
            plt.tight_layout()
            plt.savefig(os.path.join(plot_dir, "detection_{0:s}_{1:d}.pdf".format(img.time.strftime('%Y%m%d%H%M'), k)))
            print_label = label.labels
            print_label = np.ma.masked_where(print_label == 0, print_label)
            print_clouds = np.ma.masked_where(print_label == 0, cloud_labels_object.labels)
            img.save(os.path.join(plot_dir, "rectified_{0:s}_{1:d}.png".format(img.time.strftime('%Y%m%d%H%M'), k)))
            scipy.misc.imsave(
                os.path.join(plot_dir, "lables_kmean_{0:s}_{1:d}.png".format(img.time.strftime('%Y%m%d%H%M'), k)),
                             print_label)
            scipy.misc.imsave(
                os.path.join(plot_dir, "lables_used_{0:s}_{1:d}.png".format(img.time.strftime('%Y%m%d%H%M'), k)),
                             print_clouds)
            print('finished image {0:s} of camera {1:d}'.format(img.time.strftime('%Y%m%d%H%M'), k))
        k += 1
    t=0
    if not(not clouds[0] or not clouds[1]):
        matching_result, _ = matching.matching(clouds[0], clouds[1], min_match_prob=0.9)
        for result in matching_result:
            spatial_cloud = result[1]
            successful = spatial_cloud.oper_mode()
            if debug and successful:
                fig = plt.figure()
                ax = plt.subplot(1,3,1)
                ax.axis('off')
                ax.imshow(result[1].clouds[0].image.data)
                ax = plt.subplot(1,3,2)
                ax.axis('off')
                ax.imshow(result[0].prob_map, interpolation='nearest')
                ax = plt.subplot(1,3,3)
                ax.axis('off')
                ax.imshow(result[1].clouds[1].image.data)
                plt.tight_layout()
                plt.savefig(os.path.join(plot_dir, 'matching_{0:s}_{1:d}.png'.format(img.time.strftime('%Y%m%d%H%M'), t)))
                fig = plt.figure()
                gs = gridspec.GridSpec(1,3)
                ax = plt.subplot(gs[0])
                ax.axis('off')
                ax.imshow(spatial_cloud.clouds[0].image.data)
                ax = plt.subplot(gs[1])
                ax.axis('off')
                z = spatial_cloud.positions.z
                X, Y = np.meshgrid(range(z.shape[1]), range(z.shape[0]))
                CS = ax.contour(X, Y, z)
                manual_locations = [(-1, -1.4), (-0.62, -0.7), (-2, 0.5), (1.7, 1.2), (2.0, 1.4), (2.4, 1.7)]
                plt.clabel(CS, inline=1, fontsize=10)
                plt.text(0,0,'{:5.1} m height'.format(spatial_cloud.height), color='black')
                ax = plt.subplot(gs[2])
                ax.axis('off')
                ax.imshow(spatial_cloud.clouds[1].image.data)
                plt.tight_layout()
                plt.savefig(os.path.join(plot_dir, 'height{0:s}_{1:d}.png'.format(img.time.strftime('%Y%m%d%H%M'), t)))
            height[images[0].time].append(spatial_cloud.height)
            t+=1
    save_heights(os.path.join(trained_models, 'heights_temp.json'))
    try:      
        print('finished image {0:s} calculations with {1:d} heights (min: {2:.1f}, max: {3:.1f}), duration: {4:.1f} s'.format(images[0].time.strftime('%Y%m%d%H%M'), t, np.nanmin(height[images[0].time]), np.nanmax(height[images[0].time]), time.time()-start_time))
    except:
        print('finished image {0:s} calculations with {1:d} heights, duration: {2:.1f} s'.format(images[0].time.strftime('%Y%m%d%H%M'), t, time.time()-start_time))

In [ ]:
images_available = True
gens = [cams[0].iterate_over_rectified_images(), cams[1].iterate_over_rectified_images()]
images = [next(gens[0]), next(gens[1])]
while images_available:
    for k, img in enumerate(images):
        img.loadTimefromfilename('FE{0:d}_Image_%Y%m%d_%H%M%S_UTCp1.jpg'.format(k+3))
    if (images[0].time-images[1].time).seconds<60:
        generate_doppel(images)
        try:
            images = [next(gens[0]), next(gens[1])]
        except:
            images_available = False
    elif images[0].time<images[1].time:
        try:
            images[0] = next(gens[0])
        except:
            images_available = False
    elif images[0].time>images[1].time:
        try:
            images[1] = next(gens[1])
        except:
            images_available = False
print('finished image processing')


finished image 201609031100 calculations with 7 heights (min: -588.0, max: 1780.0), duration: 56.4 s
finished image 201609031101 calculations with 6 heights (min: -143.3, max: 115.6), duration: 54.3 s
finished image 201609031102 calculations with 5 heights (min: -271.6, max: 56.2), duration: 61.9 s
finished image 201609031103 calculations with 3 heights (min: -85.1, max: 146.6), duration: 38.1 s
finished image 201609031104 calculations with 4 heights (min: -165.4, max: 169.7), duration: 39.9 s
finished image 201609031105 calculations with 5 heights (min: -15.0, max: 407.0), duration: 44.1 s
finished image 201609031106 calculations with 3 heights (min: -400.3, max: 62.2), duration: 38.6 s
finished image 201609031107 calculations with 9 heights (min: -609.6, max: 102.6), duration: 66.1 s
finished image 201609031108 calculations with 4 heights (min: -313.0, max: 65.3), duration: 48.4 s
finished image 201609031109 calculations with 3 heights (min: -5.3, max: 171.2), duration: 40.5 s
finished image 201609031110 calculations with 3 heights (min: -183.0, max: 289.8), duration: 38.3 s
finished image 201609031111 calculations with 5 heights (min: -846.4, max: 487.9), duration: 47.8 s
finished image 201609031112 calculations with 6 heights (min: -479.9, max: 188.6), duration: 52.1 s
finished image 201609031113 calculations with 3 heights (min: -277.0, max: 290.6), duration: 44.0 s
finished image 201609031114 calculations with 4 heights (min: -295.3, max: -190.4), duration: 41.7 s
finished image 201609031115 calculations with 10 heights (min: -1173.7, max: 978.1), duration: 73.2 s
finished image 201609031116 calculations with 6 heights (min: -688.0, max: 37.8), duration: 54.4 s
finished image 201609031117 calculations with 13 heights (min: -608.7, max: 2227.0), duration: 52.4 s
finished image 201609031118 calculations with 7 heights (min: -1112.2, max: 579.4), duration: 52.7 s
finished image 201609031119 calculations with 1 heights (min: -395.9, max: -395.9), duration: 25.1 s
finished image 201609031120 calculations with 2 heights (min: -2400.0, max: -96.1), duration: 21.3 s
finished image 201609031121 calculations with 4 heights (min: -2894.0, max: 1473.4), duration: 31.3 s
finished image 201609031122 calculations with 9 heights (min: -4876.6, max: 438.4), duration: 55.1 s
finished image 201609031123 calculations with 4 heights (min: -252.5, max: 355.0), duration: 32.9 s
finished image 201609031124 calculations with 2 heights (min: -32.3, max: 465.8), duration: 27.3 s
finished image 201609031125 calculations with 0 heights, duration: 34.3 s
finished image 201609031126 calculations with 7 heights (min: -634.7, max: 246.5), duration: 64.4 s
finished image 201609031127 calculations with 6 heights (min: -572.4, max: -100.9), duration: 68.0 s
finished image 201609031128 calculations with 6 heights (min: -649.6, max: 1442.2), duration: 68.8 s
finished image 201609031129 calculations with 7 heights (min: -460.5, max: -78.6), duration: 69.8 s
finished image 201609031130 calculations with 5 heights (min: -728.2, max: 1069.4), duration: 58.1 s
finished image 201609031131 calculations with 10 heights (min: -714.7, max: 467.7), duration: 57.3 s
finished image 201609031132 calculations with 9 heights (min: -553.4, max: 867.2), duration: 80.7 s
finished image 201609031133 calculations with 2 heights (min: -737.2, max: -168.9), duration: 49.2 s
finished image 201609031134 calculations with 3 heights (min: -508.5, max: 12.2), duration: 51.8 s
finished image 201609031135 calculations with 5 heights (min: -831.3, max: 5597.9), duration: 48.4 s
finished image 201609031136 calculations with 6 heights (min: -446.5, max: 1079.9), duration: 43.7 s
finished image 201609031137 calculations with 5 heights (min: -990.9, max: 280.0), duration: 57.7 s
finished image 201609031138 calculations with 11 heights (min: -1732.1, max: 1864.1), duration: 76.2 s
finished image 201609031139 calculations with 7 heights (min: -640.3, max: 439.1), duration: 38.8 s
finished image 201609031140 calculations with 10 heights (min: -516.9, max: 1452.4), duration: 83.1 s
finished image 201609031141 calculations with 11 heights (min: -2471.0, max: 1341.2), duration: 67.2 s
finished image 201609031142 calculations with 10 heights (min: -676.2, max: 589.3), duration: 61.4 s
finished image 201609031143 calculations with 4 heights (min: -2037.6, max: 793.6), duration: 39.0 s
finished image 201609031144 calculations with 3 heights (min: -1146.1, max: -161.6), duration: 52.5 s
finished image 201609031145 calculations with 5 heights (min: -281.9, max: 142.3), duration: 67.9 s
finished image 201609031146 calculations with 8 heights (min: 20.0, max: 11355.7), duration: 52.8 s
finished image 201609031147 calculations with 10 heights (min: -141.8, max: 2070.3), duration: 74.7 s
finished image 201609031148 calculations with 11 heights (min: -987.0, max: 287.7), duration: 82.3 s
finished image 201609031149 calculations with 4 heights (min: -405.0, max: -17.8), duration: 48.6 s
finished image 201609031150 calculations with 3 heights (min: -168.6, max: 325.9), duration: 38.4 s
finished image 201609031151 calculations with 1 heights (min: -437.4, max: -437.4), duration: 43.1 s
finished image 201609031152 calculations with 3 heights (min: -449.8, max: 272.3), duration: 50.9 s
finished image 201609031153 calculations with 3 heights (min: 104.3, max: 380.8), duration: 49.9 s
finished image 201609031154 calculations with 7 heights (min: -543.3, max: 865.1), duration: 40.6 s
finished image 201609031155 calculations with 6 heights (min: -863.9, max: 596.7), duration: 45.0 s
finished image 201609031156 calculations with 5 heights (min: 27.8, max: 454.6), duration: 34.5 s
finished image 201609031157 calculations with 9 heights (min: -1346.5, max: 475.8), duration: 54.2 s
finished image 201609031158 calculations with 16 heights (min: -936.2, max: 695.7), duration: 61.8 s
finished image 201609031159 calculations with 2 heights (min: -21.0, max: 598.6), duration: 46.5 s
finished image 201609031200 calculations with 2 heights (min: -273.9, max: 1272.4), duration: 57.0 s
finished image 201609031201 calculations with 1 heights (min: 808.0, max: 808.0), duration: 40.0 s
finished image 201609031202 calculations with 5 heights (min: 351.9, max: 995.2), duration: 62.0 s
finished image 201609031203 calculations with 11 heights (min: -1287.5, max: 1468.4), duration: 70.8 s
finished image 201609031204 calculations with 10 heights (min: -825.1, max: 1221.8), duration: 65.4 s
The positions aren't calculated yet!
finished image 201609031205 calculations with 9 heights, duration: 45.9 s
finished image 201609031206 calculations with 3 heights (min: -2286.1, max: 56.5), duration: 38.8 s
finished image 201609031207 calculations with 5 heights (min: -294.0, max: 1764.9), duration: 48.9 s
finished image 201609031208 calculations with 6 heights (min: -101.2, max: 450.9), duration: 52.6 s
finished image 201609031209 calculations with 4 heights (min: -610.4, max: 248.8), duration: 51.1 s
finished image 201609031210 calculations with 3 heights (min: -31.8, max: 571.2), duration: 37.5 s
finished image 201609031211 calculations with 8 heights (min: -570.3, max: 715.1), duration: 61.2 s
finished image 201609031212 calculations with 12 heights (min: -510.0, max: 806.5), duration: 64.7 s
finished image 201609031213 calculations with 5 heights (min: -2675.7, max: 320.0), duration: 47.1 s
finished image 201609031214 calculations with 8 heights (min: -428.9, max: 347.6), duration: 45.8 s
finished image 201609031215 calculations with 11 heights (min: -2652.7, max: 1140.2), duration: 51.0 s
finished image 201609031216 calculations with 10 heights (min: -2596.2, max: 4445.0), duration: 47.1 s
finished image 201609031217 calculations with 14 heights (min: -834.0, max: 1248.4), duration: 54.0 s
finished image 201609031218 calculations with 10 heights (min: -4959.8, max: 1463.0), duration: 56.3 s
finished image 201609031219 calculations with 10 heights (min: -2945.0, max: 6894.0), duration: 49.0 s
finished image 201609031220 calculations with 11 heights (min: -4421.4, max: 5195.7), duration: 64.4 s
finished image 201609031221 calculations with 11 heights (min: -5699.0, max: 5055.4), duration: 57.8 s
finished image 201609031222 calculations with 19 heights (min: -6860.9, max: 9155.1), duration: 75.0 s
finished image 201609031223 calculations with 16 heights (min: -5784.2, max: 550.2), duration: 81.7 s
finished image 201609031224 calculations with 14 heights (min: -7151.4, max: 3642.5), duration: 72.4 s
finished image 201609031225 calculations with 12 heights (min: -7701.5, max: 31697.8), duration: 64.4 s
finished image 201609031226 calculations with 11 heights (min: -25401.9, max: 5170.6), duration: 60.7 s
finished image 201609031227 calculations with 15 heights (min: -30822.3, max: 486.8), duration: 75.7 s
finished image 201609031228 calculations with 18 heights (min: -7181.4, max: 16312.2), duration: 87.1 s
finished image 201609031229 calculations with 15 heights (min: -13573.7, max: 326.1), duration: 75.3 s
The positions aren't calculated yet!
finished image 201609031230 calculations with 20 heights, duration: 72.1 s
finished image 201609031231 calculations with 14 heights (min: -4086.3, max: 1171.7), duration: 82.3 s
finished image 201609031232 calculations with 11 heights (min: -5920.1, max: 1248.3), duration: 79.9 s
finished image 201609031233 calculations with 10 heights (min: -548.1, max: 1207.1), duration: 78.9 s
finished image 201609031234 calculations with 7 heights (min: -2372.1, max: 172.3), duration: 75.9 s
finished image 201609031235 calculations with 8 heights (min: -414.6, max: 868.4), duration: 90.0 s
finished image 201609031236 calculations with 6 heights (min: -1637.9, max: 828.2), duration: 68.6 s
finished image 201609031237 calculations with 8 heights (min: -342.7, max: 496.9), duration: 62.7 s
finished image 201609031238 calculations with 9 heights (min: -440.6, max: 411.3), duration: 67.1 s
finished image 201609031239 calculations with 9 heights (min: -718.9, max: 386.4), duration: 64.6 s
finished image 201609031240 calculations with 10 heights (min: -1822.1, max: 602.0), duration: 86.2 s
finished image 201609031241 calculations with 3 heights (min: -2902.0, max: 3267.6), duration: 31.5 s
finished image 201609031242 calculations with 8 heights (min: -6552.4, max: 789.8), duration: 54.3 s
finished image 201609031243 calculations with 11 heights (min: -5528.9, max: 3441.4), duration: 67.3 s
finished image 201609031244 calculations with 17 heights (min: -6451.3, max: 12260.3), duration: 81.3 s
finished image 201609031245 calculations with 12 heights (min: -6051.9, max: 1355.0), duration: 52.3 s
finished image 201609031246 calculations with 10 heights (min: -4490.9, max: 2481.7), duration: 56.5 s
finished image 201609031247 calculations with 11 heights (min: -3519.5, max: 5615.6), duration: 64.0 s
finished image 201609031248 calculations with 12 heights (min: -25688.6, max: 2840.0), duration: 64.5 s
The positions aren't calculated yet!
finished image 201609031249 calculations with 18 heights, duration: 50.6 s
finished image 201609031250 calculations with 11 heights (min: -403.6, max: 1092.8), duration: 31.6 s
finished image 201609031251 calculations with 8 heights (min: -1045.3, max: 662.1), duration: 31.3 s
finished image 201609031252 calculations with 12 heights (min: -4416.2, max: 4180.7), duration: 50.9 s
finished image 201609031253 calculations with 10 heights (min: -2981.4, max: 7916.5), duration: 36.0 s
finished image 201609031254 calculations with 13 heights (min: -13697.3, max: 4548.4), duration: 53.3 s
finished image 201609031255 calculations with 17 heights (min: -4140.5, max: 4265.4), duration: 59.4 s
finished image 201609031256 calculations with 15 heights (min: -17192.7, max: 1501.6), duration: 79.9 s
finished image 201609031257 calculations with 13 heights (min: -9066.2, max: 15403.8), duration: 84.8 s
finished image 201609031258 calculations with 24 heights (min: -10385.5, max: 1967.7), duration: 93.4 s
finished image 201609031259 calculations with 4 heights (min: -1670.1, max: -69.6), duration: 61.6 s
finished image 201609031300 calculations with 2 heights (min: -260.6, max: 67.7), duration: 43.2 s
finished image 201609031301 calculations with 6 heights (min: -1684.8, max: 2396.1), duration: 65.4 s
finished image 201609031302 calculations with 18 heights (min: -2044.8, max: 2704.8), duration: 73.9 s
finished image 201609031303 calculations with 11 heights (min: -1692.6, max: 553.9), duration: 66.8 s
finished image 201609031304 calculations with 13 heights (min: -1392.6, max: 2080.5), duration: 86.4 s
finished image 201609031305 calculations with 15 heights (min: -277.8, max: 1862.7), duration: 90.0 s
finished image 201609031306 calculations with 5 heights (min: -648.0, max: 608.8), duration: 40.1 s
finished image 201609031307 calculations with 0 heights, duration: 13.8 s
finished image 201609031308 calculations with 2 heights (min: 280.3, max: 547.6), duration: 20.9 s
finished image 201609031309 calculations with 1 heights (min: -65.2, max: -65.2), duration: 25.3 s
finished image 201609031310 calculations with 2 heights (min: -12.7, max: 15.1), duration: 30.7 s
finished image 201609031311 calculations with 3 heights (min: -265.4, max: -96.5), duration: 48.8 s
finished image 201609031312 calculations with 3 heights (min: -423.5, max: 431.0), duration: 46.9 s
finished image 201609031313 calculations with 3 heights (min: 38.3, max: 3901.7), duration: 54.7 s
finished image 201609031314 calculations with 7 heights (min: -291.9, max: 240.8), duration: 67.3 s
finished image 201609031315 calculations with 3 heights (min: -109.7, max: 12.5), duration: 44.7 s
finished image 201609031316 calculations with 5 heights (min: -635.3, max: 160.0), duration: 54.5 s
finished image 201609031317 calculations with 7 heights (min: -531.6, max: 657.3), duration: 74.2 s
finished image 201609031318 calculations with 10 heights (min: -1518.2, max: 413.8), duration: 81.8 s
finished image 201609031319 calculations with 5 heights (min: -448.1, max: 643.1), duration: 54.2 s
finished image 201609031320 calculations with 5 heights (min: -408.1, max: 58.8), duration: 37.7 s
finished image 201609031321 calculations with 9 heights (min: -578.1, max: 928.0), duration: 66.3 s
finished image 201609031322 calculations with 12 heights (min: -346.6, max: 280.0), duration: 96.7 s
finished image 201609031323 calculations with 11 heights (min: -438.8, max: 1093.0), duration: 69.2 s
finished image 201609031324 calculations with 3 heights (min: -267.4, max: 31.1), duration: 41.9 s
finished image 201609031325 calculations with 9 heights (min: -424.6, max: 373.7), duration: 71.9 s
finished image 201609031326 calculations with 5 heights (min: -170.1, max: -4.1), duration: 64.0 s
finished image 201609031327 calculations with 9 heights (min: -1751.7, max: 425.0), duration: 86.5 s
finished image 201609031328 calculations with 9 heights (min: -341.2, max: 381.3), duration: 70.1 s
finished image 201609031329 calculations with 9 heights (min: -262.2, max: 315.2), duration: 62.9 s
finished image 201609031330 calculations with 13 heights (min: -316.6, max: 593.3), duration: 92.3 s
finished image 201609031331 calculations with 8 heights (min: 38.6, max: 1070.1), duration: 65.8 s
finished image 201609031332 calculations with 10 heights (min: -917.2, max: 537.7), duration: 53.3 s
finished image 201609031333 calculations with 11 heights (min: -5450.1, max: 1190.0), duration: 55.8 s
finished image 201609031334 calculations with 10 heights (min: -342.3, max: 3193.1), duration: 57.8 s
finished image 201609031335 calculations with 9 heights (min: -236.2, max: 463.6), duration: 72.1 s
finished image 201609031336 calculations with 10 heights (min: -90.8, max: 475.2), duration: 65.2 s
finished image 201609031337 calculations with 11 heights (min: -140.7, max: 1285.2), duration: 79.9 s
finished image 201609031338 calculations with 8 heights (min: -53.2, max: 369.6), duration: 82.4 s
finished image 201609031339 calculations with 8 heights (min: -177.2, max: 402.6), duration: 81.4 s
finished image 201609031340 calculations with 12 heights (min: -419.0, max: 581.9), duration: 86.0 s
finished image 201609031341 calculations with 16 heights (min: -9980.0, max: 569.7), duration: 83.1 s
finished image 201609031342 calculations with 10 heights (min: -1223.1, max: 745.7), duration: 63.1 s
finished image 201609031343 calculations with 18 heights (min: -3231.2, max: 1947.3), duration: 80.7 s
finished image 201609031344 calculations with 16 heights (min: -2778.7, max: 925.9), duration: 69.6 s
finished image 201609031345 calculations with 18 heights (min: -3412.2, max: 2835.4), duration: 76.1 s
finished image 201609031346 calculations with 20 heights (min: -3465.5, max: 3555.3), duration: 81.5 s
finished image 201609031347 calculations with 17 heights (min: -5027.0, max: 3570.7), duration: 82.6 s
finished image 201609031348 calculations with 14 heights (min: -4840.0, max: 6084.9), duration: 77.2 s
finished image 201609031349 calculations with 15 heights (min: -5536.6, max: 498.9), duration: 80.9 s
finished image 201609031350 calculations with 11 heights (min: -3608.1, max: 3050.3), duration: 57.2 s
finished image 201609031351 calculations with 15 heights (min: -2928.9, max: 397.8), duration: 46.4 s
finished image 201609031352 calculations with 9 heights (min: -2942.9, max: 2126.4), duration: 57.9 s
finished image 201609031353 calculations with 15 heights (min: -5698.4, max: 4019.4), duration: 78.3 s
finished image 201609031354 calculations with 11 heights (min: -3557.4, max: 6161.3), duration: 60.8 s
finished image 201609031355 calculations with 10 heights (min: -5672.8, max: 901.5), duration: 38.4 s
finished image 201609031356 calculations with 8 heights (min: -6772.4, max: 1147.4), duration: 29.5 s

In [16]:
max_len = np.max([len(height[i]) for i in height.keys()])
df_height = pd.DataFrame(columns=range(max_len), index=height.keys())
for i in df_height.index:
    for k, j in enumerate(height[i]):
        if not j is None:
            if 200<j<15000:
                df_height.ix[i, k] = j
df_height = df_height.sort()
df_height.to_json(os.path.join(trained_models, 'heights_20160903_4h_300_new.json'))

In [ ]: