<jupyter_start><jupyter_text>Load in the attorb data and figure out which TLE row you're going to use.<jupyter_code>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)<jupyter_output>Time between TLE and time you want to check: 0<jupyter_text>Loop over the entries in the attorb file and see if the Moon moves.Good news, there's less than 3" shift now between using the positions in the attorb file and when you use the TLE to determine the position.<jupyter_code>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)<jupyter_output>317.22829907610003 deg -13.462168800770106 deg<jupyter_text>Below was just to figure out that there's a 5 second difference between time timestamps in the attorb file and the times that are actually used to report the satellite position.<jupyter_code>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
from nustar_lunar_pointing.tracking import eci2el
from datetime import timedelta
from astropy.time import Time
import astropy.units as u


position = att['Position'][0]
#print(position)
t = Time(t1+timedelta(0, 60))
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))


t1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11074516261836147, 'fraction_numerical': 0.04981473857554549, 'mean_word_length': 4.412026726057906, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '541836', 'license': 'MIT', 'n_tokens_mistral': 977, 'n_tokens_neox': 913, 'n_words': 229, 'path': 'notebooks/TLE_testing.ipynb', 'repo_name': 'bwgref/nustar_lunar_pointing', 'size': '2429'}