def sanity_VoigtAstroP_R_Example(self): """ Sanity of VoigtAstroP example with instrumental resolution """ from PyAstronomy import modelSuite as ms import numpy as np import matplotlib.pylab as plt # Obtain an object of type VoigtAstroP ... v = ms.VoigtAstroP() # ... and set some parameters v["b"] = 40.7 v["f"] = 0.5 v["w0"] = 1214.0 # Damping constant [cm] v["gamma"] = 2e-9 # Generate wavelength axis ... wvl = np.linspace(1212., 1216., 200) # ... and evaluate model m = v.evaluate(wvl) # Add (Gaussian) instrumental broadening with resolution 5000 v["R"] = 5000 mr = v.evaluate(wvl)
def sanity_normalization(self): """ Normalization of AstroVoigtP """ import numpy as np from PyAstronomy import modelSuite as ms from PyAstronomy import pyaC v = ms.VoigtAstroP() # Hypothetical wvls [A] w0s = [1000., 5000, 10000.] # (pi e**2)/(m_e c) const = (4.803e-10)**2*np.pi / (9.11e-28*29979245800.0) fs = [1, 100] for f in fs: for w0 in w0s: v["w0"] = w0 v["b"] = 100. v["gamma"] = 1e-10 v["f"] = f dw = 20.0 w = np.linspace(w0-dw, w0+dw, 1000) m = v.evaluate(w) i = pyaC.ibtrapz(w/1e8, m*29979245800.0/(w/1e8)**2 , (w0-dw)/1e8, (w0+dw)/1e8) self.assertAlmostEqual(i/const, f, delta=1e-2, msg="Normalization of AstroVoigtP is broken: f, w0, i: % g, % g, % g" % (f, w0, i))
def sanity_instrumentalResolution(self): """ Checking integrity of instrumental resolution in VoigtAstroP """ import numpy as np from PyAstronomy import modelSuite as ms from PyAstronomy import pyasl v = ms.VoigtAstroP() w0 = 10830 for R in [2500, 5000, 80000]: v["w0"] = w0 v["b"] = 10. v["gamma"] = 1e-8 v["f"] = 100.0 v["R"] = 0 dw = 40.0 w = np.linspace(w0 - dw, w0 + dw, 4000) m = v.evaluate(w) v["R"] = R m2 = v.evaluate(w) fb = pyasl.instrBroadGaussFast(w, m, R, edgeHandling=None, fullout=False, maxsig=None) d = 1000 self.assertAlmostEqual( np.max(np.abs(fb[d:-d] - m2[d:-d]) / m2[d:-d]), 0.0, delta=1e-10, msg="VoigtAstroP instrumental broadening broken for R = " + str(R))
def sanity_VoigtAstroPExample(self): """ Sanity of VoigtAstroP example """ from PyAstronomy import modelSuite as ms import numpy as np import matplotlib.pylab as plt # Obtain an object of type VoigtAstroP ... v = ms.VoigtAstroP() # ... and set some parameters v["b"] = 87.7 v["f"] = 0.5 v["w0"] = 1214.0 # Damping constant [cm] v["gamma"] = 2e-9 # Generate wavelength axis ... wvl = np.linspace(1212., 1216., 200) # ... and evaluate model m = v.evaluate(wvl) # Plot result plt.plot(wvl, m, 'b.-')