Beispiel #1
0
def read_secat(catfile, fitsfile, logfile=False, wcs=False):
  patchtable = [[] for dummy in xrange(3)]  #ra, dec, NHI
  #Must catch empty catalog file:
  try: #Call will fail if the catalog file is empty or does not have the expected format
    catalog = se_catalog(catfile, readfile=True, preserve_case=False)
  except:
    print "Warning: no clumps found. Creating empty entry."
    patchtable[0].append(0), patchtable[1].append(0)
    patchtable[2].append(0)
    return patchtable

  records = len(catalog.alphapeak_j2000)
  header, image = open_image(fitsfile)
  for n in range(records):
    a, d = catalog.alphapeak_j2000[n], catalog.deltapeak_j2000[n]
    x, y = header.wcs2pix(a, d)
    x = int(np.round(x))
    y = int(np.round(y))
    maxHI = image[y, x]
    print "a,d: ", a, d, "x,y: ", x, y, "value: ", maxHI #no offset? Verify!!
    patchtable[0].append(astCoords.decimal2hms(a, " "))
    patchtable[1].append(astCoords.decimal2dms(d, " "))
    patchtable[2].append(maxHI)
    #patchtable[3].append(0.1)    #error now calculated after calling this routine
    #print "Warning: hardcoding sNHI at 0.1"
    logdump(logfile, "{} {} {}\n".format(a, d, maxHI))

  return patchtable #calling function administrates PDRID
Beispiel #2
0
def read_data(path):
    '''
    Reads Rachel's SAMs output data
    '''
    print 'Reading from %s' % path
    print 'Coverting Johnson U, B, V, and K bands to vega system'

    h_100 = 1.0

    galfile = path + 'galphot.dat'
    galdustfile = path + 'galphotdust.dat'
    profile = path + 'galprop.dat'
    halofile = path + 'halos.dat'

    g = su.se_catalog(galfile)
    gdust = su.se_catalog(galdustfile)
    p = su.se_catalog(profile)
    h = su.se_catalog(halofile)

    print 'Found %i haloes' % len(h)
    print 'Found %i galaxies' % len(g)

    AB_vega_U = 0.729977
    AB_vega_B = -0.0934
    AB_vega_V = 0.0112
    AB_vega_K = 1.854

    g.uj = g.uj - AB_vega_U
    g.bj = g.bj - AB_vega_B
    g.vj = g.vj - AB_vega_V
    g.k = g.k - AB_vega_K

    #bulge
    g.uj_bulge = g.uj_bulge - AB_vega_U
    g.bj_bulge = g.bj_bulge - AB_vega_B
    g.vj_bulge = g.vj_bulge - AB_vega_V
    g.k_bulge = g.k_bulge - AB_vega_K

    #dusty
    gdust.uj = gdust.uj - AB_vega_U
    gdust.bj = gdust.bj - AB_vega_B
    gdust.vj = gdust.vj - AB_vega_V
    gdust.j = gdust.k - AB_vega_K

    return g, gdust, p, h
Beispiel #3
0
def read_data(path):
    '''
    Reads Rachel's SAMs output data
    '''
    print 'Reading from %s' % path
    print 'Coverting Johnson U, B, V, and K bands to vega system'

    h_100 = 1.0

    galfile = path + 'galphot.dat'
    galdustfile = path + 'galphotdust.dat'
    profile = path + 'galprop.dat'
    halofile = path + 'halos.dat'

    g = su.se_catalog(galfile)
    gdust = su.se_catalog(galdustfile)
    p = su.se_catalog(profile)
    h = su.se_catalog(halofile)
    
    print 'Found %i haloes' % len(h)
    print 'Found %i galaxies' % len(g)

    AB_vega_U = 0.729977
    AB_vega_B = -0.0934
    AB_vega_V = 0.0112
    AB_vega_K = 1.854

    g.uj = g.uj - AB_vega_U
    g.bj = g.bj - AB_vega_B
    g.vj = g.vj - AB_vega_V
    g.k = g.k - AB_vega_K

    #bulge
    g.uj_bulge = g.uj_bulge - AB_vega_U
    g.bj_bulge = g.bj_bulge - AB_vega_B
    g.vj_bulge = g.vj_bulge - AB_vega_V
    g.k_bulge = g.k_bulge - AB_vega_K

    #dusty
    gdust.uj = gdust.uj - AB_vega_U
    gdust.bj = gdust.bj - AB_vega_B
    gdust.vj = gdust.vj - AB_vega_V
    gdust.j = gdust.k - AB_vega_K
    
    return g, gdust, p, h
Beispiel #4
0
        if "FIR.dat" in file:
            start = "create table FIR "
            ins = "insert into FIR values ("
            for x in range(len(formats)):
                ins += "?,"
            ins = ins[:-1] + ")"

        sql_create_string = make_sql_string(columns, formats, start)

        c = conn.cursor()

        # Create table
        c.execute(sql_create_string)

        # read data using sextutils
        data = su.se_catalog(file)

        # insert data
        # for t in data._colentries:
        #    c.execute(ins, t)
        # this can be done faster
        c.executemany(ins, data._colentries)

        # create index to make searching faster
        if "halos.dat" in file:
            c.execute("""CREATE UNIQUE INDEX %s_ids on %s (halo_id)""" % (file[:-4], file[:-4]))
        else:
            c.execute("""CREATE UNIQUE INDEX %s_ids on %s (halo_id, gal_id)""" % (file[:-4], file[:-4]))

        # Save (commit) the changes
        conn.commit()
Beispiel #5
0
        if 'FIR.dat' in file:
            start = 'create table FIR '
            ins = 'insert into FIR values ('
            for x in range(len(formats)):
                ins += '?,'
            ins = ins[:-1] + ')'
            
        sql_create_string = make_sql_string(columns, formats, start)

        c = conn.cursor()

        #Create table
        c.execute(sql_create_string)

        #read data using sextutils
        data = su.se_catalog(file)

        #insert data
        #for t in data._colentries:
        #    c.execute(ins, t)
        #this can be done faster
        c.executemany(ins, data._colentries)
        
        #create index to make searching faster
        if 'halos.dat' in file:
            c.execute('''CREATE UNIQUE INDEX %s_ids on %s (halo_id)''' % (file[:-4], file[:-4]))
        else:
            c.execute('''CREATE UNIQUE INDEX %s_ids on %s (halo_id, gal_id)''' % (file[:-4], file[:-4]))

        # Save (commit) the changes
        conn.commit()
Beispiel #6
0
from matplotlib import cm
from matplotlib.patches import Circle


#command line arguments
fits = sys.argv[1]
cat = sys.argv[2]

rad = 5
log = True

#fits file data
data = PF.getdata(fits)

#sextractor catalogue data
cat_data = su.se_catalog(cat)

#min and max
min = N.min(data)
max = N.max(data)

#make plot
P.figure(figsize=(12,12))
ax = P.subplot(111)
bb = P.gca()

if log:
    ax.imshow(N.log10(data), origin = 'lower', 
              interpolation = None,
              vmin = min*1.05,
              vmax = N.log10(max)*.9,