Just a simple visualization tool to plot the Gaussian from the regions and see what it really looks like

In the C code,

k_region(wl[i], wl[j], a, mu, sigma);

double k_region (double x0, double x1, double a, double mu, double sigma)
{
//Hanning-tapered covariance kernel

//Hanning taper is defined using radial distance from mu
double rx0 = c_kms / mu * fabs(x0 - mu);
double rx1 = c_kms / mu * fabs(x1 - mu);
double r_tap = rx0 > rx1 ? rx0 : rx1; //choose the larger distance
double r0 = 4.0 * sigma; //where the kernel goes to 0

assert(r_tap <= r0);
double taper = (0.5 + 0.5 * cos(PI * r_tap/r0));

return  taper * a*a /(2. * PI * sigma * sigma) * exp(-0.5 * 
    (c_kms * c_kms) / (mu * mu) * ((x0 - mu)*(x0 - mu) + 
        (x1 - mu)*(x1 - mu))/(sigma * sigma)); 
}

In math, the Gaussian-shaped residual is parameterized by $$R_\lambda ( a, \mu, \sigma) = \frac{a}{\sqrt{2 \pi} \sigma} \exp \left [ - \frac{r^2(\lambda, \mu)}{2 \sigma^2} \right ]$$ and thus the kernel is $$K(\lambda_i, \lambda_j | a, \mu, \sigma) = \frac{1}{2 \pi} \left ( \frac{a}{\sigma} \right )^2 \exp \left [ - \frac{r^2(\lambda_i, \mu) + r^2(\lambda_j, \mu)}{2 \sigma^2} \right ]$$


In [15]:
"""
Gauss(r, loga, mu, sigma): return a Gaussian as specified by a line region.
"""
function Gauss(r, loga, sigma, mu=0.0)
    a = 10^loga
    return a/(sqrt(2 * pi) * sigma) * exp(- r.^2/(2sigma^2))
end


Out[15]:
Gauss (generic function with 2 methods)

In [17]:
rs = linspace(-20, 20);
gs = Gauss(rs, 1., 10.);

In [3]:
import Winston

In [18]:
p = Winston.FramedPlot(
    title="Gaussian Region",
    xlabel="\\Delta v",
    ylabel="Residual")
Winston.add(p, Winston.Curve(rs, gs))


Out[18]:

In [1]:
using jlHDF5

In [2]:
spec = openData("../data/WASP14/WASP14-2009-06-14.hdf5");

In [4]:
p = Winston.FramedPlot(
title="Order 23",
xlabel="\\lambda (Ang)",
ylabel="f_\\nu")
Winston.add(p, Winston.Curve(spec.wls[:,23], spec.fls[:,23]))


Out[4]:

In [ ]: