Exemplo n.º 1
0
def get_DiUj2017_model(table, **kwargs):
    if not 'mej' in table.colnames:
        # calc the mass of ejecta
        table['mej'] = calc_meje(table['m1'], table['mb1'], table['c1'],
                                 table['m2'], table['mb2'], table['c2'])
        # calc the velocity of ejecta
        table['vej'] = calc_vej(table['m1'], table['c1'], table['m2'],
                                table['c2'])

    # Throw out smaples where the mass ejecta is less than zero.
    mask = (table['mej'] > 0)
    table = table[mask]
    if len(table) == 0: return table

    # Log mass ejecta
    table['mej10'] = np.log10(table['mej'])
    # Initialize columns
    timeseries = np.arange(table['tini'][0], table['tmax'][0] + table['dt'][0],
                           table['dt'][0])
    table['t'] = [np.zeros(timeseries.size)]
    table['lbol'] = [np.zeros(timeseries.size)]
    table['mag'] = [{}]

    # Loop over samples
    for isample in range(len(table)):
        table['t'][isample], table['lbol'][isample], table['mag'][
            isample] = calc_lc(table['tini'][isample], table['tmax'][isample],
                               table['dt'][isample], table['mej'][isample],
                               table['vej'][isample], table['vmin'][isample],
                               table['th'][isample], table['ph'][isample],
                               table['kappa'][isample], table['eps'][isample],
                               table['alp'][isample], table['eth'][isample],
                               table['flgbct'][isample])
    return table
Exemplo n.º 2
0
def lightcurve(tini, tmax, dt, beta, kappa_r, m1, mb1, c1, m2, mb2, c2):

    mej = calc_meje(m1, mb1, c1, m2, mb2, c2)
    vej = calc_vej(m1, c1, m2, c2)
    t, lbol, mag, Tobs = calc_lc(tini, tmax, dt, mej, vej, beta, kappa_r)

    return t, lbol, mag, Tobs
Exemplo n.º 3
0
def lightcurve_break(tini,tmax,dt,slope_r,kappa_r,t_break,slope_break,m1,mb1,c1,m2,mb2,c2):

    mej = calc_meje(m1,mb1,c1,m2,mb2,c2)
    vej = calc_vej(m1,c1,m2,c2)
    t, lbol, mag, Tobs = calc_lc_break(tini,tmax,dt,mej,vej,slope_r,kappa_r,t_break,slope_break)

    return t, lbol, mag, Tobs
Exemplo n.º 4
0
def get_SmCh2017_model(table, **kwargs):
    if not 'mej' in table.colnames:
        # calc the mass of ejecta
        table['mej'] = calc_meje(table['m1'], table['mb1'], table['c1'], table['m2'], table['mb2'], table['c2'])
        # calc the velocity of ejecta
        table['vej'] = calc_vej(table['m1'],table['c1'],table['m2'],table['c2'])

    # Throw out smaples where the mass ejecta is less than zero.
    mask = (table['mej'] > 0)
    table = table[mask]
    if len(table) == 0: return table

    # Log mass ejecta
    table['mej10'] = np.log10(table['mej'])
    # Initialize lightcurve values in table
    timeseries = np.arange(table['tini'][0], table['tmax'][0]+table['dt'][0], table['dt'][0])
    table['t'] = [np.zeros(timeseries.size)]
    table['lbol'] = [np.zeros(timeseries.size)]
    table['mag'] =  [np.zeros([9, timeseries.size])]
    table['Tobs'] = [np.zeros(timeseries.size)]

    # calc lightcurve for each sample
    for isample in range(len(table)):
        table['t'][isample], table['lbol'][isample], table['mag'][isample], table['Tobs'][isample] = calc_lc(table['tini'][isample], table['tmax'][isample],
                                                                     table['dt'][isample], table['mej'][isample],
                                                                     table['vej'][isample], table['slope_r'][isample], table['kappa_r'][isample])
    return table
