FittingFunction
Documentation for FittingFunction.
A set of functions I am often using in carrying out regressions.
FittingFunction.BandFittingFunction.BknPowFittingFunction.CPLFittingFunction.Counts2MagFittingFunction.Ecm2sA2JyFittingFunction.ExtinctionFittingFunction.GaussAbsFittingFunction.GaussianFittingFunction.GetAtomicDataFittingFunction.Jy2Ecm2sAFittingFunction.Mag2CountsFittingFunction.NorrisPulseFittingFunction.PLFittingFunction.Pol2StokesFittingFunction.SBPLFittingFunction.SBPL2FittingFunction.SmoothPLFittingFunction.Stokes2PolFittingFunction.TauVoigtFittingFunction.VoigtFunctTGFittingFunction.XAbs
FittingFunction.Band — MethodBand(E,α,β,E₀,A)Compute the so-called 'Band function'
#Arguments
Einput energy.αlow-energy index.βhigh-energy index.E₀break energy.Anormalization.
The peak-energy is then $Ep = (2+α)E₀$.
Examples
Band(300.,-2.,-1.,200.,1.)
# output
-0.45304697140984085FittingFunction.BknPow — MethodBknPow(Evals::AbstractVector{<:Real}, breaks::AbstractVector{<:Real}, alphas::AbstractVector{<:Real})Compute a 'broken power-law' at the input values 'Evals'.
#Arguments
Evals: Vectors of input energies.breaks: Ordered vector of break points.alphas: Ordered vector of power-law indices.
FittingFunction.CPL — MethodCPL(E,N,α,Ec;E0=1.)Compute a cut-off power-law.
Arguments
αspectral index.Nnormalization.Einput energy.Eccut-off energy.E0energy for power-law normalization.
Examples
CPL(3.,1.,-1.,2.)
# output
0.0743767200494766FittingFunction.Counts2Mag — MethodCounts2Mag(cts,ects;zp=25.0,ezp=0.0)Convert counts (or flux) to magntudes,
Arguments
ctscounts.ectscount uncertainty.zpmagnitude zero-pointzpzero-point uncertainty.
Examples
Counts2Mag(100,10)
# output
(20.0, 0.10857362047581294)FittingFunction.Ecm2sA2Jy — MethodEcm2sA2Jy(fluden, lambd)Convert flux densities in $erg~s^{-1} cm^{-2} Angstrom^{-1}$ to $Jy$.
Arguments
fludenflux density ($erg~s^{-1} cm^{-2} Angstrom^{-1}$).lambdwavelength ($Angstrom$).
Examples
Ecm2sA2Jy([1.2e-15,2e-15,2.5e-15],[5000,5500,6000])
# output
3-element Vector{Float64}:
0.001
0.002016666666666667
0.0029999999999999996FittingFunction.Extinction — MethodExtinction(wave,EBV;gal="SMC",Rv=FFGals["SMC"],z=0.)Compute the UV/optical/extinction.
Argguments
waveinput wavelengths (Angstrom).EBVcolor excess E(B-V) (magnitude).galone of the galaxy extinction recipes listed in the 'FFGals' (exported) dictionary.Rvselective extinction.zredshift of the absorpber.
References about the adopted extinction curves are discussed in the documentation of the DustExtinction package.
Examples
Extinction(5500.,1,gal="MW",Rv=FFGals["MW"],z=0.)
# output
0.06016612224448964FittingFunction.GaussAbs — MethodGaussAbs(E,Ed,σ,El)Compute a Gaussian absorption.
Arguments
Eddepth. atEinput energy.Elabsorption center.σabsorption width ($FWHM/2.35$).Anormalization.
Examples
GaussAbs(2.,1.,0.1,2.)
# output
0.018510395162776326FittingFunction.Gaussian — MethodGaussian(E,A,σ,El)Compute a Gaussian.
Arguments
Einput energy.ElGussian center.σabsorption width ($FWHM/2.35$).Anormalization.
Examples
Gaussian(3.,1.,0.1,2.)
# output
4.009419869036418FittingFunction.GetAtomicData — FunctionGetAtomicData(table::String="")::DataFrameReturn a table with atomic data among those available.
Calling the function with no parameter shows the available tables. At present we have:
- "FitLyman". This is the original table generated for the "FitLyman" ESO-MIDAS package.
- "JitrikBunge04". This is a collection of atomic data prepared by Jitrik & Bunge (2004).
- "VALD03". This is a collection of atomic data extracted from the VALD3 database.
Examples
fly = GetAtomicData("FitLyman")FittingFunction.Jy2Ecm2sA — MethodJy2Ecm2sA(fluden, lambd)Convert flux densities in $Jy$ to $erg~s^{-1} cm^{-2} Angstrom^{-1}$.
Arguments
fludenflux density ($Jy$).lambdwavelength ($Angstrom$).
Examples
Jy2Ecm2sA([1e-3,2e-3,3e-3],[5000,5500,6000])
# output
3-element Vector{Float64}:
1.2000000000000002e-15
1.9834710743801656e-15
2.5e-15FittingFunction.Mag2Counts — MethodMag2Counts(mag,emag;zp=25.0)Convert magnitudes to counts (or flux).
Arguments
maginput magnitude.emagmagnitude uncertainty.zpzero-point.
Examples
Mag2Counts(20,0.1)
# output
(100.0, 9.210340371976184)FittingFunction.NorrisPulse — MethodNorrisPulse(x;pulsNorm,tmax,σ_rise,σ_decay,pulsSharpness,base)Compute an asymmetric pulse shape according to the recipe reported in Norris et al. (1996).
Arguments
xinput vector.pulsNormthe nornalization of the pulse.tmaxthe maximum of the pulse.σ_risethe time-scale of the rising phase.σ_decaythe time-scale of the decaying phase.pulsSharpnesspulse sharpness parameter.basesignal level without the pulse.
Examples
NorrisPulse([1.,2.,3.,4.,5.],pulsNorm=1.5,tmax=3.,σ_rise=1.,σ_decay=2.,pulsSharpness=1.1,base=0.3)
# output
5-element Vector{Float64}:
0.47585740398559895
0.8518191617571635
1.8
1.2407748943132098
0.8518191617571635FittingFunction.PL — MethodPL(E,N,α;E0=1.)Compute a power-law with.
Arguments
αspectral index.Nnormalization.Einput energy.E0power-law energy normalization.
Examples
PL(3.,1.,-1.)
# output
0.3333333333333333FittingFunction.Pol2Stokes — MethodPol2Stokes(i, p, t, c; ep=0.0, et=0.0, ec=0.0)Compute the Stokes parameters for a given polarisation degree and position angle.
Arguments
itotal intensity.ppolarisation degree.tposition angle (randians).cthe circular polarisation.eppolarization uncertainty.etposition angle uncertainty.eccircular polarization uncertainty.
The ouput is: intensity q, u, v Stokes parameters and respective errors.
Examples
Pol2Stokes(1.,0.1,0.1,0.)
# output
(1.0, 0.09800665778412417, 0.019866933079506124, 0.0, 0.0, 0.0, 0.0)FittingFunction.SBPL — MethodSBPL(E,N,α,β,Eb)Compute a smoothly joint broken power-law.
Arguemnts
αpre-break spectral index.βpost-break spectral index.Ebbreak energy.Nnormalization.Einput energy.
Examples
SBPL(6.,1.,-1.,-1.5,5.)
# output
0.15214515486254615FittingFunction.SBPL2 — MethodSBPL2(E,N,α,β,γ,Eb1,Eb2)Compute a smoothly joint double broken power-law.
Arguments
αpre-break spectral index.βinter-break spectral index.γpost-break spectral index.Eb1first break energy.Eb2second break energy.Nnormalization.Einput energy.
Examples
SBPL2([4.,6.,8.],1.,-1.,-1.5,-2.,5.,7.)
# output
3-element Vector{Float64}:
0.25
0.06804138174397717
0.04133986423538423FittingFunction.SmoothPL — MethodSmoothPL(E,N,α1,α2,,EB=1.;s=1.)Compute a smoothly joint power-law with smoothness parameter.
Arguments
α1pre-break spectral index.α1post-break spectral index.Nnormalization.Einput energy.E0power-law energy normalization.ssmoothness parameter.
Examples
SmoothPL(3.,1.,-0.5,-1.5,1.,s=1.1)
# output
3.4226591419723746FittingFunction.Stokes2Pol — MethodStokes2Pol(i, q, u, v; eq=0.0, eu=0.0, ev=0.0)Compute the polarisation degree and position angle from the Stokes parameters.
Arguments
itotal intensity.qverical/horizontal polarization.uoblique polarization.vcircular polarisation.equncertainty on theqparameter.euuncertainty on theuparameter.evuncertainty on thevparameter.
The ouput is given by the intensity i, polarisation degree, p, position angle (randians) theta and circular polarisation chi, with respective errors.
Examples
Stokes2Pol(1.,0.1,0.1,0.)
# output
(1.0, 0.14142135623730953, 0.39269908169872414, 0.0, 0.0, 0.0, 0.0)FittingFunction.TauVoigt — MethodTauVoigt(λ,NHI,DopplerBroadening,z,transition)Compute the opacity due to a given absorption transition.
Arguments
λis the wavelenghths ($cm$).Nthe column density ($cm^{-2}$).DopplerBroadeningis the Doppler broadening ($cm~s^{-1}$).zis the source redshift.transitionis a tuple formed by the central wawelength ($cm$), the oscillator strength and the damping coefficient ($s^{-1}$) for the given transition.
The Doppler broadening factor is typicaly due to either an intrinsic thermal broadening ($b_K = \sqrt{2KT/m}$) or to a turbulent motion of the gas ($b_T = \sqrt{σ_T}$, where $σ_T$ is the inner velocity dispersion). These two factors can be summed in quadrature, i.e. $b = \sqrt{b_K^2 + b_T^2}$.
Examples
TauVoigt(range(start=1494.5,stop=1495.5,step=0.1) .* 1e-8,1e18,1e5,0.,[1495.05*1e-8,0.54,8.106e8])
# output
11-element Vector{Float64}:
0.5408331361420329
0.8079604230648749
1.3357686994197793
2.618871809580839
7.282358478732964
66.40911467182524
66.40911467182524
7.282358478732964
2.618871809580839
1.3357686994184856
0.8079604230648749FittingFunction.VoigtFunctTG — MethodVoigtFuncTG(a,v)Approximate the Voigt (or line broadening function) function.
It was introduced by Tepper-Garcia (2006). It is of high accuracy provided that $a \le 10^{-4}$. The $a$ and $v$ parameters are defined as: $a = \frac{\Gamma \lambda_c}{4\pi b 10^{13}}$ and $v = \frac{(\lambda_c - \lambda)c}{b \lambda_c \sqrt{2 \log 2}}$, where $\lambda_c$ is the central wavelength of the transition, $c$ the speed of light, $b$ the Doppler broadening factor and $\Gamma$ the damping coefficient.
Examples
FittingFunction.VoigtFunctTG(1e-5,1.)
# output
0.36788094737611143FittingFunction.XAbs — MethodXAbs(E; NH=1e20, z=0)Compute the effective absorption cross section per hydrogen atom.
It is based on the Morrison & McCammon (1983) recipe.
Arguments
Eis the energy (KeV, in the 0.03-10 KeV range).Nis the column density (particle per square cm).zis the redshift.
Examples
XAbs([0.5,1.25,2.], NH=1e20, z=0)
# output
3-element Vector{Float64}:
0.9290803992951834
0.9868927382232576
0.9957079871273042