def sanity_slowVsFast(self): """ Comparing 'slow' and 'fast' algorithm. """ wvl = numpy.arange(4999., 5011., 0.04) flux = numpy.zeros(len(wvl)) flux[150] = 0.5 bfast = fastRotBroad(wvl, flux, 0.37, 37.) bslow = rotBroad(wvl, flux, 0.37, 37.) indi = numpy.where(numpy.logical_and(wvl > 5000., wvl < 5010.))[0] self.assertAlmostEqual(numpy.max(numpy.abs( bfast[indi] - bslow[indi] )), 0.0, delta=1e-5) flux[150] = 1.0 A = -0.05 s = 0.1 mu = 5004.1635788 flux += A/numpy.sqrt(2.*numpy.pi*s**2) * \ numpy.exp(-(wvl-mu)**2/(2.*s**2)) bfast = fastRotBroad(wvl, flux, 0.81, 11.37) bslow = rotBroad(wvl, flux, 0.81, 11.37) indi = numpy.where(numpy.logical_and(wvl > 5000., wvl < 5010.))[0] self.assertAlmostEqual(numpy.max(numpy.abs( bfast[indi] - bslow[indi] )), 0.0, delta=1e-5)
def sanity_rotBroadEW(self): """ Checking whether "rotBroad" changes the EW. """ import numpy as np from PyAstronomy import funcFit as fuf import scipy.integrate as sci # Create a spectrum with a single Gaussian # line using funcFit's GaussFit1d object. # Note that this object is not used for # fitting here, but only a calculate a # Gaussian. g = fuf.GaussFit1d() g["mu"] = 5005. g["A"] = -0.1 g["sig"] = 0.1 g["off"] = 1.0 # Evaluate the spectrum with 0.01 A bin size wvl = np.linspace(5003., 5007., 400) flux = g.evaluate(wvl) refEW = abs(g["A"]) for broad in np.linspace(0.1, 100., 1.): for eps in np.linspace(0., 1., 0.2): nflux = rotBroad(wvl, flux, epsilon=eps, vsini=broad) ew = 4. - sci.trapz(nflux, wvl) self.assertAlmostEqual(ew, refEW, 5, "The EW in rotbroad changes for: vsini = " + \ str(broad) + ", and eps = " + str(eps))