This repository has been archived by the owner on Mar 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Nearest_Binary.py
64 lines (49 loc) · 2.26 KB
/
Nearest_Binary.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
import numpy as np
import pandas as pd
from astropy import units as u
from astroquery.simbad import Simbad
import astropy.coordinates as coord
from astropy.coordinates import SkyCoord
Simbad.add_votable_fields('otype')
Simbad.TIMEOUT = 200
df = pd.read_csv('Hcat.csv') #Catalog of High/Low Mass Binaries
df['Flag'] = np.zeros((len(df)))
for i in range(len(df)):
if df['Object Type'][i] == 'LMXB':
df['Flag'][i] = 1
elif df['Object Type'][i] == 'HMXB':
df['Flag'][i] = 1
elif df['Object Type'][i] == 'EB*':
df['Flag'][i] = 1
elif df['Object Type'][i] == 'LPV*':
df['Flag'][i] = 1
elif df['Object Type'][i] == 'Symbiotic*':
df['Flag'][i] = 1
ra = df['ra']
dec = df['dec']
df['New_Name'] = np.zeros(len(df))
df['New_Type'] = np.zeros(len(df))
for i in range(len(df)): #If the nearest source is not a binary, match it to the nearest HMXB/LMXB within 10arcmin
if df['Flag'][i] == 0:
result_table = Simbad.query_region(coord.SkyCoord(ra[i], dec[i], unit=(u.deg, u.deg), frame='icrs'), radius='0d10m0s')
if result_table:
print(i)
for j in range(len(result_table)):
if result_table['OTYPE'][j].decode("utf-8") == 'LMXB':
df['New_Name'][i] = result_table['MAIN_ID'][j].decode("utf-8")
df['New_Type'][i] = result_table['OTYPE'][j].decode("utf-8")
break;
elif result_table['OTYPE'][j].decode("utf-8") == 'HMXB':
df['New_Name'][i] = result_table['MAIN_ID'][j].decode("utf-8")
df['New_Type'][i] = result_table['OTYPE'][j].decode("utf-8")
break;
elif result_table['OTYPE'][j].decode("utf-8") == 'LPV*':
df['New_Name'][i] = result_table['MAIN_ID'][j].decode("utf-8")
df['New_Type'][i] = result_table['OTYPE'][j].decode("utf-8")
break;
elif result_table['OTYPE'][j].decode("utf-8") == 'EB*':
df['New_Name'][i] = result_table['MAIN_ID'][j].decode("utf-8")
df['New_Type'][i] = result_table['OTYPE'][j].decode("utf-8")
break;
print(df.head())
df.to_csv('Hcat.csv', index=None)