ApJdataFrames
Title
: Results of the ROTOR-program
Authors
: Grankin et al.
Data is from this paper:
http://www.aanda.org/articles/aa/full/2008/09/aa8476-07/aa8476-07.html
In [1]:
import warnings
warnings.filterwarnings("ignore")
In [2]:
import pandas as pd
In [3]:
from astropy.io import ascii, votable, misc
In [4]:
#! mkdir ../data/Grankin08
In [5]:
#! wget -q -O ../data/Grankin08/table1_orig.tex http://www.aanda.org/articles/aa/full/2008/09/aa8476-07/table1.tex
In [6]:
#! wget -q -O ../data/Grankin08/table3.tex http://www.aanda.org/articles/aa/full/2008/09/aa8476-07/table3.tex \
In [7]:
! ls ../data/Grankin08/
Ew, it's in $\LaTeX$ format!
In [8]:
#! head -n 30 ../data/Grankin08/table1.tex
In [9]:
#! cp ../data/Grankin08/table1_orig.tex ../data/Grankin08/table1_mod.tex
In [10]:
#! sed -i 's/\\farcs/./g' ../data/Grankin08/table1_mod.tex
In [11]:
names_1 = ['Name', 'HBC', 'SpT', 'JD_min_max', 'N_seasons', 'V_range', 'N_obs', 'avgB_V', 'avgV_R', 'mult', 'ref']
In [12]:
tab1 = pd.read_csv('../data/Grankin08/table1_mod.tex', sep='&',
skiprows=10, names=names_1, engine='python', skipfooter=8)
In [13]:
tab1.tail()
Out[13]:
In [14]:
tab1.to_csv('../data/Grankin08/table1.csv', index=False)
In [15]:
#! tail -n 15 ../data/Grankin08/table3.tex
In [16]:
names = ['Name', 'Epochs', 'delta_V_min', 'delta_V_max', 'HJD0-24000000', 'Period', 'Ref1', 'Ref2']
In [17]:
tab3 = pd.read_csv('../data/Grankin08/table3.tex', sep='&', comment='\\',
skiprows=10, names=names, engine='python', skipfooter=5)
In [18]:
tab3.tail()
Out[18]:
In [19]:
tab3.to_csv('../data/Grankin08/table3.csv', index=False)
Copied from Vizier and pasted into a text document...
In [20]:
#! head ../data/Grankin08/grankin08_dat_files.txt
In [21]:
#gr_dat = pd.read_csv('../data/Grankin08/grankin08_dat_files.txt', usecols=[0],
# delim_whitespace=True, names=['filename'])
Download the data:
In [22]:
import os
Only need to run this once:
for i in range(len(gr_dat)):
#for i in range(3):
fn = gr_dat.filename[i]
web_addr = 'http://vizier.cfa.harvard.edu/vizier/ftp/cats/J/A+A/479/827/phot/'
cmd = 'curl '+ web_addr + fn +' > ' + '../data/Grankin08/phot/'+fn
os.system(cmd)
print(cmd)
In [23]:
#! gzip -d ../data/Grankin08/phot/*.dat.gz
In [24]:
#gr_dat['dat_fn'] = gr_dat.filename.str[0:-3]
In [25]:
from astroquery.simbad import Simbad
In [26]:
gr_t1 = tab1
In [27]:
gr_t1['HBC_name'] = 'HBC' + gr_t1.HBC
In [28]:
gr_t1['alt_name'] = gr_t1.HBC_name
In [29]:
gr_t1.alt_name[18] = 'TAP 10'
gr_t1.alt_name[19] = 'TAP 11'
gr_t1.alt_name[20] = 'TAP 14'
In [30]:
Simbad.add_votable_fields('sptype', 'otype')
In [31]:
gr_t1['pref_name'] = ''
gr_t1['RA'] = ''
gr_t1['DEC'] = ''
gr_t1['SpT_simbad'] = ''
gr_t1['Otype_simbad'] = ''
In [32]:
N_sources = len(gr_t1)
In [33]:
for i in range(N_sources):
name = gr_t1.Name[i]
name_alt = gr_t1.alt_name[i]
result_table = Simbad.query_object(name)
try:
RA, DEC = result_table['RA'].data.data[0], result_table['DEC'].data.data[0]
SpT, Otype = result_table['SP_TYPE'].data.data[0], result_table['OTYPE'].data.data[0]
print("{} was found in Simbad.".format(name))
except TypeError:
print("Attempt 1 did not work for {}, trying HBC name: {}...".format(name, name_alt), end='')
result_table = Simbad.query_object(name_alt)
RA, DEC = result_table['RA'].data.data[0], result_table['DEC'].data.data[0]
SpT, Otype = result_table['SP_TYPE'].data.data[0], result_table['OTYPE'].data.data[0]
print(' success!')
name = name_alt
gr_t1 = gr_t1.set_value(i, 'pref_name', name)
gr_t1 = gr_t1.set_value(i, 'RA', RA)
gr_t1 = gr_t1.set_value(i, 'DEC', DEC)
gr_t1 = gr_t1.set_value(i, 'SpT_simbad', SpT.decode())
gr_t1 = gr_t1.set_value(i, 'Otype_simbad', Otype.decode())
for i in range(N_sources):
name = gr_t1.Name[i]
name_alt = gr_t1.alt_name[i]
result_table = Simbad.query_object(name)
try:
RA, DEC = result_table['RA'].data.data[0], result_table['DEC'].data.data[0]
SpT, Otype = result_table['SP_TYPE'].data.data[0], result_table['OTYPE'].data.data[0]
print("{} was found in Simbad.".format(name))
except TypeError:
print("Attempt 1 did not work for {}, trying HBC name: {}...".format(name, name_alt), end='')
result_table = Simbad.query_object(name_alt)
RA, DEC = result_table['RA'].data.data[0], result_table['DEC'].data.data[0]
SpT, Otype = result_table['SP_TYPE'].data.data[0], result_table['OTYPE'].data.data[0]
print(' success!')
name = name_alt
gr_t1 = gr_t1.set_value(i, 'pref_name', name)
gr_t1 = gr_t1.set_value(i, 'RA', RA)
gr_t1 = gr_t1.set_value(i, 'DEC', DEC)
gr_t1 = gr_t1.set_value(i, 'SpT_simbad', SpT.decode())
gr_t1 = gr_t1.set_value(i, 'Otype_simbad', Otype.decode())
In [34]:
gr_t1.tail()
Out[34]:
In [35]:
gr_t1.to_csv('../data/Grankin08/table1_plus.csv', index=False)
In [36]:
tab3.to_csv('../data/Grankin08/table3.csv', index=False)