In [65]:
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import astropy.coordinates as coord
import astropy.units as u
from mpl_toolkits.mplot3d import Axes3D
from astropy.io import ascii
tbl = ascii.read('/home/glauffer/Dropbox/FURG/final_project/data/rrc_ID_RA_DEC_I.txt', guess=False, Reader=ascii.Tab)
tbl
Out[65]:
In [66]:
#convertendo RA e DEC
ra = coord.Angle(tbl['RA'], unit = u.hour)
dec = coord.Angle(tbl['DEC'], unit = u.degree)
In [67]:
#Converter RA e Dec em X e Y de acordo com o paper do Pejcha (2009)
import numpy as np
x = (ra.degree - 80.35) * np.cos(dec.degree)
y = dec.degree + 69.68
ra_dec = np.around(np.column_stack((x,y)), decimals=1) #arrendondamento para o primeiro decimal apos a virgula
print(ra_dec)
In [68]:
ext_map = np.array(np.loadtxt('/home/glauffer/Dropbox/FURG/final_project/data/extinction_map/lmcextmap.dat', skiprows=29))
x_map = np.column_stack((ext_map.T[0], ext_map.T[1]))
y_map = np.column_stack((ext_map.T[2], ext_map.T[3]))
ext = np.ones(len(ra_dec))
for i in range(len(ra_dec)):
if ra_dec[i,0]>(-4.7): # or ():
ext[i] = 0
if ra_dec[i,0]>4.9:
ext[i] = 0
if ra_dec[i,1]>(-3.4): #or
ext[i] = 0
if ra_dec[i,1]>3.2:
ext[i] = 0
else:
try:
ext[i] = ext_map[np.where((x_map.T[0] == ra_dec[i,0]) & (y_map.T[0] == ra_dec[i,1]))][0][4]
except IndexError:
ext[i] = 0
ext
Out[68]:
In [69]:
magI_correct = tbl['I'] - 1.10*ext
#tbl['I']
len(magI_correct)
Out[69]:
In [70]:
#load CE periods
#ce_p = np.array(np.loadtxt('/home/glauffer/Dropbox/FURG/final_project/data/rrlyr_C_CEperiod.txt',dtype = float, usecols = 1))
ce_p = ascii.read('/home/glauffer/Dropbox/FURG/final_project/data/rrlyr_C_CEperiod.txt', guess=False, Reader=ascii.Tab)
len(ce_p['CE_p'])
Out[70]:
In [71]:
A = np.column_stack((np.log(ce_p['CE_p']), np.ones_like(ce_p['CE_p'])))
x, res, rank, s = np.linalg.lstsq(A,magI_correct)
print('m - A= ', x[0], '*log P + ', x[1])
In [72]:
plt.plot(np.log(ce_p['CE_p']), magI_correct, 'ro', ms=0.5)
plt.plot(np.log(ce_p['CE_p']), x[0]*np.log(ce_p['CE_p']) + x[1], 'r-', label='m - A= %f*log P +%f'%(x[0],x[1]))
plt.gca().invert_yaxis()
plt.legend()
#plt.xlim(-2.0,0)
Out[72]:
In [73]:
#calculando o modulo de distancia
u = magI_correct - x[0]*np.log(ce_p['CE_p'])-x[1]
u
Out[73]:
In [74]:
#passando para distancia -> r = 10**(0.2*(u+5))
r = np.zeros(len(u))
r = 10**(0.2*u+0.2*5)#+0.2*1.10*ext)
#sendo a distancia media 50 kpc -> r_lmc = r+50
r_lmc = np.zeros(len(r))
r_lmc = r + 50e3
r_lmc
Out[74]:
In [75]:
#plot das coordenadas RA e DEC
plt.plot(ra.degree, dec.degree, 'bo', ms=1.)
plt.plot(np.mean(ra.degree), np.mean(dec.degree), 'go')
print(np.mean(ra.degree), np.mean(dec.degree))
In [76]:
#Calculando as coordenadas x, y, z
r_lmc_0 = 50e3
ra_0 = np.mean(ra.radian)
dec_0 = np.mean(dec.radian)
x = -r_lmc * np.sin(ra.radian - ra_0) * np.cos(dec.radian)
y = r_lmc * np.sin(dec.radian)*np.cos(dec_0) - r_lmc * np.sin(dec_0) * np.cos(ra.radian - ra_0) * np.cos(dec.radian)
z = r_lmc_0 - r_lmc * np.sin(dec.radian) * np.sin(dec_0) - r_lmc * np.cos(dec_0)*np.cos(ra.radian) - ra_0 * np.cos(dec.radian)
In [78]:
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.plot(x, y, z, 'ro' ,ms=.5)
Out[78]:
In [77]: