In [1]:
from astropy.io.fits import getdata, getheader
from nustar_lunar_pointing.tracking import get_epoch_tle, convert_nustar_time, get_moon_j2000
In [2]:
tlefile = '../data/NusTAR.tle'
att = getdata('../data/nu60160109002A.attorb')
hdr = getheader('../data/nu60160109002A.attorb', 1)
mjdref = hdr['MJDREFI']
checktime = convert_nustar_time(att[0]['TIME'])
mindt, line1, line2 = get_epoch_tle(checktime, tlefile)
print("Time between TLE and time you want to check:", mindt)
In [21]:
from astropy.coordinates import SkyCoord
doff = []
for ind, t0 in enumerate(att['Time']):
t1 = convert_nustar_time(t0)
ra_moon1, dec_moon1 = get_moon_j2000(t1, line1, line2)
moon_sky1 = SkyCoord(ra_moon1, dec_moon1)
# position = att[ind]['Position']
# ra_moon2, dec_moon2 = get_moon_j2000(t1, line1, line2, position=position)
# moon_sky2 = SkyCoord(ra_moon2, dec_moon2)
# doff.extend([moon_sky1.separation(moon_sky2).arcsec])
if ind > 100:
break
break
print(ra_moon1, dec_moon1)
#print(ra_moon2, dec_moon2)
print(position)
In [22]:
from nustar_lunar_pointing.tracking import get_nustar_location
from numpy import sqrt
roff = []
for ind, t0 in enumerate(att['Time']):
t1 = convert_nustar_time(t0)
tle_position = get_nustar_location(t1, line1, line2)
position = att[ind]['Position']
dx = tle_position - position
dr = 0.
for val in dx:
dr += val**2.
roff.extend([sqrt(dr)])
if ind > 10:
break
break
In [24]:
from nustar_lunar_pointing.tracking import eci2el
from astropy.time import Time
import astropy.units as u
position = att['Position'][0]
#print(position)
t = Time(t1)
loc = eci2el(*tle_position*u.km,t)
print(loc.to_geodetic())
print(att['SAT_LON'][0], att['SAT_LAT'][0], att['SAT_ALT'][0]*u.km - (1*u.R_earth).to(u.km))
In [ ]: