import csc
import numpy as np
import os

thetas = np.arange(90,-1,-1)

files=[]
true_thetas = []
for theta in thetas:
	filename = 'Ba2NaOsO6-001-cant-010-'+str(int(theta))+'-mu-histo.tsv'
	if os.path.exists(filename):
		meta,properties,f = csc.begin_read(filename)
		files.append(f)
		true_thetas.append(theta)
		del f

i=0
is_eof = False
newfile = open('Ba2NaOsO6-001-cant-010-3d-mu-histo.tsv','w')
while not is_eof:
	for i in range(len(true_thetas)):
		values,error = csc.readline(files[i],properties)
		if error == 'EOF':
			exit()
		elif error == None:
			#if it's within the range, shove it into the histogram
			newfile.write(str(true_thetas[i])+'\t'+str(values['mu'])+'\t'+str(values['pdf'])+'\n')