Exemplo n.º 5
0
def get_Me2017_model(table, **kwargs):
    """
.. py:function:: get_Me2017_model(table, **kwargs) 

   :param table table: a table which must at least have columns of solar masses of objects the baryonic masses of the objects and the compactness of the object. The table except m1, mb1, c1, m2, mb2, c2, mej and vej as column names
   :return: The lbol, mag and sampling times of the KN Metzger 2017
   :rtype: table

    """
    if not 'mej' in table.colnames:
        # calc the mass of ejecta
        table['mej'] = calc_meje(table['m1'], table['mb1'], table['c1'],
                                 table['m2'], table['mb2'], table['c2'])
        # calc the velocity of ejecta
        table['vej'] = calc_vej(table['m1'], table['c1'], table['m2'],
                                table['c2'])

    # Throw out smaples where the mass ejecta is less than zero.
    mask = (table['mej'] > 0)
    table = table[mask]
    if len(table) == 0: return table

    # Log mass ejecta
    table['mej10'] = np.log10(table['mej'])

    # Initialize lightcurve values in table
    timeseries = np.arange(table['tini'][0], table['tmax'][0] + table['dt'][0],
                           table['dt'][0])
    table['t'] = [np.zeros(timeseries.size)]
    table['lbol'] = [np.zeros(timeseries.size)]
    table['mag'] = [np.zeros([9, timeseries.size])]
    table['Tobs'] = [np.zeros(timeseries.size)]

    # calc lightcurve for each sample
    for isample in range(len(table)):
        # Calc lightcurve
        table['t'][isample], table['lbol'][isample], table['mag'][
            isample], table['Tobs'][isample] = calc_lc(
                table['tini'][isample], table['tmax'][isample],
                table['dt'][isample], table['mej'][isample],
                table['vej'][isample], table['beta'][isample],
                table['kappa_r'][isample])
    return table
    samples = samples.downsample(Nsamples=100)
    # Calc lambdas
    samples = samples.calc_tidal_lambda(remove_negative_lambda=True)
    # Calc compactness
    samples = samples.calc_compactness(fit=True)
    # Calc baryonic mass
    samples = samples.calc_baryonic_mass(EOS=None, TOV=None, fit=True)

    if (not 'mej' in samples.colnames) and (not 'vej' in samples.colnames):
        from gwemlightcurves.EjectaFits.DiUj2017 import calc_meje, calc_vej
        # calc the mass of ejecta
        samples['mej'] = calc_meje(samples['m1'], samples['mb1'],
                                   samples['c1'], samples['m2'],
                                   samples['mb2'], samples['c2'])
        # calc the velocity of ejecta
        samples['vej'] = calc_vej(samples['m1'], samples['c1'], samples['m2'],
                                  samples['c2'])

        # Add draw from a gaussian in the log of ejecta mass with 1-sigma size of 70%
        erroropt = 'none'
        if erroropt == 'none':
            print "Not applying an error to mass ejecta"
        elif erroropt == 'log':
            samples['mej'] = np.power(
                10., np.random.normal(np.log10(samples['mej']), 0.236))
        elif erroropt == 'lin':
            samples['mej'] = np.random.normal(samples['mej'],
                                              0.72 * samples['mej'])
        elif erroropt == 'loggauss':
            samples['mej'] = np.power(
                10., np.random.normal(np.log10(samples['mej']), 0.312))
        idx = np.where(samples['mej'] > 0)[0]
