#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 30 22:10:56 2017

@author: thomas
"""

import Deltadispof
from numpy import arange
import time

altLayer = [[19800000000.0, 8800000000.0, 2200, 5], 
            [107800000000.0, 35200000000.0, 2200, 5], 
            [19800000000.0, 8800000000.0, 2200, 5], 
            [107800000000.0, 35200000000.0, 2200, 5], 
            [19800000000.0, 8800000000.0, 2200, 5], 
            [107800000000.0, 35200000000.0, 2200, 5], 
            [19800000000.0, 8800000000.0, 2200, 5], 
            [107800000000.0, 35200000000.0, 2200, 5], 
            [19800000000.0, 8800000000.0, 2200, 5], 
            [107800000000.0, 35200000000.0, 2200, 5]]

alt10 = [[19800000000.0, 8800000000.0, 2200, 10], 
            [107800000000.0, 35200000000.0, 2200, 10], 
            [19800000000.0, 8800000000.0, 2200, 10], 
            [107800000000.0, 35200000000.0, 2200, 10], 
            [19800000000.0, 8800000000.0, 2200, 10], 
            [107800000000.0, 35200000000.0, 2200, 10], 
            [19800000000.0, 8800000000.0, 2200, 10], 
            [107800000000.0, 35200000000.0, 2200, 10], 
            [19800000000.0, 8800000000.0, 2200, 10], 
            [107800000000.0, 35200000000.0, 2200, 10]]

alt50 = [[19800000000.0, 8800000000.0, 2200, 50], 
            [107800000000.0, 35200000000.0, 2200, 50], 
            [19800000000.0, 8800000000.0, 2200, 50], 
            [107800000000.0, 35200000000.0, 2200, 50], 
            [19800000000.0, 8800000000.0, 2200, 50], 
            [107800000000.0, 35200000000.0, 2200, 50], 
            [19800000000.0, 8800000000.0, 2200, 50], 
            [107800000000.0, 35200000000.0, 2200, 50], 
            [19800000000.0, 8800000000.0, 2200, 50], 
            [107800000000.0, 35200000000.0, 2200, 50]]



strong_In = [[19800000000.0, 6600000000.0, 2200, 5], 
           [61600000000.0, 24200000000.0, 2200, 5], 
           [20900000000.0, 7700000000.0, 2200, 5], 
           [66000000000.0, 26400000000.0, 2200, 5], 
           [22000000000.0, 8800000000.0, 2200, 5], 
           [70400000000.0, 28600000000.0, 2200, 5], 
           [23100000000.0, 9900000000.0, 2200, 5], 
           [74800000000.0, 30800000000.0, 2200, 5], 
           [24200000000.0, 11000000000.0, 2200, 5], 
           [79200000000.0, 33000000000.0, 2200, 5]]

green = [[23232000000.0, 4444000000.0, 2200, 50], 
         [45144000000.0, 9790000000.0, 2200, 50], 
         [68508000000.0, 6358000000.0, 2200, 50], 
         [32604000000.0, 5764000000.0, 2200, 50], 
         [70730000000.0, 6424000000.0, 2200, 50], 
         [35200000000.0, 5632000000.0, 2200, 50], 
         [36079999999.99999, 13970000000.0, 2200, 50], 
         [39732000000.0, 9526000000.0, 2200, 50], 
         [69234000000.0, 17622000000.0, 2200, 50], 
         [38082000000.0, 8272000000.0, 2200, 50]]

freq = arange(50,100.0,5)

def DeltaFun(data,freq_range):
    
    e0 = time.time()
    c0 = time.clock()
    
    dcurve = []
    
    for x in freq:
        dcurve.append(Deltadispof.Dispof(data, x, (2500,4000), .1))
    
    # get the maximuum number of modes seen  ####
    maxmode = []
    for x in dcurve:
        maxmode.append(len(x))
    numberofmodes = max(maxmode)
    # create list for each mode and corresponding frequency  ####
    modes = []
    freqpermode = []
    for y in range(numberofmodes):
        modes.append([])
        freqpermode.append([])
    # populate mode lists with roots  ####
    fvalue = 0  # index for frequency to mode velocity pair
    for z in dcurve:  # loop through roots to get modes
        # loop through modes to form velocity/frequency pair
        for mode in range(numberofmodes):
            if len(z) > mode:
                modes[mode].append(z[mode])
                freqpermode[mode].append(freq[fvalue])
        fvalue = fvalue + 1
    elapsed_time = time.time() - e0
    cpu_time = time.clock() - c0
    print(modes)
    print(freqpermode)
    print(elapsed_time)
    print(cpu_time)
    
DeltaFun(alt10,freq)


