Exemplo n.º 1
0
def compare_ttVSubv(mname, path, bands=['U', 'B', 'V', 'R', 'I'], t_cut=1., is_plot_time_points=False):
    dic_results = {}

    model = Stella(mname, path=path)
    tt = model.read_tt_data()

    # time cut  days
    mags = tt[tt['time'] > t_cut]
    n1 = mags.dtype.names

    def f(x):
        if len(x) == 2 and x.startswith('M'):
            return x.replace('M', '')
        else:
            return x

    n2 = map(lambda x: f(x), n1)
    mags.dtype.names = n2

    dic_results['tt'] = mags

    # ubv
    serial_spec = model.read_series_spectrum(t_diff=1.05)
    mags = serial_spec.mags_bands(bands)
    dic_results['ubv'] = mags

    plot_all(dic_results, bands, title=mname, is_time_points=is_plot_time_points)
Exemplo n.º 2
0
def compute_vel(name, path, z=0., t_beg=1., t_end=None, t_diff=1.05):
    model = Stella(name, path=path)
    if not model.is_res_data or not model.is_tt_data:
        if not model.is_res_data:
            print "There are no res-file for %s in the directory: %s " % (name, path)
        if not model.is_tt_data:
            print "There are no tt-file for %s in the directory: %s " % (name, path)
        return None

    if t_end is None:
        t_end = float('inf')

    res = model.get_res()
    tt = model.read_tt_data()
    tt = tt[tt['time'] >= t_beg]  # time cut  days

    radiuses = list()
    vels = list()
    times = list()
    Rph_spline = interpolate.splrep(tt['time'], tt['Rph'], s=0)
    for nt in range(len(tt['time'])):
        t = tt['time'][nt]
        if t > t_end:
            break
        if t < t_beg or np.abs(t / t_beg < t_diff):
            continue
        t_beg = t
        radius = interpolate.splev(t, Rph_spline)
        if np.isnan(radius):
            radius = np.interp(t, tt['time'], tt['Rph'], 0, 0)  # One-dimensional linear interpolation.
        block = res.read_at_time(time=t)
        if block is None:
            break

        if True:
            vel = np.interp(radius, block['R14']*1e14, block['V8'], 0, 0)  # One-dimensional linear interpolation.
            vels.append(vel * 1e8)
        else:
            idx = np.abs(block['R14'] - radius / 1e14).argmin()
            vels.append(block['V8'][idx] * 1e8)

        radiuses.append(radius)
        times.append(t * (1. + z))  # redshifted time

    # show results
    res = np.array(np.zeros(len(vels)),
                   dtype=np.dtype({'names': ['time', 'vel', 'r'],
                                   'formats': [np.float] * 3}))
    res['time'] = times
    res['vel'] = vels
    res['r'] = radiuses
    return res
Exemplo n.º 3
0
def compute_tcolor(name, path, bands, d=rf.pc_to_cm(10.0), z=0.0, t_cut=1.0):
    model = Stella(name, path=path)

    if not model.is_ph_data:
        print "No ph-data for: " + str(model)
        return None

    if not model.is_tt_data:
        print "No tt-data for: " + str(model)
        return None

    # serial_spec = model.read_series_spectrum(t_diff=1.)
    # curves = serial_spec.flux_to_curves(bands, d=distance)
    serial_spec = model.read_series_spectrum(t_diff=1.05, t_beg=t_cut)
    # curves = serial_spec.
    mags = serial_spec.mags_bands(bands, z=z, d=d)

    # read R_ph
    tt = model.read_tt_data()
    tt = tt[tt["time"] > t_cut]  # time cut  days

    # compute Tnu, W
    Tnu, Teff, W = compute_Tnu_w(serial_spec, tt=tt)

    # fit mags by B(T_col) and get \zeta\theta & T_col
    Tcolors, zetaR, times = compute_Tcolor_zeta(mags, tt=tt, bands=bands, freq=serial_spec.Freq, d=d, z=z)

    # show results
    res = np.array(
        np.zeros(len(Tcolors)),
        dtype=np.dtype({"names": ["time", "Tcol", "zeta", "Tnu", "Teff", "W"], "formats": [np.float64] * 6}),
    )
    res["time"] = times
    res["Tcol"] = Tcolors
    res["zeta"] = zetaR
    res["Tnu"] = Tnu
    res["Teff"] = Teff
    res["W"] = W

    return res