Exemple #1
0
def create_noisy(struct, threshold, save_spot):

	#get distance matrix and output it
	print "Calculating distance matrix..."
	dist_matrix = calc_dist_matrix(struct)
	
	#add noise to DM then scale it
	print "Adding noise to DIST matrix..."
	noise_matrix = np.random.normal(0, 1, dist_matrix.shape)
	noise_matrix = noise_matrix * float(threshold)
	
	#combine matrices
	print "Combining matrices..."
	out_matrix = dist_matrix + (dist_matrix * noise_matrix)

	
	#print "Saving distance matrix (May take a while)..."
	#np.savetxt(save_spot + '_DIST_NOISY.dat', dist_matrix, fmt='%10.4f', delimiter='\t', newline='\n')

	#get IF using 1/d, change ratio if you want a different conversion
	print "Calculating IF matrix..."
	if_matrix = []
	for dist in np.nditer(out_matrix):
		if dist == 0.0:
			if_matrix.append(1.0 / 0.01)
		else:
			if_matrix.append(1.0 / dist)
		
	#now shape the matrix
	if_matrix_np = np.array(if_matrix).reshape(dist_matrix.shape)
	
	print "Saving IF matrix (May take a while)..."
	np.savetxt(save_spot, if_matrix_np, fmt='%10.4f', delimiter='\t', newline='\n')
Exemple #2
0
def create_dm(struct, save_spot):
	
	#get distance matrix and output it
	print "Calculating distance matrix..."
	dist_matrix = calc_dist_matrix(struct)
	
	print "Saving distance matrix (May take a while)..."
	np.savetxt(save_spot, dist_matrix, fmt='%10.4f', delimiter='\t', newline='\n')
Exemple #3
0
def create_ifm(struct, save_spot):

	#get IF using 1/d, change ratio if you want a different conversion
	dist_matrix = calc_dist_matrix(struct)
	print "Calculating IF matrix..."
	if_matrix = []
	for dist in np.nditer(dist_matrix):
		if dist == 0.0:
			if_matrix.append(1.0 / 0.01)
		else:
			if_matrix.append(1.0 / dist)
		
	#now shape the matrix
	if_matrix_np = np.array(if_matrix).reshape(dist_matrix.shape)
		
	print "Saving IF matrix (May take a while)..."
	np.savetxt(save_spot, if_matrix_np, fmt='%10.4f', delimiter='\t', newline='\n')