So I have tried to plot a log log curve of intensity vs frequency using planck equation with the help of python.But I didn't get the output.i don't know were are the errors exactly.
import matplotlib.pyplot as plt
import numpy as np
h = 6.626e-34
c = 3.0e+8
k = 1.38e-23
def planck(freq, T):
a = 2.0*h*freq**3
b = h*freq/(k*T)
intensity = a/ ( (c**2) * (np.exp(b) - 1.0) )
return intensity
frequency = np.logspace(10e+9, 10e+19, 1e10,endpoint=False)
# intensity at 3000K, 5000K, 10000K, 20000K,30000K
intensity3000 = planck(frequency, 3000.)
intensity5000 = planck(frequency, 5000.)
intensity10000 = planck(frequency, 10000.)
intensity20000 = planck(frequency, 20000.)
intensity30000=planck(frequency,30000.)
plt.loglog(frequency, intensity3000, 'k-')
# plot intensity3000 versus frequency in Hz as a black line
plt.loglog(frequency, intensity5000, 'y-')
# 5000K yellow line
plt.loglog(frequency, intensity10000, 'r-')
# 10000K red line
plt.loglog(frequency, intensity20000, 'g-')
# 20000K green line
plt.xlim([10e+9,10e+19])
plt.ylim([1,1e10])
# show the plot
plt.show()
I tried to run the program .but this is what I got:
> Traceback (most recent call last): File
> "/data/user/0/ru.iiec.pydroid3/app_HOME/planckplot.py", line 11, in
> <module> File "<__array_function__ internals>", line 5, in logspace
> File
> "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/numpy/core/function_base.py",
> line 275, in logspace
> y = linspace(start, stop, num=num, endpoint=endpoint, axis=axis) File "<__array_function__ internals>", line 5, in linspace File
> "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/numpy/core/function_base.py",
> line 120, in linspace
> num = operator.index(num) TypeError: 'float' object cannot be interpreted as an integer
I am really stuck here. What I am looking for is a log-log
graph with B_nu
in units of Joule/sec/meter^2/steradian/Hertz
along the Y-axis and frequency in Hertz along the X-axis. The frequency range is taken from 10^9 Hz to 10^19 Hz.
Ps:I have only beginner level python knowledge.