-
Notifications
You must be signed in to change notification settings - Fork 1
/
uplow_bounds_wx.py
48 lines (39 loc) · 1.42 KB
/
uplow_bounds_wx.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
#import numpy as np
import matplotlib.pyplot as plt
from integrator.simpsons import simpsrule as integrate
from functions.t0_part1b import t0_part1b as t0
from numpy import arange
from numpy import abs
#set function
ft = t0()
#set range of w_x values to cycle through
rangwx = [-100,0]
#set step
step = 1e-2
#omega_m values: mean and upper and lower 1-sigma and 2-sigma bounds
Xs = [0.45, 0.25, 0.30, 0.35, 0.40]
#t_0 values: mean and upper and lower 1-sigma and 2-sigma bounds
Ys = [15.0, 10.6, 11.7, 12.8, 13.9]
#statements to show when printing w_x value
meanings = ['2-sigma upper bound: ', '1-sigma lower bound: ', 'Mean: ', '1-sigma upper bound: ', '2-sigma lower bound: ']
#tolerance - how far from the actual answer the calculated answer can be
tolerance = 1e-2
#create text file
text_file = open("wx_values.txt", "w")
#cycle through each bound on omega_m
for i in range(0, len(Xs)):
#cycle through all w_x values in range
for wx in arange(rangwx[0], rangwx[1]+step, step):
#set w_x
ft.update(wx = wx)
#calculate value of t_0
val = ft.cal(Xs[i])
#print(val)
#compare calculated value of t_0 to actual value
if abs(Ys[i]-val) <= tolerance:
print(meanings[i] + str(wx))
#print to text file
text_file.write("%s %f" % (meanings[i], wx) + "\n")
break
#close text file
text_file.close()