In [1]:
from nustar_pysolar import planning, io
from imp import reload
reload(planning)
import astropy.units as u
In [2]:
fname = io.download_occultation_times(outdir='../data/')
print(fname)
In [3]:
tlefile = io.download_tle(outdir='../data')
print(tlefile)
times, line1, line2 = io.read_tle_file(tlefile)
In [4]:
tstart = '2017-07-18T12:00:00'
tend = '2017-07-18T20:00:00'
orbits = planning.sunlight_periods(fname, tstart, tend)
We can more or less pick any angle that we want. But this angle has to be specified a little in advance so that the NuSTAR SOC can plan the "slew in" maneuvers. Below puts DET0 in the top left corner (north-east with respect to RA/Dec coordinates).
In [5]:
pa = planning.get_nustar_roll(tstart, 0)
print("NuSTAR Roll angle for Det0 in NE quadrant: {}".format(pa))
In [6]:
offset = [-190., -47.]*u.arcsec
In [7]:
from astropy.coordinates import SkyCoord
for ind, orbit in enumerate(orbits):
midTime = (0.5*(orbit[1] - orbit[0]) + orbit[0])
sky_pos = planning.get_sky_position(midTime, offset)
print("Orbit: {}".format(ind))
print("Orbit start: {} Orbit end: {}".format(orbit[0].isoformat(), orbit[1].isoformat()))
print('Aim time: {} RA (deg): {} Dec (deg): {}'.format(midTime.isoformat(), sky_pos[0], sky_pos[1]))
skyfield_pos = planning.get_skyfield_position(midTime, offset, load_path='../data')
print('SkyField Aim time: {} RA (deg): {} Dec (deg): {}'.format(midTime.isoformat(), skyfield_pos[0], skyfield_pos[1]))
skyfield_ephem = SkyCoord(skyfield_pos[0], skyfield_pos[1])
sunpy_ephem = SkyCoord(sky_pos[0], sky_pos[1])
print("")
print("Offset between SkyField and Astropy: {} arcsec".format(skyfield_ephem.separation(sunpy_ephem).arcsec))
print("")
In [16]:
from astropy.coordinates import SkyCoord
from datetime import timedelta
for ind, orbit in enumerate(orbits):
midTime = orbit[0]
while(midTime < orbit[1]):
sky_pos = planning.get_sky_position(midTime, offset)
skyfield_pos = planning.get_skyfield_position(midTime, offset, load_path='../data', parallax_correction=True)
skyfield_geo = planning.get_skyfield_position(midTime, offset, load_path='../data', parallax_correction=False)
skyfield_ephem = SkyCoord(skyfield_pos[0], skyfield_pos[1])
skyfield_geo_ephem = SkyCoord(skyfield_geo[0], skyfield_geo[1])
# sunpy_ephem = SkyCoord(sky_pos[0], sky_pos[1])
print('Offset between parallax-corrected positions and geoenctric is {} arcsec'.format(
skyfield_geo_ephem.separation(skyfield_ephem).arcsec)
)
dra, ddec = skyfield_geo_ephem.spherical_offsets_to(skyfield_ephem)
print('{0} delta-RA, {1} delta-Dec'.format(dra.to(u.arcsec), ddec.to(u.arcsec)))
print('')
midTime += timedelta(seconds=100)
break
In [ ]: