Untitled
unknown
plain_text
2 years ago
1.1 kB
7
Indexable
def hermitian_pulse(pol_num, bandwidth, centre, FWHM, num = 1000, x_type = "freq"):
'''
Creates spectrum with \"pol-num\"-th Hermit-Gauss intensity mode. "bandwidth" is a tuple with start and the end of the entire spectrum.
"centre" and "FWHM" characterize the pulse itself. The spectrum is composed of \"num\" = 1000 points on default.
'''
# exceptions
if x_type not in ["freq", "wl", "time"]:
raise Exception("x_type must be either \"freq\", \"nm\" or \"time\"")
# modules
import spectral_analysis as sa
from scipy.special import hermite as hermite_gen
# and calculations
hermite_pol = hermite_gen(pol_num)
def gauss(x, mu, std):
return 1/(std*np.sqrt(2*np.pi))*np.exp(-(x-mu)**2/(2*std**2))
X = np.linspace(bandwidth[0], bandwidth[1], num = num)
sd = FWHM/2.355
Y_gauss = gauss(X, centre, sd)
Y_hermite = hermite_pol(2*(X-centre)/FWHM)
Y_out = Y_hermite*Y_gauss
spectrum_out = sa.spectrum(X, Y_out, "freq", "intensity")
spectrum_out.normalize(norm = "L2", shift_to_zero = False)
return spectrum_outEditor is loading...