Was mit diesem Python -Variablen -Namens -Namen nicht falsch ist: Name 'Thetas' ist nicht definiert [geschlossen]Python

Python-Programme
Anonymous
 Was mit diesem Python -Variablen -Namens -Namen nicht falsch ist: Name 'Thetas' ist nicht definiert [geschlossen]

Post by Anonymous »

Ich versuche, das Ergebnis von Projekt 5 in
http://www.simpetus.com/projects.html#m ... _radiation
zu zeichnen, aber erhalten Sie eine EN -Fehlermeldung

Code: Select all

NameError: name 'thetas' is not defined
< /code>
In Zeile 12 des folgenden Programms < /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

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post