def super_worker(self, *args): # generate parameter dict for transit function input pars = self.init.copy() for k in range(len(self.keys)): pars[self.keys[k]] = args[k] # compute white noise noise = pars['rp']**2 / pars['sig_tol'] ndata = np.random.normal(1, noise, len(self.t)) # generate transit + variability t = self.t - np.min(self.t) A = pars['A'] + pars['A'] * np.sin(2 * np.pi * t / pars['PA']) w = pars['w'] + pars['w'] * np.sin(2 * np.pi * t / pars['Pw']) data = transit(time=self.t, values=pars) * ndata * ( 1 + A * np.sin(2 * np.pi * t / w + pars['phi'])) #2018 Apr 24 - ndata is the noise signal but without any transit in it # So results has one column that is all the transit and noise parameters, # the next column contains the transit + noise signals, # and the final column contains just the noise signals without any transits # add systematic into noise "same distribution different points" ndata = np.random.normal(1, noise, len( self.t)) * (1 + A * np.sin(2 * np.pi * t / w + pars['phi'])) return args, data, ndata
def super_worker(self, *args): # generate parameter dict for transit function input pars = self.init.copy() for k in range(len(self.keys)): pars[self.keys[k]] = args[k] # compute white noise noise = pars['rp']**2 / pars['sig_tol'] ndata = np.random.normal(1, noise, len(self.t)) # generate transit + variability t = self.t - np.min(self.t) A = pars['A'] + pars['A'] * np.sin(2 * np.pi * t / pars['PA']) w = pars['w'] + pars['w'] * np.sin(2 * np.pi * t / pars['Pw']) kk = np.random.randint(2, 5) w = w / kk tt = transit(time=self.t, values=pars) tt = 1 + (tt - 1) * np.random.normal(1, 0.15) data = tt * ndata * (1 + A * np.sin(2 * np.pi * t / w + pars['phi'])) # add systematic into noise "same distribution different points" ndata = np.random.normal(1, noise, len( self.t)) * (1 + A * np.sin(2 * np.pi * t / w + pars['phi'])) return args, data, ndata
def generate_positives(residuals, pars, N=10000, minsnr=1.5, snrscale=2): positive = [] snrs = [] # generate some positive examples for i in range(10000): # choose random sample of time, ensure we have enough data points `` length = 0 while (length != 180): di = np.random.choice(np.arange(len(times))) # make sure we get enough data for NN ti = np.random.choice(np.arange(len(times[di]))) start_t = times[di][ti] end_t = times[di][ti] + 2 * 180 / (24 * 60) tmask = (times[di] > start_t) & (times[di] < end_t) length = tmask.sum() tlength = 0 # make sure the transit length is sufficient while (tlength < 15): std = np.std(residuals[di][tmask]) snr = minsnr + np.random.uniform() * snrscale snrs.append(snr) # create parameters for injected data set pars['ar'] = np.random.uniform() * 7 + 7 pars['per'] = np.random.uniform() * 4 + 2 pars['tm'] = np.median( times[di][tmask]) + np.random.random() / 24 / 60 pars['rp'] = (np.abs(snr) * std)**0.5 tmodel = transit(time=times[di][tmask], values=pars) if (snr < 0): tmodel *= -1 tmodel += 2 tlength = (tmodel != 1).sum() # create data and assess transit probability data = residuals[di][tmask] * tmodel pdata = preprocessing.scale(data) positive.append(pdata) return snrs, positive
# plt.show() NPTS = 1000 # simulate transit data from ELCA import lc_fitter, transit from flux_decorrelation import gaussian_weights t = np.linspace(0.85,1.05,NPTS) init = { 'rp':0.1, 'ar':14.07, # Rp/Rs, a/Rs 'per':3.336817, 'inc':88.75, # Period (days), Inclination 'u1': 0.3, 'u2': 0, # limb darkening (linear, quadratic) 'ecc':0, 'ome':0, # Eccentricity, Arg of periastron 'a0':1, 'a1':0, # Airmass extinction terms 'a2':0, 'tm':0.95 } # tm = Mid Transit time (Days) data = transit(time=t, values=init) #+ np.random.normal(0, 2e-4, len(t)) # simulate PSFs on detector xcent = [15.13] ycent = [14.96] sigmax = [0.55] sigmay = [0.55] for i in range(1,NPTS): xcent.append( xcent[i-1] + np.random.normal(0,0.005) ) ycent.append( ycent[i-1] + np.random.normal(0,0.005) ) sigmax.append( sigmax[i-1] + np.random.normal(0,0.0005) ) sigmay.append( sigmay[i-1] + np.random.normal(0,0.0005) ) # simulate images on detector X = np.zeros((NPTS,7))
# GENERATE DATA NDAYS = 30 CADENCE = 29.4 # minutes NPTS = int(NDAYS * 24 * 60 / CADENCE) # transit data t = np.linspace(0.5, 0.5 + NDAYS, NPTS) init = { 'rp': 0.1, 'ar': 12.0, # Rp/Rs, a/Rs 'per': 8, 'inc': 90, # Period (days), Inclination 'u1': 0.7, '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) model = transit(time=t, values=init) data = model * np.random.normal(1, 1000e-6, NPTS) + 500e-6 * np.sin( 2 * np.pi * np.arange(NPTS) / (0.5 * NPTS)) alphas, rgba_colors = time_series_eval(data, mlp, spacing=5, ws=180) plot_time_series(t, data, alphas, rgba_colors) # TODO implement BLS
'rp': 0.1, 'ar': 12, # 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) for v in changes[key]: init[key] = v ax[i, j].plot(t, transit(time=t, values=init), label="{} = {}".format(label[key], v)) ax[i, j].legend(loc='best') ax[i, j].set_xlabel('Time (Days)') ax[i, j].set_ylim([0.986, 1.0005]) if j == 1: ax[i, j].get_yaxis().set_ticks([]) else: ax[i, j].set_ylabel('Relative Flux') plt.savefig('transit_shape_analysis.png')