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

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_113.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-04-25T22:00:00'
tend = '2019-04-26T23: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]:
pa = planning.get_nustar_roll(tstart, 0)
print(tstart)
print("NuSTAR Roll angle for Det0 in NE quadrant: {}".format(pa))


2019-04-25T22:00:00
NuSTAR Roll angle for Det0 in NE quadrant: 335.02417910451334 deg

This is where you actually make the Mosaic for Orbit 1


In [6]:
# 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[0].copy()
print(orbit)
#...adjust the index above to get the correct orbit. Then uncomment below.

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


[datetime.datetime(2019, 4, 25, 22, 9, 50), datetime.datetime(2019, 4, 25, 23, 11, 40)]
Orbit start: 2019-04-25T22:09:50 Orbit end: 2019-04-25T23:11:40
('Dwell per position:', 148.4)

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

[#################################] 100% deltat.data
[#################################] 100% deltat.preds
[#################################] 100% Leap_Second.dat
[#################################] 100% de436.bsp

This is where you actually make the Mosaic for Orbit 2


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[1].copy()
print(orbit)
#...adjust the index above to get the correct orbit. Then uncomment below.

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


[datetime.datetime(2019, 4, 25, 23, 46, 30), datetime.datetime(2019, 4, 26, 0, 48, 20)]
Orbit start: 2019-04-25T23:46:30 Orbit end: 2019-04-26T00:48:20
('Dwell per position:', 148.4)

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

This is where you actually make the Mosaic for Orbit 3


In [10]:
# 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[2].copy()
print(orbit)
#...adjust the index above to get the correct orbit. Then uncomment below.

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


[datetime.datetime(2019, 4, 26, 1, 23, 10), datetime.datetime(2019, 4, 26, 2, 25)]
Orbit start: 2019-04-26T01:23:10 Orbit end: 2019-04-26T02:25:00
('Dwell per position:', 148.4)

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

This is where you actually make the Mosaic for Orbit 4


In [12]:
# 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[3].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, 4, 26, 2, 59, 50), datetime.datetime(2019, 4, 26, 4, 1, 40)]
Orbit start: 2019-04-26T02:59:50 Orbit end: 2019-04-26T04:01:40
('Dwell per position:', 148.4)

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