return X_test, y_test, pvals, keys, time if __name__ == "__main__": models = { 'SVM': load_model('models/SVM_transit.h5'), 'MLP': load_model('models/MLP_transit.h5'), 'Wavelet MLP': load_model('models/Wavelet MLP_transit.h5'), 'CNN 1D': load_model('models/CNN 1D_transit.h5'), } # load OG data X_test, y_test, pvals, keys, OGtime = load_data('transit_data_test.pkl', whiten=True, NULL=False) colors = { 'MLP': 'red', 'Wavelet MLP': 'green', 'CNN 1D': 'blue', 'SVM': 'orange' } # resolution of data relative original npts = np.arange(X_test.shape[1] * 0.25, X_test.shape[1] * 2, 30).astype(int) idxs = np.arange(X_test.shape[1]) # filter by
def generate(N): try: X_test, y_test, pvals, keys, time = load_data( 'test_dt{}.pkl'.format(N), whiten=True, NULL=False) except: print('Generating Data:', N) settings = {'ws': 360, 'dt': 360. / N} hw = (0.5 * N * settings['dt']) / 60. / 24. # half width in days t = np.linspace(1 - hw, 1 + hw, N) dt = t.max() - t.min() # default transit parameters init = { 'rp': 0.1, 'ar': 12.0, # Rp/Rs, a/Rs 'per': 2, 'inc': 90, # Period (days), Inclination 'u1': 0.5, 'u2': 0, # limb darkening (linear, quadratic) 'ecc': 0, 'ome': 0, # Eccentricity, Arg of periastron 'a0': 1, 'a1': 0, # Airmass extinction terms 'a2': 0, 'tm': 1 } # tm = Mid Transit time (Days) pgrid_test = { # TEST data 'rp': (np.array([200, 500, 1000, 2500, 5000, 10000]) / 1e6)**0.5, # transit depth (ppm) -> Rp/Rs 'per': np.linspace(*[2, 4, 5]), 'inc': np.array([86, 87, 90]), 'sig_tol': np.linspace( *[0.25, 3, 12]), # generate noise based on X times the tdepth # stellar variability systematics 'phi': np.linspace(*[0, np.pi, 4]), 'A': np.array([250, 500, 1000, 2000]) / 1e6, 'w': np.array([6, 12, 24]) / 24., # periods in days 'PA': [ -4 * dt, 4 * dt, 100 ], # doubles amp, zeros amp between min time and max time, 1000=no amplitude change 'Pw': [-12 * dt, 4 * dt, 100], #-12dt=period halfs, 4dt=period doubles, 1000=no change } data = dataGenerator(**{ 'pgrid': pgrid_test, 'settings': settings, 'init': init }) data.generate() pickle.dump( { 'keys': data.keys, 'results': data.results, 'time': data.t }, open('pickle_data/test_dt{}.pkl'.format(N), 'wb')) X_test, y_test, pvals, keys, time = load_data( 'test_dt{}.pkl'.format(N), whiten=True, NULL=False) return X_test, y_test, pvals, keys, time
from keras.utils import np_utils import matplotlib.pyplot as plt import numpy as np import pickle if __name__ == "__main__": models = { 'SVM': load_model('models/SVM_transit.h5'), 'MLP': load_model('models/MLP_transit.h5'), 'Wavelet MLP': load_model('models/Wavelet MLP_transit.h5'), 'CNN 1D': load_model('models/CNN 1D_transit.h5'), } # load DATA X_test, y_test, pvals, keys, time = load_data('transit_data_test.pkl', whiten=True) Xw_test = wavy(X_test) Xc_test = X_test.reshape((X_test.shape[0], X_test.shape[1], 1)) #y_test = np_utils.to_categorical(y_test, num_classes=2) tests = { 'MLP': X_test, 'Wavelet MLP': Xw_test, 'CNN 1D': Xc_test, 'SVM': X_test } colors = { 'MLP': 'red', 'Wavelet MLP': 'green', 'CNN 1D': 'blue',