Module funclib
source code
Database with model functions.
To be used with the ivs.sigproc.fit.minimizer
function or with the evaluate
function in this module.
>>> p = plt.figure()
>>> x = np.linspace(-10,10,1000)
>>> p = plt.plot(x,evaluate('gauss',x,[5,1.,2.,0.5]),label='gauss')
>>> p = plt.plot(x,evaluate('voigt',x,[20.,1.,1.5,3.,0.5]),label='voigt')
>>> p = plt.plot(x,evaluate('lorentz',x,[5,1.,2.,0.5]),label='lorentz')
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
]include figure]]ivs_sigproc_fit_funclib01.png]
>>> p = plt.figure()
>>> x = np.linspace(0,10,1000)[1:]
>>> p = plt.plot(x,evaluate('power_law',x,[2.,3.,1.5,0,0.5]),label='power_law')
>>> p = plt.plot(x,evaluate('power_law',x,[2.,3.,1.5,0,0.5])+evaluate('gauss',x,[1.,5.,0.5,0,0]),label='power_law + gauss')
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
]include figure]]ivs_sigproc_fit_funclib02.png]
>>> p = plt.figure()
>>> x = np.linspace(0,10,1000)
>>> p = plt.plot(x,evaluate('sine',x,[1.,2.,0,0]),label='sine')
>>> p = plt.plot(x,evaluate('sine_linfreqshift',x,[1.,0.5,0,0,.5]),label='sine_linfreqshift')
>>> p = plt.plot(x,evaluate('sine_expfreqshift',x,[1.,0.5,0,0,1.2]),label='sine_expfreqshift')
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
]include figure]]ivs_sigproc_fit_funclib03.png]
>>> p = plt.figure()
>>> p = plt.plot(x,evaluate('sine',x,[1.,2.,0,0]),label='sine')
>>> p = plt.plot(x,evaluate('sine_orbit',x,[1.,2.,0,0,0.1,10.,0.1]),label='sine_orbit')
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
]include figure]]ivs_sigproc_fit_funclib03a.png]
>>> p = plt.figure()
>>> x_single = np.linspace(0,10,1000)
>>> x_double = np.vstack([x_single,x_single])
>>> p = plt.plot(x_single,evaluate('kepler_orbit',x_single,[2.5,0.,0.5,0,3,1.]),label='kepler_orbit (single)')
>>> y_double = evaluate('kepler_orbit',x_double,[2.5,0.,0.5,0,3,2.,-4,2.],type='double')
>>> p = plt.plot(x_double[0],y_double[0],label='kepler_orbit (double 1)')
>>> p = plt.plot(x_double[1],y_double[1],label='kepler_orbit (double 2)')
>>> p = plt.plot(x,evaluate('box_transit',x,[2.,0.4,0.1,0.3,0.5]),label='box_transit')
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
]include figure]]ivs_sigproc_fit_funclib04.png]
>>> p = plt.figure()
>>> x = np.linspace(-1,1,1000)
>>> gammas = [-0.25,0.1,0.25,0.5,1,2,4]
>>> y = np.array([evaluate('soft_parabola',x,[1.,0,1.,gamma]) for gamma in gammas])
divide by zero encountered in power
>>> for iy,gamma in zip(y,gammas): p = plt.plot(x,iy,label="soft_parabola $\gamma$={:.2f}".format(gamma))
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
]include figure]]ivs_sigproc_fit_funclib05.png]
>>> p = plt.figure()
>>> x = np.logspace(-1,2,1000)
>>> blbo = evaluate('blackbody',x,[10000.,1.],wave_units='micron',flux_units='W/m3')
>>> raje = evaluate('rayleigh_jeans',x,[10000.,1.],wave_units='micron',flux_units='W/m3')
>>> wien = evaluate('wien',x,[10000.,1.],wave_units='micron',flux_units='W/m3')
>>> p = plt.subplot(221)
>>> p = plt.title(r'$\lambda$ vs $F_\lambda$')
>>> p = plt.loglog(x,blbo,label='Black Body')
>>> p = plt.loglog(x,raje,label='Rayleigh-Jeans')
>>> p = plt.loglog(x,wien,label='Wien')
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
>>> blbo = evaluate('blackbody',x,[10000.,1.],wave_units='micron',flux_units='Jy')
>>> raje = evaluate('rayleigh_jeans',x,[10000.,1.],wave_units='micron',flux_units='Jy')
>>> wien = evaluate('wien',x,[10000.,1.],wave_units='micron',flux_units='Jy')
>>> p = plt.subplot(223)
>>> p = plt.title(r"$\lambda$ vs $F_\nu$")
>>> p = plt.loglog(x,blbo,label='Black Body')
>>> p = plt.loglog(x,raje,label='Rayleigh-Jeans')
>>> p = plt.loglog(x,wien,label='Wien')
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
>>> x = np.logspace(0.47,3.47,1000)
>>> blbo = evaluate('blackbody',x,[10000.,1.],wave_units='THz',flux_units='Jy')
>>> raje = evaluate('rayleigh_jeans',x,[10000.,1.],wave_units='THz',flux_units='Jy')
>>> wien = evaluate('wien',x,[10000.,1.],wave_units='THz',flux_units='Jy')
>>> p = plt.subplot(224)
>>> p = plt.title(r"$\nu$ vs $F_\nu$")
>>> p = plt.loglog(x,blbo,label='Black Body')
>>> p = plt.loglog(x,raje,label='Rayleigh-Jeans')
>>> p = plt.loglog(x,wien,label='Wien')
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
>>> blbo = evaluate('blackbody',x,[10000.,1.],wave_units='THz',flux_units='W/m3')
>>> raje = evaluate('rayleigh_jeans',x,[10000.,1.],wave_units='THz',flux_units='W/m3')
>>> wien = evaluate('wien',x,[10000.,1.],wave_units='THz',flux_units='W/m3')
>>> p = plt.subplot(222)
>>> p = plt.title(r"$\nu$ vs $F_\lambda$")
>>> p = plt.loglog(x,blbo,label='Black Body')
>>> p = plt.loglog(x,raje,label='Rayleigh-Jeans')
>>> p = plt.loglog(x,wien,label='Wien')
>>> leg = plt.legend(loc='best')
>>> leg.get_frame().set_alpha(0.5)
]include figure]]ivs_sigproc_fit_funclib06.png]
|
evaluate(funcname,
domain,
parameters,
**kwargs)
Evaluate a function on specified interval with specified parameters. |
source code
|
|
|
blackbody(wave_units='AA',
flux_units='erg/s/cm2/AA',
disc_integrated=True)
Blackbody (T, scale). |
source code
|
|
|
|
|
wien(wave_units='AA',
flux_units='erg/s/cm2/AA',
disc_integrated=True)
Wien approximation (T, scale). |
source code
|
|
|
kepler_orbit(type='single')
Kepler orbits ((p,t0,e,omega,K,v0) or (p,t0,e,omega,K1,v01,K2,v02)) |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sine_orbit(t0=0.,
nmax=10)
Sine with a sinusoidal frequency shift
(ampl,freq,phase,const,forb,asini,omega,(,ecc)) |
source code
|
|
|
|
|
|
|
|
|
|
|
|
|
_complex_error_function(x)
Complex error function |
source code
|
|
|
logger = logging.getLogger("SP.FUNCLIB")
|
blackbody(wave_units='AA',
flux_units='erg/s/cm2/AA',
disc_integrated=True)
| source code
|
Blackbody (T, scale).
- Parameters:
wave_units (string) - wavelength units
flux_units (string) - flux units
disc_integrated (bool) - sets units equal to SED models
|
rayleigh_jeans(wave_units='AA',
flux_units='erg/s/cm2/AA',
disc_integrated=True)
| source code
|
Rayleigh-Jeans tail (T, scale).
- Parameters:
wave_units (string) - wavelength units
flux_units (string) - flux units
disc_integrated (bool) - sets units equal to SED models
|
wien(wave_units='AA',
flux_units='erg/s/cm2/AA',
disc_integrated=True)
| source code
|
Wien approximation (T, scale).
- Parameters:
wave_units (string) - wavelength units
flux_units (string) - flux units
disc_integrated (bool) - sets units equal to SED models
|
Kepler orbits ((p,t0,e,omega,K,v0) or
(p,t0,e,omega,K1,v01,K2,v02))
A single kepler orbit parameters are: [p, t0, e, omega, k, v0]
A double kepler orbit parameters are: [p, t0, e, omega, k_1, v0_1,
k_2, v0_2] Warning: This function uses 2d input and output!
|
Box transit model (cont,freq,ingress,egress,depth)
- Parameters:
t0 (float) - reference time (defaults to 0)
|
Polynomial (a1,a0).
y(x) = ai*x**i + a(i-1)*x**(i-1) + ... + a1*x + a0
- Parameters:
d (int) - degree of the polynomial
|
Soft parabola (ta,vlsr,vinf,gamma).
See Olofsson 1993ApJS...87...267O.
T_A(x) = T_A(0) * [ 1 - ((x- v_lsr)/v_inf)**2 ] ** (gamma/2)
|
Gaussian (a,mu,sigma,c)
f(x) = a * exp( - (x - mu)**2 / (2 * sigma**2) ) + c
|
Sine (ampl,freq,phase,const)
f(x) = ampl * sin(2pi*freq*x + 2pi*phase) + const
|
Sine with linear frequency shift (ampl,freq,phase,const,D).
Similar to sine , but with extra parameter 'D', which is
the linear frequency shift parameter.
- Parameters:
t0 (float) - reference time (defaults to 0)
|
Sine with exponential frequency shift (ampl,freq,phase,const,K).
Similar to sine , but with extra parameter 'K', which is
the exponential frequency shift parameter.
frequency(x) = freq / log(K) * (K**(x-t0)-1)
f(x) = ampl * sin( 2*pi * (frequency + phase))
- Parameters:
t0 (float) - reference time (defaults to 0)
|
Sine with a sinusoidal frequency shift
(ampl,freq,phase,const,forb,asini,omega,(,ecc))
Similar to sine , but with extra parameter 'asini' and
'forb', which are the orbital parameters. forb in cycles/day or something
similar, asini in au.
For eccentric orbits, add longitude of periastron 'omega' (radians)
and 'ecc' (eccentricity).
- Parameters:
t0 (float) - reference time (defaults to 0)
nmax (int) - number of terms to include in series for eccentric orbit
|
Power law (A,B,C,f0,const)
P(f) = A / (1+ B(f-f0))**C + const
|
Lorentz profile (ampl,mu,gamma,const)
P(f) = A / ( (x-mu)**2 + gamma**2) + const
|
Voigt profile (ampl,mu,sigma,gamma,const)
z = (x + gamma*i) / (sigma*sqrt(2)) V = A * Real[cerf(z)] /
(sigma*sqrt(2*pi))
|
Multiple sines.
- Parameters:
n (int) - number of sines
|
Multiple black bodies.
- Parameters:
n (int) - number of blackbodies
|
evaluate(funcname,
domain,
parameters,
**kwargs)
| source code
|
Evaluate a function on specified interval with specified
parameters.
Extra keywords are passed to the funcname.
Example:
>>> x = np.linspace(-5,5,1000)
>>> y = evaluate('gauss',x,[1.,0.,2.,0.])
- Parameters:
funcname (str) - name of the function
domain (array) - domain to evaluate onto
parameters (array) - parameter of the function
|