PyCS Tutorial

Milan Williams and Phil Marshall, June 2016

In this notebook we work through the PyCS "demo1" tutorial, to show how the PyCS package enables the estimation of a lens time delay from example light curve data. The original tutorial is in the form of a set of 6 scripts, that can be viewed on the PyCS website here. The demo1 code itself can be browsed in the PyCS GitHub repository here.

1. Obtaining PyCS and its Sample Data

The "demo1" tutorial uses a 4-image light curve dataset that comes with the PyCS repository. Let's download this and use PyCS to analyze it. If you haven't yet followed the SLTimer installation instructions you should do that before attempting to import pycs.


In [1]:
import os, urllib
from __future__ import print_function
import pycs
%matplotlib inline

We need to grab rdbfile (the demo1 dataset) from webdir (the appropriate PyCS GitHub folder). We only need to download rdbfile if it doesn't already exist.


In [2]:
webdir = 'https://raw.githubusercontent.com/COSMOGRAIL/PyCS/master/demo/demo1/data/'
rdbfile = 'trialcurves.txt'
    
url = os.path.join(webdir, rdbfile)
if not os.path.isfile(rdbfile):
    urllib.urlretrieve(url, rdbfile)
    
!wc -l $rdbfile


     194 trialcurves.txt

2. Displaying the Light Curve Data

First lets read in the data from the rdbfile, in this case from a simple text file with a one-line header. (Other formats are supported as well.)


In [3]:
lcs = [
        pycs.gen.lc.rdbimport(rdbfile, 'A', 'mag_A', 'magerr_A', "Trial"),
        pycs.gen.lc.rdbimport(rdbfile, 'B', 'mag_B', 'magerr_B', "Trial"),
        pycs.gen.lc.rdbimport(rdbfile, 'C', 'mag_C', 'magerr_C', "Trial"),
        pycs.gen.lc.rdbimport(rdbfile, 'D', 'mag_D', 'magerr_D', "Trial")
]


Checking header of "trialcurves.txt"...
Reading "trialcurves.txt"...
[Trial/A] with 192 points imported (0 of them masked).
Checking header of "trialcurves.txt"...
Reading "trialcurves.txt"...
[Trial/B] with 192 points imported (0 of them masked).
Checking header of "trialcurves.txt"...
Reading "trialcurves.txt"...
[Trial/C] with 192 points imported (0 of them masked).
Checking header of "trialcurves.txt"...
Reading "trialcurves.txt"...
[Trial/D] with 192 points imported (0 of them masked).

We'll want to plot each light curve with a different color:


In [4]:
pycs.gen.mrg.colourise(lcs)

If we shift the data by the "true" time shifts, the light curves will line up nicely for display purposes. We will infer the time delays from the data later in this notebook.


In [5]:
lcs[1].shifttime(-5.0)
lcs[2].shifttime(-20.0)
lcs[3].shifttime(-70.0)

Now to display our plot!


In [6]:
pycs.gen.lc.display(lcs, figsize=(20, 7), jdrange=(53900, 55500))


To save this figure to a file:


In [7]:
pycs.gen.lc.display(lcs, filename="fig_trialcurves_true-shifted.pdf")


Plot written to fig_trialcurves_true-shifted.pdf

It's useful to store the lightcurve objects in a pickle for easy re-starting - here's the function for doing that:


In [8]:
pycs.gen.util.writepickle(lcs, "trialcurves_true-shifted.pkl")


Wrote trialcurves_true-shifted.pkl

In further scripts, you can now import the data by reading this file.


In [9]:
lcs = pycs.gen.util.readpickle("trialcurves_true-shifted.pkl")


Read trialcurves_true-shifted.pkl

We will now undo these shifts, and from now on we will "forget" about the true delays.


In [10]:
for l in lcs:
        l.resetshifts()

You can do a variety of things with this file to find out more information. For example, the longinfo() method will provide you with the number of points, gap length, shifts, median, mean, maximum, minimum, and the colour it is plotted in.


In [11]:
for l in lcs: print(l.longinfo())


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	[Trial/A]
192 points (total), 0 of which are masked
4 seasons (gap: >60), gap length : 164.0 +/- 33.8 days
Sampling : median 4.0, mean 4.4, max 25.1, min 0.83 days
Shifts : (0.00000,0.00000,0.00) [days, mag, flux]
Colour : red
Common properties : 
   All properties : 
Comments :
   Imported from trialcurves.txt, columns (1, 2, 3)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	[Trial/B]
192 points (total), 0 of which are masked
4 seasons (gap: >60), gap length : 164.0 +/- 33.8 days
Sampling : median 4.0, mean 4.4, max 25.1, min 0.83 days
Shifts : (0.00000,0.00000,0.00) [days, mag, flux]
Colour : blue
Common properties : 
   All properties : 
Comments :
   Imported from trialcurves.txt, columns (1, 4, 5)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	[Trial/C]
192 points (total), 0 of which are masked
4 seasons (gap: >60), gap length : 164.0 +/- 33.8 days
Sampling : median 4.0, mean 4.4, max 25.1, min 0.83 days
Shifts : (0.00000,0.00000,0.00) [days, mag, flux]
Colour : #009900
Common properties : 
   All properties : 
Comments :
   Imported from trialcurves.txt, columns (1, 6, 7)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
	[Trial/D]
192 points (total), 0 of which are masked
4 seasons (gap: >60), gap length : 164.0 +/- 33.8 days
Sampling : median 4.0, mean 4.4, max 25.1, min 0.83 days
Shifts : (0.00000,0.00000,0.00) [days, mag, flux]
Colour : purple
Common properties : 
   All properties : 
Comments :
   Imported from trialcurves.txt, columns (1, 8, 9)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 

Another thing we can do is export the data into a text file called "out_trialcurves.txt". In this case, since we have not altered the original data, this file will contain the same information as trialcurves.txt.


In [12]:
pycs.gen.util.multilcsexport(lcs, "out_trialcurves.txt", separator="\t", verbose=True, properties=None)


[Trial/A]
[Trial/B]
[Trial/C]
[Trial/D]
Wrote the lightcurves into out_trialcurves.txt

3. Fitting the Light Curves with a Free-Knot Spline Model

Let's now fit a spline model to our lightcurve data. At first we'll ignore microlensing and just set up a single spline curve to capture the intrinsic AGN variability. Then we'll add in additional curves to model the microlensing, and refine the fit.

3.1 Basic Fit

PyCS contains library functions for optimizing such a model, but the optimization has to be carried out according to a user-defined schedule. Shown here is a simple attempt to get a multi-purpose schedule for optimizing a free-knot spline model: we optimize the spline three times, twice roughly with two different knotsteps, and then once to fine-tune the parameters.


In [13]:
def spl(lcs):
    spline = pycs.spl.topopt.opt_rough(lcs, nit=5, knotstep=50)
    for l in lcs:
        l.resetml()
    spline = pycs.spl.topopt.opt_rough(lcs, nit=5, knotstep=30)
    spline = pycs.spl.topopt.opt_fine(lcs, nit=10, knotstep=20)
    return spline

This optimization function (and each subroutine it calls) returns a spline object.


In [14]:
spline = spl(lcs)


