#             latex_info.round_to_n(total_picking_max.value / sgrb2_age_myr / 1e6,2)])

print("SFR({1} Myr) = {0}".format(totalrow[-1], sgrb2_age_myr))
sfrbrickage = (latex_info.round_to_n(
    totalrow[4].to(u.Msun).value / (sgrb2_brick_age_myr * 1e6), 2) *
               (u.Msun / u.yr))
print("SFR({1} Myr) = {0}".format(sfrbrickage, sgrb2_brick_age_myr))
sfrdynage_totmax = latex_info.round_to_n(
    total_picking_max.value / sgrb2_age_myr / 1e6, 2)
print("SFR({1} Myr) = {0}".format(sfrdynage_totmax, sgrb2_age_myr))
sfrbrickage_totmax = (latex_info.round_to_n(
    total_picking_max.to(u.Msun).value / (sgrb2_brick_age_myr * 1e6), 2) *
                      (u.Msun / u.yr))
print("SFR({1} Myr) = {0}".format(sfrbrickage_totmax, sgrb2_brick_age_myr))

with open(paths.texpath('sfr.tex'), 'w') as fh:
    fh.write("\\newcommand{{\\sfrdynage}}{{{0}\\xspace}}\n".format(
        totalrow[-1].to(u.Msun / u.yr).value))
    fh.write("\\newcommand{{\\sfrbrickage}}{{{0}\\xspace}}\n".format(
        sfrbrickage.to(u.Msun / u.yr).value))
    fh.write("\\newcommand{{\\sfrdynagemax}}{{{0}\\xspace}}\n".format(
        sfrdynage_totmax))
    fh.write("\\newcommand{{\\sfrbrickagemax}}{{{0}\\xspace}}\n".format(
        sfrbrickage_totmax.to(u.Msun / u.yr).value))

formats = {
    'SFR':
    lambda x: latex_info.strip_trailing_zeros(str(x)),
    '$M_{\\rm inf}^s$':
    lambda x: "{0}".format(x) if x != -999 else '-',
    '$M_{\\rm count}^s$':
    beam = Beam.from_fits_header(header)
    ww = wcs.WCS(header)

    nrp = noiseregion.to_pixel(ww)
    mask = nrp.to_mask()
    noise = mask.cutout(data)[mask.data.astype('bool')].std()

    sourceImask = sourceIcircle.to_pixel(ww).to_mask()
    sourceIpeak = sourceImask.cutout(data)[sourceImask.data.astype(
        'bool')].max()

    row = (r"{band} & {robust} & {bmaj:0.3f} & {bmin:0.3f} & {bpa:0.1f} &"
           r" {jtok:0.1f} &"
           r" {rms:0.3f} & {srcipeak:0.3f} & {DR:0d} \\".format(
               band="B3" if "B3" in fn else "B6",
               bmaj=beam.major.to(u.arcsec).value,
               bmin=beam.minor.to(u.arcsec).value,
               bpa=beam.pa.to(u.deg).value,
               rms=noise * 1e3,
               robust=('-2' if 'r-2' in fn else '0.5'
                       if 'r0.5' in fn else '2' if 'r2' in fn else 'ERROR'),
               srcipeak=sourceIpeak * 1e3,
               DR=int((sourceIpeak / noise) / 10) * 10,
               jtok=(beam.jtok(freq).value / 1e3),
           ))
    datatext.append(row)

with open(paths.texpath('image_metadata.tex'), 'w') as texfh:

    texfh.write(tabletext.replace("XXDATAXX", "\n".join(datatext)))
latexdict['tabletype'] = 'table'
latexdict['tablefoot'] = (
    "}\par\n"
    "The Classification column consists of three letter codes "
    "as described in Section \\ref{sec:classification}.  "
    "In column 1, "
    "\\texttt{S} indicates a strong source, "
    "\\texttt{W} indicates weak or low-confidence source. "
    "In column 2, an \\texttt{X} indicates a match with the "
    "\citet{Muno2009a} Chandra X-ray source catalog, while an "
    "underscore indicates there was no match.  "
    "In column 3, \\texttt{M} indicates a match with the, "
    "\citet{Caswell2010a} Methanol Multibeam Survey "
    "\\methanol maser catalog, while an underscore indicates "
    "there was no match."
    "In Column 4, \\texttt{W} indicates a match to the "
    "\\citep{McGrath2004a} water maser survey, while an "
    "underscore indicates there was no match.  "
    "  Finally, we include the SIMBAD "
    "\\citep{Wenger2000a} "
    "source object type classification if one was found."
    "  The full electronic version of this table is available at "
    "\\url{https://github.com/keflavich/SgrB2_ALMA_3mm_Mosaic/blob/master/tables/continuum_photometry_withSIMBAD_andclusters.ipac} "
    "and will be made available via the journal at the time of publication.")

cont_tbl.sort('$S_{\\nu,max}$')
cont_tbl[:-35:-1].write(paths.texpath("continuum_photometry.tex"),
                        formats=formats,
                        overwrite=True,
                        latexdict=latexdict)
import os
import paths
import glob

figstr = """
\Figure{{figures/pointsource_seds/{fname}}}
{{Point source photometry of {objname}.  See Figure \\ref{{fig:d4sed}} for
details}}
{{fig:{objname}sed}}{{1}}{{7in}}\n\clearpage\n"""

with open(paths.texpath("ptsrcphotometryfigures.tex"), "w") as f:
    for fn in glob.glob(paths.fpath("pointsource_seds/*png")):
        fname = os.path.split(fn)[-1]
        objname = fname.split("_")[0]
        f.write(figstr.format(fname=fname, objname=objname))
ulines = np.array(['U' in ln for ln in linenames], dtype='bool')
tbl = tbl[ulines]['Line Name', 'Frequency', 'Fitted Width', 'Fitted Amplitude']

tbl.sort('Frequency')

tbl.write('unknown_line_fits.txt', format='ascii.fixed_width')

latexdict = latex_info.latexdict.copy()
latexdict['header_start'] = '\label{tab:unknown_line_frequencies}'
latexdict['caption'] = 'Unknown Line Frequencies'
latexdict['preamble'] = '\centering'
latexdict['tablefoot'] = (
    '\n\par The frequencies listed have a systematic '
    'uncertainty of about 2 \\kms (1.5 MHz) because '
    'they are referenced to the U232.511 line, which '
    'has an unknown rest frequency.  The rest frequency '
    'used for the U232.511 line was selected to maximize '
    'the symmetry of the emission around 5 \\kms.  '
    'Some lines were detected in only part of the disk '
    'and therefore had bad or malformed profiles in the '
    'stacked spectrum; these have fits marked with -\'s.')
formats = {
    'Frequency': lambda x: "{0:0.3f}".format(x),
    'Fitted Width': lambda x: "-" if np.isnan(x) else "{0:0.1f}".format(x),
    'Fitted Amplitude': lambda x: "-" if np.isnan(x) else "{0:0.1f}".format(x),
}
tbl.write(paths.texpath('unknown_line_freqs.tex'),
          formats=formats,
          latexdict=latexdict,
          overwrite=True)
示例#6
0
        print(v)

    return lines


if __name__ == "__main__":
    formatted, data = zip(*make_meta_tables(DEBUG=False))
    dates = [datetime.datetime.strptime(x[0], '%d-%b-%Y') for x in data]

    lines = "\n".join([x for _, x in sorted(set(zip(dates, formatted)))])
    print()
    print(lines)

    basetable = r"""
\begin{table*}[htp]
\centering
\caption{Observation Summary}
\begin{tabular}{llllllll}
\label{tab:observations}
Date & Band & Array & Observation Duration &  Baseline Length Range  & \# of antennae & FluxCal & PhaseCal\\
     &      &       & seconds              & meters                    &              &         &         \\
\hline
DATA
\hline
\end{tabular}
\end{table*}
"""

    with open(paths.texpath('obs_metadata.tex'), 'w') as fh:
        fh.write(basetable.replace("DATA", lines))
                                    (formats['e' + cn](err) if 'e' +
                                     cn in formats else formats[cn](err)))
             if '-' != formats[cn](val) else '-')
            if err != 0.0 else formats[cn](val)
            for val, err in zip(ntbl[cn], ntbl['e' + cn])
        ]
        unit = ntbl[cn].unit
        ntbl.remove_column(cn)
        ntbl.remove_column('e' + cn)
        ntbl.add_column(table.Column(data=new_col, name=cn, unit=unit))
        newformats[cn] = lambda x: x

ntbl = ntbl['Frequency', 'Disk FWHM', 'Disk Radius', 'Disk PA', 'Pt RA',
            'Pt Dec', 'Pt Amp', 'Pt Width', 'Pt Flux', 'Total Flux', 'Pt \%', ]
ntbl.sort('Frequency')
ntbl.write(paths.texpath('continuum_fit_parameters.tex'),
           format='ascii.latex',
           formats=newformats,
           latexdict=latexdict,
           overwrite=True)

with open(paths.texpath('continuum_beams.tex'), 'w') as fh:
    for band in beams:
        bm = beams[band]
        argdict = {
            'bandid':
            band.replace("3", "three").replace("6",
                                               "six").replace("7", "seven"),
            'major':
            strip_trailing_zeros('{0:0.5g}'.format(
                round_to_n(bm.major.to(u.arcsec).value, 2))),
import os
import paths
import glob

figstr = """
\Figure{{figures/pointsource_seds/{fname}}}
{{Point source photometry of {objname}.  See Figure \\ref{{fig:d4sed}} for
details}}
{{fig:{objname}sed}}{{1}}{{7in}}\n\clearpage\n"""

with open(paths.texpath('ptsrcphotometryfigures.tex'),'w') as f:
    for fn in glob.glob(paths.fpath('pointsource_seds/*png')):
        fname = os.path.split(fn)[-1]
        objname = fname.split("_")[0]
        f.write(figstr.format(fname=fname, objname=objname))


示例#9
0
ax3.errorbar(cont_tbl['peak_90GHz'][~significant_mask],
             spindx[~significant_mask],
             xerr=cont_tbl['bgmad_90GHz'][~significant_mask],
             yerr=spindx_err[~significant_mask],
             marker='.',
             linestyle='',
             alpha=0.25,
             color='b')
ax3.set_ylim(-4, 4)
ax3.set_xlabel("90 GHz peak $S_\\nu$")
ax3.set_ylabel("90-100 GHz Spectral Index")

alphaok_mask = (np.abs(cont_tbl['alpha']) >
                cont_tbl['alphaerror'] * 5) | (cont_tbl['alphaerror'] < 0.1)
ngt2 = ((cont_tbl['alpha'] > 2) & alphaok_mask).sum()
with open(paths.texpath('alpha.tex'), 'w') as fh:
    fh.write("\\newcommand{{\\nalphas}}{{{0}\\xspace}}\n".format(
        alphaok_mask.sum()))
    fh.write("\\newcommand{{\\ngttwo}}{{{0}\\xspace}}\n".format(ngt2))
    print("{0} sources have acceptable alpha measurements".format(
        alphaok_mask.sum()))

fig4 = pl.figure(4)
fig4.clf()
ax4 = fig4.gca()
ax4.set_xscale('log')
ax4.errorbar(cont_tbl['peak'][alphaok_mask],
             cont_tbl['alpha'][alphaok_mask],
             xerr=cont_tbl['bgmad'][alphaok_mask],
             yerr=cont_tbl['alphaerror'][alphaok_mask],
             linewidth=0.5,
示例#10
0
                                            if 'e'+cn in formats else
                                            formats[cn](err))
                                          )
                    if '-' != formats[cn](val) else '-') if err != 0.0
                   else formats[cn](val)
                   for val, err in zip(ntbl[cn], ntbl['e'+cn])]
        unit = ntbl[cn].unit
        ntbl.remove_column(cn)
        ntbl.remove_column('e'+cn)
        ntbl.add_column(table.Column(data=new_col, name=cn, unit=unit))
        newformats[cn] = lambda x: x


ntbl = ntbl['Frequency', 'Disk FWHM', 'Disk Radius', 'Disk PA', 'Pt RA', 'Pt Dec', 'Pt Amp', 'Pt Width', 'Pt Flux', 'Total Flux', 'Pt \%', ]
ntbl.sort('Frequency')
ntbl.write(paths.texpath('continuum_fit_parameters.tex'), format='ascii.latex',
           formats=newformats,
           latexdict=latexdict, overwrite=True)


with open(paths.texpath('continuum_beams.tex'), 'w') as fh:
    for band in beams:
        bm = beams[band]
        argdict = {'bandid': band.replace("3","three").replace("6", "six").replace("7", "seven"),
                   'major': strip_trailing_zeros('{0:0.5g}'.format(round_to_n(bm.major.to(u.arcsec).value,2))),
                   'minor': strip_trailing_zeros('{0:0.5g}'.format(round_to_n(bm.minor.to(u.arcsec).value,2))),
                   'pa': strip_trailing_zeros('{0:0.5g}'.format(round_to_n(bm.pa.to(u.deg).value,3))),
                  }
        fh.write("\\newcommand{{\\{bandid}maj}}{{{major}}}\n".format(**argdict))
        fh.write("\\newcommand{{\\{bandid}min}}{{{minor}}}\n".format(**argdict))
        fh.write("\\newcommand{{\\{bandid}pa}}{{{pa}}}\n".format(**argdict))