Ejemplo n.º 1
0
    def writer(filename, catalog, fmt=None):
        """
        construct a dict of the data
        this method preserves the data types in the VOTable
        """
        tab_dict = {}
        name_list = []
        for name in catalog[0].names:
            col_name = name
            if catalog[0].galactic:
                if name.startswith('ra'):
                    col_name = 'lon' + name[2:]
                elif name.endswith('ra'):
                    col_name = name[:-2] + 'lon'
                elif name.startswith('dec'):
                    col_name = 'lat' + name[3:]
                elif name.endswith('dec'):
                    col_name = name[:-3] + 'lat'
            col_name = pre + col_name
            tab_dict[col_name] = [getattr(c, name, None) for c in catalog]
            name_list.append(col_name)
        t = Table(tab_dict, meta=meta)
        # re-order the columns
        t = t[[n for n in name_list]]

        if fmt is not None:
            if fmt in ["vot", "vo", "xml"]:
                vot = from_table(t)
                # description of this votable
                vot.description = repr(meta)
                writetoVO(vot, filename)
            elif fmt in ['hdf5']:
                t.write(filename, path='data', overwrite=True)
            elif fmt in ['fits']:
                writeFITSTable(filename, t)
            else:
                ascii.write(t, filename, fmt, overwrite=True)
        else:
            ascii.write(t, filename, overwrite=True)
        return
Ejemplo n.º 2
0
    def writer(filename, catalog, fmt=None):
        """
        construct a dict of the data
        this method preserves the data types in the VOTable
        """
        tab_dict = {}
        name_list = []
        for name in catalog[0].names:
            col_name = name
            if catalog[0].galactic:
                if name.startswith('ra'):
                    col_name = 'lon'+name[2:]
                elif name.endswith('ra'):
                    col_name = name[:-2] + 'lon'
                elif name.startswith('dec'):
                    col_name = 'lat'+name[3:]
                elif name.endswith('dec'):
                    col_name = name[:-3] + 'lat'
            col_name = pre + col_name
            tab_dict[col_name] = [getattr(c, name, None) for c in catalog]
            name_list.append(col_name)
        t = Table(tab_dict, meta=meta)
        # re-order the columns
        t = t[[n for n in name_list]]

        if fmt is not None:
            if fmt in ["vot", "vo", "xml"]:
                vot = from_table(t)
                # description of this votable
                vot.description = repr(meta)
                writetoVO(vot, filename)
            elif fmt in ['hdf5']:
                t.write(filename, path='data', overwrite=True)
            elif fmt in ['fits']:
                writeFITSTable(filename, t)
            else:
                ascii.write(t, filename, fmt, overwrite=True)
        else:
            ascii.write(t, filename, overwrite=True)
        return
Ejemplo n.º 3
0
 def writer(filename, catalog, fmt=None):
     # construct a dict of the data
     # this method preserves the data types in the VOTable
     tab_dict = {}
     for name in catalog[0].names:
         tab_dict[name] = [getattr(c, name, None) for c in catalog]
     t = Table(tab_dict,meta=meta)
     # re-order the columns
     t = t[[n for n in catalog[0].names]]
     if fmt is not None:
         if fmt in ["vot", "vo", "xml"]:
             vot = from_table(t)
             # description of this votable
             vot.description = repr(meta)
             writetoVO(vot, filename)
         elif fmt in ['hdf5']:
             t.write(filename,path='data',overwrite=True)
         elif fmt in ['fits']:
             writeFITSTable(filename,t)
         else:
             ascii.write(t, filename, fmt)
     else:
         ascii.write(t, filename)
     return
Ejemplo n.º 4
0
 def writer(filename, catalog, fmt=None):
     # construct a dict of the data
     # this method preserves the data types in the VOTable
     tab_dict = {}
     for name in catalog[0].names:
         tab_dict[name] = [getattr(c, name, None) for c in catalog]
     t = Table(tab_dict, meta=meta)
     # re-order the columns
     t = t[[n for n in catalog[0].names]]
     if fmt is not None:
         if fmt in ["vot", "vo", "xml"]:
             vot = from_table(t)
             # description of this votable
             vot.description = repr(meta)
             writetoVO(vot, filename)
         elif fmt in ['hdf5']:
             t.write(filename, path='data', overwrite=True)
         elif fmt in ['fits']:
             writeFITSTable(filename, t)
         else:
             ascii.write(t, filename, fmt)
     else:
         ascii.write(t, filename)
     return
Ejemplo n.º 5
0
ax1 = fig.add_subplot(111,projection="polar")
ax1.set_title('Polar Beam Model Map')
c = ax1.scatter(Az0_samp[0],r,c=10**temp_poly_co[:,k_max-1],label='Order')
fig.colorbar(c)

plt.show()
"""

################################################################################
# Creating output VO table
################################################################################
#"""

print "Writing V0 table"

filename_body = 'model'

