-
Notifications
You must be signed in to change notification settings - Fork 0
/
stripPrecession.py
103 lines (77 loc) · 2.78 KB
/
stripPrecession.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/python3
import numpy as np
from os import walk, getcwd
import sys
# print(getcwd())
# f = []
# for (dirpath, dirnames, filenames) in walk(getcwd()):
# f.extend(filenames)
# break # will only get the files right there
# print(f)
# sep_set = set([])
# Pre_N = input("Enter Pre N ")
# Post_N = input("Enter Post N ")
# Pre_R = input("Enter Pre R ")
# Post_R = input("Enter Post R ")
# for filename in f:
# if (Pre_N in filename and Post_N in filename):
# sep_set.add(filename[len(Pre_N):-len(Post_N)])
# elif (Pre_R in filename and Post_R in filename):
# sep_set.add(filename[len(Pre_R):-len(Post_R)])
# print(sep_set)
# # stop = input("stoppit?q/n ")
# # if stop is 'q':
# # exit(0)
# sep_list = []
# postfix = ""
# for bh_sep in sep_set:
# Rfile = Pre_R + bh_sep + Post_R
# Nfile = Pre_N + bh_sep + Post_N
# keep_going = 'y'
# found = True
# print(Rfile, Nfile)
# while found:
# try:
# Rdata = np.genfromtxt(Rfile, names=True, usecols=('Precession'))
# Ndata = np.genfromtxt(Nfile, names=True, usecols=('Precession'))
# found = False
# except OSError as e:
# print(e)
# keep_going = input('Did not find that file. Enter \'n\' if done: ')
# if keep_going is 'n':
# break
# Rfile = input('The full name of the Relativistic precession file: ')
# Nfile = input('The full name of the Newtonian precession file: ')
# if keep_going is 'n':
# break
# Rcol = Rdata['Precession']
# Ncol = Ndata['Precession']
# print(Rcol, type(Rcol))
# print(Ncol, type(Ncol))
# Nfloat = isinstance(Ncol, (float, np.ndarray))
# Rfloat = isinstance(Rcol, (float, np.ndarray))
# sep_list.append([float(bh_sep), Ncol if Nfloat else Ncol[0], Rcol if Rfloat else Rcol[0]])
# sep_list = sorted(sep_list)
# print(sep_list)
# header_text = "Separation Newtonian Relativistic"
# np.savetxt('result.dat', sep_list, header=header_text)
keep_going = 't'
sep_list = []
while keep_going is not 'n':
Rfile = input('relativistic: ')
Nfile = input('newtonian: ')
Rdata = np.genfromtxt(Rfile, names=True, usecols=('Precession'))
Ndata = np.genfromtxt(Nfile, names=True, usecols=('Precession'))
bh_sep = input('bh sep: ')
Rcol = Rdata['Precession']
Ncol = Ndata['Precession']
print(Rcol, type(Rcol))
print(Ncol, type(Ncol))
Nfloat = isinstance(Ncol, (float,))
Rfloat = isinstance(Rcol, (float,))
sep_list.append([float(bh_sep), Ncol if Nfloat else Ncol[0], Rcol if Rfloat else Rcol[0]])
keep_going = input('keep going?')
sep_list = sorted(sep_list)
print(sep_list)
header_text = "Separation Newtonian Relativistic"
np.savetxt('result2.dat', sep_list, header=header_text)