In [1]:
from nustar_pysolar import planning, io
import astropy.units as u
import warnings
warnings.filterwarnings('ignore')
from astropy.coordinates import SkyCoord

Download the list of occultation periods from the MOC at Berkeley.

Note that the occultation periods typically only are stored at Berkeley for the future and not for the past. So this is only really useful for observation planning.


In [2]:
fname = io.download_occultation_times(outdir='../data/')
print(fname)


../data/NUSTAR.2019_240.SHADOW_ANALYSIS.txt

Download the NuSTAR TLE archive.

This contains every two-line element (TLE) that we've received for the whole mission. We'll expand on how to use this later.

The times, line1, and line2 elements are now the TLE elements for each epoch.


In [3]:
tlefile = io.download_tle(outdir='../data')
print(tlefile)
times, line1, line2 = io.read_tle_file(tlefile)


../data/NuSTAR.tle

Here is where we define the observing window that we want to use.

Note that tstart and tend must be in the future otherwise you won't find any occultation times and sunlight_periods will return an error.


In [4]:
tstart = '2019-09-01T22:00:00'
tend = '2019-09-02T24:00:00'
orbits = planning.sunlight_periods(fname, tstart, tend)

We want to know how to orient NuSTAR for the Sun.

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).

This is what you tell the SOC you want the "Sky PA angle" to be.


In [5]:
tcheck = '2019-09-02T04:00:00'
pa = planning.get_nustar_roll(tcheck, 0)
print(tcheck)
print("NuSTAR Roll angle for Det0 in NE quadrant: {}".format(pa))


2019-09-02T04:00:00
NuSTAR Roll angle for Det0 in NE quadrant: 21.249277506860864 deg

In [6]:
orbits


Out[6]:
[[datetime.datetime(2019, 9, 1, 22, 16, 40),
  datetime.datetime(2019, 9, 1, 23, 18, 10)],
 [datetime.datetime(2019, 9, 1, 23, 53, 20),
  datetime.datetime(2019, 9, 2, 0, 54, 50)],
 [datetime.datetime(2019, 9, 2, 1, 30),
  datetime.datetime(2019, 9, 2, 2, 31, 30)],
 [datetime.datetime(2019, 9, 2, 3, 6, 30),
  datetime.datetime(2019, 9, 2, 4, 8, 10)],
 [datetime.datetime(2019, 9, 2, 4, 43, 10),
  datetime.datetime(2019, 9, 2, 5, 44, 50)],
 [datetime.datetime(2019, 9, 2, 6, 19, 50),
  datetime.datetime(2019, 9, 2, 7, 21, 30)],
 [datetime.datetime(2019, 9, 2, 7, 56, 30),
  datetime.datetime(2019, 9, 2, 8, 58)],
 [datetime.datetime(2019, 9, 2, 9, 33, 10),
  datetime.datetime(2019, 9, 2, 10, 34, 40)],
 [datetime.datetime(2019, 9, 2, 11, 9, 50),
  datetime.datetime(2019, 9, 2, 12, 11, 20)],
 [datetime.datetime(2019, 9, 2, 12, 46, 30),
  datetime.datetime(2019, 9, 2, 13, 48)],
 [datetime.datetime(2019, 9, 2, 14, 23, 10),
  datetime.datetime(2019, 9, 2, 15, 24, 40)],
 [datetime.datetime(2019, 9, 2, 15, 59, 50),
  datetime.datetime(2019, 9, 2, 17, 1, 20)],
 [datetime.datetime(2019, 9, 2, 17, 36, 30),
  datetime.datetime(2019, 9, 2, 18, 38)],
 [datetime.datetime(2019, 9, 2, 19, 13, 10),
  datetime.datetime(2019, 9, 2, 20, 14, 40)],
 [datetime.datetime(2019, 9, 2, 20, 49, 50),
  datetime.datetime(2019, 9, 2, 21, 51, 20)],
 [datetime.datetime(2019, 9, 2, 22, 26, 20),
  datetime.datetime(2019, 9, 2, 23, 28)]]

