Example #1
0
data=cur.fetchall()
kra=np.array([datum[0] for datum in data])
kde=np.array([datum[1] for datum in data])
kp=np.array([datum[2]*datum[3] for datum in data])
kpmp=np.array([datum[3] for datum in data])

#now we open the fit file of hihg membership stars from the Deacon&Hambly
dhf=fits.open("../DeaconHamblydata/DeaconHambly2004.HighProb.fit")
dhra=dhf[1].data.field('RAJ2000')
dhde=dhf[1].data.field('DEJ2000')
dhp=dhf[1].data.field('Prob')

mycoords=SkyCoord(kra,kde,unit='deg')
dhcoords=SkyCoord(dhra,dhde,unit='deg')

matches, dist = matchCatalog(dhcoords,mycoords,1.0,0)
print matches
pp=[]
ppm=[]
for i in matches:
	nm, na = matchCatalog(SkyCoord(np.array(kra[i]),np.array(kde[i]),unit='deg'),dhcoords,1.0,0)
#	print nm
	if nm.size>0:
		pp=pp+[(kp[i],dhp[nm])]
		ppm=ppm+[(kpmp[i],dhp[nm])]
		outfiel.write("kra{0}\tkde{1}\thgra{2}\tdhde{3}\tkp{4}\tdhp{5}\n".format(kra[i],kde[i],dhra[nm],dhde[nm],kp[i],dhp[nm]))
print len(pp)
kpp=[i[0] for i in ppm]
dhpp=[i[1] for i in ppm]
plt.plot(kpp, dhpp, 'm.')
plt.show()
import pandas as pd
import numpy as np
from astropy.coordinates import SkyCoord
from matchCatalog import matchCatalog
import rpy2.robjects as ro
from rpy2.robjects import r
from rpy2.robjects import pandas2ri
from rpy2.robjects import numpy2ri
pandas2ri.activate()
numpy2ri.activate
import psycopg2
con=psycopg2.connect("dbname='stars' user='******' host='localhost'")
cur=con.cursor()
cur.execute("select ra, de from sheikhi")
sdf=pd.DataFrame(cur.fetchall(),columns=['ra','de'])
cur.execute("Select raj2000, dej2000 , knownmember from plotdata")
cdf=pd.DataFrame(cur.fetchall(),columns=['ra','de','km'])
ssk=SkyCoord(sdf['ra'],sdf['de'],unit='deg')
csk=SkyCoord(cdf['ra'],cdf['de'],unit='deg')
matches, dist = matchCatalog(csk,ssk,3.0,0)
print sum(cdf['km'].values[matches])
print len(matches)
Example #3
0
# This program looks through my catalog of known members, as well as the sheikhi catalog.  It flags the data in the sheikhi catalog that is shared so that I can avoid using it. if need be.
import psycopg2
import pandas as pd
from matchCatalog import matchCatalog
from astropy.coordinates import SkyCoord

con = psycopg2.connect("dbname='stars' user='******' host='localhost'")
cur = con.cursor()
cur.execute("select ra, de from sheikhi;")
sdf = pd.DataFrame(cur.fetchall(), columns=["ra", "de"])
cur.execute("select raj2000, dej2000 from alphaperprevmembers")
pmdf = pd.DataFrame(cur.fetchall(), columns=["ra", "de"])
ssk = SkyCoord(sdf["ra"], sdf["de"], unit="deg")
ask = SkyCoord(pmdf["ra"], pmdf["de"], unit="deg")
matches, dist = matchCatalog(ask, ssk, 3.0, 0)
om, od = matchCatalog(ssk, ask, 3.0, 0)
print max(matches)
print max(om)
try:
    cur.execute("drop table temp")
    con.commit()
except:
    cur.close()
    con.close()
    con = psycopg2.connect("dbname='stars' user='******' host='localhost'")
    cur = con.cursor()
cur.execute("create table temp (ra double precision, de double precision);")
con.commit()
for m in matches:
    cur.execute("insert into temp (ra, de) values ({0},{1})".format(sdf["ra"][m], sdf["de"][m]))
con.commit()
Example #4
0
import psycopg2
import pandas as pd
from matchCatalog import matchCatalog
from astropy.coordinates import SkyCoord
con=psycopg2.connect("dbname='stars' user='******' host='localhost'")
cur=con.cursor()
cur.execute("select raj2000, dej2000 from upc where abspi<6 and abspi>8;")
udf=pd.DataFrame(cur.fetchall(),columns=['ra','de'])
cur.execute("select raj2000, dej2000 from alphaperprevmembers")
pmdf=pd.DataFrame(cur.fetchall(),columns=['ra','de'])
usc=SkyCoord(udf['ra'],udf['de'],unit='deg')
pmsc=SkyCoord(pmdf['ra'],pmdf['de'],unit='deg')
matches, dist, = matchCatalog(pmsc,usc,3.0,0)
print len(matches)
try: 
	cur.execute('drop table temp')
	con.commit()
except:
	cur.close()
	con.close()
	con=psycopg2.connect("dbname='stars' user='******' host='localhost'")
	cur=con.cursor()
cur.execute('create table temp (ra double precision, de double precision)')
cur.execute("update upc set ap=0;")
con.commit()
for i in matches:
	cur.execute("insert into temp (ra, de) values({0},{1})".format(udf['ra'][i],udf['de'][i]))
con.commit()
cur.execute("update upc set ap=1 where (raj2000, dej2000) in (select ra, de from temp)")
con.commit()
cur.execute('drop table temp')
Example #5
0
count=0
for name in imp.keys():
   cs=imp[name]
   cur.execute("select {0} from {1}".format(', '.join(cs), str(name)))
   imp[name]=pd.DataFrame(cur.fetchall(), columns=['ra', 'de'])
   count=count+len(imp[name]['ra'])
cur.execute("select ra, dec from alejandroslist where mem > 50;")
imp['alejandros']=pd.DataFrame(cur.fetchall(),columns=['ra','de'])
count=count+len(imp['alejandros']['ra'])
print 'count={0}'.format(count)
masterra=imp['sheikhi']['ra'].tolist()
masterde=imp['sheikhi']['de'].tolist()
for name in imp.keys():
   if name!='sheikhi':
      master=SkyCoord(masterra,masterde,unit='deg')
      print 'ehllo wolrd!'
      temp=SkyCoord(imp[name]['ra'],imp[name]['de'],unit='deg')
      matches, dist = matchCatalog(master,temp,30.0,0)
      print "For catalog {0} there were {1} matches out of {2} members".format(name,len(matches),len(temp))
      vals=[]
      for i in range(len(temp)):
         if i not in matches:
            vals=vals+[i]
      masterra=masterra+((imp[name]['ra'].values[vals]).tolist())
      masterde=masterde+((imp[name]['de'].values[vals]).tolist())
      
print len(masterra)
import matplotlib.pyplot as plt
plt.plot(masterra,masterde,'k.')
plt.show()
Example #6
0


import psycopg2
from matchCatalog import matchCatalog
from astropy.coordinates import SkyCoord
import pandas as pd
con=psycopg2.connect("dbname='stars' user='******' host='localhost'")
cur=con.cursor()
cur.execute("select ra, de from sheikhi")
sheikhi=pd.DataFrame(cur.fetchall(), columns=['ra','de'])
cur.execute("select raj2000, dej2000, _2mkey from workingcatalog")
wc=pd.DataFrame(cur.fetchall(),columns=['ra','de','key'])
shc= SkyCoord(sheikhi['ra'],sheikhi['de'],unit='deg')
wcoord=SkyCoord(wc['ra'],wc['de'],unit='deg')
matches, dist = matchCatalog(shc,wcoord,3.0,0)
print max(matches)
mm=[i for i in matches]
try:
	cur.execute("drop table temp")
except:
	cur.close()
	con.close()
	con=psycopg2.connect("dbname='stars' user='******' host='localhost'")
	cur=con.cursor()
cur.execute("create table temp (key character varying)")
con.commit()
keys=wc['key'].values[mm]
for k in keys:
	cur.execute("insert into temp (key) values (('{0}'::character varying))".format(k))
con.commit()