Exemplo n.º 7
0
def get_Bu2019lr_model(table, **kwargs):

    if 'LoadModel' in kwargs:
        LoadModel = kwargs['LoadModel']
    else:
        LoadModel = False

    if 'SaveModel' in kwargs:
        SaveModel = kwargs['SaveModel']
    else:
        SaveModel = False

    if 'ModelPath' in kwargs:
        ModelPath = kwargs['ModelPath']

    if 'doAB' in kwargs:
        doAB = kwargs['doAB']
    else:
        doAB = True

    if 'doSpec' in kwargs:
        doSpec = kwargs['doSpec']
    else:
        doSpec = False

    if not 'n_coeff' in table.colnames:
        if doAB:
            table['n_coeff'] = 43
            #table['n_coeff'] = 2
        elif doSpec:
            table['n_coeff'] = 21

    if doAB:
        if not Global.svd_mag_model == 0:
            svd_mag_model = Global.svd_mag_model
        else:
            if LoadModel:
                #if True:
                modelfile = os.path.join(ModelPath, 'Bu2019lr_mag.pkl')
                with open(modelfile, 'rb') as handle:
                    svd_mag_model = pickle.load(handle)
            else:
                svd_mag_model = svd_utils.calc_svd_mag(
                    table['tini'][0],
                    table['tmax'][0],
                    table['dt'][0],
                    model="Bu2019lr",
                    n_coeff=table['n_coeff'][0])
                modelfile = os.path.join(ModelPath, 'Bu2019lr_mag.pkl')
                with open(modelfile, 'wb') as handle:
                    pickle.dump(svd_mag_model,
                                handle,
                                protocol=pickle.HIGHEST_PROTOCOL)
            Global.svd_mag_model = svd_mag_model

        if not Global.svd_lbol_model == 0:
            svd_lbol_model = Global.svd_lbol_model
        else:
            if LoadModel:
                #if True:
                modelfile = os.path.join(ModelPath, 'Bu2019lr_lbol.pkl')
                with open(modelfile, 'rb') as handle:
                    svd_lbol_model = pickle.load(handle)
            else:
                svd_lbol_model = svd_utils.calc_svd_lbol(
                    table['tini'][0],
                    table['tmax'][0],
                    table['dt'][0],
                    model="Bu2019lr",
                    n_coeff=table['n_coeff'][0])
                modelfile = os.path.join(ModelPath, 'Bu2019lr_lbol.pkl')
                with open(modelfile, 'wb') as handle:
                    pickle.dump(svd_lbol_model,
                                handle,
                                protocol=pickle.HIGHEST_PROTOCOL)
            Global.svd_lbol_model = svd_lbol_model
    elif doSpec:
        if not Global.svd_spec_model == 0:
            svd_spec_model = Global.svd_spec_model
        else:
            if LoadModel:
                #if True:
                modelfile = os.path.join(ModelPath, 'Bu2019lr_spec.pkl')
                with open(modelfile, 'rb') as handle:
                    svd_spec_model = pickle.load(handle)
            else:
                svd_spec_model = svd_utils.calc_svd_spectra(
                    table['tini'][0],
                    table['tmax'][0],
                    table['dt'][0],
                    table['lambdaini'][0],
                    table['lambdamax'][0],
                    table['dlambda'][0],
                    model="Bu2019lr",
                    n_coeff=table['n_coeff'][0])
                modelfile = os.path.join(ModelPath, 'Bu2019lr_spec.pkl')
                with open(modelfile, 'wb') as handle:
                    pickle.dump(svd_spec_model,
                                handle,
                                protocol=pickle.HIGHEST_PROTOCOL)
            Global.svd_spec_model = svd_spec_model

    if not 'mej_dyn' in table.colnames:
        # calc the mass of ejecta
        table['mej_dyn'] = calc_meje(table['m1'], table['mb1'], table['c1'],
                                     table['m2'], table['mb2'], table['c2'])
        # calc the velocity of ejecta
        table['vej'] = calc_vej(table['m1'], table['c1'], table['m2'],
                                table['c2'])

    # Throw out smaples where the mass ejecta is less than zero.
    mask = (table['mej_dyn'] > 0)
    table = table[mask]
    if len(table) == 0: return table

    # Log mass ejecta
    table['mej_dyn10'] = np.log10(table['mej_dyn'])
    table['mej_wind10'] = np.log10(table['mej_wind'])
    # Initialize lightcurve values in table

    timeseries = np.arange(table['tini'][0], table['tmax'][0] + table['dt'][0],
                           table['dt'][0])
    table['t'] = [np.zeros(timeseries.size)]
    if doAB:
        table['lbol'] = [np.zeros(timeseries.size)]
        table['mag'] = [np.zeros([9, timeseries.size])]
    elif doSpec:
        lambdas = np.arange(table['lambdaini'][0],
                            table['lambdamax'][0] + table['dlambda'][0],
                            table['dlambda'][0])
        table['lambda'] = [np.zeros(lambdas.size)]
        table['spec'] = [np.zeros([lambdas.size, timeseries.size])]

    # calc lightcurve for each sample
    for isample in range(len(table)):
        print('Generating sample %d/%d' % (isample, len(table)))
        if doAB:
            table['t'][isample], table['lbol'][isample], table['mag'][
                isample] = svd_utils.calc_lc(
                    table['tini'][isample],
                    table['tmax'][isample],
                    table['dt'][isample], [
                        np.log10(table['mej_dyn'][isample]),
                        np.log10(table['mej_wind'][isample]),
                        table['phi'][isample], table['theta'][isample]
                    ],
                    svd_mag_model=svd_mag_model,
                    svd_lbol_model=svd_lbol_model,
                    model="Bu2019lr")
        elif doSpec:
            table['t'][isample], table['lambda'][isample], table['spec'][
                isample] = svd_utils.calc_spectra(
                    table['tini'][isample],
                    table['tmax'][isample],
                    table['dt'][isample],
                    table['lambdaini'][isample],
                    table['lambdamax'][isample] + table['dlambda'][isample],
                    table['dlambda'][isample], [
                        np.log10(table['mej_dyn'][isample]),
                        np.log10(table['mej_wind'][isample]),
                        table['phi'][isample], table['theta'][isample]
                    ],
                    svd_spec_model=svd_spec_model,
                    model="Bu2019lr")

    return table
Exemplo n.º 8
0
def get_Bu2019lm_model(table, **kwargs):

    if 'LoadModel' in kwargs:
        LoadModel = kwargs['LoadModel']
    else:
        LoadModel = False

    if 'SaveModel' in kwargs:
        SaveModel = kwargs['SaveModel']
    else:
        SaveModel = False

    if 'ModelPath' in kwargs:
        ModelPath = kwargs['ModelPath']

    if 'doAB' in kwargs:
        doAB = kwargs['doAB']
    else:
        doAB = True

    if 'doSpec' in kwargs:
        doSpec = kwargs['doSpec']
    else:
        doSpec = False

    if not 'n_coeff' in table.colnames:
        if doAB:
            #table['n_coeff'] = 43
            table['n_coeff'] = 10
        elif doSpec:
            table['n_coeff'] = 21

    if not 'gptype' in table.colnames:
        table['gptype'] = 'sklearn'

    if doAB:
        if not Global.svd_mag_model == 0:
            svd_mag_model = Global.svd_mag_model
        else:
            if np.all(table['gptype'] == "sklearn"):
                modelfile = os.path.join(ModelPath, 'Bu2019lm_mag.pkl')
            elif np.all(table['gptype'] == "gpytorch"):
                modelfile = os.path.join(ModelPath, 'Bu2019lm_mag_gpy.pkl')
            elif np.all(table['gptype'] == "gp_api"):
                modelfile = os.path.join(ModelPath, 'Bu2019lm_mag_gpapi.pkl')
            elif np.all(table['gptype'] == "tensorflow"):
                modelfile = os.path.join(ModelPath, 'Bu2019lm_mag_tf.pkl')
            if LoadModel:
                #if True:
                with open(modelfile, 'rb') as handle:
                    svd_mag_model = pickle.load(handle)

                if np.all(table['gptype'] == "tensorflow"):
                    outdir = modelfile.replace(".pkl", "")
                    for filt in svd_mag_model.keys():
                        outfile = os.path.join(outdir, f'{filt}.h5')
                        svd_mag_model[filt]['model'] = load_model(outfile)

            else:
                svd_mag_model = svd_utils.calc_svd_mag(
                    table['tini'][0],
                    table['tmax'][0],
                    table['dt'][0],
                    model="Bu2019lm",
                    n_coeff=table['n_coeff'][0],
                    gptype=table['gptype'])

                if np.all(table['gptype'] == "tensorflow"):
                    outdir = modelfile.replace(".pkl", "")
                    if not os.path.isdir(outdir):
                        os.makedirs(outdir)
                    for filt in svd_mag_model.keys():
                        outfile = os.path.join(outdir, f'{filt}.h5')
                        svd_mag_model[filt]['model'].save(outfile)
                        del svd_mag_model[filt]['model']

                with open(modelfile, 'wb') as handle:
                    pickle.dump(svd_mag_model,
                                handle,
                                protocol=pickle.HIGHEST_PROTOCOL)

                if np.all(table['gptype'] == "tensorflow"):
                    for filt in svd_mag_model.keys():
                        outfile = os.path.join(outdir, f'{filt}.h5')
                        svd_mag_model[filt]['model'] = load_model(outfile)

            if np.all(table['gptype'] == "gp_api"):
                for filt in svd_mag_model.keys():
                    for ii in range(len(svd_mag_model[filt]["gps"])):
                        svd_mag_model[filt]["gps"][ii] = svd_utils.load_gpapi(
                            svd_mag_model[filt]["gps"][ii])
            Global.svd_mag_model = svd_mag_model

        if not Global.svd_lbol_model == 0:
            svd_lbol_model = Global.svd_lbol_model
        else:
            if np.all(table['gptype'] == "sklearn"):
                modelfile = os.path.join(ModelPath, 'Bu2019lm_lbol.pkl')
            elif np.all(table['gptype'] == "gpytorch"):
                modelfile = os.path.join(ModelPath, 'Bu2019lm_lbol_gpy.pkl')
            elif np.all(table['gptype'] == "gp_api"):
                modelfile = os.path.join(ModelPath, 'Bu2019lm_lbol_gpapi.pkl')
            elif np.all(table['gptype'] == "tensorflow"):
                modelfile = os.path.join(ModelPath, 'Bu2019lm_lbol_tf.pkl')
            if LoadModel:
                #if True:

                with open(modelfile, 'rb') as handle:
                    svd_lbol_model = pickle.load(handle)

                if np.all(table['gptype'] == "tensorflow"):
                    outdir = modelfile.replace(".pkl", "")
                    outfile = os.path.join(outdir, 'model.h5')
                    svd_lbol_model['model'] = load_model(outfile)

            else:
                svd_lbol_model = svd_utils.calc_svd_lbol(
                    table['tini'][0],
                    table['tmax'][0],
                    table['dt'][0],
                    model="Bu2019lm",
                    n_coeff=table['n_coeff'][0],
                    gptype=table['gptype'])

                if np.all(table['gptype'] == "tensorflow"):
                    outdir = modelfile.replace(".pkl", "")
                    if not os.path.isdir(outdir):
                        os.makedirs(outdir)
                    outfile = os.path.join(outdir, 'model.h5')
                    svd_lbol_model['model'].save(outfile)
                    del svd_lbol_model['model']

                with open(modelfile, 'wb') as handle:
                    pickle.dump(svd_lbol_model,
                                handle,
                                protocol=pickle.HIGHEST_PROTOCOL)

                if np.all(table['gptype'] == "tensorflow"):
                    svd_lbol_model['model'] = load_model(outfile)

            if np.all(table['gptype'] == "gp_api"):
                for ii in range(len(svd_lbol_model["gps"])):
                    svd_lbol_model["gps"][ii] = svd_utils.load_gpapi(
                        svd_lbol_model["gps"][ii])

            Global.svd_lbol_model = svd_lbol_model
    elif doSpec:
        if not Global.svd_spec_model == 0:
            svd_spec_model = Global.svd_spec_model
        else:
            if LoadModel:
                #if True:
                modelfile = os.path.join(ModelPath, 'Bu2019lm_spec.pkl')
                with open(modelfile, 'rb') as handle:
                    svd_spec_model = pickle.load(handle)
            else:
                svd_spec_model = svd_utils.calc_svd_spectra(
                    table['tini'][0],
                    table['tmax'][0],
                    table['dt'][0],
                    table['lambdaini'][0],
                    table['lambdamax'][0],
                    table['dlambda'][0],
                    model="Bu2019lm",
                    n_coeff=table['n_coeff'][0])
                modelfile = os.path.join(ModelPath, 'Bu2019lm_spec.pkl')
                with open(modelfile, 'wb') as handle:
                    pickle.dump(svd_spec_model,
                                handle,
                                protocol=pickle.HIGHEST_PROTOCOL)
            Global.svd_spec_model = svd_spec_model

    if not 'mej_dyn' in table.colnames:
        # calc the mass of ejecta
        table['mej_dyn'] = calc_meje(table['m1'], table['mb1'], table['c1'],
                                     table['m2'], table['mb2'], table['c2'])
        # calc the velocity of ejecta
        table['vej'] = calc_vej(table['m1'], table['c1'], table['m2'],
                                table['c2'])

    # Throw out smaples where the mass ejecta is less than zero.
    mask = (table['mej_dyn'] > 0)
    table = table[mask]
    if len(table) == 0: return table

    # Log mass ejecta
    table['mej_dyn10'] = np.log10(table['mej_dyn'])
    table['mej_wind10'] = np.log10(table['mej_wind'])
    # Initialize lightcurve values in table

    timeseries = np.arange(table['tini'][0], table['tmax'][0] + table['dt'][0],
                           table['dt'][0])
    table['t'] = [np.zeros(timeseries.size)]
    if doAB:
        table['lbol'] = [np.zeros(timeseries.size)]
        table['mag'] = [np.zeros([9, timeseries.size])]
    elif doSpec:
        lambdas = np.arange(table['lambdaini'][0],
                            table['lambdamax'][0] + table['dlambda'][0],
                            table['dlambda'][0])
        table['lambda'] = [np.zeros(lambdas.size)]
        table['spec'] = [np.zeros([lambdas.size, timeseries.size])]

    # calc lightcurve for each sample
    for isample in range(len(table)):
        print(np.log10(table['mej_dyn'][isample]),
              np.log10(table['mej_wind'][isample]), table['phi'][isample],
              table['theta'][isample])

        print('Generating sample %d/%d' % (isample, len(table)))
        if doAB:
            table['t'][isample], table['lbol'][isample], table['mag'][
                isample] = svd_utils.calc_lc(
                    table['tini'][isample],
                    table['tmax'][isample],
                    table['dt'][isample], [
                        np.log10(table['mej_dyn'][isample]),
                        np.log10(table['mej_wind'][isample]),
                        table['phi'][isample], table['theta'][isample]
                    ],
                    svd_mag_model=svd_mag_model,
                    svd_lbol_model=svd_lbol_model,
                    model="Bu2019lm",
                    gptype=table['gptype'][0])
        elif doSpec:
            table['t'][isample], table['lambda'][isample], table['spec'][
                isample] = svd_utils.calc_spectra(
                    table['tini'][isample],
                    table['tmax'][isample],
                    table['dt'][isample],
                    table['lambdaini'][isample],
                    table['lambdamax'][isample] + table['dlambda'][isample],
                    table['dlambda'][isample], [
                        np.log10(table['mej_dyn'][isample]),
                        np.log10(table['mej_wind'][isample]),
                        table['phi'][isample], table['theta'][isample]
                    ],
                    svd_spec_model=svd_spec_model,
                    model="Bu2019lm")

    return table
