Home | Trees | Indices | Help |
---|
|
Evaluate model functions.
Most functions accept a domain of interest and a set of parameters, and return a model function (e.g., a sine, gaussian etc...). Parameters are usually a record array containing named fields for the parameters.
Some nonlinear optimizers expect and return parameters as a 1D array of the independent parameters. Therefore, all functions also accept these 1D numpy arrays, and they are converted by check_input to record arrays. The latter function actually accepts both record arrays and 1D arrays, and acts as a translator between the two parameter representations.
|
|||
|
|||
Evaluating model fits | |||
---|---|---|---|
float |
|
||
percentage |
|
||
float |
|
||
float |
|
||
ndarray (shape n) |
|
||
Timeseries | |||
ndarray,ndarray(, ndarray) |
|
||
array |
|
||
array |
|
||
array |
|
||
array |
|
||
array |
|
||
|
|||
|
|||
array |
|
||
|
|||
General purpose | |||
array |
|
||
|
|||
array |
|
||
array |
|
||
Convert record arrays to flat arrays and back | |||
normal numpy array or record array |
|
||
normal numpy array or record array |
|
||
normal numpy array or record array |
|
||
normal numpy array or record array |
|
||
normal numpy array or record array |
|
||
normal numpy array or record array |
|
||
normal numpy array or record array |
|
||
normal numpy array or record array |
|
||
Helper functions | |||
|
|
|||
logger = logging.getLogger('SIGPROC.EVAL')
|
|
Residual sum of squares.
|
Calculate variance reduction.
|
BIC for time regression This one is based on the MLE of the variance, Sigma_k^2 = RSS/n Where our maximum likelihood estimator is then (RSS/n)^n
|
AIC for time regression This one is based on the MLE of the variance, Sigma_k^2 = RSS/n Where our maximum likelihood estimator is then (RSS/n)^n
|
Use Fisher's test to combine probabilities. http://en.wikipedia.org/wiki/Fisher's_method >>> rvs1 = distributions.norm().rvs(10000) >>> rvs2 = distributions.norm().rvs(10000) >>> pvals1 = scipy.stats.distributions.norm.sf(rvs1) >>> pvals2 = scipy.stats.distributions.norm.sf(rvs2) >>> fpval = fishers_method([pvals1,pvals2]) And make a plot (compare with the wiki page). >>> p = pl.figure() >>> p = pl.scatter(pvals1,pvals2,c=fpval,edgecolors='none',cmap=pl.cm.spectral) >>> p = pl.colorbar()
|
Construct a phasediagram, using frequency nu0. Possibility to include a linear frequency shift D. If needed, the indices can be returned. To 'unphase', just do: Example usage: >>> original = np.random.normal(size=10) >>> indices = np.argsort(original) >>> inv_indices = np.argsort(indices) >>> all(original == np.take(np.take(original,indices),inv_indices)) True Optionally, the zero time point can be given, it will be subtracted from all time points Joris De Ridder, Pieter Degroote
|
Creates a harmonic function based on given parameters. Parameter fields: This harmonic function is of the form f(p1,...,pm;x1,...,x_n) = ∑ c_i + a_i sin(2 π (f_i+ φ_i)) where p_i are parameters and x_i are observation times. Parameters can be given as a record array containing columns 'ampl', 'freq' and 'phase', and optionally also 'const' (the latter array is summed up so to reduce it to one number).
Parameters can also be given as normal 1D numpy array. In that case,
it will be transformed into a record array by the
Example usage: We construct a synthetic signal with two frequencies. >>> times = np.linspace(0,100,1000) >>> const = 4. >>> ampls = [0.01,0.004] >>> freqs = [0.1,0.234] >>> phases = [0.123,0.234] The signal can be made via a record array >>> parameters = np.rec.fromarrays([[const,0],ampls,freqs,phases],names = ('const','ampl','freq','phase')) >>> mysine = sine(times,parameters) or a normal 1D numpy array >>> parameters = np.hstack([const,np.ravel(np.column_stack([ampls,freqs,phases]))]) >>> mysine = sine(times,parameters) Of course, the latter is easier if you have your parameters in a list: >>> freq1 = [0.01,0.1,0.123] >>> freq2 = [0.004,0.234,0.234] >>> parameters = np.hstack([freq1,freq2]) >>> mysine = sine(times,parameters)
|
Creates a sine function with a linear frequency shift. Parameter fields: Similar to Only accepts record arrays as parameters (for the moment).
|
Creates a sine function with a sinusoidal frequency shift. Parameter fields: Similar to For eccentric orbits, add longitude of periastron 'omega' (radians) and 'ecc' (eccentricity). Only accepts record arrays as parameters (for the moment).
|
Evaluate a periodic spline function Parameter fields:
|
Construct a radial velocity curve due to Kepler orbit(s). Parameter fields:
|
Compute coefficients for differential correction method. See page 97-98 of Hilditch's book "An introduction to close binary stars".
|
Simultaneous evaluation of two binary components. parameter fields must be
|
Evaluate a box transit model. Parameter fields: Parameters [[frequency,depth, fractional start, fraction end, continuum]]
|
Spotted model from Lanza (2003). Extract from Carrington Map. Included: - presence of faculae through Q-factor (set constant to 5 or see Chapman et al. 1997 or Solank & Unruh for a scaling law, since this factor decreases strongly with decreasing rotation period. - differential rotation through B-value (B/period = 0.2 for the sun) - limb-darkening through coefficients ap, bp and cp - non-equidistant time series - individual starspot evolution and lifetime following a Gaussian law, (see Hall & Henry (1993) for a relation between stellar radius and sunspot lifetime), through an optional 3rd (time of maximum) and 4th parameter (decay time) Not included: - distinction between umbra's and penumbra - sunspot structure Parameters of global star: - i_sun: inclination angle, i=pi/2 is edge-on, i=0 is pole on. - l0: 'epoch angle', if L0=0, spot with coordinate (0,0) starts in center of disk, if L0=0, spot is in center of disk after half a rotation period - period: equatorial period - b: differential rotation b = Omega_pole - Omega_eq where Omega is in radians per time unit (angular velocity) - ap,bp,cp: limb darkening Parameters of spots: - lambda: 'greenwich' coordinate (longitude) (pi means push to back of star if l0=0) - theta: latitude (latitude=0 means at equator, latitude=pi/2 means on pole (B{not colatitude}) - A: size - maxt0 (optional): time of maximum size - decay (optional): exponential decay speed Note: alpha = (Omega_eq - Omega_p) / Omega_eq alpha = -b /2*pi * period Use for fitting! |
Evaluate a gaussian fit. Parameter fields: Evaluating one Gaussian: >>> x = np.linspace(-20,20,10000) >>> pars = [0.5,0.,3.] >>> y = gauss(x,pars) >>> p = pl.plot(x,y,'k-') Evaluating multiple Gaussian, with and without constants: >>> pars = [0.5,0.,3.,0.1,-10,1.,.1] >>> y = gauss(x,pars) >>> p = pl.plot(x,y,'r-')
|
Evaluate Lorentz profile P(f) = A / ( (x-mu)**2 + gamma**2) Parameters fields: Evaluating one Lorentzian: >>> x = np.linspace(-20,20,10000) >>> pars = [0.5,0.,3.] >>> y = lorentz(x,pars) >>> p = pl.figure() >>> p = pl.plot(x,y,'k-') Evaluating multiple Lorentzians, with and without constants: >>> pars = [0.5,0.,3.,0.1,-10,1.,.1] >>> y = lorentz(x,pars) >>> p = pl.plot(x,y,'r-')
|
Evaluate a Voigt profile. Field parameters: Function: z = (x + gamma*i) / (sigma*sqrt(2)) V = A * Real[cerf(z)] / (sigma*sqrt(2*pi)) >>> x = np.linspace(-20,20,10000) >>> pars1 = [0.5,0.,2.,2.] >>> pars2 = [0.5,0.,1.,2.] >>> pars3 = [0.5,0.,2.,1.] >>> y1 = voigt(x,pars1) >>> y2 = voigt(x,pars2) >>> y3 = voigt(x,pars3) >>> p = pl.figure() >>> p = pl.plot(x,y1,'b-') >>> p = pl.plot(x,y2,'g-') >>> p = pl.plot(x,y3,'r-') Multiple voigt profiles: >>> pars4 = [0.5,0.,2.,1.,0.1,-3,0.5,0.5,0.01] >>> y4 = voigt(x,pars4) >>> p = pl.plot(x,y4,'c-')
|
Evaluate a power law. Parameter fields: Function: P(f) = A / (1+ Bf)**C + const >>> x = np.linspace(0,10,1000) >>> pars1 = [0.5,1.,1.] >>> pars2 = [0.5,1.,2.] >>> pars3 = [0.5,2.,1.] >>> y1 = power_law(x,pars1) >>> y2 = power_law(x,pars2) >>> y3 = power_law(x,pars3) >>> p = pl.figure() >>> p = pl.plot(x,y1,'b-') >>> p = pl.plot(x,y2,'g-') >>> p = pl.plot(x,y3,'r-') Multiple power laws: >>> pars4 = pars1+pars2+pars3 >>> y4 = power_law(x,pars4) >>> p = pl.plot(x,y4,'c-')
|
Prepare sine function parameters in correct form for evaluating/fitting. If you input a record array, this function will output a 1D numpy array containing only the independent parameters for use in nonlinear fitting algorithms. If you input a 1D numpy array, it will output a record array.
|
Prepare Kepler orbit parameters in correct form for evaluating/fitting. If you input a record array, this function will output a 1D numpy array containing only the independent parameters for use in nonlinear fitting algorithms. If you input a 1D numpy array, it will output a record array.
|
Prepare Kepler orbit parameters in correct form for evaluating/fitting. If you input a record array, this function will output a 1D numpy array containing only the independent parameters for use in nonlinear fitting algorithms. If you input a 1D numpy array, it will output a record array.
|
Prepare sine function parameters in correct form for evaluating/fitting. If you input a record array, this function will output a 1D numpy array containing only the independent parameters for use in nonlinear fitting algorithms. If you input a 1D numpy array, it will output a record array.
|
Prepare gauss function parameters in correct form for evaluating/fitting. If you input a record array, this function will output a 1D numpy array containing only the independent parameters for use in nonlinear fitting algorithms. If you input a 1D numpy array, it will output a record array.
|
Prepare Lorentz function parameters in correct form for evaluating/fitting. If you input a record array, this function will output a 1D numpy array containing only the independent parameters for use in nonlinear fitting algorithms. If you input a 1D numpy array, it will output a record array.
|
Prepare voigt function parameters in correct form for evaluating/fitting. If you input a record array, this function will output a 1D numpy array containing only the independent parameters for use in nonlinear fitting algorithms. If you input a 1D numpy array, it will output a record array.
|
Prepare gauss function parameters in correct form for evaluating/fitting. If you input a record array, this function will output a 1D numpy array containing only the independent parameters for use in nonlinear fitting algorithms. If you input a 1D numpy array, it will output a record array.
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Fri Mar 30 10:45:19 2018 | http://epydoc.sourceforge.net |