newvot = Table( [name, ra_str, dec_str, ra, dec, coeff_arr[:,1], S_centralfreq, beamvalue, beamvalue_approx, S_centralfreq_uncorrected,\
 app_poly_co_tup_list,peak_flux_wide, int_flux_wide, a_wide, b_wide, pa_wide],\
    names=('Name','ra_str','dec_str','ra','dec', 'alpha','S_centralfreq',
        'beamvalue','beamvalue_approx','S_centralfreq_uncorrected','apparent_poly_coeff','peak_flux_wide','int_flux_wide',\
        'a_wide', 'b_wide', 'pa_wide'), meta={'name': 'first table'} )

writetoVO(newvot, filename_body + "_morecolumns_temp.vot")

#"""
print 'Completed'
end0 = time.time()

print "Total runtime = ", np.round(end0 - start0, 3), "s\n"
Ejemplo n.º 6
0
        hdu_in.writeto(outfits, clobber=True)

    if options.average:
        if options.scaleint:
            print "Scaling the integrated fluxes in the catalogue downward by a direction-independent factor of " + str(
                psf_ratio)
            data['int_flux'] /= psf_ratio
        else:
            print "Scaling the peak fluxes in the catalogue upward by a direction-independent factor of " + str(
                psf_ratio)
            data['peak_flux'] *= psf_ratio
        vot = Table(data)
        # description of this votable
        vot.description = "Corrected for position-independent PSF variation"
        print "Writing to " + output
        writetoVO(vot, output)
    else:
        print "Performing direction-dependent PSF correction."
        psf_in = fits.open(psfimage)
        w = wcs.WCS(psf_in[0].header, naxis=2)

        unmara, unmadec = np.array(data['ra']).tolist(), np.array(
            data['dec']).tolist()
        rapix, decpix = w.wcs_world2pix(unmara, unmadec, 1)
        raintpix, decintpix = np.array(np.round(rapix),
                                       dtype=int), np.array(np.round(decpix),
                                                            dtype=int)
        raclip, decclip = np.clip(raintpix, 0,
                                  psf_in[0].data.shape[1] - 1), np.clip(
                                      decintpix, 0,
                                      psf_in[0].data.shape[0] - 1)
Ejemplo n.º 7
0
ands = ["a1_2.vot", "a2_3.vot", "a3_4.vot", "a4_1.vot"]
revands = ["a2_1.vot", "a3_2.vot", "a4_3.vot", "a1_4.vot"]

for amatch, rmatch in zip(ands, revands):
    output = amatch.replace(".vot", "_best.vot")
    if not os.path.exists(output):
        print "Generating " + output
        a = parse_single_table(amatch)
        r = parse_single_table(rmatch)
        data_a = a.array
        data_r = r.array
        indices_a = np.where(data_a['local_rms_1'] < data_a['local_rms_2'])
        indices_r = np.where(data_r['local_rms_1'] < data_r['local_rms_2'])
        data_x = np.ma.concatenate([data_a[indices_a], data_r[indices_r]])
        vot = Table(data_x)
        writetoVO(vot, 'temp.vot')
        # Run through tpipe and keep the right columns (i.e. none of the _2 columns)
        #        os.system('stilts tpipe in=temp.vot cmd=\'keepcols "island source background local_rms ra_str dec_str ra err_ra dec err_dec peak_flux err_peak_flux int_flux err_int_flux a err_a b err_b pa err_pa flags residual_mean residual_std uuid"\' out='+output)
        # For the older version of Aegean (no uuid)
        os.system(
            'stilts tpipe in=temp.vot cmd=\'keepcols "island source background local_rms ra_str dec_str ra err_ra dec err_dec peak_flux err_peak_flux int_flux err_int_flux a err_a b err_b pa err_pa flags residual_mean residual_std"\' out='
            + output)

# Not using XOR means we don't have to rename the columns later
# Crossmatch 1 with 2, 2 with 3, 3 with 4, 4 with 1, saving only things which DON'T overlap
if not os.path.exists('x1_2.vot'):
    os.system(
        'stilts tmatch2 matcher=skyellipse params=30 in1=' + table1 + ' in2=' +
        table2 +
        ' out=x1_2.vot values1="ra dec a b pa" values2="ra dec a b pa" ofmt=votable find=all fixcols=none join=1not2'
    )
Ejemplo n.º 8
0
    os.remove('vlssr_temp.vot')
    os.remove('vlssr_crop.vot')
    os.remove('temp_vlssr_match.vot')
    os.remove(Mmatchvot)
    os.remove(Vmatchvot)

    table = parse_single_table(outputfile)
    data = table.array
else:
    table = parse_single_table(sparse)
    data = table.array

x = data['ra']
if max(x) > 360.:
    print "RA goes higher than 360 degrees! Panic!"
    sys.exit(1)
y = data['dec']

# Downselect to unresolved sources

mask = []
# Filter out any sources where Aegean's flags weren't zero
indices = np.where((data['flags'] == 0) & (
    (data['peak_flux'] / data['local_rms']) >= options.minsnr))
mask.extend(indices[0])
mask = np.array(mask)

vot = Table(data[mask])
vot.description = "Sources selected for PSF calculation."
writetoVO(vot, outputfile)