Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/COSMOGRAIL/PyCS
Browse files Browse the repository at this point in the history
  • Loading branch information
vbonvin committed Oct 18, 2016
2 parents 0b2e7f1 + e91d9be commit b131d59
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
18 changes: 18 additions & 0 deletions demo/demo1/access_results.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

import pycs

results = pycs.sim.run.collect(directory="./sims_copies_opt_spl")

# The object "results" is an instance of the class pycs.sim.run.runresults. You can directly access the following attributes:

print results.labels # A list of the QSO image names (defines the order of QSO images with which the following results are given)
print results.tsarray # A 2D array with the measured time shifts. Shape is (number of sets, number of QSO images)
print results.truetsarray # Idem, for the TRUE time shifts, in case of simulated data
print results.qs # A 1D array with the "chi2" or dispersion values. Shape is (number of sets).

# Note that these "tsarrays" contain time shifts, not time delays.
# To get time delays between images "A" and "B" (i.e., results.labels[0] and results.labels[1]),
# you will have to compute the differences yourself:

measured_delays = results.tsarray[:,1] - results.tsarray[:,0]
print measured_delays
9 changes: 6 additions & 3 deletions pycs/regdiff2/gpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np


def regression(x, y, yerr, theta0, verbose=True):
def regression(x, y, yerr, verbose=True, **kwargs):
"""
Give me data points
yerr is the 1sigma error of each y
Expand All @@ -23,8 +23,11 @@ def regression(x, y, yerr, theta0, verbose=True):
# random_start=3, verbose=verbose)


gp = GaussianProcess(corr='squared_exponential',
theta0=theta0, random_start=1, nugget = 0.001, verbose=verbose)
mykwargs = {"theta0" : 1.0e2, "nugget" : 0.001}
mykwargs.update(kwargs)
#print mykwargs

gp = GaussianProcess(corr='squared_exponential', random_start=1, verbose=verbose, **mykwargs)


#gp = GaussianProcess(corr='squared_exponential',
Expand Down
4 changes: 2 additions & 2 deletions pycs/regdiff2/rslc.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def wtv(self, method = "weights"):



def factory(l, theta0 = 1.0e5, pad=0.0, pd=2, plotcolour=None):
def factory(l, pad=0.0, pd=2, plotcolour=None, **kwargs):
"""
Give me a lightcurve, I return a regularly sampled light curve, by performing some regression.
Expand Down Expand Up @@ -115,7 +115,7 @@ def factory(l, theta0 = 1.0e5, pad=0.0, pd=2, plotcolour=None):
def meanprior(query):
return (0.0 * query + mean_mag)

regfct = gpr.regression(jds, mags, magerrs, theta0=theta0)
regfct = gpr.regression(jds, mags, magerrs, **kwargs)
(rsmags, rsmagerrs) = regfct(rsjds)

return rslc(rsjds, rsmags, rsmagerrs, pad, pd, timeshift=timeshift, name=name, plotcolour=plotcolour)
Expand Down
2 changes: 1 addition & 1 deletion pycs/sim/draw.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def draw(lcs, spline, shotnoise=None, shotnoisefrac=1.0, tweakml=None, scaletwea



def multidraw(lcs, spline=None, optfctnots=None, onlycopy=False, n=20, npkl=5, simset="draw", simdir=None, shotnoise=None, shotnoisefrac=1.0, truetsr=0.0, tweakml=None, scaletweakresi=True, tweakspl=None, shuffle=True, verbose=True, trace=False):
def multidraw(lcs, spline=None, optfctnots=None, onlycopy=False, n=20, npkl=5, simset="draw", simdir=None, shotnoise=None, shotnoisefrac=1.0, truetsr=8.0, tweakml=None, scaletweakresi=True, tweakspl=None, shuffle=True, verbose=True, trace=False):
"""
Even higher wrapper to produce mock + tweaked lightcurves, and save them into a directory (as pickle files),
in preparation for analysing them with :py:func:`pycs.sim.run.multirun`
Expand Down
2 changes: 2 additions & 0 deletions sphinx/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ To measure time delays with ``pycs``, you'll typically write a script calling so

If you have already read our :doc:`papers<citing>`, you might want to proceed with :doc:`installation`, or the :doc:`tutorial/tutorial`. To get a quick first impression of how PyCS looks in practice, install PyCS and then go directly to the :doc:`tutorial/demo1`. These show you how to **reproduce** the figures from the method paper.

.. warning:: Please also read :doc:`this<warning>`.

Questions ?
-----------
Expand All @@ -28,6 +29,7 @@ Contents
.. toctree::
:maxdepth: 2

A word of warning <warning>
installation
tutorial/tutorial
citing
Expand Down
13 changes: 13 additions & 0 deletions sphinx/source/warning.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Warning & Disclaimer
====================


By *itself*, the use of PyCS does not guarantee realistic time-delay uncertainty estimates. All we have (blindly) demonstrated regarding the quality of PyCS uncertainty estimates assumes a careful generation of the simulated light curves. Keep in mind that the PyCS approach involves setting values or ranges for several parameters. In principle, the impact of these settings has to be assessed on each light curve set, as described in the PyCS paper (`Tewes et al. 2013 <http://dx.doi.org/10.1051/0004-6361/201220123>`_).

.. warning:: In particular, obtaining uncertainty estimates by running on simulated light curves that all have a same true delay (i.e., setting ``truetsr = 0``, in PyCS terminology) can lead to **vastly underestimated error bars**.

It is of **high importance** to use simulations with a range of plausible true time delays to tune and/or verify the accuracy and precision of time-delay estimators. Tests on simulations with only a single true time delay do not probe reliably the quality of a time-delay estimation, as many time-delay estimators are prone to responding unsteadily to the true delay. Do not hesitate to contact us (see front page of this documentation) in case of doubts!

.. note:: Please try to avoid publishing time delays with overly optimistic uncertainty estimates. Seemingly accurate measurements might be propagated into unrealistic cosmological inferences, and harm the community. Be critical, and aim for the most comprehensive instead of the smallest error bar.

Thanks!

0 comments on commit b131d59

Please sign in to comment.