Exemplo n.º 9
0
        c1, c2 = 0.147, 0.147
        mb1, mb2 = lightcurve_utils.EOSfit(m1, c1), lightcurve_utils.EOSfit(
            m2, c2)
        th = 0.2
        ph = 3.14

        if m1 > 3:
            from gwemlightcurves.EjectaFits.KaKy2016 import calc_meje, calc_vave
            mej = calc_meje(q, chi_eff, c2, mb2, m2)
            vej = calc_vave(q)

        else:
            from gwemlightcurves.EjectaFits.DiUj2017 import calc_meje, calc_vej
            mej = calc_meje(m1, mb1, c1, m2, mb2, c2)
            vej = calc_vej(m1, c1, m2, c2)

        filename = os.path.join(plotDir, 'truth_mej_vej.dat')
        fid = open(filename, 'w+')
        fid.write('%.5f %.5f\n' % (mej, vej))
        fid.close()

        if m1 > 3:
            filename = os.path.join(plotDir, 'truth.dat')
            fid = open(filename, 'w+')
            fid.write('%.5f %.5f %.5f %.5f %.5f\n' % (q, chi_eff, c2, mb2, m2))
            fid.close()

            t, lbol, mag = KaKy2016_model(q, chi_eff, m2, mb2, c2, th, ph)

        else:
