def create_testcase04():

    bjd0 = bjd_obs - Tref

    y_pla = instrument['RV_offset1'] + \
            kp.kepler_RV_T0P(bjd0,
                             planet_b['f'],
                             planet_b['P'],
                             planet_b['K'],
                             planet_b['e'],
                             planet_b['o']) + \
            kp.kepler_RV_T0P(bjd0,
                             planet_c['f'],
                             planet_c['P'],
                             planet_c['K'],
                             planet_c['e'],
                             planet_c['o'])

    mod_pl = np.random.normal(y_pla, instrument['RV_precision'])

    #Tcent_b = kp.kepler_phase2Tc_Tref(planet_b['P'], planet_b['f'], planet_b['e'], planet_b['o']) + Tref
    Tcent_b = np.random.normal(
        np.arange(0, 10) * planet_b['P'] + kp.kepler_phase2Tc_Tref(
            planet_b['P'], planet_b['f'], planet_b['e'], planet_b['o']) + Tref,
        instrument['T0_precision'])

    Tcent_c = np.random.normal(
        np.arange(0, 10) * planet_c['P'] + kp.kepler_phase2Tc_Tref(
            planet_c['P'], planet_c['f'], planet_c['e'], planet_c['o']) + Tref,
        instrument['T0_precision'])

    fileout = open('TestCase04_RV.dat', 'w')
    for b, r in zip(bjd_obs, mod_pl):
        fileout.write('{0:f}  {1:.2f}  {2:.2f}  {3:d}  {4:d}  {5:d}\n'.format(
            b, r, instrument['RV_precision'], 0, 0, -1))
    fileout.close()

    fileout = open('TestCase04_Tcent_b.dat', 'w')
    for i_Tc, v_Tc in enumerate(Tcent_b):
        fileout.write('{0:d}  {1:.4f}  {2:.4f}  {3:d}\n'.format(
            i_Tc, v_Tc, instrument['T0_precision'], 0))
    fileout.close()

    fileout = open('TestCase04_Tcent_c.dat', 'w')
    for i_Tc, v_Tc in enumerate(Tcent_c):
        fileout.write('{0:d}  {1:.4f}  {2:.4f}  {3:d}\n'.format(
            i_Tc, v_Tc, instrument['T0_precision'], 0))
    fileout.close()
def create_testcase07():
    import george

    bjd0 = bjd_obs - Tref

    err = bjd0 * 0 + instrument['RV_precision']

    gp_pams = np.zeros(4)
    gp_pams[0] = np.log(activity['Hamp_RV1']) * 2
    gp_pams[1] = np.log(activity['Pdec']) * 2
    gp_pams[2] = 1. / (2 * activity['Oamp']**2)
    gp_pams[3] = np.log(activity['Prot'])

    kernel = np.exp(gp_pams[0]) * \
             george.kernels.ExpSquaredKernel(metric=np.exp(gp_pams[1])) * \
             george.kernels.ExpSine2Kernel(gamma=gp_pams[2], log_period=gp_pams[3])

    gp = george.GP(kernel)

    gp.compute(bjd0, err)
    prediction1 = gp.sample(bjd0)

    gp_pams[0] = np.log(activity['Hamp_RV2']) * 2
    kernel = np.exp(gp_pams[0]) * \
             george.kernels.ExpSquaredKernel(metric=np.exp(gp_pams[1])) * \
             george.kernels.ExpSine2Kernel(gamma=gp_pams[2], log_period=gp_pams[3])

    gp = george.GP(kernel)

    gp.compute(bjd0, err)
    prediction2 = gp.sample(bjd0)

    y_pla = kp.kepler_RV_T0P(bjd0, planet_b['f'], planet_b['P'], planet_b['K'],
                             planet_b['e'], planet_b['o'])

    mod_pl1 = np.random.normal(y_pla + prediction1 + instrument['RV_offset1'],
                               instrument['RV_precision'])
    mod_pl2 = np.random.normal(y_pla + prediction2 + instrument['RV_offset2'],
                               instrument['RV_precision'])

    Tcent_b = np.random.normal(
        np.arange(0, 1) * planet_b['P'] + kp.kepler_phase2Tc_Tref(
            planet_b['P'], planet_b['f'], planet_b['e'], planet_b['o']) + Tref,
        instrument['T0_precision'])

    fileout = open('TestCase07_RV_dataset1.dat', 'w')
    for b, r in zip(bjd_obs, mod_pl1):
        fileout.write('{0:f}  {1:.2f}  {2:.2f}  {3:d}  {4:d}  {5:d}\n'.format(
            b, r, instrument['RV_precision'], 0, 0, -1))
    fileout.close()

    fileout = open('TestCase07_RV_dataset2.dat', 'w')
    for b, r in zip(bjd_obs, mod_pl2):
        fileout.write('{0:f}  {1:.2f}  {2:.2f}  {3:d}  {4:d}  {5:d}\n'.format(
            b, r, instrument['RV_precision'], 0, 0, -1))
    fileout.close()

    fileout = open('TestCase07_Tcent_b.dat', 'w')
    for i_Tc, v_Tc in enumerate(Tcent_b):
        fileout.write('{0:d}  {1:.4f}  {2:.4f}  {3:d}\n'.format(
            i_Tc, v_Tc, instrument['T0_precision'], 0))
    fileout.close()
