NameError: name 'thetas' is not defined
< /code>
в строке 12 следующей программы < /p>
import matplotlib.pyplot as plt
import numpy as np
import numpy.matlib
import math
lmin = 2.0 # source min wavelength
lmax = 5.0 # source max wavelength
fmin = 1/lmax # source min frequency
fmax = 1/lmin # source max frequency
fcen = 0.5*(fmin+fmax)
thetas = np.append(thetas, range(0,35,5))
kx = [fcen*math.sin(t) for t in [math.radians(float(t)) for t in thetas]]
Refl = np.empty((50,thetas.size))
Abs = np.empty((50,thetas.size))
theta_out = np.empty((50,thetas.size))
for k in range(thetas.size):
f0 = np.genfromtxt("flux0_a4.3_theta{}.dat".format(thetas[k]), delimiter=",")
f = np.genfromtxt("flux_a4.3_r1.72_theta{}.dat".format(thetas[k]), delimiter=",")
Refl[:,k] = -f[:,1]/f0[:,1]
theta_out[:,k] = np.asarray([math.degrees(math.asin(kx[k]/f0[j,0])) for j in range(50)])
Abs[:,k] = np.asarray([(1-Refl[j,k])*math.cos(math.radians(theta_out[j,k])) for j in range(50)])
Abs[Abs
Подробнее здесь: [url]https://stackoverflow.com/questions/79725556/what-is-wrong-with-this-python-variable-nameerror-name-thetas-is-not-defined[/url]
Я пытаюсь построить результат проекта 5 в http://www.simpetus.com/projects.html#meep_thermal_radiation , но получите сообщение об ошибке [code]NameError: name 'thetas' is not defined < /code> в строке 12 следующей программы < /p> import matplotlib.pyplot as plt import numpy as np import numpy.matlib import math
lmin = 2.0 # source min wavelength lmax = 5.0 # source max wavelength fmin = 1/lmax # source min frequency fmax = 1/lmin # source max frequency fcen = 0.5*(fmin+fmax)
thetas = np.append(thetas, range(0,35,5)) kx = [fcen*math.sin(t) for t in [math.radians(float(t)) for t in thetas]] Refl = np.empty((50,thetas.size)) Abs = np.empty((50,thetas.size)) theta_out = np.empty((50,thetas.size))
for k in range(thetas.size): f0 = np.genfromtxt("flux0_a4.3_theta{}.dat".format(thetas[k]), delimiter=",") f = np.genfromtxt("flux_a4.3_r1.72_theta{}.dat".format(thetas[k]), delimiter=",") Refl[:,k] = -f[:,1]/f0[:,1] theta_out[:,k] = np.asarray([math.degrees(math.asin(kx[k]/f0[j,0])) for j in range(50)]) Abs[:,k] = np.asarray([(1-Refl[j,k])*math.cos(math.radians(theta_out[j,k])) for j in range(50)])
Я пытался запустить интерактивный интерпретатор Python, набрав python в командной строке Windows, но выдал ошибку:
python
Traceback (most recent call last):
File , line 1, in
NameError: name 'python' is not defined
>>>