Starting opt_rough on initial delays :
AB   +0.00 | AC   +0.00 | AD   +0.00 | BC   +0.00 | BD   +0.00 | CD   +0.00
Aiming at curves A, B, C, D.
Starting ML optimization ...
Done !
First spline and ML opt done.
AB  +14.00 | AC  -11.00 | AD  -16.00 | BC  -25.00 | BD  -30.00 | CD   -5.00    (Iteration  1, r2 =  71081.7)
AB  +23.00 | AC   +4.00 | AD  -15.00 | BC  -19.00 | BD  -38.00 | CD  -19.00    (Iteration  2, r2 =  69006.6)
AB  +27.00 | AC  +12.00 | AD  -11.00 | BC  -15.00 | BD  -38.00 | CD  -23.00    (Iteration  3, r2 =  68455.6)
AB  +29.00 | AC  +15.00 | AD  -10.00 | BC  -14.00 | BD  -39.00 | CD  -25.00    (Iteration  4, r2 =  68294.0)
AB  +31.00 | AC  +17.00 | AD   -9.00 | BC  -14.00 | BD  -40.00 | CD  -26.00    (Iteration  5, r2 =  68191.8)
Rough time shifts done :
AB  +31.00 | AC  +17.00 | AD   -9.00 | BC  -14.00 | BD  -40.00 | CD  -26.00
Starting opt_rough on initial delays :
AB  +31.00 | AC  +17.00 | AD   -9.00 | BC  -14.00 | BD  -40.00 | CD  -26.00
Aiming at curves A, B, C, D.
Starting ML optimization ...
Done !
First spline and ML opt done.
AB  +33.00 | AC  +25.00 | AD  -15.00 | BC   -8.00 | BD  -48.00 | CD  -40.00    (Iteration  1, r2 =  64997.5)
AB  +34.00 | AC  +27.00 | AD  -15.00 | BC   -7.00 | BD  -49.00 | CD  -42.00    (Iteration  2, r2 =  64850.0)
AB  +35.00 | AC  +28.00 | AD  -15.00 | BC   -7.00 | BD  -50.00 | CD  -43.00    (Iteration  3, r2 =  64722.0)
AB  +36.00 | AC  +29.00 | AD  -16.00 | BC   -7.00 | BD  -52.00 | CD  -45.00    (Iteration  4, r2 =  64587.4)
AB  +36.00 | AC  +30.00 | AD  -16.00 | BC   -6.00 | BD  -52.00 | CD  -46.00    (Iteration  5, r2 =  64460.5)
Rough time shifts done :
AB  +36.00 | AC  +30.00 | AD  -16.00 | BC   -6.00 | BD  -52.00 | CD  -46.00
Starting opt_fine on initial delays :
AB  +36.00 | AC  +30.00 | AD  -16.00 | BC   -6.00 | BD  -52.00 | CD  -46.00
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +38.03 | AC  +34.83 | AD  -23.96 | BC   -3.21 | BD  -61.99 | CD  -58.79    (Iteration  1, r2 =  55568.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +38.98 | AC  +36.85 | AD  -27.15 | BC   -2.13 | BD  -66.13 | CD  -64.00    (Iteration  2, r2 =  54473.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +39.51 | AC  +37.74 | AD  -27.44 | BC   -1.77 | BD  -66.95 | CD  -65.18    (Iteration  3, r2 =  53906.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +39.53 | AC  +37.96 | AD  -27.66 | BC   -1.57 | BD  -67.18 | CD  -65.62    (Iteration  4, r2 =  53620.5)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +39.68 | AC  +38.08 | AD  -27.68 | BC   -1.60 | BD  -67.36 | CD  -65.76    (Iteration  5, r2 =  53465.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +39.65 | AC  +38.21 | AD  -27.72 | BC   -1.44 | BD  -67.38 | CD  -65.93    (Iteration  6, r2 =  53316.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +39.69 | AC  +38.25 | AD  -27.89 | BC   -1.44 | BD  -67.58 | CD  -66.13    (Iteration  7, r2 =  53190.1)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +39.74 | AC  +38.39 | AD  -27.97 | BC   -1.36 | BD  -67.71 | CD  -66.35    (Iteration  8, r2 =  52999.5)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +39.78 | AC  +38.42 | AD  -28.19 | BC   -1.36 | BD  -67.98 | CD  -66.62    (Iteration  9, r2 =  52874.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  +39.82 | AC  +38.38 | AD  -28.36 | BC   -1.44 | BD  -68.18 | CD  -66.73    (Iteration 10, r2 =  52800.7)
Timeshift stabilization and releasing of splflat :
AB  +39.82 | AC  +38.42 | AD  -28.46 | BC   -1.40 | BD  -68.28 | CD  -66.88    (Iteration  1, r2 =  52799.4)
AB  +39.87 | AC  +38.42 | AD  -28.46 | BC   -1.45 | BD  -68.33 | CD  -66.88    (Iteration  2, r2 =  52799.2)
AB  +39.87 | AC  +38.42 | AD  -28.46 | BC   -1.45 | BD  -68.33 | CD  -66.88    (Iteration  3, r2 =  52799.2)
AB  +39.87 | AC  +38.42 | AD  -28.46 | BC   -1.45 | BD  -68.33 | CD  -66.88    (Iteration  4, r2 =  52799.2)
AB  +39.87 | AC  +38.42 | AD  -28.46 | BC   -1.45 | BD  -68.33 | CD  -66.88    (Iteration  5, r2 =  52799.2)

Now let's print out the measured time delays, computed from the current time shifts of each curve. Note that the lcs objects now contain shifts provided to them by the spline model.


In [15]:
basic_time_delays = pycs.gen.lc.getnicetimedelays(lcs, separator="\n", sorted=True)
print("Time Delays (no microlensing):")
print(basic_time_delays)


Time Delays (no microlensing):
AB  +39.87
AC  +38.42
AD  -28.46
BC   -1.45
BD  -68.33
CD  -66.88

We can now redisplay our light curve plot, but with the spline model overlaid and the inferred shifts applied. Remember, it won't look very good, as the curves do not overlap without a microlensing model.


In [16]:
pycs.gen.lc.display(lcs, [spline], knotsize=0.01, figsize=(20, 7), jdrange=(53900, 55500))


3.2 Including Microlensing

Now let's factor in four independent polynomial curves to account for any microlensing in our light curves.


In [17]:
pycs.gen.polyml.addtolc(lcs[1], nparams=2, autoseasonsgap=600.0)
pycs.gen.polyml.addtolc(lcs[2], nparams=3, autoseasonsgap=600.0)
pycs.gen.polyml.addtolc(lcs[3], nparams=3, autoseasonsgap=600.0)

Now, let's try the model optimization again. The result should be much better!


In [18]:
spline = spl(lcs)


Starting opt_rough on initial delays :
AB  +39.87 | AC  +38.42 | AD  -28.46 | BC   -1.45 | BD  -68.33 | CD  -66.88
Aiming at curves A.
Starting ML optimization ...
Working on the poly ML of [Trial/B](27.987,-0.647,0)|poly/2|
Working on the poly ML of [Trial/C](26.541,-1.603,0)|poly/3|
Working on the poly ML of [Trial/D](-40.339,-2.092,0)|poly/3|
Done !
First spline and ML opt done.
AB  +15.87 | AC  +24.42 | AD  -45.46 | BC   +8.55 | BD  -61.33 | CD  -69.88    (Iteration  1, r2 =  30181.0)
AB   -1.13 | AC   +3.42 | AD  -58.46 | BC   +4.55 | BD  -57.33 | CD  -61.88    (Iteration  2, r2 =  22541.0)
AB   -8.13 | AC  -12.58 | AD  -64.46 | BC   -4.45 | BD  -56.33 | CD  -51.88    (Iteration  3, r2 =  19645.8)
AB  -13.13 | AC  -21.58 | AD  -68.46 | BC   -8.45 | BD  -55.33 | CD  -46.88    (Iteration  4, r2 =  18551.8)
AB  -15.13 | AC  -26.58 | AD  -69.46 | BC  -11.45 | BD  -54.33 | CD  -42.88    (Iteration  5, r2 =  18256.0)
Rough time shifts done :
AB  -15.13 | AC  -26.58 | AD  -69.46 | BC  -11.45 | BD  -54.33 | CD  -42.88
Starting opt_rough on initial delays :
AB  -15.13 | AC  -26.58 | AD  -69.46 | BC  -11.45 | BD  -54.33 | CD  -42.88
Aiming at curves A.
Starting ML optimization ...
Working on the poly ML of [Trial/B](-14.013,-0.647,0)|poly/2|
Working on the poly ML of [Trial/C](-25.459,-1.603,0)|poly/3|
Working on the poly ML of [Trial/D](-68.339,-2.092,0)|poly/3|
Done !
First spline and ML opt done.
AB  -16.13 | AC  -27.58 | AD  -73.46 | BC  -11.45 | BD  -57.33 | CD  -45.88    (Iteration  1, r2 =  14873.1)
AB  -16.13 | AC  -27.58 | AD  -74.46 | BC  -11.45 | BD  -58.33 | CD  -46.88    (Iteration  2, r2 =  14869.2)
AB  -16.13 | AC  -27.58 | AD  -75.46 | BC  -11.45 | BD  -59.33 | CD  -47.88    (Iteration  3, r2 =  14867.1)
AB  -16.13 | AC  -27.58 | AD  -75.46 | BC  -11.45 | BD  -59.33 | CD  -47.88    (Iteration  4, r2 =  14867.1)
AB  -16.13 | AC  -27.58 | AD  -75.46 | BC  -11.45 | BD  -59.33 | CD  -47.88    (Iteration  5, r2 =  14867.1)
Rough time shifts done :
AB  -16.13 | AC  -27.58 | AD  -75.46 | BC  -11.45 | BD  -59.33 | CD  -47.88
Starting opt_fine on initial delays :
AB  -16.13 | AC  -27.58 | AD  -75.46 | BC  -11.45 | BD  -59.33 | CD  -47.88
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -13.64 | AC  -24.89 | AD  -73.34 | BC  -11.24 | BD  -59.70 | CD  -48.46    (Iteration  1, r2 =  11374.8)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -12.90 | AC  -24.07 | AD  -72.49 | BC  -11.17 | BD  -59.59 | CD  -48.42    (Iteration  2, r2 =  11229.8)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -12.49 | AC  -23.78 | AD  -72.11 | BC  -11.29 | BD  -59.62 | CD  -48.33    (Iteration  3, r2 =  11124.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -12.11 | AC  -23.59 | AD  -71.96 | BC  -11.48 | BD  -59.85 | CD  -48.37    (Iteration  4, r2 =  11041.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -11.94 | AC  -23.58 | AD  -72.01 | BC  -11.64 | BD  -60.08 | CD  -48.44    (Iteration  5, r2 =  10979.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -11.84 | AC  -23.56 | AD  -71.98 | BC  -11.72 | BD  -60.13 | CD  -48.42    (Iteration  6, r2 =  10930.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -11.68 | AC  -23.68 | AD  -71.95 | BC  -12.00 | BD  -60.27 | CD  -48.27    (Iteration  7, r2 =  10892.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -11.57 | AC  -23.64 | AD  -71.98 | BC  -12.07 | BD  -60.41 | CD  -48.34    (Iteration  8, r2 =  10858.5)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -11.42 | AC  -23.77 | AD  -71.97 | BC  -12.35 | BD  -60.55 | CD  -48.20    (Iteration  9, r2 =  10830.8)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB  -11.36 | AC  -23.79 | AD  -71.91 | BC  -12.43 | BD  -60.55 | CD  -48.12    (Iteration 10, r2 =  10812.3)
Timeshift stabilization and releasing of splflat :
AB  -11.36 | AC  -23.95 | AD  -71.91 | BC  -12.58 | BD  -60.55 | CD  -47.96    (Iteration  1, r2 =  10811.7)
AB  -11.36 | AC  -23.95 | AD  -71.97 | BC  -12.58 | BD  -60.61 | CD  -48.02    (Iteration  2, r2 =  10811.6)
AB  -11.36 | AC  -23.95 | AD  -71.97 | BC  -12.58 | BD  -60.61 | CD  -48.02    (Iteration  3, r2 =  10811.6)
AB  -11.36 | AC  -23.95 | AD  -71.97 | BC  -12.58 | BD  -60.61 | CD  -48.02    (Iteration  4, r2 =  10811.6)
AB  -11.36 | AC  -23.95 | AD  -71.97 | BC  -12.58 | BD  -60.61 | CD  -48.02    (Iteration  5, r2 =  10811.6)

In [19]:
pycs.gen.lc.display(lcs, [spline], knotsize=0.01, figsize=(20, 7), jdrange=(53900, 55500))


The new time delays should show the difference once microlensing is factored in. We'll compare our previous time delay output to this output.


In [20]:
polynomial_microlensing_time_delays = pycs.gen.lc.getnicetimedelays(lcs, separator="\n", sorted=True)
print("Time Delays (microlensing included, with polynomials):")
print(polynomial_microlensing_time_delays)

print("cf. Time Delays (no microlensing):")
print(basic_time_delays)


Time Delays (microlensing included, with polynomials):
AB  -11.36
AC  -23.95
AD  -71.97
BC  -12.58
BD  -60.61
CD  -48.02
cf. Time Delays (no microlensing):
AB  +39.87
AC  +38.42
AD  -28.46
BC   -1.45
BD  -68.33
CD  -66.88

3.3 Modeling Microlensing with Splines

If we add spline models for the microlensing, they displace the polynomial model:


In [21]:
pycs.gen.splml.addtolc(lcs[0], knotstep=150)
pycs.gen.splml.addtolc(lcs[1], knotstep=150)
pycs.gen.splml.addtolc(lcs[2], knotstep=150)
pycs.gen.splml.addtolc(lcs[3], knotstep=150)


I replace an existing mircolensing.
I replace an existing mircolensing.
I replace an existing mircolensing.

Let's re-optimize and see what happens to the time delays:


In [22]:
spline = spl(lcs)


Starting opt_rough on initial delays :
AB  -11.36 | AC  -23.95 | AD  -71.97 | BC  -12.58 | BD  -60.61 | CD  -48.02
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/A](-1.141,0.000,0)|~3/u/7~|
Working on the spline ML of [Trial/B](-12.503,-0.647,0)|~3/u/7~|
Working on the spline ML of [Trial/C](-25.088,-1.603,0)|~3/u/7~|
Working on the spline ML of [Trial/D](-73.109,-2.092,0)|~3/u/7~|
Done !
First spline and ML opt done.
AB  -12.36 | AC  -23.95 | AD  -76.97 | BC  -11.58 | BD  -64.61 | CD  -53.02    (Iteration  1, r2 =   9231.6)
AB  -13.36 | AC  -23.95 | AD  -80.97 | BC  -10.58 | BD  -67.61 | CD  -57.02    (Iteration  2, r2 =   9162.3)
AB  -13.36 | AC  -23.95 | AD  -82.97 | BC  -10.58 | BD  -69.61 | CD  -59.02    (Iteration  3, r2 =   9141.6)
AB  -13.36 | AC  -23.95 | AD  -84.97 | BC  -10.58 | BD  -71.61 | CD  -61.02    (Iteration  4, r2 =   9128.9)
AB  -13.36 | AC  -23.95 | AD  -85.97 | BC  -10.58 | BD  -72.61 | CD  -62.02    (Iteration  5, r2 =   9124.1)
Rough time shifts done :
AB  -13.36 | AC  -23.95 | AD  -85.97 | BC  -10.58 | BD  -72.61 | CD  -62.02
Starting opt_rough on initial delays :
AB  -13.36 | AC  -23.95 | AD  -85.97 | BC  -10.58 | BD  -72.61 | CD  -62.02
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/A](-1.141,0.000,0)|~3/u/7~|
Working on the spline ML of [Trial/B](-14.503,-0.647,0)|~3/u/7~|
Working on the spline ML of [Trial/C](-25.088,-1.603,0)|~3/u/7~|
Working on the spline ML of [Trial/D](-87.109,-2.092,0)|~3/u/7~|
Done !
First spline and ML opt done.
AB  -13.36 | AC  -23.95 | AD  -79.97 | BC  -10.58 | BD  -66.61 | CD  -56.02    (Iteration  1, r2 =   7140.5)
AB  -12.36 | AC  -22.95 | AD  -77.97 | BC  -10.58 | BD  -65.61 | CD  -55.02    (Iteration  2, r2 =   7089.8)
AB  -12.36 | AC  -22.95 | AD  -76.97 | BC  -10.58 | BD  -64.61 | CD  -54.02    (Iteration  3, r2 =   7080.1)
AB  -12.36 | AC  -22.95 | AD  -76.97 | BC  -10.58 | BD  -64.61 | CD  -54.02    (Iteration  4, r2 =   7075.1)
AB  -12.36 | AC  -22.95 | AD  -76.97 | BC  -10.58 | BD  -64.61 | CD  -54.02    (Iteration  5, r2 =   7071.5)
Rough time shifts done :
AB  -12.36 | AC  -22.95 | AD  -76.97 | BC  -10.58 | BD  -64.61 | CD  -54.02
Starting opt_fine on initial delays :
AB  -12.36 | AC  -22.95 | AD  -76.97 | BC  -10.58 | BD  -64.61 | CD  -54.02
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -7.25 | AC  -22.71 | AD  -70.50 | BC  -15.46 | BD  -63.25 | CD  -47.78    (Iteration  1, r2 =   2707.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -5.83 | AC  -21.54 | AD  -68.73 | BC  -15.72 | BD  -62.90 | CD  -47.18    (Iteration  2, r2 =   2355.2)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -5.34 | AC  -21.09 | AD  -68.37 | BC  -15.75 | BD  -63.03 | CD  -47.28    (Iteration  3, r2 =   2258.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -5.12 | AC  -20.89 | AD  -68.11 | BC  -15.77 | BD  -62.99 | CD  -47.22    (Iteration  4, r2 =   2222.5)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -4.99 | AC  -20.90 | AD  -68.05 | BC  -15.91 | BD  -63.06 | CD  -47.15    (Iteration  5, r2 =   2201.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -4.99 | AC  -20.85 | AD  -68.12 | BC  -15.86 | BD  -63.13 | CD  -47.27    (Iteration  6, r2 =   2194.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -4.97 | AC  -20.87 | AD  -68.26 | BC  -15.90 | BD  -63.28 | CD  -47.39    (Iteration  7, r2 =   2179.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -4.96 | AC  -20.85 | AD  -68.25 | BC  -15.89 | BD  -63.29 | CD  -47.40    (Iteration  8, r2 =   2172.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -4.94 | AC  -20.83 | AD  -68.19 | BC  -15.88 | BD  -63.24 | CD  -47.36    (Iteration  9, r2 =   2172.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
AB   -4.96 | AC  -20.87 | AD  -68.29 | BC  -15.91 | BD  -63.33 | CD  -47.42    (Iteration 10, r2 =   2170.9)
Timeshift stabilization and releasing of splflat :
AB   -4.80 | AC  -20.68 | AD  -68.55 | BC  -15.88 | BD  -63.75 | CD  -47.87    (Iteration  1, r2 =   2117.1)
AB   -4.83 | AC  -20.71 | AD  -68.58 | BC  -15.88 | BD  -63.75 | CD  -47.87    (Iteration  2, r2 =   2104.8)
AB   -4.77 | AC  -20.71 | AD  -68.58 | BC  -15.94 | BD  -63.81 | CD  -47.87    (Iteration  3, r2 =   2097.1)
AB   -4.80 | AC  -20.66 | AD  -68.62 | BC  -15.86 | BD  -63.81 | CD  -47.95    (Iteration  4, r2 =   2091.9)
AB   -4.80 | AC  -20.66 | AD  -68.62 | BC  -15.86 | BD  -63.81 | CD  -47.95    (Iteration  5, r2 =   2088.5)

In [23]:
spline_microlensing_time_delays = pycs.gen.lc.getnicetimedelays(lcs, separator="\n", sorted=True)
print("Time Delays (microlensing included, with splines):")
print(spline_microlensing_time_delays)

print("cf. Time Delays (microlensing included, with polynomials):")
print(polynomial_microlensing_time_delays)


Time Delays (microlensing included, with splines):
AB   -4.80
AC  -20.66
AD  -68.62
BC  -15.86
BD  -63.81
CD  -47.95
cf. Time Delays (microlensing included, with polynomials):
AB  -11.36
AC  -23.95
AD  -71.97
BC  -12.58
BD  -60.61
CD  -48.02

We see differences, but the results from the two types of microlensing model are much closer together than either of them are with the time delays from the "no microlensing" model.

What do these spline microlensing models look like?


In [24]:
pycs.gen.lc.display(lcs, [spline], knotsize=0.01, figsize=(20, 7), jdrange=(53900, 55500))


Let's save this to a PDF figure:


In [25]:
pycs.gen.lc.display(lcs, [spline], knotsize=0.01, figsize=(20, 7), jdrange=(53900, 55500),filename="fig_modelfit.pdf")


Plot written to fig_modelfit.pdf

Now that we have a well-optimized model, lets save it and the shifted light curves to a pickle file that we can use later.


In [26]:
pycs.gen.util.writepickle((lcs, spline), "optspline.pkl")


Wrote optspline.pkl

4. Estimating the Time Delay Uncertainties

Error estimation with PyCS is performed by re-sampling the data, re-optimizing the model, and accumulating statistics about the resulting time delays.

To evaluate the intrinsic variance of the optimizer, we make Ncopies copies of the dataset, and re-optimize the model for each one. To probe the width of the likelihood function itself, we generate and use Nmocks synthetic datasets, with slightly different time delays. For the latter step, we need to read in an optimized model and its shifted light curves. In each case we'll need to collect together the many optimized light curves' time delays at the end, and compute some statistics.

First, though, we need to clear out any previous simulations we did, because PyCS works on all files in a simulation folder, and we don't want to mix up any old files with new ones.


In [27]:
!\rm -rfv sims_copies sims_mocks
!\rm -rfv sims_copies_opt_spl sims_copies_opt_disp sims_copies_opt_regdiff
!\rm -rfv sims_mocks_opt_spl sims_mocks_opt_disp sims_mocks_opt_regdiff


sims_copies/1_1466725864.10343.pkl
sims_copies/2_1466725864.11248.pkl
sims_copies/3_1466725864.12040.pkl
sims_copies/4_1466725864.13045.pkl
sims_copies
sims_mocks/1_1466725864.15065.pkl
sims_mocks/2_1466725864.21035.pkl
sims_mocks/3_1466725864.26235.pkl
sims_mocks/4_1466725864.32128.pkl
sims_mocks
sims_copies_opt_spl/1_1466725864.10343_opt.pkl
sims_copies_opt_spl/1_1466725864.10343_runresults.pkl
sims_copies_opt_spl/2_1466725864.11248_opt.pkl
sims_copies_opt_spl/2_1466725864.11248_runresults.pkl
sims_copies_opt_spl/3_1466725864.12040_opt.pkl
sims_copies_opt_spl/3_1466725864.12040_runresults.pkl
sims_copies_opt_spl/4_1466725864.13045_opt.pkl
sims_copies_opt_spl/4_1466725864.13045_runresults.pkl
sims_copies_opt_spl
sims_mocks_opt_spl/1_1466725864.15065_opt.pkl
sims_mocks_opt_spl/1_1466725864.15065_runresults.pkl
sims_mocks_opt_spl/2_1466725864.21035_opt.pkl
sims_mocks_opt_spl/2_1466725864.21035_runresults.pkl
sims_mocks_opt_spl/3_1466725864.26235_opt.pkl
sims_mocks_opt_spl/3_1466725864.26235_runresults.pkl
sims_mocks_opt_spl/4_1466725864.32128_opt.pkl
sims_mocks_opt_spl/4_1466725864.32128_runresults.pkl
sims_mocks_opt_spl

4.1 Re-sampling the Light Curve Data

First, the plain copies:


In [28]:
n, npkl = 1, 4
Ncopies = n*npkl
print("Making",Ncopies,"copies of the original dataset:")
pycs.sim.draw.multidraw(lcs, onlycopy=True, n=n, npkl=npkl, simset="copies")


Making 4 copies of the original dataset:
Now thowing dice into sims_copies ...
Input shifts :
A    -5.34 | B   -10.14 | C   -26.00 | D   -73.96
Input delays :
AB   -4.80 | AC  -20.66 | AD  -68.62 | BC  -15.86 | BD  -63.81 | CD  -47.95
Preparing 1 identical copies for pkl 1/4 ...
Wrote sims_copies/1_1466727298.48273.pkl
Preparing 1 identical copies for pkl 2/4 ...
Wrote sims_copies/2_1466727298.49102.pkl
Preparing 1 identical copies for pkl 3/4 ...
Wrote sims_copies/3_1466727298.50024.pkl
Preparing 1 identical copies for pkl 4/4 ...
Wrote sims_copies/4_1466727298.50913.pkl

Now the synthetic light curves:


In [29]:
(modellcs, modelspline)  = pycs.gen.util.readpickle("optspline.pkl")


Read optspline.pkl

We want each synthetic light curve to have slightly different underlying microlensing signals as well as a slightly different set of time delays. This is achieved via a set of "tweak" functions, that implement some small scale extrinsic variability when we generate the synthetic curves. Note that the control parameters beta, sigma, and fmin have to be asserted, these values can be changed.


In [30]:
def Atweakml(lcs):
    return pycs.sim.twk.tweakml(lcs, beta=-1.5, sigma=0.25, fmin=1/500.0, fmax=None, psplot=False)

def Btweakml(lcs):
    return pycs.sim.twk.tweakml(lcs, beta=-1.0, sigma=0.9, fmin=1/500.0, fmax=None, psplot=False)

def Ctweakml(lcs):
    return pycs.sim.twk.tweakml(lcs, beta=-1.0, sigma=1.5, fmin=1/500.0, fmax=None, psplot=False)

def Dtweakml(lcs):
    return pycs.sim.twk.tweakml(lcs, beta=-0.0, sigma=4.5, fmin=1/500.0, fmax=None, psplot=False)

At this place, only if you know what you are doing, you can manually adjust the microlensing or the delays. If not, run this script. This will run n simulations for each element in the pickle file.


In [31]:
n, npkl = 1, 4
Nmocks = n*npkl
truetsr = 8.0
print("Making",Nmocks,"synthetic datasets, varying time delays by +/-",truetsr/2.0,"days")
pycs.sim.draw.saveresiduals(modellcs, modelspline)
pycs.sim.draw.multidraw(modellcs, modelspline, n=n, npkl=npkl, simset="mocks",
        truetsr=truetsr, tweakml=[Atweakml, Btweakml, Ctweakml, Dtweakml])


Making 4 synthetic datasets, varying time delays by +/- 4.0 days
Now thowing dice into sims_mocks ...
Input shifts :
A    -5.34 | B   -10.14 | C   -26.00 | D   -73.96
Input delays :
AB   -4.80 | AC  -20.66 | AD  -68.62 | BC  -15.86 | BD  -63.81 | CD  -47.95
Drawing 1 simulations for pkl 1/4 ...
Wrote sims_mocks/1_1466727306.28380.pkl
Drawing 1 simulations for pkl 2/4 ...
Wrote sims_mocks/2_1466727306.37004.pkl
Drawing 1 simulations for pkl 3/4 ...
/Users/pjm/miniconda2/lib/python2.7/site-packages/pycs/gen/spl.py:342: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  if (self.t == None):
Wrote sims_mocks/3_1466727306.43678.pkl
Drawing 1 simulations for pkl 4/4 ...
Wrote sims_mocks/4_1466727306.50516.pkl

Note that we chose the name of our set of synthetic light curves "1Kset1" via the simset kwarg. "truetsr=8.0" means that the synthetic curves will get random true time shifts in a range of about 8.0 days around the time shifts of the model lcs objects.

4.2 Re-running the Model Fits

Now, we will run the free-knot spline technique using the plain copies we made earlier of the data. This will take a while: we're doing Ncopies separate model optimizations.


In [32]:
pycs.sim.run.multirun("copies", lcs, spl, optset="spl", tsrand=10.0, keepopt=True)


I have found 4 simulation pickles in sims_copies.
I'll write my results into the directory sims_copies_opt_spl.
Initial conditions : 
[Trial/A](-5.340,0.000,0)|~3/12l12b/7~|
[Trial/B](-10.144,-0.647,0)|~3/12l12b/7~|
[Trial/C](-26.003,-1.603,0)|~3/12l12b/7~|
[Trial/D](-73.957,-2.092,0)|~3/12l12b/7~|
--- Casino running on simset copies, optset spl ---
Read sims_copies/1_1466727298.48273.pkl
Working for sims_copies_opt_spl/1_1466727298.48273_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting opt_rough on initial delays :
DB  +71.81 | DC  +38.75 | DA  +69.72 | BC  -33.06 | BA   -2.09 | CA  +30.97
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/D](-73.608,-2.092,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/B](-1.798,-0.647,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/C](-34.858,-1.603,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/A](-3.889,0.000,0)|~3/12l12b/7~|
Done !
First spline and ML opt done.
DB  +69.81 | DC  +44.75 | DA  +70.72 | BC  -25.06 | BA   +0.91 | CA  +25.97    (Iteration  1, r2 =   8036.8)
DB  +69.81 | DC  +49.75 | DA  +72.72 | BC  -20.06 | BA   +2.91 | CA  +22.97    (Iteration  2, r2 =   7799.9)
DB  +69.81 | DC  +52.75 | DA  +73.72 | BC  -17.06 | BA   +3.91 | CA  +20.97    (Iteration  3, r2 =   7713.2)
DB  +69.81 | DC  +54.75 | DA  +74.72 | BC  -15.06 | BA   +4.91 | CA  +19.97    (Iteration  4, r2 =   7668.6)
DB  +69.81 | DC  +54.75 | DA  +74.72 | BC  -15.06 | BA   +4.91 | CA  +19.97    (Iteration  5, r2 =   7661.0)
Rough time shifts done :
DB  +69.81 | DC  +54.75 | DA  +74.72 | BC  -15.06 | BA   +4.91 | CA  +19.97
Starting opt_rough on initial delays :
DB  +69.81 | DC  +54.75 | DA  +74.72 | BC  -15.06 | BA   +4.91 | CA  +19.97
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/D](-78.608,-2.092,0)|~3/u/7~|
Working on the spline ML of [Trial/B](-8.798,-0.647,0)|~3/u/7~|
Working on the spline ML of [Trial/C](-23.858,-1.603,0)|~3/u/7~|
Working on the spline ML of [Trial/A](-3.889,0.000,0)|~3/u/7~|
Done !
First spline and ML opt done.
DB  +66.81 | DC  +53.75 | DA  +75.72 | BC  -13.06 | BA   +8.91 | CA  +21.97    (Iteration  1, r2 =   7481.1)
DB  +65.81 | DC  +53.75 | DA  +75.72 | BC  -12.06 | BA   +9.91 | CA  +21.97    (Iteration  2, r2 =   7449.7)
DB  +65.81 | DC  +53.75 | DA  +75.72 | BC  -12.06 | BA   +9.91 | CA  +21.97    (Iteration  3, r2 =   7445.3)
DB  +65.81 | DC  +53.75 | DA  +75.72 | BC  -12.06 | BA   +9.91 | CA  +21.97    (Iteration  4, r2 =   7441.2)
DB  +65.81 | DC  +53.75 | DA  +75.72 | BC  -12.06 | BA   +9.91 | CA  +21.97    (Iteration  5, r2 =   7437.2)
Rough time shifts done :
DB  +65.81 | DC  +53.75 | DA  +75.72 | BC  -12.06 | BA   +9.91 | CA  +21.97
Starting opt_fine on initial delays :
DB  +65.81 | DC  +53.75 | DA  +75.72 | BC  -12.06 | BA   +9.91 | CA  +21.97
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +64.81 | DC  +47.44 | DA  +70.29 | BC  -17.37 | BA   +5.48 | CA  +22.85    (Iteration  1, r2 =   2526.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.24 | DC  +46.92 | DA  +69.81 | BC  -18.32 | BA   +4.57 | CA  +22.89    (Iteration  2, r2 =   2413.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.38 | DC  +46.81 | DA  +69.76 | BC  -18.57 | BA   +4.38 | CA  +22.95    (Iteration  3, r2 =   2367.2)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.35 | DC  +46.69 | DA  +69.75 | BC  -18.66 | BA   +4.40 | CA  +23.06    (Iteration  4, r2 =   2347.8)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.32 | DC  +46.77 | DA  +69.78 | BC  -18.55 | BA   +4.46 | CA  +23.00    (Iteration  5, r2 =   2328.7)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.29 | DC  +46.86 | DA  +69.80 | BC  -18.43 | BA   +4.51 | CA  +22.94    (Iteration  6, r2 =   2334.5)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.19 | DC  +46.79 | DA  +69.77 | BC  -18.40 | BA   +4.57 | CA  +22.97    (Iteration  7, r2 =   2327.6)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.22 | DC  +46.79 | DA  +69.79 | BC  -18.43 | BA   +4.57 | CA  +23.00    (Iteration  8, r2 =   2326.7)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.24 | DC  +46.87 | DA  +69.81 | BC  -18.37 | BA   +4.57 | CA  +22.94    (Iteration  9, r2 =   2324.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.12 | DC  +46.73 | DA  +69.72 | BC  -18.40 | BA   +4.60 | CA  +22.99    (Iteration 10, r2 =   2319.8)
Timeshift stabilization and releasing of splflat :
DB  +64.95 | DC  +47.60 | DA  +69.54 | BC  -17.35 | BA   +4.60 | CA  +21.94    (Iteration  1, r2 =   2150.2)
DB  +65.01 | DC  +47.83 | DA  +69.57 | BC  -17.18 | BA   +4.56 | CA  +21.74    (Iteration  2, r2 =   2137.6)
DB  +65.01 | DC  +47.91 | DA  +69.57 | BC  -17.09 | BA   +4.56 | CA  +21.66    (Iteration  3, r2 =   2133.9)
DB  +65.01 | DC  +47.91 | DA  +69.57 | BC  -17.09 | BA   +4.56 | CA  +21.66    (Iteration  4, r2 =   2132.7)
DB  +64.95 | DC  +47.86 | DA  +69.51 | BC  -17.09 | BA   +4.56 | CA  +21.66    (Iteration  5, r2 =   2132.1)
Shifted 1 simulations, using 1 CPU, time : 16
Wrote sims_copies_opt_spl/1_1466727298.48273_opt.pkl
Wrote sims_copies_opt_spl/1_1466727298.48273_runresults.pkl
--- Casino running on simset copies, optset spl ---
Read sims_copies/2_1466727298.49102.pkl
Working for sims_copies_opt_spl/2_1466727298.49102_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting opt_rough on initial delays :
DC  +50.81 | DB  +69.23 | DA  +69.77 | CB  +18.42 | CA  +18.96 | BA   +0.54
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/D](-76.328,-2.092,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/C](-25.518,-1.603,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/B](-7.097,-0.647,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/A](-6.555,0.000,0)|~3/12l12b/7~|
Done !
First spline and ML opt done.
/Users/pjm/miniconda2/lib/python2.7/site-packages/pycs/sim/run.py:130: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  if qs != None:
DC  +52.81 | DB  +69.23 | DA  +71.77 | CB  +16.42 | CA  +18.96 | BA   +2.54    (Iteration  1, r2 =   7864.5)
DC  +53.81 | DB  +69.23 | DA  +72.77 | CB  +15.42 | CA  +18.96 | BA   +3.54    (Iteration  2, r2 =   7806.7)
DC  +54.81 | DB  +69.23 | DA  +73.77 | CB  +14.42 | CA  +18.96 | BA   +4.54    (Iteration  3, r2 =   7769.4)
DC  +55.81 | DB  +70.23 | DA  +74.77 | CB  +14.42 | CA  +18.96 | BA   +4.54    (Iteration  4, r2 =   7761.6)
DC  +55.81 | DB  +70.23 | DA  +74.77 | CB  +14.42 | CA  +18.96 | BA   +4.54    (Iteration  5, r2 =   7757.1)
Rough time shifts done :
DC  +55.81 | DB  +70.23 | DA  +74.77 | CB  +14.42 | CA  +18.96 | BA   +4.54
Starting opt_rough on initial delays :
DC  +55.81 | DB  +70.23 | DA  +74.77 | CB  +14.42 | CA  +18.96 | BA   +4.54
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/D](-81.328,-2.092,0)|~3/u/7~|
Working on the spline ML of [Trial/C](-25.518,-1.603,0)|~3/u/7~|
Working on the spline ML of [Trial/B](-11.097,-0.647,0)|~3/u/7~|
Working on the spline ML of [Trial/A](-6.555,0.000,0)|~3/u/7~|
Done !
First spline and ML opt done.
DC  +54.81 | DB  +67.23 | DA  +75.77 | CB  +12.42 | CA  +20.96 | BA   +8.54    (Iteration  1, r2 =   7496.2)
DC  +53.81 | DB  +66.23 | DA  +75.77 | CB  +12.42 | CA  +21.96 | BA   +9.54    (Iteration  2, r2 =   7455.1)
DC  +53.81 | DB  +65.23 | DA  +75.77 | CB  +11.42 | CA  +21.96 | BA  +10.54    (Iteration  3, r2 =   7439.1)
DC  +53.81 | DB  +65.23 | DA  +75.77 | CB  +11.42 | CA  +21.96 | BA  +10.54    (Iteration  4, r2 =   7434.8)
DC  +53.81 | DB  +65.23 | DA  +75.77 | CB  +11.42 | CA  +21.96 | BA  +10.54    (Iteration  5, r2 =   7430.7)
Rough time shifts done :
DC  +53.81 | DB  +65.23 | DA  +75.77 | CB  +11.42 | CA  +21.96 | BA  +10.54
Starting opt_fine on initial delays :
DC  +53.81 | DB  +65.23 | DA  +75.77 | CB  +11.42 | CA  +21.96 | BA  +10.54
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +47.80 | DB  +64.68 | DA  +70.36 | CB  +16.88 | CA  +22.56 | BA   +5.68    (Iteration  1, r2 =   2540.6)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +47.11 | DB  +64.96 | DA  +69.63 | CB  +17.85 | CA  +22.52 | BA   +4.67    (Iteration  2, r2 =   2438.8)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +46.79 | DB  +65.17 | DA  +69.57 | CB  +18.38 | CA  +22.78 | BA   +4.40    (Iteration  3, r2 =   2375.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +46.67 | DB  +65.17 | DA  +69.56 | CB  +18.50 | CA  +22.89 | BA   +4.39    (Iteration  4, r2 =   2362.5)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +46.61 | DB  +65.11 | DA  +69.60 | CB  +18.50 | CA  +23.00 | BA   +4.49    (Iteration  5, r2 =   2347.7)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +46.59 | DB  +65.11 | DA  +69.61 | CB  +18.52 | CA  +23.02 | BA   +4.50    (Iteration  6, r2 =   2357.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +46.67 | DB  +65.08 | DA  +69.64 | CB  +18.41 | CA  +22.97 | BA   +4.56    (Iteration  7, r2 =   2340.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +46.67 | DB  +65.00 | DA  +69.55 | CB  +18.33 | CA  +22.88 | BA   +4.54    (Iteration  8, r2 =   2335.6)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +46.61 | DB  +65.06 | DA  +69.69 | CB  +18.46 | CA  +23.08 | BA   +4.62    (Iteration  9, r2 =   2337.7)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DC  +46.69 | DB  +65.14 | DA  +69.71 | CB  +18.46 | CA  +23.03 | BA   +4.57    (Iteration 10, r2 =   2349.1)
Timeshift stabilization and releasing of splflat :
DC  +47.63 | DB  +65.02 | DA  +69.59 | CB  +17.40 | CA  +21.97 | BA   +4.57    (Iteration  1, r2 =   2165.2)
DC  +47.81 | DB  +65.02 | DA  +69.59 | CB  +17.21 | CA  +21.78 | BA   +4.57    (Iteration  2, r2 =   2152.3)
DC  +47.81 | DB  +65.02 | DA  +69.59 | CB  +17.21 | CA  +21.78 | BA   +4.57    (Iteration  3, r2 =   2148.5)
DC  +47.75 | DB  +64.96 | DA  +69.53 | CB  +17.21 | CA  +21.78 | BA   +4.57    (Iteration  4, r2 =   2147.1)
DC  +47.75 | DB  +64.96 | DA  +69.53 | CB  +17.21 | CA  +21.78 | BA   +4.57    (Iteration  5, r2 =   2146.5)
Shifted 1 simulations, using 1 CPU, time : 18
Wrote sims_copies_opt_spl/2_1466727298.49102_opt.pkl
Wrote sims_copies_opt_spl/2_1466727298.49102_runresults.pkl
--- Casino running on simset copies, optset spl ---
Read sims_copies/3_1466727298.50024.pkl
Working for sims_copies_opt_spl/3_1466727298.50024_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting opt_rough on initial delays :
CB  +19.83 | CA  +14.54 | CD  -43.41 | BA   -5.29 | BD  -63.24 | AD  -57.95
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/C](-25.846,-1.603,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/B](-6.012,-0.647,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/A](-11.303,0.000,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/D](-69.253,-2.092,0)|~3/12l12b/7~|
Done !
First spline and ML opt done.
CB  +16.83 | CA  +15.54 | CD  -49.41 | BA   -1.29 | BD  -66.24 | AD  -64.95    (Iteration  1, r2 =   7871.8)
CB  +14.83 | CA  +15.54 | CD  -53.41 | BA   +0.71 | BD  -68.24 | AD  -68.95    (Iteration  2, r2 =   7686.7)
CB  +13.83 | CA  +15.54 | CD  -55.41 | BA   +1.71 | BD  -69.24 | AD  -70.95    (Iteration  3, r2 =   7614.0)
CB  +12.83 | CA  +15.54 | CD  -57.41 | BA   +2.71 | BD  -70.24 | AD  -72.95    (Iteration  4, r2 =   7560.9)
CB  +12.83 | CA  +16.54 | CD  -57.41 | BA   +3.71 | BD  -70.24 | AD  -73.95    (Iteration  5, r2 =   7519.4)
Rough time shifts done :
CB  +12.83 | CA  +16.54 | CD  -57.41 | BA   +3.71 | BD  -70.24 | AD  -73.95
Starting opt_rough on initial delays :
CB  +12.83 | CA  +16.54 | CD  -57.41 | BA   +3.71 | BD  -70.24 | AD  -73.95
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/C](-26.846,-1.603,0)|~3/u/7~|
Working on the spline ML of [Trial/B](-14.012,-0.647,0)|~3/u/7~|
Working on the spline ML of [Trial/A](-10.303,0.000,0)|~3/u/7~|
Working on the spline ML of [Trial/D](-84.253,-2.092,0)|~3/u/7~|
Done !
First spline and ML opt done.
CB  +11.83 | CA  +20.54 | CD  -55.41 | BA   +8.71 | BD  -67.24 | AD  -75.95    (Iteration  1, r2 =   7411.3)
CB  +11.83 | CA  +22.54 | CD  -54.41 | BA  +10.71 | BD  -66.24 | AD  -76.95    (Iteration  2, r2 =   7320.0)
CB  +11.83 | CA  +22.54 | CD  -54.41 | BA  +10.71 | BD  -66.24 | AD  -76.95    (Iteration  3, r2 =   7315.2)
CB  +11.83 | CA  +22.54 | CD  -54.41 | BA  +10.71 | BD  -66.24 | AD  -76.95    (Iteration  4, r2 =   7311.4)
CB  +11.83 | CA  +22.54 | CD  -54.41 | BA  +10.71 | BD  -66.24 | AD  -76.95    (Iteration  5, r2 =   7307.9)
Rough time shifts done :
CB  +11.83 | CA  +22.54 | CD  -54.41 | BA  +10.71 | BD  -66.24 | AD  -76.95
Starting opt_fine on initial delays :
CB  +11.83 | CA  +22.54 | CD  -54.41 | BA  +10.71 | BD  -66.24 | AD  -76.95
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +15.76 | CA  +23.42 | CD  -47.96 | BA   +7.66 | BD  -63.72 | AD  -71.38    (Iteration  1, r2 =   3217.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +15.91 | CA  +23.05 | CD  -47.22 | BA   +7.14 | BD  -63.13 | AD  -70.27    (Iteration  2, r2 =   3113.2)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +15.96 | CA  +23.01 | CD  -47.10 | BA   +7.04 | BD  -63.07 | AD  -70.11    (Iteration  3, r2 =   3091.6)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +16.01 | CA  +23.05 | CD  -47.14 | BA   +7.04 | BD  -63.15 | AD  -70.19    (Iteration  4, r2 =   3065.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +16.01 | CA  +22.99 | CD  -47.34 | BA   +6.97 | BD  -63.35 | AD  -70.32    (Iteration  5, r2 =   3064.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +16.01 | CA  +23.04 | CD  -47.36 | BA   +7.03 | BD  -63.37 | AD  -70.40    (Iteration  6, r2 =   3059.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +16.01 | CA  +22.97 | CD  -47.50 | BA   +6.96 | BD  -63.51 | AD  -70.47    (Iteration  7, r2 =   3102.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +16.01 | CA  +23.09 | CD  -47.51 | BA   +7.08 | BD  -63.52 | AD  -70.60    (Iteration  8, r2 =   3120.1)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +15.96 | CA  +23.13 | CD  -47.57 | BA   +7.17 | BD  -63.53 | AD  -70.69    (Iteration  9, r2 =   3146.1)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
CB  +15.86 | CA  +23.03 | CD  -47.73 | BA   +7.17 | BD  -63.59 | AD  -70.76    (Iteration 10, r2 =   3155.8)
Timeshift stabilization and releasing of splflat :
CB  +16.32 | CA  +21.89 | CD  -48.15 | BA   +5.57 | BD  -64.47 | AD  -70.03    (Iteration  1, r2 =   2389.6)
CB  +16.22 | CA  +21.60 | CD  -48.23 | BA   +5.38 | BD  -64.45 | AD  -69.84    (Iteration  2, r2 =   2375.7)
CB  +16.22 | CA  +21.54 | CD  -48.23 | BA   +5.32 | BD  -64.45 | AD  -69.77    (Iteration  3, r2 =   2372.2)
CB  +16.17 | CA  +21.54 | CD  -48.23 | BA   +5.37 | BD  -64.40 | AD  -69.77    (Iteration  4, r2 =   2370.6)
CB  +16.17 | CA  +21.47 | CD  -48.17 | BA   +5.30 | BD  -64.34 | AD  -69.64    (Iteration  5, r2 =   2369.4)
Shifted 1 simulations, using 1 CPU, time : 17
Wrote sims_copies_opt_spl/3_1466727298.50024_opt.pkl
Wrote sims_copies_opt_spl/3_1466727298.50024_runresults.pkl
--- Casino running on simset copies, optset spl ---
Read sims_copies/4_1466727298.50913.pkl
Working for sims_copies_opt_spl/4_1466727298.50913_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting opt_rough on initial delays :
DB  +51.32 | DA  +58.50 | DC  +34.51 | BA   +7.18 | BC  -16.81 | AC  -23.99
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/D](-67.545,-2.092,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/B](-16.227,-0.647,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/A](-9.046,0.000,0)|~3/12l12b/7~|
Working on the spline ML of [Trial/C](-33.036,-1.603,0)|~3/12l12b/7~|
Done !
First spline and ML opt done.
DB  +59.32 | DA  +64.50 | DC  +44.51 | BA   +5.18 | BC  -14.81 | AC  -19.99    (Iteration  1, r2 =   7872.1)
DB  +65.32 | DA  +68.50 | DC  +51.51 | BA   +3.18 | BC  -13.81 | AC  -16.99    (Iteration  2, r2 =   7656.4)
DB  +68.32 | DA  +71.50 | DC  +54.51 | BA   +3.18 | BC  -13.81 | AC  -16.99    (Iteration  3, r2 =   7602.6)
DB  +70.32 | DA  +73.50 | DC  +56.51 | BA   +3.18 | BC  -13.81 | AC  -16.99    (Iteration  4, r2 =   7575.6)
DB  +71.32 | DA  +74.50 | DC  +57.51 | BA   +3.18 | BC  -13.81 | AC  -16.99    (Iteration  5, r2 =   7561.4)
Rough time shifts done :
DB  +71.32 | DA  +74.50 | DC  +57.51 | BA   +3.18 | BC  -13.81 | AC  -16.99
Starting opt_rough on initial delays :
DB  +71.32 | DA  +74.50 | DC  +57.51 | BA   +3.18 | BC  -13.81 | AC  -16.99
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trial/D](-85.545,-2.092,0)|~3/u/7~|
Working on the spline ML of [Trial/B](-14.227,-0.647,0)|~3/u/7~|
Working on the spline ML of [Trial/A](-11.046,0.000,0)|~3/u/7~|
Working on the spline ML of [Trial/C](-28.036,-1.603,0)|~3/u/7~|
Done !
First spline and ML opt done.
DB  +68.32 | DA  +75.50 | DC  +55.51 | BA   +7.18 | BC  -12.81 | AC  -19.99    (Iteration  1, r2 =   7590.2)
DB  +66.32 | DA  +76.50 | DC  +54.51 | BA  +10.18 | BC  -11.81 | AC  -21.99    (Iteration  2, r2 =   7426.2)
DB  +66.32 | DA  +76.50 | DC  +54.51 | BA  +10.18 | BC  -11.81 | AC  -21.99    (Iteration  3, r2 =   7420.9)
DB  +66.32 | DA  +76.50 | DC  +54.51 | BA  +10.18 | BC  -11.81 | AC  -21.99    (Iteration  4, r2 =   7416.6)
DB  +66.32 | DA  +76.50 | DC  +54.51 | BA  +10.18 | BC  -11.81 | AC  -21.99    (Iteration  5, r2 =   7412.5)
Rough time shifts done :
DB  +66.32 | DA  +76.50 | DC  +54.51 | BA  +10.18 | BC  -11.81 | AC  -21.99
Starting opt_fine on initial delays :
DB  +66.32 | DA  +76.50 | DC  +54.51 | BA  +10.18 | BC  -11.81 | AC  -21.99
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +64.93 | DA  +70.42 | DC  +47.62 | BA   +5.48 | BC  -17.31 | AC  -22.79    (Iteration  1, r2 =   2527.5)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.21 | DA  +69.76 | DC  +46.90 | BA   +4.55 | BC  -18.31 | AC  -22.86    (Iteration  2, r2 =   2433.5)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.28 | DA  +69.69 | DC  +46.77 | BA   +4.41 | BC  -18.51 | AC  -22.92    (Iteration  3, r2 =   2372.8)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.26 | DA  +69.67 | DC  +46.70 | BA   +4.41 | BC  -18.56 | AC  -22.97    (Iteration  4, r2 =   2345.7)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.30 | DA  +69.73 | DC  +46.78 | BA   +4.43 | BC  -18.52 | AC  -22.95    (Iteration  5, r2 =   2339.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.21 | DA  +69.67 | DC  +46.74 | BA   +4.46 | BC  -18.48 | AC  -22.94    (Iteration  6, r2 =   2333.2)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.22 | DA  +69.62 | DC  +46.70 | BA   +4.39 | BC  -18.53 | AC  -22.92    (Iteration  7, r2 =   2321.2)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.26 | DA  +69.72 | DC  +46.83 | BA   +4.45 | BC  -18.43 | AC  -22.89    (Iteration  8, r2 =   2330.1)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.16 | DA  +69.65 | DC  +46.78 | BA   +4.48 | BC  -18.39 | AC  -22.87    (Iteration  9, r2 =   2316.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DB  +65.14 | DA  +69.72 | DC  +46.80 | BA   +4.58 | BC  -18.34 | AC  -22.92    (Iteration 10, r2 =   2315.6)
Timeshift stabilization and releasing of splflat :
DB  +65.05 | DA  +69.49 | DC  +47.68 | BA   +4.45 | BC  -17.37 | AC  -21.82    (Iteration  1, r2 =   2140.7)
DB  +65.00 | DA  +69.49 | DC  +47.83 | BA   +4.50 | BC  -17.16 | AC  -21.66    (Iteration  2, r2 =   2127.5)
DB  +65.00 | DA  +69.49 | DC  +47.89 | BA   +4.50 | BC  -17.11 | AC  -21.61    (Iteration  3, r2 =   2123.7)
DB  +65.00 | DA  +69.49 | DC  +47.89 | BA   +4.50 | BC  -17.11 | AC  -21.61    (Iteration  4, r2 =   2122.4)
DB  +64.94 | DA  +69.43 | DC  +47.82 | BA   +4.50 | BC  -17.11 | AC  -21.61    (Iteration  5, r2 =   2121.8)
Shifted 1 simulations, using 1 CPU, time : 21
Wrote sims_copies_opt_spl/4_1466727298.50913_opt.pkl
Wrote sims_copies_opt_spl/4_1466727298.50913_runresults.pkl

Now, we will run the free-knot spline technique on each of the Nmocks synthetic light curve datasets we made earlier - again, this will take a while. Note the keepopt=True kwarg: this will make it easier to read the residuals from the synthetic curves with the residuals from the observed data. You can change the name "optset" to anything, though it should best reflect the name of the full method, including the settings of the microlensing.


In [33]:
tsrand = 1.0
pycs.sim.run.multirun("mocks", lcs, spl, optset="spl", tsrand=tsrand, keepopt=True)


I have found 4 simulation pickles in sims_mocks.
I'll write my results into the directory sims_mocks_opt_spl.
Initial conditions : 
[Trial/A](-5.340,0.000,0)|~3/12l12b/7~|
[Trial/B](-10.144,-0.647,0)|~3/12l12b/7~|
[Trial/C](-26.003,-1.603,0)|~3/12l12b/7~|
[Trial/D](-73.957,-2.092,0)|~3/12l12b/7~|
--- Casino running on simset mocks, optset spl ---
Read sims_mocks/1_1466727306.28380.pkl
Working for sims_mocks_opt_spl/1_1466727306.28380_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting opt_rough on initial delays :
BC  -16.05 | BD  -62.87 | BA   +5.14 | CD  -46.82 | CA  +21.19 | DA  +68.01
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trialsim/B](-10.159,-0.647,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/C](-26.208,-1.602,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/D](-73.030,-2.062,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/A](-5.020,-0.003,0)|~3/12l12b/7~|
Done !
First spline and ML opt done.
BC  -18.05 | BD  -68.87 | BA   +7.14 | CD  -50.82 | CA  +25.19 | DA  +76.01    (Iteration  1, r2 =  10963.7)
BC  -18.05 | BD  -70.87 | BA   +9.14 | CD  -52.82 | CA  +27.19 | DA  +80.01    (Iteration  2, r2 =  10744.8)
BC  -18.05 | BD  -71.87 | BA  +10.14 | CD  -53.82 | CA  +28.19 | DA  +82.01    (Iteration  3, r2 =  10665.2)
BC  -18.05 | BD  -71.87 | BA  +11.14 | CD  -53.82 | CA  +29.19 | DA  +83.01    (Iteration  4, r2 =  10608.9)
BC  -17.05 | BD  -71.87 | BA  +12.14 | CD  -54.82 | CA  +29.19 | DA  +84.01    (Iteration  5, r2 =  10572.6)
Rough time shifts done :
BC  -17.05 | BD  -71.87 | BA  +12.14 | CD  -54.82 | CA  +29.19 | DA  +84.01
Starting opt_rough on initial delays :
BC  -17.05 | BD  -71.87 | BA  +12.14 | CD  -54.82 | CA  +29.19 | DA  +84.01
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trialsim/B](-17.159,-0.647,0)|~3/u/7~|
Working on the spline ML of [Trialsim/C](-34.208,-1.602,0)|~3/u/7~|
Working on the spline ML of [Trialsim/D](-89.030,-2.062,0)|~3/u/7~|
Working on the spline ML of [Trialsim/A](-5.020,-0.003,0)|~3/u/7~|
Done !
First spline and ML opt done.
BC  -17.05 | BD  -68.87 | BA  +14.14 | CD  -51.82 | CA  +31.19 | DA  +83.01    (Iteration  1, r2 =   8687.1)
BC  -17.05 | BD  -68.87 | BA  +14.14 | CD  -51.82 | CA  +31.19 | DA  +83.01    (Iteration  2, r2 =   8672.3)
BC  -17.05 | BD  -67.87 | BA  +14.14 | CD  -50.82 | CA  +31.19 | DA  +82.01    (Iteration  3, r2 =   8667.1)
BC  -17.05 | BD  -67.87 | BA  +14.14 | CD  -50.82 | CA  +31.19 | DA  +82.01    (Iteration  4, r2 =   8661.9)
BC  -17.05 | BD  -67.87 | BA  +14.14 | CD  -50.82 | CA  +31.19 | DA  +82.01    (Iteration  5, r2 =   8657.8)
Rough time shifts done :
BC  -17.05 | BD  -67.87 | BA  +14.14 | CD  -50.82 | CA  +31.19 | DA  +82.01
Starting opt_fine on initial delays :
BC  -17.05 | BD  -67.87 | BA  +14.14 | CD  -50.82 | CA  +31.19 | DA  +82.01
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -17.79 | BD  -63.24 | BA  +13.57 | CD  -45.44 | CA  +31.36 | DA  +76.81    (Iteration  1, r2 =   3261.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -18.16 | BD  -62.42 | BA  +13.37 | CD  -44.26 | CA  +31.54 | DA  +75.80    (Iteration  2, r2 =   3128.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -18.42 | BD  -62.09 | BA  +13.32 | CD  -43.67 | CA  +31.74 | DA  +75.40    (Iteration  3, r2 =   3092.7)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -18.42 | BD  -62.20 | BA  +13.23 | CD  -43.79 | CA  +31.65 | DA  +75.44    (Iteration  4, r2 =   3035.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -18.42 | BD  -62.46 | BA  +13.17 | CD  -44.04 | CA  +31.59 | DA  +75.64    (Iteration  5, r2 =   3046.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -18.22 | BD  -62.40 | BA  +13.20 | CD  -44.18 | CA  +31.42 | DA  +75.60    (Iteration  6, r2 =   3032.2)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -18.16 | BD  -62.40 | BA  +13.20 | CD  -44.24 | CA  +31.37 | DA  +75.60    (Iteration  7, r2 =   3027.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -18.10 | BD  -62.53 | BA  +13.20 | CD  -44.43 | CA  +31.31 | DA  +75.74    (Iteration  8, r2 =   3012.7)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -17.99 | BD  -62.53 | BA  +13.18 | CD  -44.54 | CA  +31.17 | DA  +75.71    (Iteration  9, r2 =   3004.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -18.05 | BD  -62.60 | BA  +13.18 | CD  -44.55 | CA  +31.22 | DA  +75.77    (Iteration 10, r2 =   3003.3)
Timeshift stabilization and releasing of splflat :
BC  -18.50 | BD  -62.48 | BA  +12.61 | CD  -43.98 | CA  +31.11 | DA  +75.09    (Iteration  1, r2 =   2688.3)
BC  -18.49 | BD  -62.53 | BA  +12.62 | CD  -44.04 | CA  +31.11 | DA  +75.15    (Iteration  2, r2 =   2674.0)
BC  -18.44 | BD  -62.59 | BA  +12.56 | CD  -44.15 | CA  +31.00 | DA  +75.15    (Iteration  3, r2 =   2670.4)
BC  -18.44 | BD  -62.59 | BA  +12.59 | CD  -44.15 | CA  +31.03 | DA  +75.18    (Iteration  4, r2 =   2668.1)
BC  -18.38 | BD  -62.59 | BA  +12.59 | CD  -44.21 | CA  +30.97 | DA  +75.18    (Iteration  5, r2 =   2666.4)
Shifted 1 simulations, using 1 CPU, time : 18
Wrote sims_mocks_opt_spl/1_1466727306.28380_opt.pkl
Wrote sims_mocks_opt_spl/1_1466727306.28380_runresults.pkl
--- Casino running on simset mocks, optset spl ---
Read sims_mocks/2_1466727306.37004.pkl
Working for sims_mocks_opt_spl/2_1466727306.37004_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting opt_rough on initial delays :
DA  +69.35 | DC  +47.62 | DB  +64.32 | AC  -21.73 | AB   -5.03 | CB  +16.70
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trialsim/D](-74.585,-2.092,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/A](-5.234,-0.036,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/C](-26.965,-1.632,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/B](-10.265,-0.680,0)|~3/12l12b/7~|
Done !
First spline and ML opt done.
DA  +76.35 | DC  +56.62 | DB  +69.32 | AC  -19.73 | AB   -7.03 | CB  +12.70    (Iteration  1, r2 =  10535.6)
DA  +79.35 | DC  +60.62 | DB  +71.32 | AC  -18.73 | AB   -8.03 | CB  +10.70    (Iteration  2, r2 =  10430.3)
DA  +81.35 | DC  +62.62 | DB  +72.32 | AC  -18.73 | AB   -9.03 | CB   +9.70    (Iteration  3, r2 =  10384.7)
DA  +83.35 | DC  +64.62 | DB  +74.32 | AC  -18.73 | AB   -9.03 | CB   +9.70    (Iteration  4, r2 =  10384.9)
DA  +84.35 | DC  +65.62 | DB  +75.32 | AC  -18.73 | AB   -9.03 | CB   +9.70    (Iteration  5, r2 =  10390.0)
Rough time shifts done :
DA  +84.35 | DC  +65.62 | DB  +75.32 | AC  -18.73 | AB   -9.03 | CB   +9.70
Starting opt_rough on initial delays :
DA  +84.35 | DC  +65.62 | DB  +75.32 | AC  -18.73 | AB   -9.03 | CB   +9.70
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trialsim/D](-89.585,-2.092,0)|~3/u/7~|
Working on the spline ML of [Trialsim/A](-5.234,-0.036,0)|~3/u/7~|
Working on the spline ML of [Trialsim/C](-23.965,-1.632,0)|~3/u/7~|
Working on the spline ML of [Trialsim/B](-14.265,-0.680,0)|~3/u/7~|
Done !
First spline and ML opt done.
DA  +78.35 | DC  +58.62 | DB  +67.32 | AC  -19.73 | AB  -11.03 | CB   +8.70    (Iteration  1, r2 =   9062.1)
DA  +78.35 | DC  +58.62 | DB  +66.32 | AC  -19.73 | AB  -12.03 | CB   +7.70    (Iteration  2, r2 =   9034.3)
DA  +78.35 | DC  +57.62 | DB  +66.32 | AC  -20.73 | AB  -12.03 | CB   +8.70    (Iteration  3, r2 =   9024.2)
DA  +78.35 | DC  +57.62 | DB  +66.32 | AC  -20.73 | AB  -12.03 | CB   +8.70    (Iteration  4, r2 =   9018.8)
DA  +78.35 | DC  +57.62 | DB  +66.32 | AC  -20.73 | AB  -12.03 | CB   +8.70    (Iteration  5, r2 =   9013.5)
Rough time shifts done :
DA  +78.35 | DC  +57.62 | DB  +66.32 | AC  -20.73 | AB  -12.03 | CB   +8.70
Starting opt_fine on initial delays :
DA  +78.35 | DC  +57.62 | DB  +66.32 | AC  -20.73 | AB  -12.03 | CB   +8.70
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +74.53 | DC  +51.94 | DB  +64.24 | AC  -22.59 | AB  -10.29 | CB  +12.30    (Iteration  1, r2 =   3921.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +73.99 | DC  +51.33 | DB  +64.65 | AC  -22.66 | AB   -9.34 | CB  +13.32    (Iteration  2, r2 =   3545.7)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +73.66 | DC  +51.04 | DB  +64.70 | AC  -22.62 | AB   -8.96 | CB  +13.66    (Iteration  3, r2 =   3346.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +73.43 | DC  +51.10 | DB  +64.71 | AC  -22.33 | AB   -8.72 | CB  +13.61    (Iteration  4, r2 =   3228.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +73.54 | DC  +51.21 | DB  +64.91 | AC  -22.33 | AB   -8.62 | CB  +13.70    (Iteration  5, r2 =   3179.8)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +73.47 | DC  +51.21 | DB  +64.81 | AC  -22.26 | AB   -8.66 | CB  +13.60    (Iteration  6, r2 =   3093.6)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +73.34 | DC  +51.19 | DB  +64.79 | AC  -22.15 | AB   -8.55 | CB  +13.60    (Iteration  7, r2 =   3058.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +73.29 | DC  +51.19 | DB  +64.79 | AC  -22.10 | AB   -8.51 | CB  +13.60    (Iteration  8, r2 =   3050.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +73.36 | DC  +51.25 | DB  +64.85 | AC  -22.10 | AB   -8.51 | CB  +13.60    (Iteration  9, r2 =   3018.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +73.42 | DC  +51.22 | DB  +64.91 | AC  -22.20 | AB   -8.51 | CB  +13.69    (Iteration 10, r2 =   3020.9)
Timeshift stabilization and releasing of splflat :
DA  +72.98 | DC  +51.99 | DB  +65.21 | AC  -20.98 | AB   -7.76 | CB  +13.22    (Iteration  1, r2 =   2712.5)
DA  +73.10 | DC  +52.30 | DB  +65.39 | AC  -20.80 | AB   -7.71 | CB  +13.09    (Iteration  2, r2 =   2703.2)
DA  +73.17 | DC  +52.36 | DB  +65.45 | AC  -20.80 | AB   -7.71 | CB  +13.09    (Iteration  3, r2 =   2700.3)
DA  +73.17 | DC  +52.36 | DB  +65.40 | AC  -20.80 | AB   -7.76 | CB  +13.04    (Iteration  4, r2 =   2698.4)
DA  +73.17 | DC  +52.27 | DB  +65.40 | AC  -20.89 | AB   -7.76 | CB  +13.13    (Iteration  5, r2 =   2697.1)
Shifted 1 simulations, using 1 CPU, time : 19
Wrote sims_mocks_opt_spl/2_1466727306.37004_opt.pkl
Wrote sims_mocks_opt_spl/2_1466727306.37004_runresults.pkl
--- Casino running on simset mocks, optset spl ---
Read sims_mocks/3_1466727306.43678.pkl
Working for sims_mocks_opt_spl/3_1466727306.43678_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting opt_rough on initial delays :
BC  -16.75 | BD  -63.55 | BA   +4.85 | CD  -46.81 | CA  +21.60 | DA  +68.41
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trialsim/B](-10.074,-0.647,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/C](-26.819,-1.586,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/D](-73.628,-2.026,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/A](-5.222,0.053,0)|~3/12l12b/7~|
Done !
First spline and ML opt done.
BC  -20.75 | BD  -76.55 | BA   +1.85 | CD  -55.81 | CA  +22.60 | DA  +78.41    (Iteration  1, r2 =   8237.0)
BC  -22.75 | BD  -81.55 | BA   -0.15 | CD  -58.81 | CA  +22.60 | DA  +81.41    (Iteration  2, r2 =   8014.7)
BC  -22.75 | BD  -83.55 | BA   -1.15 | CD  -60.81 | CA  +21.60 | DA  +82.41    (Iteration  3, r2 =   7911.6)
BC  -22.75 | BD  -85.55 | BA   -1.15 | CD  -62.81 | CA  +21.60 | DA  +84.41    (Iteration  4, r2 =   7902.0)
BC  -22.75 | BD  -85.55 | BA   -2.15 | CD  -62.81 | CA  +20.60 | DA  +83.41    (Iteration  5, r2 =   7835.1)
Rough time shifts done :
BC  -22.75 | BD  -85.55 | BA   -2.15 | CD  -62.81 | CA  +20.60 | DA  +83.41
Starting opt_rough on initial delays :
BC  -22.75 | BD  -85.55 | BA   -2.15 | CD  -62.81 | CA  +20.60 | DA  +83.41
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trialsim/B](-7.074,-0.647,0)|~3/u/7~|
Working on the spline ML of [Trialsim/C](-29.819,-1.586,0)|~3/u/7~|
Working on the spline ML of [Trialsim/D](-92.628,-2.026,0)|~3/u/7~|
Working on the spline ML of [Trialsim/A](-9.222,0.053,0)|~3/u/7~|
Done !
First spline and ML opt done.
BC  -23.75 | BD  -82.55 | BA   +1.85 | CD  -58.81 | CA  +25.60 | DA  +84.41    (Iteration  1, r2 =   8401.7)
BC  -24.75 | BD  -80.55 | BA   +2.85 | CD  -55.81 | CA  +27.60 | DA  +83.41    (Iteration  2, r2 =   8323.9)
BC  -24.75 | BD  -78.55 | BA   +3.85 | CD  -53.81 | CA  +28.60 | DA  +82.41    (Iteration  3, r2 =   8295.6)
BC  -24.75 | BD  -77.55 | BA   +3.85 | CD  -52.81 | CA  +28.60 | DA  +81.41    (Iteration  4, r2 =   8289.4)
BC  -24.75 | BD  -77.55 | BA   +3.85 | CD  -52.81 | CA  +28.60 | DA  +81.41    (Iteration  5, r2 =   8285.1)
Rough time shifts done :
BC  -24.75 | BD  -77.55 | BA   +3.85 | CD  -52.81 | CA  +28.60 | DA  +81.41
Starting opt_fine on initial delays :
BC  -24.75 | BD  -77.55 | BA   +3.85 | CD  -52.81 | CA  +28.60 | DA  +81.41
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -28.36 | BD  -76.64 | BA   +0.04 | CD  -48.28 | CA  +28.40 | DA  +76.68    (Iteration  1, r2 =   3615.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -28.88 | BD  -75.38 | BA   -0.42 | CD  -46.50 | CA  +28.45 | DA  +74.96    (Iteration  2, r2 =   3536.5)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -28.82 | BD  -74.85 | BA   -0.46 | CD  -46.04 | CA  +28.36 | DA  +74.40    (Iteration  3, r2 =   3471.0)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -28.82 | BD  -74.39 | BA   -0.46 | CD  -45.58 | CA  +28.36 | DA  +73.93    (Iteration  4, r2 =   3426.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -28.74 | BD  -74.13 | BA   -0.49 | CD  -45.39 | CA  +28.24 | DA  +73.63    (Iteration  5, r2 =   3413.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -28.72 | BD  -73.92 | BA   -0.58 | CD  -45.21 | CA  +28.13 | DA  +73.34    (Iteration  6, r2 =   3390.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -29.04 | BD  -73.66 | BA   -0.62 | CD  -44.62 | CA  +28.42 | DA  +73.04    (Iteration  7, r2 =   3392.2)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -29.16 | BD  -73.59 | BA   -0.68 | CD  -44.43 | CA  +28.48 | DA  +72.91    (Iteration  8, r2 =   3386.8)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -29.20 | BD  -73.59 | BA   -0.71 | CD  -44.39 | CA  +28.49 | DA  +72.88    (Iteration  9, r2 =   3412.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
BC  -29.32 | BD  -73.06 | BA   -0.74 | CD  -43.74 | CA  +28.58 | DA  +72.32    (Iteration 10, r2 =   3397.0)
Timeshift stabilization and releasing of splflat :
BC  -27.92 | BD  -73.25 | BA   -0.90 | CD  -45.33 | CA  +27.02 | DA  +72.35    (Iteration  1, r2 =   2127.2)
BC  -27.86 | BD  -73.57 | BA   -1.00 | CD  -45.71 | CA  +26.86 | DA  +72.57    (Iteration  2, r2 =   2117.4)
BC  -27.80 | BD  -73.70 | BA   -1.00 | CD  -45.90 | CA  +26.81 | DA  +72.70    (Iteration  3, r2 =   2113.3)
BC  -27.80 | BD  -73.77 | BA   -1.00 | CD  -45.96 | CA  +26.81 | DA  +72.77    (Iteration  4, r2 =   2111.2)
BC  -27.74 | BD  -73.83 | BA   -1.00 | CD  -46.09 | CA  +26.75 | DA  +72.83    (Iteration  5, r2 =   2109.8)
Shifted 1 simulations, using 1 CPU, time : 18
Wrote sims_mocks_opt_spl/3_1466727306.43678_opt.pkl
Wrote sims_mocks_opt_spl/3_1466727306.43678_runresults.pkl
--- Casino running on simset mocks, optset spl ---
Read sims_mocks/4_1466727306.50516.pkl
Working for sims_mocks_opt_spl/4_1466727306.50516_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting opt_rough on initial delays :
DA  +69.39 | DB  +64.28 | DC  +47.86 | AB   -5.12 | AC  -21.53 | BC  -16.42
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trialsim/D](-73.807,-2.092,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/A](-4.413,0.005,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/B](-9.529,-0.617,0)|~3/12l12b/7~|
Working on the spline ML of [Trialsim/C](-25.948,-1.588,0)|~3/12l12b/7~|
Done !
First spline and ML opt done.
DA  +74.39 | DB  +65.28 | DC  +52.86 | AB   -9.12 | AC  -21.53 | BC  -12.42    (Iteration  1, r2 =   8585.5)
DA  +77.39 | DB  +66.28 | DC  +55.86 | AB  -11.12 | AC  -21.53 | BC  -10.42    (Iteration  2, r2 =   8397.5)
DA  +79.39 | DB  +67.28 | DC  +57.86 | AB  -12.12 | AC  -21.53 | BC   -9.42    (Iteration  3, r2 =   8318.8)
DA  +80.39 | DB  +67.28 | DC  +58.86 | AB  -13.12 | AC  -21.53 | BC   -8.42    (Iteration  4, r2 =   8256.4)
DA  +81.39 | DB  +67.28 | DC  +59.86 | AB  -14.12 | AC  -21.53 | BC   -7.42    (Iteration  5, r2 =   8206.3)
Rough time shifts done :
DA  +81.39 | DB  +67.28 | DC  +59.86 | AB  -14.12 | AC  -21.53 | BC   -7.42
Starting opt_rough on initial delays :
DA  +81.39 | DB  +67.28 | DC  +59.86 | AB  -14.12 | AC  -21.53 | BC   -7.42
Aiming at first curve.
Starting ML optimization ...
Working on the spline ML of [Trialsim/D](-84.807,-2.092,0)|~3/u/7~|
Working on the spline ML of [Trialsim/A](-3.413,0.005,0)|~3/u/7~|
Working on the spline ML of [Trialsim/B](-17.529,-0.617,0)|~3/u/7~|
Working on the spline ML of [Trialsim/C](-24.948,-1.588,0)|~3/u/7~|
Done !
First spline and ML opt done.
DA  +81.39 | DB  +63.28 | DC  +57.86 | AB  -18.12 | AC  -23.53 | BC   -5.42    (Iteration  1, r2 =   7514.0)
DA  +81.39 | DB  +62.28 | DC  +56.86 | AB  -19.12 | AC  -24.53 | BC   -5.42    (Iteration  2, r2 =   7465.7)
DA  +81.39 | DB  +61.28 | DC  +55.86 | AB  -20.12 | AC  -25.53 | BC   -5.42    (Iteration  3, r2 =   7443.1)
DA  +81.39 | DB  +61.28 | DC  +55.86 | AB  -20.12 | AC  -25.53 | BC   -5.42    (Iteration  4, r2 =   7435.0)
DA  +81.39 | DB  +61.28 | DC  +55.86 | AB  -20.12 | AC  -25.53 | BC   -5.42    (Iteration  5, r2 =   7427.1)
Rough time shifts done :
DA  +81.39 | DB  +61.28 | DC  +55.86 | AB  -20.12 | AC  -25.53 | BC   -5.42
Starting opt_fine on initial delays :
DA  +81.39 | DB  +61.28 | DC  +55.86 | AB  -20.12 | AC  -25.53 | BC   -5.42
Iterations :
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +76.40 | DB  +58.83 | DC  +48.91 | AB  -17.57 | AC  -27.50 | BC   -9.93    (Iteration  1, r2 =   2747.7)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +75.18 | DB  +58.85 | DC  +47.86 | AB  -16.33 | AC  -27.32 | BC  -10.99    (Iteration  2, r2 =   2618.3)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +74.73 | DB  +58.66 | DC  +47.36 | AB  -16.07 | AC  -27.37 | BC  -11.30    (Iteration  3, r2 =   2555.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +74.64 | DB  +58.66 | DC  +47.06 | AB  -15.97 | AC  -27.57 | BC  -11.60    (Iteration  4, r2 =   2539.2)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +74.59 | DB  +58.73 | DC  +46.97 | AB  -15.86 | AC  -27.62 | BC  -11.76    (Iteration  5, r2 =   2512.6)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +74.54 | DB  +58.73 | DC  +46.97 | AB  -15.81 | AC  -27.57 | BC  -11.76    (Iteration  6, r2 =   2503.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +74.57 | DB  +58.73 | DC  +47.03 | AB  -15.85 | AC  -27.54 | BC  -11.70    (Iteration  7, r2 =   2511.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +74.63 | DB  +58.73 | DC  +47.09 | AB  -15.91 | AC  -27.54 | BC  -11.64    (Iteration  8, r2 =   2511.9)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +74.63 | DB  +58.66 | DC  +47.09 | AB  -15.97 | AC  -27.54 | BC  -11.57    (Iteration  9, r2 =   2512.4)
Start
opt_ts_indi brute done
opt_ts_indi fine done
opt_ml done
opt_source BOK done
DA  +74.69 | DB  +58.72 | DC  +47.15 | AB  -15.97 | AC  -27.54 | BC  -11.57    (Iteration 10, r2 =   2511.3)
Timeshift stabilization and releasing of splflat :
DA  +74.77 | DB  +58.97 | DC  +48.17 | AB  -15.79 | AC  -26.60 | BC  -10.81    (Iteration  1, r2 =   2367.4)
DA  +74.71 | DB  +59.04 | DC  +48.26 | AB  -15.68 | AC  -26.45 | BC  -10.77    (Iteration  2, r2 =   2358.6)
DA  +74.78 | DB  +59.03 | DC  +48.32 | AB  -15.74 | AC  -26.45 | BC  -10.71    (Iteration  3, r2 =   2355.9)
DA  +74.78 | DB  +59.03 | DC  +48.32 | AB  -15.74 | AC  -26.45 | BC  -10.71    (Iteration  4, r2 =   2354.5)
DA  +74.84 | DB  +59.10 | DC  +48.38 | AB  -15.74 | AC  -26.45 | BC  -10.71    (Iteration  5, r2 =   2353.6)
Shifted 1 simulations, using 1 CPU, time : 19
Wrote sims_mocks_opt_spl/4_1466727306.50516_opt.pkl
Wrote sims_mocks_opt_spl/4_1466727306.50516_runresults.pkl

Note: The two lines of code above do not (always) run, possibly due to a bug that should be reported to PyCS. Here is the resulting error message.

RuntimeError: Knot spacing min = 7.283257, epsilon = 10.000000

4.3 Collecting the Outputs

First, let's get the results from the copies of the observed light curves.


In [34]:
dataresults = [
        pycs.sim.run.collect("sims_copies_opt_spl", "blue", "Free-knot spline technique")
]


Reading 4 runresult pickles...
OK, I have collected 4 runs from Free-knot spline technique

Now, we can turn this into a simple histogram that will give the instrinic variance. It will be saved to a file called "fig_instrinsicvariance.pdf", for readability. The option dataout=True will save the delay point estimate, to be used below.


In [37]:
pycs.sim.plot.hists(dataresults, r=5.0, nbins=100, showqs=False,
        filename="fig_intrinsicvariance.pdf", dataout=True)


Wrote sims_copies_opt_spl_delays.pkl
Plotting "Free-knot spline technique (Measured, 4) "
     Labels : A, B, C, D
     Median shifts : -9.31, -14.14, -30.94, -78.90
     Std shifts : 2.52, 2.67, 2.46, 2.53

We read the results obtained on the synthetic curves.


In [38]:
simresults = [
        pycs.sim.run.collect("sims_mocks_opt_spl", "blue", "Free-knot spline technique")
]


Reading 4 runresult pickles...
OK, I have collected 4 runs from Free-knot spline technique

Now we can perform the error analysis. This will be saved to a file called "fig_measvstrue.pdf". The option dataout=True will save the random and systematic error, to be used below.


In [39]:
pycs.sim.plot.measvstrue(simresults, errorrange=3.5, r=5.0, nbins = 1, binclip=True, binclipr=20.0,
        plotpoints=False, filename="fig_measvstrue.pdf", dataout=True)


Wrote sims_mocks_opt_spl_errorbars.pkl

With the same data we can also show the relationship between measurements. This will be written to a file called "fig_covplot.pdf".


In [40]:
pycs.sim.plot.covplot(simresults, filename="fig_covplot.pdf")


Finally we group the information saved by these steps to get the results in form of a summary plot. Let's define our variables.


In [43]:
dataresults = [(pycs.gen.util.readpickle("sims_copies_opt_spl_delays.pkl"),
               pycs.gen.util.readpickle("sims_mocks_opt_spl_errorbars.pkl"))]


Read sims_copies_opt_spl_delays.pkl
Read sims_mocks_opt_spl_errorbars.pkl

Now we can display our plot! It will be saved to a file called "fig_delays.pdf".


In [44]:
pycs.sim.plot.newdelayplot(dataresults, rplot=6.0, displaytext=True,
        filename = "fig_delays.pdf", refshifts=[{"colour":"gray", "shifts":(0, -5, -20, -70)}])


Objects : A, B, C, D
Delays : Free-knot spline technique <-> Errors : Free-knot spline technique
################################################################################
           Delay AB
                   Free-knot spline technique :  -4.73 +/- 0.92 (0.92, 0.01)
################################################################################
           Delay AC
                   Free-knot spline technique : -21.63 +/- 1.91 (1.08, 1.57)
################################################################################
           Delay BC
                   Free-knot spline technique : -16.90 +/- 0.49 (0.48, 0.08)
################################################################################
           Delay AD
                   Free-knot spline technique : -69.53 +/- 0.94 (0.94, 0.07)
################################################################################
           Delay BD
                   Free-knot spline technique : -64.80 +/- 0.33 (0.30, 0.15)
################################################################################
           Delay CD
                   Free-knot spline technique : -47.90 +/- 1.68 (1.30, 1.07)
################################################################################

5. Comparing Different Curve-shifting Techniques

PyCS supports a number of different time delay estimation methods, as well as the free-knot spline curve-shifting model. Let's try a couple more of them now, and compare with the spline model (which we already optimized and explored). We'll start the other two the same way, on the original data and with a reasonable set of guessed initial shifts, for a fair comparison.


In [45]:
import pycs.regdiff

for l in lcs:
    l.resetshifts()
    
lcs[1].shifttime(-7.0)
lcs[2].shifttime(-22.0)
lcs[3].shifttime(-65.0)

print(pycs.gen.lc.getnicetimedelays(lcs, separator="\n", sorted=True))

def regdiff(lcs):
    return pycs.regdiff.multiopt.opt_ts(lcs, pd=5, scale=200.0, verbose=True)
def disp(lcs):
    return pycs.disp.topopt.opt_full(lcs, rawdispersionmethod, nit=5, verbose=True)


AB   -7.00
AC  -22.00
AD  -65.00
BC  -15.00
BD  -58.00
CD  -43.00

5.1 Dispersion Method

Our second technique will be the dispersion technique. First, let's run the code needed to define our variables.


In [46]:
rawdispersionmethod = lambda lc1, lc2 : pycs.disp.disps.linintnp(lc1, lc2, interpdist = 30.0)
dispersionmethod = lambda lc1, lc2 : pycs.disp.disps.symmetrize(lc1, lc2, rawdispersionmethod)

Next, let's factor in our microlensing models (polynomials).


In [47]:
pycs.gen.polyml.addtolc(lcs[0], nparams=2, autoseasonsgap = 60.0)
pycs.gen.polyml.addtolc(lcs[1], nparams=2, autoseasonsgap = 60.0)
pycs.gen.polyml.addtolc(lcs[2], nparams=2, autoseasonsgap = 60.0)
pycs.gen.polyml.addtolc(lcs[3], nparams=2, autoseasonsgap = 60.0)

Now we will run using the dispersion technique on our plain copies data, created earlier.


In [50]:
pycs.sim.run.multirun("copies", lcs, disp, optset="disp", tsrand=10.0)


I have found 4 simulation pickles in sims_copies.
I'll write my results into the directory sims_copies_opt_disp.
(The latter already exists.)
Initial conditions : 
[Trial/A]|poly/2222|
[Trial/B](-7.000,0.000,0)|poly/2222|
[Trial/C](-22.000,0.000,0)|poly/2222|
[Trial/D](-65.000,0.000,0)|poly/2222|

And now we will run the dispersion technique on our synthetic light curve data.


In [51]:
pycs.sim.run.multirun("mocks", lcs, disp, optset="disp", tsrand=10.0)


I have found 4 simulation pickles in sims_mocks.
I'll write my results into the directory sims_mocks_opt_disp.
(The latter already exists.)
Initial conditions : 
[Trial/A]|poly/2222|
[Trial/B](-7.000,0.000,0)|poly/2222|
[Trial/C](-22.000,0.000,0)|poly/2222|
[Trial/D](-65.000,0.000,0)|poly/2222|

5.2 Regression Difference Method

First we run the regression difference technique on our plain copies data, created earlier.


In [52]:
pycs.sim.run.multirun("copies", lcs, regdiff, optset="regdiff", tsrand=10.0)


I have found 4 simulation pickles in sims_copies.
I'll write my results into the directory sims_copies_opt_regdiff.
Initial conditions : 
[Trial/A]|poly/2222|
[Trial/B](-7.000,0.000,0)|poly/2222|
[Trial/C](-22.000,0.000,0)|poly/2222|
[Trial/D](-65.000,0.000,0)|poly/2222|
--- Casino running on simset copies, optset regdiff ---
Read sims_copies/1_1466727298.48273.pkl
Working for sims_copies_opt_regdiff/1_1466727298.48273_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting regdiff opt_ts, initial time delays :
BD  -64.47 | BC  -31.11 | BA   +3.32 | DC  +33.36 | DA  +67.79 | CA  +34.43
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Regressions done.
Starting time shift optimization ...
Initial pars (shifts, not delays) :  [-62.7692434  -29.4091527    5.01738152]
Brute 1 shifts : [-62.7692434  -14.4091527    5.01738152]
Brute 1 errorfct : 0.004813
Brute 2 shifts : [-62.7692434  -14.4091527    7.51738152]
Brute 2 errorfct : 0.004775
Brute 3 shifts : [-64.0192434  -14.4091527    6.26738152]
Brute 3 errorfct : 0.004762
Brute 4 shifts : [-64.0192434  -14.4091527    6.76738152]
Brute 4 errorfct : 0.004760
Optimization terminated successfully.
         Current function value: 0.004760
         Iterations: 1
         Function evaluations: 40
Final shifts : [-64.12900889 -14.55829214   6.75942231]
Final errorfct : 0.004760
Optimization done ! Optimal time delays :
BD  -65.83 | BC  -16.26 | BA   +5.06 | DC  +49.57 | DA  +70.89 | CA  +21.32
Shifted 1 simulations, using 1 CPU, time : 5
Wrote sims_copies_opt_regdiff/1_1466727298.48273_runresults.pkl
--- Casino running on simset copies, optset regdiff ---
Read sims_copies/2_1466727298.49102.pkl
Working for sims_copies_opt_regdiff/2_1466727298.49102_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting regdiff opt_ts, initial time delays :
BA   +5.50 | BD  -55.78 | BC  -18.23 | AD  -61.28 | AC  -23.73 | DC  +37.55
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Regressions done.
Starting time shift optimization ...
Initial pars (shifts, not delays) :  [ -0.65155158 -61.93172234 -24.38492945]
Brute 1 shifts : [ -0.65155158 -71.93172234 -24.38492945]
Brute 1 errorfct : 0.004810
Brute 2 shifts : [ -0.65155158 -71.93172234 -21.88492945]
Brute 2 errorfct : 0.004762
Brute 3 shifts : [ -0.65155158 -71.93172234 -21.88492945]
Brute 3 errorfct : 0.004762
Brute 4 shifts : [ -1.15155158 -71.93172234 -22.38492945]
Brute 4 errorfct : 0.004760
Optimization terminated successfully.
         Current function value: 0.004760
         Iterations: 1
         Function evaluations: 44
Final shifts : [ -1.24386842 -72.04216094 -22.38590532]
Final errorfct : 0.004760
Optimization done ! Optimal time delays :
BA   +4.91 | BD  -65.89 | BC  -16.23 | AD  -70.80 | AC  -21.14 | DC  +49.66
Shifted 1 simulations, using 1 CPU, time : 5
Wrote sims_copies_opt_regdiff/2_1466727298.49102_runresults.pkl
--- Casino running on simset copies, optset regdiff ---
Read sims_copies/3_1466727298.50024.pkl
Working for sims_copies_opt_regdiff/3_1466727298.50024_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting regdiff opt_ts, initial time delays :
AB  -13.70 | AC  -27.53 | AD  -69.61 | BC  -13.83 | BD  -55.91 | CD  -42.08
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Regressions done.
Starting time shift optimization ...
Initial pars (shifts, not delays) :  [ -8.29692965 -22.12850963 -64.20863084]
Brute 1 shifts : [  1.70307035 -17.12850963 -64.20863084]
Brute 1 errorfct : 0.004805
Brute 2 shifts : [  1.70307035 -14.62850963 -64.20863084]
Brute 2 errorfct : 0.004775
Brute 3 shifts : [  0.45307035 -15.87850963 -65.45863084]
Brute 3 errorfct : 0.004760
Brute 4 shifts : [  0.45307035 -15.87850963 -65.45863084]
Brute 4 errorfct : 0.004760
Optimization terminated successfully.
         Current function value: 0.004760
         Iterations: 1
         Function evaluations: 36
Final shifts : [  0.46217708 -15.84667839 -65.40093386]
Final errorfct : 0.004760
Optimization done ! Optimal time delays :
AB   -4.94 | AC  -21.25 | AD  -70.80 | BC  -16.31 | BD  -65.86 | CD  -49.55
Shifted 1 simulations, using 1 CPU, time : 5
Wrote sims_copies_opt_regdiff/3_1466727298.50024_runresults.pkl
--- Casino running on simset copies, optset regdiff ---
Read sims_copies/4_1466727298.50913.pkl
Working for sims_copies_opt_regdiff/4_1466727298.50913_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting regdiff opt_ts, initial time delays :
BD  -59.36 | BC  -21.34 | BA   +7.32 | DC  +38.02 | DA  +66.68 | CA  +28.66
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Regressions done.
Starting time shift optimization ...
Initial pars (shifts, not delays) :  [-64.0003116  -25.9821258    2.67666589]
Brute 1 shifts : [-69.0003116  -20.9821258    2.67666589]
Brute 1 errorfct : 0.004840
Brute 2 shifts : [-71.5003116  -20.9821258    0.17666589]
Brute 2 errorfct : 0.004766
Brute 3 shifts : [-70.2503116  -20.9821258    0.17666589]
Brute 3 errorfct : 0.004760
Brute 4 shifts : [-70.7503116  -20.9821258    0.17666589]
Brute 4 errorfct : 0.004760
Optimization terminated successfully.
         Current function value: 0.004760
         Iterations: 1
         Function evaluations: 35
Final shifts : [-70.51321964 -20.94472825   0.22424934]
Final errorfct : 0.004760
Optimization done ! Optimal time delays :
BD  -65.87 | BC  -16.31 | BA   +4.86 | DC  +49.57 | DA  +70.74 | CA  +21.17
Shifted 1 simulations, using 1 CPU, time : 5
Wrote sims_copies_opt_regdiff/4_1466727298.50913_runresults.pkl

And then we run the regression difference technique on our synthetic light curve data.


In [53]:
pycs.sim.run.multirun("mocks", lcs, regdiff, optset="regdiff", tsrand=10.0)


I have found 4 simulation pickles in sims_mocks.
I'll write my results into the directory sims_mocks_opt_regdiff.
Initial conditions : 
[Trial/A]|poly/2222|
[Trial/B](-7.000,0.000,0)|poly/2222|
[Trial/C](-22.000,0.000,0)|poly/2222|
[Trial/D](-65.000,0.000,0)|poly/2222|
--- Casino running on simset mocks, optset regdiff ---
Read sims_mocks/1_1466727306.28380.pkl
Working for sims_mocks_opt_regdiff/1_1466727306.28380_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting regdiff opt_ts, initial time delays :
DA  +58.66 | DB  +43.94 | DC  +34.41 | AB  -14.71 | AC  -24.24 | BC   -9.53
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Regressions done.
Starting time shift optimization ...
Initial pars (shifts, not delays) :  [ -2.14999888 -16.86345655 -26.39303903]
Brute 1 shifts : [ 12.85000112  -1.86345655 -21.39303903]
Brute 1 errorfct : 0.005330
Brute 2 shifts : [ 15.35000112   3.13654345 -16.39303903]
Brute 2 errorfct : 0.005177
Brute 3 shifts : [ 15.35000112   1.88654345 -16.39303903]
Brute 3 errorfct : 0.005149
Brute 4 shifts : [ 15.35000112   1.88654345 -16.89303903]
Brute 4 errorfct : 0.005146
Optimization terminated successfully.
         Current function value: 0.005145
         Iterations: 2
         Function evaluations: 84
Final shifts : [ 15.06714701   1.71570547 -16.96641165]
Final errorfct : 0.005145
Optimization done ! Optimal time delays :
DA  +75.87 | DB  +62.52 | DC  +43.84 | AB  -13.35 | AC  -32.03 | BC  -18.68
Shifted 1 simulations, using 1 CPU, time : 6
Wrote sims_mocks_opt_regdiff/1_1466727306.28380_runresults.pkl
--- Casino running on simset mocks, optset regdiff ---
Read sims_mocks/2_1466727306.37004.pkl
Working for sims_mocks_opt_regdiff/2_1466727306.37004_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting regdiff opt_ts, initial time delays :
AB   +0.47 | AC  -27.31 | AD  -55.65 | BC  -27.78 | BD  -56.12 | CD  -28.34
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Regressions done.
Starting time shift optimization ...
Initial pars (shifts, not delays) :  [ -2.71949104 -30.49859478 -58.84182908]
Brute 1 shifts : [ -7.71949104 -20.49859478 -73.84182908]
Brute 1 errorfct : 0.005002
Brute 2 shifts : [-10.21949104 -22.99859478 -76.34182908]
Brute 2 errorfct : 0.004944
Brute 3 shifts : [ -8.96949104 -22.99859478 -76.34182908]
Brute 3 errorfct : 0.004934
Brute 4 shifts : [ -8.96949104 -22.49859478 -75.84182908]
Brute 4 errorfct : 0.004933
Optimization terminated successfully.
         Current function value: 0.004931
         Iterations: 2
         Function evaluations: 67
Final shifts : [ -9.08518909 -22.83519618 -76.03308245]
Final errorfct : 0.004931
Optimization done ! Optimal time delays :
AB   -5.89 | AC  -19.64 | AD  -72.84 | BC  -13.75 | BD  -66.95 | CD  -53.20
Shifted 1 simulations, using 1 CPU, time : 6
Wrote sims_mocks_opt_regdiff/2_1466727306.37004_runresults.pkl
--- Casino running on simset mocks, optset regdiff ---
Read sims_mocks/3_1466727306.43678.pkl
Working for sims_mocks_opt_regdiff/3_1466727306.43678_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting regdiff opt_ts, initial time delays :
BA   -5.84 | BC  -19.86 | BD  -55.88 | AC  -14.02 | AD  -50.04 | CD  -36.02
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Regressions done.
Starting time shift optimization ...
Initial pars (shifts, not delays) :  [ -5.4271219  -19.45059523 -55.46569288]
Brute 1 shifts : [ -0.4271219  -24.45059523 -70.46569288]
Brute 1 errorfct : 0.004891
Brute 2 shifts : [ -0.4271219  -26.95059523 -75.46569288]
Brute 2 errorfct : 0.004688
Brute 3 shifts : [ -0.4271219  -25.70059523 -75.46569288]
Brute 3 errorfct : 0.004680
Brute 4 shifts : [ -0.9271219  -26.20059523 -75.46569288]
Brute 4 errorfct : 0.004678
Optimization terminated successfully.
         Current function value: 0.004677
         Iterations: 1
         Function evaluations: 35
Final shifts : [ -0.849327   -26.11412294 -75.50575679]
Final errorfct : 0.004677
Optimization done ! Optimal time delays :
BA   -1.26 | BC  -26.53 | BD  -75.92 | AC  -25.26 | AD  -74.66 | CD  -49.39
Shifted 1 simulations, using 1 CPU, time : 5
Wrote sims_mocks_opt_regdiff/3_1466727306.43678_runresults.pkl
--- Casino running on simset mocks, optset regdiff ---
Read sims_mocks/4_1466727306.50516.pkl
Working for sims_mocks_opt_regdiff/4_1466727306.50516_runresults.pkl, 1 simulations.
Starting the curve shifting on a single CPU, no multiprocessing...
Starting regdiff opt_ts, initial time delays :
CD  -28.80 | CB  +23.74 | CA  +39.33 | DB  +52.54 | DA  +68.13 | BA  +15.59
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Computing GPR with params pow=1.5, amp=2.0, scale=200.0, errscale=5.0
Regressions done.
Starting time shift optimization ...
Initial pars (shifts, not delays) :  [-59.85347788  -7.31348973   8.27960434]
Brute 1 shifts : [-74.85347788 -17.31348973  -1.72039566]
Brute 1 errorfct : 0.004456
Brute 2 shifts : [-79.85347788 -19.81348973  -4.22039566]
Brute 2 errorfct : 0.004317
Brute 3 shifts : [-78.60347788 -18.56348973  -2.97039566]
Brute 3 errorfct : 0.004308
Brute 4 shifts : [-79.10347788 -19.06348973  -2.97039566]
Brute 4 errorfct : 0.004301
Optimization terminated successfully.
         Current function value: 0.004300
         Iterations: 1
         Function evaluations: 36
Final shifts : [-79.14881489 -19.08234453  -2.90703487]
Final errorfct : 0.004300
Optimization done ! Optimal time delays :
CD  -48.10 | CB  +11.97 | CA  +28.15 | DB  +60.07 | DA  +76.24 | BA  +16.18
Shifted 1 simulations, using 1 CPU, time : 5
Wrote sims_mocks_opt_regdiff/4_1466727306.50516_runresults.pkl

5.3. Method Comparison

Let's repeat the collection and plotting steps from above, but now showing all three methods.


In [54]:
dataresults = [
        pycs.sim.run.collect("sims_copies_opt_spl", "blue", "Free-knot spline technique"),
        pycs.sim.run.collect("sims_copies_opt_disp", "red", "Dispersion-like technique"),
        pycs.sim.run.collect("sims_copies_opt_regdiff", "green", "Regression difference technique")
]


Reading 4 runresult pickles...
OK, I have collected 4 runs from Free-knot spline technique
Reading 4 runresult pickles...
OK, I have collected 4 runs from Dispersion-like technique
Reading 4 runresult pickles...
OK, I have collected 4 runs from Regression difference technique

In [55]:
pycs.sim.plot.hists(dataresults, r=5.0, nbins=100, showqs=False,
        filename="fig_intrinsicvariance.pdf", dataout=True)


Wrote sims_copies_opt_spl_delays.pkl
Wrote sims_copies_opt_disp_delays.pkl
Wrote sims_copies_opt_regdiff_delays.pkl
Plotting "Free-knot spline technique (Measured, 4) "
     Labels : A, B, C, D
     Median shifts : -9.31, -14.14, -30.94, -78.90
     Std shifts : 2.52, 2.67, 2.46, 2.53
Plotting "Dispersion-like technique (Measured, 4) "
     Labels : A, B, C, D
     Median shifts : 2.09, -4.02, -20.20, -66.79
     Std shifts : 7.35, 7.31, 7.37, 7.37
Plotting "Regression difference technique (Measured, 4) "
     Labels : A, B, C, D
     Median shifts : 2.81, -2.09, -18.40, -67.96
     Std shifts : 3.37, 3.31, 3.30, 3.33

In [56]:
simresults = [        
    pycs.sim.run.collect("sims_mocks_opt_spl", "blue", "Free-knot spline technique"),
    pycs.sim.run.collect("sims_mocks_opt_disp", "red", "Dispersion-like technique"),
    pycs.sim.run.collect("sims_mocks_opt_regdiff", "green", "Regression difference technique")
]


Reading 4 runresult pickles...
OK, I have collected 4 runs from Free-knot spline technique
Reading 4 runresult pickles...
OK, I have collected 4 runs from Dispersion-like technique
Reading 4 runresult pickles...
OK, I have collected 4 runs from Regression difference technique

In [57]:
pycs.sim.plot.measvstrue(simresults, errorrange=3.5, r=5.0, nbins = 1, binclip=True, binclipr=20.0,
        plotpoints=False, filename="fig_measvstrue.pdf", dataout=True)


Wrote sims_mocks_opt_spl_errorbars.pkl
Wrote sims_mocks_opt_disp_errorbars.pkl
Wrote sims_mocks_opt_regdiff_errorbars.pkl

In [58]:
pycs.sim.plot.covplot(simresults, filename="fig_covplot.pdf")



In [59]:
disp = (pycs.gen.util.readpickle("sims_copies_opt_disp_delays.pkl"),
        pycs.gen.util.readpickle("sims_mocks_opt_disp_errorbars.pkl"))

regdiff = (pycs.gen.util.readpickle("sims_copies_opt_regdiff_delays.pkl"),
        pycs.gen.util.readpickle("sims_mocks_opt_regdiff_errorbars.pkl"))

spl = (pycs.gen.util.readpickle("sims_copies_opt_spl_delays.pkl"),
       pycs.gen.util.readpickle("sims_mocks_opt_spl_errorbars.pkl"))


Read sims_copies_opt_disp_delays.pkl
Read sims_mocks_opt_disp_errorbars.pkl
Read sims_copies_opt_regdiff_delays.pkl
Read sims_mocks_opt_regdiff_errorbars.pkl
Read sims_copies_opt_spl_delays.pkl
Read sims_mocks_opt_spl_errorbars.pkl

Our final plot! Again, over-writing ("fig_delays.pdf"), but summarizing the performance of the three methods.


In [60]:
pycs.sim.plot.newdelayplot([disp, regdiff, spl], rplot=6.0, displaytext=True,
        filename = "fig_delays.pdf", refshifts=[{"colour":"gray", "shifts":(0, -5, -20, -70)}])


Objects : A, B, C, D
Delays : Dispersion-like technique <-> Errors : Dispersion-like technique
Delays : Regression difference technique <-> Errors : Regression difference technique
Delays : Free-knot spline technique <-> Errors : Free-knot spline technique
################################################################################
           Delay AB
                    Dispersion-like technique :  -5.88 +/- 0.96 (0.65, 0.70)
              Regression difference technique :  -4.94 +/- 0.67 (0.39, 0.54)
                   Free-knot spline technique :  -4.73 +/- 0.92 (0.92, 0.01)
################################################################################
           Delay AC
                    Dispersion-like technique : -22.36 +/- 1.70 (1.09, 1.31)
              Regression difference technique : -21.22 +/- 1.75 (0.51, 1.68)
                   Free-knot spline technique : -21.63 +/- 1.91 (1.08, 1.57)
################################################################################
           Delay BC
                    Dispersion-like technique : -16.48 +/- 0.45 (0.42, 0.18)
              Regression difference technique : -16.28 +/- 0.82 (0.08, 0.81)
                   Free-knot spline technique : -16.90 +/- 0.49 (0.48, 0.08)
################################################################################
           Delay AD
                    Dispersion-like technique : -68.98 +/- 1.38 (1.32, 0.41)
              Regression difference technique : -70.81 +/- 1.26 (0.95, 0.82)
                   Free-knot spline technique : -69.53 +/- 0.94 (0.94, 0.07)
################################################################################
           Delay BD
                    Dispersion-like technique : -63.10 +/- 1.23 (0.70, 1.02)
              Regression difference technique : -65.86 +/- 1.25 (1.10, 0.59)
                   Free-knot spline technique : -64.80 +/- 0.33 (0.30, 0.15)
################################################################################
           Delay CD
                    Dispersion-like technique : -46.62 +/- 1.10 (0.98, 0.50)
              Regression difference technique : -49.59 +/- 0.83 (0.81, 0.18)
                   Free-knot spline technique : -47.90 +/- 1.68 (1.30, 1.07)
################################################################################