赤方偏移の値のセットがあり、宇宙の減速パラメーターの対応する値のセットがあります。プロットが与えられます:
ここで、q = 0のグラフから正確にzの値が必要です。私は多くのコマンドを試しましたが、それらはすべてある種のエラーにつながります。私はPythonにあまり詳しくないので、それらすべてを修正する方法を試すことすらできません。
コマンドを試したとき:
z1 = interp1d(z,q,0)
結果は次のとおりです。
0x051899F0のscipy.interpolate.interpolate.interp1dオブジェクト
どうすればこれを解決できますか?
私のコード:
while z0<zf:' '
z.append(z0)
a.append(1/(1+z0))
term=((1+(omega/(B-1)))*a[k]**(3*(B-1)))
H.append(((term-(omega/(B-1)))*H02)**0.5)
q.append(-1-((H0*term*3*(B-1)*(term-(omega/(B-1)))-0.5)/(2*H[k])))
print '%.2f \t%.4f \t%.4f \t%.15f'%(z[k],a[k],H[k],q[k])
k=k+1
z0=z0+h
Your code had some issues. I only have Python 3 here so if you have any problem understanding something just ask (changed a bit the print
and the input
function parts).
You did not define the H02
so I just stated it was equal to H0
. Correct that if it is wrong. Here is your corrected code (see the comments for important stuff):
from pylab import*
import matplotlib.pyplot as plt
from scipy.interpolate import interp1d
fig, ax = subplots()
k = 0
omega, B, H0 = 0.6911, 0.019921992722139001, 67.74
H02 = H0 + 0 # You didn't specify this so I had to make up something
z0 = 0
h = 0.05
z, a, H, q = [], [], [], []
print('Value of H0, Omega and Beta:%.3f,%.4f,%.18f'%(H0, omega, B))
zf = float(input('Enter the final value of redshift:')) # Remember that this needs to output a number
print('Red shift Scale factor Hubble parameter q value') # I chose 10 in my test.
print('===========================================================')
while z0 < zf:
z.append(z0)
a.append(1/(1+z0))
term=((1+(omega/(B-1)))*a[k]**(3*(B-1)))
H.append(((term-(omega/(B-1)))*H02)**0.5)
q.append(-1-((H0*term*3*(B-1)*(term-(omega/(B-1)))-0.5)/(2*H[k])))
print('%.2f \t%.4f \t%.4f \t%.15f'%(z[k], a[k], H[k], q[k]))
k = k+1
z0 = z0+h
title('Decceleration parameter(q) versus Red shift(z) graph ')
xlabel('Redshift z')
ylabel('Decceleration parameter q')
z1 = interp1d(q, z)
print(z1(40000)) # I used a redshift parameter of 10 and 0 does not exist in the data limits so I just used 40 000.
plot(z, q)
plot([z1(40000), z1(40000)], [0, 40000], c='r')
plot([0, z1(40000)], [40000, 40000], c='r')
ax.spines['left'].set_position('zero')
ax.spines['right'].set_color('none')
ax.yaxis.tick_left()
ax.spines['bottom'].set_position('zero')
ax.spines['top'].set_color('none')
ax.xaxis.tick_bottom()
show()
, and it results in this:
I added the red line to show you the result of the interpolation which is made like this:
z1 = interp1d(q, z) # Create your function with your q (input) and z (output)
result = z1(40000) # This is checking the value of z when q=40000
The thing you need to remember is that interp1D
will only be able to interpolate in the region of the data you gave. So if q
is within 10
and 100
you cannot interpolate q=0
.
私は10の赤方偏移を使用しました(主題は面白そうに見えましたが、何を使用すればよいかわかりませんでした)。これはプロットに影響を与えていないようですので、ここにコードを入れたとき、またはコメントから理解しようとしたときに何かがうまくいかなかったと思います(プロットが私のものとは異なるため)。すべてが正常であることを確認し、問題を解決するために使用できるパーツを使用してください。
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加