Exemplo n.º 10
0
def get_RoFe2017_model(table, **kwargs):

    if not 'n_coeff' in table.colnames:
        table['n_coeff'] = 100

    if not Global.svd_mag_model == 0:
        svd_mag_model = Global.svd_mag_model
    else:
        svd_mag_model = svd_utils.calc_svd_mag(table['tini'][0],
                                               table['tmax'][0],
                                               table['dt'][0],
                                               model="RoFe2017",
                                               n_coeff=table['n_coeff'][0])
        Global.svd_mag_model = svd_mag_model

    if not Global.svd_lbol_model == 0:
        svd_lbol_model = Global.svd_lbol_model
    else:
        svd_lbol_model = svd_utils.calc_svd_lbol(table['tini'][0],
                                                 table['tmax'][0],
                                                 table['dt'][0],
                                                 model="RoFe2017",
                                                 n_coeff=table['n_coeff'][0])
        Global.svd_lbol_model = svd_lbol_model

    if not 'mej' in table.colnames:
        # calc the mass of ejecta
        table['mej'] = calc_meje(table['m1'], table['mb1'], table['c1'],
                                 table['m2'], table['mb2'], table['c2'])
        # calc the velocity of ejecta
        table['vej'] = calc_vej(table['m1'], table['c1'], table['m2'],
                                table['c2'])

    # Throw out smaples where the mass ejecta is less than zero.
    mask = (table['mej'] > 0)
    table = table[mask]
    if len(table) == 0: return table

    # Log mass ejecta
    table['mej10'] = np.log10(table['mej'])
    # Initialize lightcurve values in table

    timeseries = np.arange(table['tini'][0], table['tmax'][0] + table['dt'][0],
                           table['dt'][0])
    table['t'] = [np.zeros(timeseries.size)]
    table['lbol'] = [np.zeros(timeseries.size)]
    table['mag'] = [np.zeros([9, timeseries.size])]

    # calc lightcurve for each sample
    for isample in range(len(table)):
        table['t'][isample], table['lbol'][isample], table['mag'][
            isample] = svd_utils.calc_lc(
                table['tini'][isample],
                table['tmax'][isample],
                table['dt'][isample], [
                    np.log10(table['mej'][isample]), table['vej'][isample],
                    table['Ye'][isample]
                ],
                svd_mag_model=svd_mag_model,
                svd_lbol_model=svd_lbol_model,
                model="RoFe2017")

    return table