Пример #1
0
def at2018cow(ax, col, legend):
    """ 231.5 GHz light curve and 9 GHz light curve """
    d = Planck15.luminosity_distance(z=0.014).cgs.value

    # high frequency
    a, b, c = sma_lc()
    dt, f, ef = b
    ef_comb = np.sqrt(ef**2 + (0.15 * f)**2)
    nu = 231.5E9
    lum = plot_line(ax[0],
                    d,
                    dt,
                    nu * f,
                    'AT2018cow',
                    None,
                    col,
                    legend,
                    zorder=10)
    ax[0].text(dt[0] / 1.2,
               lum[0],
               'AT2018cow',
               fontsize=11,
               verticalalignment='center',
               horizontalalignment='right')

    # low frequency
    nu = 9E9
    data_dir = "/Users/annaho/Dropbox/Projects/Research/AT2018cow/data"
    dat = Table.read("%s/radio_lc.dat" % data_dir,
                     delimiter="&",
                     format='ascii.no_header')
    tel = np.array(dat['col2'])
    choose = np.logical_or(tel == 'SMA', tel == 'ATCA')

    days = np.array(dat['col1'][choose])
    freq = np.array(dat['col3'][choose]).astype(float)
    flux_raw = np.array(dat['col4'][choose])
    flux = np.array([float(val.split("pm")[0][1:]) for val in flux_raw])
    eflux_sys = np.array([0.1 * f for f in flux])
    eflux_form = np.array(
        [float(val.split("pm")[1][0:-1]) for val in flux_raw])
    eflux = np.sqrt(eflux_sys**2 + eflux_form**2)
    choose = freq == 9

    # add the Margutti point
    x = np.hstack((days[choose], 83.51))
    y = np.hstack((flux[choose], 9.1)) * nu
    lum = plot_line(ax[1], d, x, y, 'AT2018cow', None, col, legend, zorder=10)
    ax[1].text(x[-1],
               lum[-1] * 1.2,
               'AT2018cow',
               fontsize=11,
               verticalalignment='bottom',
               horizontalalignment='center')
Пример #2
0
for col in np.arange(ncol - 1):
    rowstr += "%s & "
rowstr += "%s \\\ \n"

outputf = open("paper_table_%s.txt" % label, "w")
outputf.write("\\startlongtable \n")
outputf.write("\\begin{deluxetable}{%s} \n" % colstr)
outputf.write("\\tablecaption{%s\label{tab:%s}} \n" % (caption, label))
outputf.write("\\tablewidth{0pt} \n")
outputf.write("\\tablehead{ %s } \n" % colheadstr)
#outputf.write("\\rotate \n")
outputf.write("\\tabletypesize{\scriptsize} \n")
outputf.write("\startdata \n")

# Get the SMA light curves with fractional dt and scaled flux
a, b, c = sma_lc()
dt, nu, f, ef = a
tvals = np.unique(dt)

for ii, t in enumerate(tvals):
    # For each time
    choose = dt == t
    # For each frequency observed at that time
    nu_unique = np.unique(nu[choose])
    for jj, nuval in enumerate(nu_unique):
        # Select the relevant data points
        flux_raw = f[choose][nu[choose] == nuval]
        eflux_raw = ef[choose][nu[choose] == nuval]
        if len(flux_raw) == 2:
            w = 1 / (eflux_raw)**2
            fmean, wsum = np.average(flux_raw, weights=w, returned=True)
Пример #3
0
""" Full SMA light curve breaking data into all frequency tunings, 
for the Appendix """

import numpy as np
import matplotlib
from matplotlib import rc
rc("font", family="serif")
rc("text", usetex=True)
import matplotlib.pyplot as plt
import sys
sys.path.append("/Users/annaho/Dropbox/Projects/Research/AT2018cow/code")
from scale_fluxes import sma_lc
from get_radio import get_data_all

out = sma_lc()
t, nu, f, ef = out[0]

# A non-detection will either have a negative flux value
# or an uncertainty that is larger in magnitude than the flux value
det = np.logical_and(f > 0, np.abs(f) > ef)

