Lv2_dj_lsp.py
def psd_error(times,rates,errors):
	"""
	obtain errors for the best frequency estimate of the signal
	"""

	"""
	print(len(times),len(rates),len(errors))
	newdatachoice = np.random.choice(len(times),size=int(0.1*len(times)))

	newtimes = list(np.array([times[0]])) + list(np.array([times[-1]])) + list(times[np.array(list(set(newdatachoice)))])
	newrates = list(np.array([rates[0]])) + list(np.array([rates[-1]])) + list(rates[np.array(list(set(newdatachoice)))])
	newerrs = list(np.array([errors[0]])) + list(np.array([errors[-1]])) + list(errors[np.array(list(set(newdatachoice)))])

	times = newtimes
	rates = newrates
	errors = newerrs
	print(len(times),len(rates),len(errors))
	"""
	freqs_list = []
	psds_list = []
	for j in tqdm(range(1000)):
		new_rates = np.zeros(len(rates))
		for i in range(len(rates)):
			if rates[i] != 0:
				new_rates[i] = np.random.normal(loc=rates[i],scale=errors[i])

		trunc_times = times-times[0]

		newchoice = np.random.choice(len(trunc_times),size=len(trunc_times))
		rand_times = trunc_times[np.array(list(set(newchoice)))]
		rand_rates = new_rates[np.array(list(set(newchoice)))]
		omega,psd,prob3,prob4,prob5 = lsp(rand_times,rand_rates)

		nu_reg = omega/(2.0*np.pi)
		freq = omega/(2*np.pi)
		psds_list.append( np.max(psd[(freq>=8.2e-6)&(freq<=8.4e-6)]) )
		freqs_list.append( freq[psd==psds_list[-1]][0])

	#plt.figure()
	#plt.plot(freq,psd,'rx-')
	#plt.show()

	return freqs_list,psds_list

	obtain errors for the best frequency estimate of the signal
	
obtain errors for the best frequency estimate of the signal
obtain errors for the best frequency estimate of the signal
def psd_error(times,rates,errors):
	freqs_list = []
	psds_list = []
	for j in tqdm(range(1000)):
		new_rates = np.zeros(len(rates))
		for i in range(len(rates)):
			if rates[i] != 0:
				new_rates[i] = np.random.normal(loc=rates[i],scale=errors[i])
		trunc_times = times-times[0]
		newchoice = np.random.choice(len(trunc_times),size=len(trunc_times))
		rand_times = trunc_times[np.array(list(set(newchoice)))]
		rand_rates = new_rates[np.array(list(set(newchoice)))]
		omega,psd,prob3,prob4,prob5 = lsp(rand_times,rand_rates)
		nu_reg = omega/(2.0*np.pi)
		freq = omega/(2*np.pi)
		psds_list.append( np.max(psd[(freq>=8.2e-6)&(freq<=8.4e-6)]) )
		freqs_list.append( freq[psd==psds_list[-1]][0])
	return freqs_list,psds_list
def psd_error ( times , rates , errors ) : """
	print(len(times),len(rates),len(errors))
	newdatachoice = np.random.choice(len(times),size=int(0.1*len(times)))

	newtimes = list(np.array([times[0]])) + list(np.array([times[-1]])) + list(times[np.array(list(set(newdatachoice)))])
	newrates = list(np.array([rates[0]])) + list(np.array([rates[-1]])) + list(rates[np.array(list(set(newdatachoice)))])
	newerrs = list(np.array([errors[0]])) + list(np.array([errors[-1]])) + list(errors[np.array(list(set(newdatachoice)))])

	times = newtimes
	rates = newrates
	errors = newerrs
	print(len(times),len(rates),len(errors))
	""" freqs_list = [ ] psds_list = [ ] for j in tqdm ( range ( 1000 ) ) : new_rates = np . zeros ( len ( rates ) ) for i in range ( len ( rates ) ) : if rates [ i ] != 0 : new_rates [ i ] = np . random . normal ( loc = rates [ i ] , scale = errors [ i ] ) trunc_times = times - times [ 0 ] newchoice = np . random . choice ( len ( trunc_times ) , size = len ( trunc_times ) ) rand_times = trunc_times [ np . array ( list ( set ( newchoice ) ) ) ] rand_rates = new_rates [ np . array ( list ( set ( newchoice ) ) ) ] omega , psd , prob3 , prob4 , prob5 = lsp ( rand_times , rand_rates ) nu_reg = omega / ( 2.0 * np . pi ) freq = omega / ( 2 * np . pi ) psds_list . append ( np . max ( psd [ ( freq >= 8.2e-6 ) & ( freq <= 8.4e-6 ) ] ) ) freqs_list . append ( freq [ psd == psds_list [ - 1 ] ] [ 0 ] ) return freqs_list , psds_list
obtain errors for the best frequency estimate of the signal
obtain errors for the best frequency estimate of the signal
"""
	obtain errors for the best frequency estimate of the signal
	""" """
	print(len(times),len(rates),len(errors))
	newdatachoice = np.random.choice(len(times),size=int(0.1*len(times)))

	newtimes = list(np.array([times[0]])) + list(np.array([times[-1]])) + list(times[np.array(list(set(newdatachoice)))])
	newrates = list(np.array([rates[0]])) + list(np.array([rates[-1]])) + list(rates[np.array(list(set(newdatachoice)))])
	newerrs = list(np.array([errors[0]])) + list(np.array([errors[-1]])) + list(errors[np.array(list(set(newdatachoice)))])

	times = newtimes
	rates = newrates
	errors = newerrs
	print(len(times),len(rates),len(errors))
	""" #plt.figure() #plt.plot(freq,psd,'rx-') #plt.show()
times
rates
errors