In [7]:
# Pointing locations for solar center:
orbit_ind = 0
for di in range(9):
    orbit_ind += 1
    this_orbit = orbits[orbit_ind].copy()

    offset = [0, 0]*u.arcsec
    midTime = (0.5*(this_orbit[1] - this_orbit[0]) + this_orbit[0])
    sky_pos = planning.get_skyfield_position(midTime, offset, load_path='../data', parallax_correction=True)
    print("Orbit {} start: {} Orbit end: {}".format(orbit_ind, this_orbit[0].isoformat(), this_orbit[1].isoformat()))
    print('Aim time: {} RA (deg): {} Dec (deg): {}'.format(midTime.isoformat(), sky_pos[0], sky_pos[1]))
    print("")


Orbit 1 start: 2019-09-01T23:53:20 Orbit end: 2019-09-02T00:54:50
Aim time: 2019-09-02T00:24:05 RA (deg): 160.60374498885943 deg Dec (deg): 8.19314996408991 deg

Orbit 2 start: 2019-09-02T01:30:00 Orbit end: 2019-09-02T02:31:30
Aim time: 2019-09-02T02:00:45 RA (deg): 160.664592474608 deg Dec (deg): 8.168764947095454 deg

Orbit 3 start: 2019-09-02T03:06:30 Orbit end: 2019-09-02T04:08:10
Aim time: 2019-09-02T03:37:20 RA (deg): 160.72539621619288 deg Dec (deg): 8.14439213327861 deg

Orbit 4 start: 2019-09-02T04:43:10 Orbit end: 2019-09-02T05:44:50
Aim time: 2019-09-02T05:14:00 RA (deg): 160.786232214513 deg Dec (deg): 8.119987505541445 deg

Orbit 5 start: 2019-09-02T06:19:50 Orbit end: 2019-09-02T07:21:30
Aim time: 2019-09-02T06:50:40 RA (deg): 160.84706249285418 deg Dec (deg): 8.09557310525118 deg

Orbit 6 start: 2019-09-02T07:56:30 Orbit end: 2019-09-02T08:58:00
Aim time: 2019-09-02T08:27:15 RA (deg): 160.90784908932807 deg Dec (deg): 8.07117104598068 deg

Orbit 7 start: 2019-09-02T09:33:10 Orbit end: 2019-09-02T10:34:40
Aim time: 2019-09-02T10:03:55 RA (deg): 160.96866798389712 deg Dec (deg): 8.046737210051205 deg

Orbit 8 start: 2019-09-02T11:09:50 Orbit end: 2019-09-02T12:11:20
Aim time: 2019-09-02T11:40:35 RA (deg): 161.02948121105345 deg Dec (deg): 8.022293689111295 deg

Orbit 9 start: 2019-09-02T12:46:30 Orbit end: 2019-09-02T13:48:00
Aim time: 2019-09-02T13:17:15 RA (deg): 161.0902887884872 deg Dec (deg): 7.997840512407558 deg

This is where you actually make the Mosaic for Orbit 4


In [8]:
# Just use the first orbit...or choose one. This may download a ton of deltat.preds, which is a known 
# bug to be fixed.
orbit = orbits[4].copy()
print(orbit)
#...adjust the index above to get the correct orbit. Then uncomment below.

planning.make_mosaic(orbit, make_regions=True, outfile='orbit4_mosaic.txt', write_output=True)


[datetime.datetime(2019, 9, 2, 4, 43, 10), datetime.datetime(2019, 9, 2, 5, 44, 50)]
Orbit start: 2019-09-02T04:43:10 Orbit end: 2019-09-02T05:44:50
('Dwell per position:', 148.0)

NuSTAR Roll Angle to get roll relative to Sun of 0.00 is 21.26 deg
Step of FOV PA direction is 111.26 deg


In [ ]: