forked from vincepota-zz/VIMOSda
/
velocity_comparison.py
executable file
·126 lines (94 loc) · 4.19 KB
/
velocity_comparison.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
from pyraf import iraf
import glob
import pandas as pd
import tqdm
import numpy as np
from matplotlib.pylab import plt
from astropy import units as u
from astropy import coordinates as coords
from astropy.coordinates import SkyCoord
fmatch = pd.read_table('/Volumes/VINCE/OAC/master_adp_ugri_clean.txt', delim_whitespace = True)
fmatch = fmatch.replace((-9999.0, -8888.0), np.nan)
fmatch.index = fmatch.ID
GCs = pd.read_csv('/Volumes/VINCE/OAC/GCs_903.csv', dtype = {'ID': object}, comment = '#')
stars = pd.read_csv('/Volumes/VINCE/OAC/stars_903.csv', dtype = {'ID': object}, comment = '#')
stars.drop_duplicates(subset ='ID', inplace=True)
GCs.index = GCs.ID
stars.index = stars.ID
total = pd.concat([GCs,stars])
final = pd.concat([fmatch,total['flag']], axis = 1)
final[['ID_f11','RA_g', 'DEC_g', 'flag']].to_csv('spectro_with_flags.csv', index = False)
cols = ['RA_g','DEC_g','VREL_helio','VERR', 'u_auto', 'g_auto',
'r_auto', 'i_auto','class']
GCsToAdd = pd.DataFrame(GCs[(GCs.flag == 'g') | (GCs.flag == 'm')][cols].values,
columns = [cols])
# ----------------------------------
S_GCs = pd.read_table('/Volumes/VINCE/OAC/fxcor/SchuberthGCs.csv', sep=r'\s+').replace(99.99, np.nan)
S_GCs = S_GCs.drop_duplicates(['Rmag', 'C-R','HRV']).reset_index(drop = True)
S_Stars = pd.read_table('/Volumes/VINCE/OAC/fxcor/SchuberthStars.csv', sep=r'\s+').replace(99.99, np.nan)
S_Stars = S_Stars.drop_duplicates(['Rmag', 'C-R', 'HRV']).reset_index(drop = True)
cat1 = coords.SkyCoord(GCs['RA_g'], GCs['DEC_g'], unit=(u.degree, u.degree))
cat2 = coords.SkyCoord(S_GCs['RA'], S_GCs['DEC'], unit=(u.degree, u.degree))
index,dist2d, _ = cat1.match_to_catalog_sky(cat2)
mask = dist2d.arcsec < 0.4
new_idx = index[mask]
VIMOS = GCs.ix[mask].reset_index(drop = True)
SchuberthMatch = S_GCs.ix[new_idx].reset_index(drop = True)
print len(SchuberthMatch)
x = VIMOS['VREL_helio']
xerr = VIMOS['VERR']
y = SchuberthMatch['HRV']
yerr = SchuberthMatch['e.1']
print 'rms (VIMOS - Schuberth) GCs = ', np.std(x-y)
plt.close('all')
plt.figure(figsize=(6,6))
plt.errorbar(x, y, yerr= yerr, xerr = xerr, fmt = 'o', c ='black', label = 'Schuberth et al.')
plt.plot([-200, 2200], [-200, 2200], '--k')
plt.xlim(-200,2200)
plt.ylim(-200,2200)
x = VIMOS['r_auto']
y = SchuberthMatch['Rmag']
plt.scatter(x, y, c ='black')
# ----------------------------------
# ----------------------------------
cat1 = coords.SkyCoord(stars['RA_g'], stars['DEC_g'], unit=(u.degree, u.degree))
cat2 = coords.SkyCoord(S_Stars['RA'], S_Stars['DEC'], unit=(u.degree, u.degree))
index,dist2d, _ = cat1.match_to_catalog_sky(cat2)
mask = dist2d.arcsec < 0.4
new_idx = index[mask]
VIMOS = stars.ix[mask].reset_index(drop = True)
SchuberthMatch = S_Stars.ix[new_idx].reset_index(drop = True)
print len(SchuberthMatch)
x = VIMOS['VREL_helio']
xerr = VIMOS['VERR']
y = SchuberthMatch['HRV']
yerr = SchuberthMatch['e.1']
plt.errorbar(x, y, yerr= yerr, xerr = xerr, fmt = 'o', c ='black')
plt.plot([400, 2200], [400, 2200], '--k')
print 'rms (VIMOS - Schuberth) stars = ', np.std(x-y)
# ----------------------------------
# ----------------------------------
Bergond = pd.read_table('/Volumes/VINCE/OAC/Bergond.txt', sep=';',comment='#')
BergondGCs = Bergond[Bergond['Type'] =='gc']
BergondGCs[['RAJ2000', 'DEJ2000']].to_csv('/Volumes/VINCE/OAC/imaging/BergondGCs_RADEC.reg', index = False, sep =' ', header = None)
cat1 = coords.SkyCoord(GCs['RA_g'], GCs['DEC_g'], unit=(u.degree, u.degree))
cat2 = coords.SkyCoord(BergondGCs['RAJ2000'], BergondGCs['DEJ2000'], unit=(u.degree, u.degree))
index,dist2d, _ = cat1.match_to_catalog_sky(cat2)
mask = dist2d.arcsec < 0.3
new_idx = index[mask]
VIMOS = GCs.ix[mask].reset_index(drop = True)
BergondMatch = BergondGCs.ix[new_idx].reset_index(drop = True)
print len(BergondMatch)
x = VIMOS['VREL_helio']
xerr = VIMOS['VERR']
y = BergondMatch['HRV']
yerr = BergondMatch['e_HRV']
plt.errorbar(x, y, yerr= yerr, xerr = xerr, fmt = 'o', c ='red',label = 'Bergond et al.')
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
plt.xlabel(r'Velocity from this work [km s$^-1$ ]')
plt.ylabel(r'Velocity from the literature [km s$^-1$ ]')
plt.legend(loc = 'upper left')
plt.tight_layout()
plt.show()
print 'rms (VIMOS - Bergond) GCs = ', np.std(x-y)