# Only plot detections
t = t[det]
nu = nu[det]
f = f[det]
ef = ef[det]

npts = len(np.unique(nu))

c = ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c']
markers = ['o', 's', 'v', '^']
Пример #4
0
f = 0.5  # filling factor
t0 = 22
R0 = 7E15
c = 3E10
t = np.arange(1, 30)
R = R0 * (t / t0)
V = (4 / 3) * f * np.pi * R**3
v = 0.13 * c

# Radiation energy density
L = np.interp(t, dt, lum)
Uph = L / (4 * np.pi * R**2 * c)

# Magnetic energy density
UB = (6**2 / (8 * np.pi))

# Ratio of energy densities
Uratio = Uph / UB

# Ratio of X-ray to radio luminosity
d = Planck15.luminosity_distance(z=0.014).cgs.value
dt_x, f_x, ef_x = get_xrt()
l_x = np.interp(t, dt_x, f_x * 4 * np.pi * d**2)

a, b = sma_lc()
dt_rad, f_rad, ef = b
ef_rad = np.sqrt(ef**2 + (0.15 * f)**2)
l_rad = np.interp(t, dt_rad, 230E9 * f_rad * 1E-3 * 1E-23 * 4 * np.pi * d**2)
Lratio = l_x / l_rad
Пример #5
0
def sma(ax):
    data_dir = "/Users/annaho/Dropbox/Projects/Research/AT2018cow/data"
    dat = Table.read("%s/radio_lc.dat" % data_dir,
                     delimiter="&",
                     format='ascii.no_header')
    tel = np.array(dat['col2'])
    choose = np.logical_or(tel == 'SMA', tel == 'ATCA')

    days = np.array(dat['col1'][choose])
    freq = np.array(dat['col3'][choose]).astype(float)
    flux_raw = np.array(dat['col4'][choose])
    flux = np.array([float(val.split("pm")[0][1:]) for val in flux_raw])
    eflux_sys = np.array([0.1 * f for f in flux])
    eflux_form = np.array(
        [float(val.split("pm")[1][0:-1]) for val in flux_raw])
    eflux = np.sqrt(eflux_sys**2 + eflux_form**2)

    a, b, c = sma_lc()
    dt, f, ef = b  # 230 GHz light curve
    ef_comb = np.sqrt(ef**2 + (0.15 * f)**2)
    ax.scatter(dt[:-1],
               f[:-1],
               marker='s',
               c='k',
               label="SMA: 230.6--234.6 GHz")
    ax.errorbar(dt[:-1], f[:-1], ef_comb[:-1], fmt='s', c='#000004',
                lw=1.5)  # black in inferno
    ax.plot(dt[:-1], f[:-1], linestyle='-', c='k', lw=1.5)
    #plt.axvline(x=30)

    dt, f, ef = c  # 345 GHz light curve
    ef_comb = np.sqrt(ef**2 + (0.15 * f)**2)
    ax.errorbar(dt,
                f,
                ef_comb,
                fmt='*',
                c='#f98e09',
                lw=0.5,
                alpha=0.8,
                ms=11,
                label="SMA: 341.5--349 GHz")
    ax.plot(dt, f, linestyle='-', c='#f98e09', lw=1.5)

    # non-detection
    # what is the 3-sigma of the non-detection?
    # x + 3-sigma
    # for 231.5 GHz, it's X=0.62, 3-sig = 3*0.64
    val = 0.62
    sig = 0.64
    ax.scatter(76.27, val + 3 * sig, marker="_", c='k', s=200)
    ax.scatter(76.27, val, marker="_", c='k', s=100)
    ax.scatter(76.27, val, marker=".", c='k', s=30)
    ax.arrow(76.27,
             val + 3 * sig,
             0,
             -3 * sig,
             length_includes_head=True,
             head_width=5,
             head_length=0.1,
             fc='k')

    # for 351.0, the non-detection is -0.32 +/- 1.76
    val = -0.32
    sig = 1.76
    ax.scatter(76.27, val + 3 * sig, marker="_", c='#f98e09', s=200)
    ax.scatter(76.27, val, marker="_", c='#f98e09', s=100)
    ax.scatter(76.27, val, marker=".", c='#f98e09', s=30)
    ax.arrow(76.27,
             val + 3 * sig,
             0,
             -3 * sig,
             length_includes_head=True,
             head_width=5,
             head_length=0.1,
             fc='#f98e09',
             ec='#f98e09')

    # Do 34 GHz
    choose = freq == 34
    # dont include the last point
    xfit = days[choose][0:-1]
    yfit = flux[choose][0:-1]
    eyfit = eflux[choose][0:-1]
    # fit a nu^2 power law
    out = np.polyfit(np.log10(xfit), np.log10(yfit), deg=1)
    x = np.linspace(min(xfit), max(xfit))
    y = 10**(out[0] * np.log10(x) + out[1])
    ax.errorbar(days[choose],
                flux[choose],
                yerr=eflux[choose],
                fmt='o',
                mec='#57106e',
                lw=1.5,
                ms=7,
                label="ATCA: 34 GHz",
                mfc='white')
    ax.plot(x, y, ls='--', c='#57106e')
    ax.text(17, 9.5, r'$f_\nu \propto t^2$', fontsize=midfont)

    # for SMA proposal
    #ax.axvline(x=5, color='#8da0cb', alpha=0.5, lw=7)
    #ax.axvline(x=12, color='#8da0cb', alpha=0.5, lw=7)

    # cross hatches for the Day 10, Day 13/14, and Day 22 measurements
    ax.text(10, 70, 'S', fontsize=smallfont)
    ax.text(14, 70, 'S', fontsize=smallfont)
    ax.text(22, 70, 'S', fontsize=smallfont)

    # optical timeline:
    ax.text(3,
            100,
            r'broad ($>0.1c$) feature',
            fontsize=smallfont,
            verticalalignment='bottom')
    ax.annotate('',
                xy=(8.5, 100),
                xytext=(8.5, 150),
                arrowprops=dict(arrowstyle="-", color='k'))
    ax.text(9,
            100,
            r'HeII ($0.03c$)',
            fontsize=smallfont,
            verticalalignment='bottom')
    ax.text(6,
            150,
            r'IR excess appears',
            fontsize=smallfont,
            verticalalignment='bottom')
    ax.annotate('',
                xy=(16, 100),
                xytext=(16, 290),
                arrowprops=dict(arrowstyle="-", color='k'))
    ax.text(20,
            400,
            r'Redshifted HeI ($0.01c$) and',
            fontsize=smallfont,
            verticalalignment='bottom',
            horizontalalignment='right')
    ax.text(20,
            270,
            r'Balmer emission ($0.02c$) appear',
            fontsize=smallfont,
            verticalalignment='bottom',
            horizontalalignment='right')
    ax.text(17,
            150,
            r'Lines evolve blueward',
            fontsize=smallfont,
            verticalalignment='bottom',
            horizontalalignment='left')
    ax.text(17,
            100,
            r'and develop wedge shape',
            fontsize=smallfont,
            verticalalignment='bottom',
            horizontalalignment='left')
    ax.annotate('',
                xy=(30, 100),
                xytext=(30, 290),
                arrowprops=dict(arrowstyle="-", color='k'))
    ax.text(27,
            400,
            r'Emergence of HeI, CaII, OI,',
            fontsize=smallfont,
            verticalalignment='bottom',
            horizontalalignment='left')
    ax.text(27,
            270,
            r'$z$-band excess',
            fontsize=smallfont,
            verticalalignment='bottom',
            horizontalalignment='left')

    ax.set_ylim(0.5, 100)
    ax.set_yscale('log')
    ax.set_xscale('log')
    ax.set_ylabel("$f_{\\nu}$ [mJy]", fontsize=bigfont)
    ax.yaxis.set_tick_params(labelsize=midfont)
    ax.legend(fontsize=smallfont, loc='lower left', ncol=1)
    ax.set_yticks([0.5, 10, 50])
    ax.get_yaxis().set_major_formatter(matplotlib.ticker.ScalarFormatter())