def create_testcase06():
    import george

    bjd0 = photometry['phot_bjd'] - Tref
    err = bjd0 * 0 + photometry['phot_precision']
    """ Conversion of the physical parameter to the internally defined parameter
    to be passed to george
    """
    gp_pams = np.zeros(4)
    gp_pams[0] = np.log(activity['Hamp_PH']) * 2
    gp_pams[1] = np.log(activity['Pdec']) * 2
    gp_pams[2] = 1. / (2 * activity['Oamp']**2)
    gp_pams[3] = np.log(activity['Prot'])

    kernel = np.exp(gp_pams[0]) * \
             george.kernels.ExpSquaredKernel(metric=np.exp(gp_pams[1])) * \
             george.kernels.ExpSine2Kernel(gamma=gp_pams[2], log_period=gp_pams[3])

    gp = george.GP(kernel)

    gp.compute(bjd0, err)
    prediction = gp.sample(bjd0)
    obs_photometry = np.random.normal(prediction, photometry['phot_precision'])

    fileout = open('TestCase06_photometry.dat', 'w')
    for b, p in zip(photometry['phot_bjd'], obs_photometry):
        fileout.write('{0:14f} {1:14f} {2:14f} {3:5d} {4:5d} {5:5d} \n'.format(
            b, p, photometry['phot_precision'], 0, 0, -1))
    fileout.close()

    bjd0 = bjd_obs - Tref

    err = bjd0 * 0 + instrument['RV_precision']

    gp_pams[0] = np.log(activity['Hamp_RV1']) * 2
    kernel = np.exp(gp_pams[0]) * \
             george.kernels.ExpSquaredKernel(metric=np.exp(gp_pams[1])) * \
             george.kernels.ExpSine2Kernel(gamma=gp_pams[2], log_period=gp_pams[3])

    gp = george.GP(kernel)

    gp.compute(bjd0, err)
    prediction = gp.sample(bjd0)

    y_pla = kp.kepler_RV_T0P(bjd0, planet_b['f'], planet_b['P'], planet_b['K'],
                             planet_b['e'],
                             planet_b['o']) + instrument['RV_offset1']

    mod_pl = np.random.normal(y_pla + prediction, instrument['RV_precision'])

    Tcent_b = np.random.normal(
        np.arange(0, 1) * planet_b['P'] + kp.kepler_phase2Tc_Tref(
            planet_b['P'], planet_b['f'], planet_b['e'], planet_b['o']) + Tref,
        instrument['T0_precision'])

    fileout = open('TestCase06_Tcent_b.dat', 'w')
    for i_Tc, v_Tc in enumerate(Tcent_b):
        fileout.write('{0:d}  {1:.4f}  {2:.4f}  {3:d}\n'.format(
            i_Tc, v_Tc, instrument['T0_precision'], 0))
    fileout.close()

    fileout = open('TestCase06_RV.dat', 'w')
    for b, r in zip(bjd_obs, mod_pl):
        fileout.write('{0:f}  {1:.2f}  {2:.2f}  {3:d}  {4:d}  {5:d}\n'.format(
            b, r, instrument['RV_precision'], 0, 0, -1))
    fileout.close()