It uses the model of from the energy equation to kilonova light curves and colours. The step-by-step commands are in reproducing a two-component kilonova fit to the GW170817 photometry.
The data
Villar and colleagues combined 647 measurements from 18 papers and 46 instruments into one table, corrected for offsets between datasets, and marked outliers. Villar and colleagues, §2 and Table 3 We keep the detections in g, r, i, z, J, H and K or Ks that they used in their own fit and did not flag as outliers. That leaves 394 points from 0.45 to 25.4 days, with r the best covered band at 83 points and J the sparsest at 38.
The magnitudes are not corrected for dust in the Milky Way. Instead the model adds extinction, Aλ=RλE(B−V) with E(B−V)=0.1228 and the coefficients for RV=3.1. Schlafly and Finkbeiner, Table 6 The distance is fixed at 39.5Mpc.
The likelihood
Each point i has an observed magnitude Oi, an error σi and a model value Mi. The model is too simple to match every point within its error: real filters are broad while the model uses one wavelength per band, the spectrum is not a blackbody, and instruments still differ slightly. Villar and colleagues therefore add an unknown scatter σ in quadrature. Villar and colleagues, §3.2, eq. 6 We use the normalised Gaussian form
Their printed equation keeps ln(2πσi2) inside the sum with the opposite sign and a separate −(n/2)ln(2πσ2) outside it. That is not the normalisation of a Gaussian with variance σi2+σ2, so we use the form above and record the difference.
The fit maximises L rather than sampling it as Villar and colleagues did. With k free parameters, the Bayesian information criterion
penalises extra freedom. A difference above about 10 is strong evidence for the lower value.
What is free and what is fixed
The blue opacity is fixed at 0.5cm2g−1, as in Villar and colleagues' two-component model. The free parameters are the blue mass, speed and floor temperature, the red mass, speed, floor and opacity, and the scatter: eight in all.
The likelihood has several local maxima. The script starts the optimiser from many points and keeps all distinct solutions.
The third row lies close to Villar and colleagues' published values: 0.023, 0.256 for blue and 0.050, 0.149, 3.65 for red. Villar and colleagues, Table 2 Our best solution prefers a faster blue component, 0.385c, which lies beyond the largest speed, 0.3c, in the thermalization table, so its thermalization uses the table's edge values. That blue speed is best read as a property of this simplified model.
Comparing models
One grey component cannot make an early blue peak and a late infrared plateau at the same time; its BIC is worse by 522. Removing the temperature floors costs 348. Forcing the red opacity to 10, a value typical of lanthanide-rich matter, costs 226: these data prefer an intermediate opacity near 3. Villar and colleagues' published parameters, plugged into our code with only σ refitted, are worse than our optimum by 43 in −lnL and leave the late K band about 0.20 magnitudes too bright. Differences in data selection, likelihood normalisation and sampling can each contribute; we have not separated them.
The best fit is not perfect. Its worst band is H, with an rms residual of 0.40 magnitudes. Villar and colleagues found that their two-component model predicts a double-peaked K light curve that the data do not show, one reason they preferred three components. Villar and colleagues, Fig. 5
Why mass and speed trade off
The diffusion time depends on M and v only through M/v:
Raise both by the same factor and the light curve's timescale stays put. Two other things change, but more weakly: the photosphere is larger at fixed time, R=vt, so the same luminosity comes out cooler, and the thermalization fraction shifts. The data feel these second-order effects only faintly.
The low values run diagonally: (0.050,0.15), (0.055,0.16), (0.060,0.17), all with M/v near 0.34. A second, shallower branch appears near v=0.20. For two parameters, a rise of 1.15 in −lnL bounds a joint 68 percent region and a rise of 3.0 a 95 percent region. The point at v=0.20 is excluded at 68 percent but not at 95 percent.
The local error estimate from the curvature at the best fit gives ±0.0022 in red mass and ±0.0052 in red speed, with correlation 0.888. Those numbers describe the bottom of one valley. They miss the second branch, and they would understate the uncertainty if quoted alone.
Shape and viewing angle
All of this assumes spherical components. Villar and colleagues also fitted a three-component model with the blue component confined near the poles, weighting the components by 1−cosθ and cosθ. It gave a half-opening angle θ=66−3+1 degrees and masses about half those of the spherical fit. Villar and colleagues, §3.1 and §4 They treated those parameters as a guide to the effect of asymmetry, and ours deserve the same caution: the mass of a kilonova inferred from photometry depends on its assumed shape.
Lab tasks
- Lower the red mass to 0.045 and the red speed to 0.134. Check that the red diffusion time stays at 7.36 days, and estimate by eye how far the K curve moves.
- From the default, change only the red speed to 0.134. The diffusion time now changes. Compare the shift in the K curve with task 1.
- Set the red opacity to 10. Which bands move away from the points, and in which direction?
Exercises with explained answers
- Check the BIC of the two-component fit from −lnL=63.02, k=8 and n=394.
- Red mass and speed lie along M/v≈0.34. If the red speed were 0.18, what mass would keep the diffusion time unchanged?
- A colleague quotes the red mass as 0.0525±0.0022 solar masses. What would you add?
- Why can a larger extra scatter σ make −lnL smaller even though it widens every error bar?
AnswersShow the answer
- 2×63.02+8ln394=126.04+8×5.976=173.85, as in Table 3.2.
- M≈0.34×0.18=0.061 solar masses, at fixed red opacity. The profile table shows this region is not favoured by the data, because the second-order effects grow away from the best fit.
- That the error is the local curvature at one optimum. Along the diagonal valley, and on the second branch near v=0.20, other masses fit almost as well; the value also depends on the spherical, grey model and would drop by about half for the polar geometry Villar and colleagues tried.
- Each term has two parts. The squared residual divided by the variance falls as σ grows, while ln(σi2+σ2) rises. When residuals are larger than the quoted errors, the first effect wins until σ roughly matches the typical residual. Here that balance sits at 0.26 magnitudes, close to the rms residual of 0.29.
Repeat the fit yourself, with every input and failure case, in reproducing a two-component kilonova fit to the GW170817 photometry.
Try it in the Lab
Lower the red mass to 0.045 and the red speed to 0.134. The red diffusion time in the caption stays at 7.36 days, and the K curve moves by about a tenth of a magnitude. Open the kilonova light-curve Lab