In [1]:
from nustar_pysolar import planning, io
import astropy.units as u


WARNING: AstropyDeprecationWarning: astropy.utils.compat.odict.OrderedDict is now deprecated - import OrderedDict from the collections module instead [astropy.utils.compat.odict]

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.2017_250.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 [7]:
tstart = '2017-09-11T00:00:00'
tend = '2017-09-15T00: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 [8]:
pa = planning.get_nustar_roll(tstart, 0)
print("NuSTAR Roll angle for Det0 in NE quadrant: {}".format(pa))


NuSTAR Roll angle for Det0 in NE quadrant: 23.324561616831126 deg

Set up the offset you want to use here:

The first element is the direction +WEST of the center of the Sun, the second is the offset +NORTH of the center of the Sun.

If you want multiple pointing locations you can either specify an array of offsets or do this "by hand" below.


In [9]:
offset = [1100., -400.]*u.arcsec

Loop over each orbit and correct the pointing for the same heliocentric pointing position.

Note that you may want to update the pointing for solar rotation. That's up to the user to decide and is not done here.


In [11]:
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: {}".format(midTime.isoformat()))
    print('Aim time: {} RA (deg): {} Dec (deg): {}'.format(midTime.isoformat(), sky_pos[0], sky_pos[1]))
    print("")


Orbit start: 2017-09-10T23:48:20 Orbit end: 2017-09-11T00:49:30
Aim Time: 2017-09-11T00:18:55
Aim time: 2017-09-11T00:18:55 RA (deg): 168.8444822500469 deg Dec (deg): 4.675665760939547 deg

Orbit start: 2017-09-11T01:25:00 Orbit end: 2017-09-11T02:26:20
Aim Time: 2017-09-11T01:55:40
Aim time: 2017-09-11T01:55:40 RA (deg): 168.90482172609111 deg Dec (deg): 4.650220901438387 deg

Orbit start: 2017-09-11T03:01:40 Orbit end: 2017-09-11T04:03:00
Aim Time: 2017-09-11T03:32:20
Aim time: 2017-09-11T03:32:20 RA (deg): 168.96510726129736 deg Dec (deg): 4.624791714579964 deg

Orbit start: 2017-09-11T04:38:20 Orbit end: 2017-09-11T05:39:40
Aim Time: 2017-09-11T05:09:00
Aim time: 2017-09-11T05:09:00 RA (deg): 169.02539085542193 deg Dec (deg): 4.599356312960442 deg

Orbit start: 2017-09-11T06:15:00 Orbit end: 2017-09-11T07:16:20
Aim Time: 2017-09-11T06:45:40
Aim time: 2017-09-11T06:45:40 RA (deg): 169.0856725353157 deg Dec (deg): 4.573914722834457 deg

Orbit start: 2017-09-11T07:51:40 Orbit end: 2017-09-11T08:53:00
Aim Time: 2017-09-11T08:22:20
Aim time: 2017-09-11T08:22:20 RA (deg): 169.14595232776264 deg Dec (deg): 4.548466970481036 deg

Orbit start: 2017-09-11T09:28:30 Orbit end: 2017-09-11T10:29:40
Aim Time: 2017-09-11T09:59:05
Aim time: 2017-09-11T09:59:05 RA (deg): 169.2062822224168 deg Dec (deg): 4.522991136560128 deg

Orbit start: 2017-09-11T11:05:10 Orbit end: 2017-09-11T12:06:20
Aim Time: 2017-09-11T11:35:45
Aim time: 2017-09-11T11:35:45 RA (deg): 169.26655831847657 deg Dec (deg): 4.49753113344228 deg

Orbit start: 2017-09-11T12:41:50 Orbit end: 2017-09-11T13:43:00
Aim Time: 2017-09-11T13:12:25
Aim time: 2017-09-11T13:12:25 RA (deg): 169.32683260705247 deg Dec (deg): 4.472065047118643 deg

Orbit start: 2017-09-11T14:18:30 Orbit end: 2017-09-11T15:19:40
Aim Time: 2017-09-11T14:49:05
Aim time: 2017-09-11T14:49:05 RA (deg): 169.38710511464714 deg Dec (deg): 4.446592903978586 deg

Orbit start: 2017-09-11T15:55:10 Orbit end: 2017-09-11T16:56:20
Aim Time: 2017-09-11T16:25:45
Aim time: 2017-09-11T16:25:45 RA (deg): 169.44737586769475 deg Dec (deg): 4.421114730438243 deg

Orbit start: 2017-09-11T17:31:50 Orbit end: 2017-09-11T18:33:00
Aim Time: 2017-09-11T18:02:25
Aim time: 2017-09-11T18:02:25 RA (deg): 169.50764489255593 deg Dec (deg): 4.395630552942596 deg

Orbit start: 2017-09-11T19:08:30 Orbit end: 2017-09-11T20:09:40
Aim Time: 2017-09-11T19:39:05
Aim time: 2017-09-11T19:39:05 RA (deg): 169.5679122155163 deg Dec (deg): 4.370140397965842 deg

Orbit start: 2017-09-11T20:45:10 Orbit end: 2017-09-11T21:46:20
Aim Time: 2017-09-11T21:15:45
Aim time: 2017-09-11T21:15:45 RA (deg): 169.62817786278617 deg Dec (deg): 4.344644292013325 deg

Orbit start: 2017-09-11T22:21:50 Orbit end: 2017-09-11T23:23:00
Aim Time: 2017-09-11T22:52:25
Aim time: 2017-09-11T22:52:25 RA (deg): 169.68844186050165 deg Dec (deg): 4.319142261618367 deg

Orbit start: 2017-09-11T23:58:30 Orbit end: 2017-09-12T00:59:40
Aim Time: 2017-09-12T00:29:05
Aim time: 2017-09-12T00:29:05 RA (deg): 169.74870423471913 deg Dec (deg): 4.293634333346423 deg

Orbit start: 2017-09-12T01:35:10 Orbit end: 2017-09-12T02:36:20
Aim Time: 2017-09-12T02:05:45
Aim time: 2017-09-12T02:05:45 RA (deg): 169.8089650114236 deg Dec (deg): 4.26812053379131 deg

Orbit start: 2017-09-12T03:11:50 Orbit end: 2017-09-12T04:13:00
Aim Time: 2017-09-12T03:42:25
Aim time: 2017-09-12T03:42:25 RA (deg): 169.8692242165179 deg Dec (deg): 4.24260088957969 deg

Orbit start: 2017-09-12T04:48:30 Orbit end: 2017-09-12T05:49:40
Aim Time: 2017-09-12T05:19:05
Aim time: 2017-09-12T05:19:05 RA (deg): 169.92948187583292 deg Dec (deg): 4.217075427366984 deg

Orbit start: 2017-09-12T06:25:10 Orbit end: 2017-09-12T07:26:20
Aim Time: 2017-09-12T06:55:45
Aim time: 2017-09-12T06:55:45 RA (deg): 169.9897380151151 deg Dec (deg): 4.19154417384252 deg

Orbit start: 2017-09-12T08:01:50 Orbit end: 2017-09-12T09:03:00
Aim Time: 2017-09-12T08:32:25
Aim time: 2017-09-12T08:32:25 RA (deg): 170.04999266003585 deg Dec (deg): 4.166007155725799 deg

Orbit start: 2017-09-12T09:38:30 Orbit end: 2017-09-12T10:39:40
Aim Time: 2017-09-12T10:09:05
Aim time: 2017-09-12T10:09:05 RA (deg): 170.11024583618845 deg Dec (deg): 4.140464399767831 deg

Orbit start: 2017-09-12T11:15:10 Orbit end: 2017-09-12T12:16:20
Aim Time: 2017-09-12T11:45:45
Aim time: 2017-09-12T11:45:45 RA (deg): 170.17049756908847 deg Dec (deg): 4.114915932751004 deg

Orbit start: 2017-09-12T12:51:50 Orbit end: 2017-09-12T13:53:00
Aim Time: 2017-09-12T13:22:25
Aim time: 2017-09-12T13:22:25 RA (deg): 170.23074788416437 deg Dec (deg): 4.089361781493244 deg

Orbit start: 2017-09-12T14:28:30 Orbit end: 2017-09-12T15:29:50
Aim Time: 2017-09-12T14:59:10
Aim time: 2017-09-12T14:59:10 RA (deg): 170.29104874490477 deg Dec (deg): 4.063779936090902 deg

Orbit start: 2017-09-12T16:05:10 Orbit end: 2017-09-12T17:06:30
Aim Time: 2017-09-12T16:35:50
Aim time: 2017-09-12T16:35:50 RA (deg): 170.35129629914323 deg Dec (deg): 4.038214492087479 deg

Orbit start: 2017-09-12T17:41:50 Orbit end: 2017-09-12T18:43:10
Aim Time: 2017-09-12T18:12:30
Aim time: 2017-09-12T18:12:30 RA (deg): 170.4115425113941 deg Dec (deg): 4.0126434445118555 deg

Orbit start: 2017-09-12T19:18:30 Orbit end: 2017-09-12T20:19:50
Aim Time: 2017-09-12T19:49:10
Aim time: 2017-09-12T19:49:10 RA (deg): 170.47178740676057 deg Dec (deg): 3.987066820315032 deg

Orbit start: 2017-09-12T20:55:20 Orbit end: 2017-09-12T21:56:30
Aim Time: 2017-09-12T21:25:55
Aim time: 2017-09-12T21:25:55 RA (deg): 170.5320829438566 deg Dec (deg): 3.961462590496711 deg

Orbit start: 2017-09-12T22:32:00 Orbit end: 2017-09-12T23:33:10
Aim Time: 2017-09-12T23:02:35
Aim time: 2017-09-12T23:02:35 RA (deg): 170.59232527935984 deg Dec (deg): 3.935874889294554 deg

Orbit start: 2017-09-13T00:08:40 Orbit end: 2017-09-13T01:09:50
Aim Time: 2017-09-13T00:39:15
Aim time: 2017-09-13T00:39:15 RA (deg): 170.65256637281706 deg Dec (deg): 3.9102816925508765 deg

Orbit start: 2017-09-13T01:45:20 Orbit end: 2017-09-13T02:46:30
Aim Time: 2017-09-13T02:15:55
Aim time: 2017-09-13T02:15:55 RA (deg): 170.7128062490058 deg Dec (deg): 3.8846830273527364 deg

Orbit start: 2017-09-13T03:22:00 Orbit end: 2017-09-13T04:23:10
Aim Time: 2017-09-13T03:52:35
Aim time: 2017-09-13T03:52:35 RA (deg): 170.7730449326128 deg Dec (deg): 3.859078920823773 deg

Orbit start: 2017-09-13T04:58:40 Orbit end: 2017-09-13T05:59:50
Aim Time: 2017-09-13T05:29:15
Aim time: 2017-09-13T05:29:15 RA (deg): 170.83328244824577 deg Dec (deg): 3.8334694001212903 deg

Orbit start: 2017-09-13T06:35:20 Orbit end: 2017-09-13T07:36:30
Aim Time: 2017-09-13T07:05:55
Aim time: 2017-09-13T07:05:55 RA (deg): 170.89351882042817 deg Dec (deg): 3.807854492438098 deg

Orbit start: 2017-09-13T08:12:00 Orbit end: 2017-09-13T09:13:10
Aim Time: 2017-09-13T08:42:35
Aim time: 2017-09-13T08:42:35 RA (deg): 170.95375407360126 deg Dec (deg): 3.7822342250018606 deg

Orbit start: 2017-09-13T09:48:40 Orbit end: 2017-09-13T10:49:50
Aim Time: 2017-09-13T10:19:15
Aim time: 2017-09-13T10:19:15 RA (deg): 171.0139882321224 deg Dec (deg): 3.75660862507583 deg

Orbit start: 2017-09-13T11:25:20 Orbit end: 2017-09-13T12:26:30
Aim Time: 2017-09-13T11:55:55
Aim time: 2017-09-13T11:55:55 RA (deg): 171.07422132026522 deg Dec (deg): 3.7309777199590077 deg

Orbit start: 2017-09-13T13:02:00 Orbit end: 2017-09-13T14:03:10
Aim Time: 2017-09-13T13:32:35
Aim time: 2017-09-13T13:32:35 RA (deg): 171.13445336222037 deg Dec (deg): 3.7053415369859573 deg

Orbit start: 2017-09-13T14:38:40 Orbit end: 2017-09-13T15:39:50
Aim Time: 2017-09-13T15:09:15
Aim time: 2017-09-13T15:09:15 RA (deg): 171.19468438209447 deg Dec (deg): 3.679700103527339 deg

Orbit start: 2017-09-13T16:15:20 Orbit end: 2017-09-13T17:16:30
Aim Time: 2017-09-13T16:45:55
Aim time: 2017-09-13T16:45:55 RA (deg): 171.25491440390908 deg Dec (deg): 3.654053446990595 deg

Orbit start: 2017-09-13T17:52:00 Orbit end: 2017-09-13T18:53:10
Aim Time: 2017-09-13T18:22:35
Aim time: 2017-09-13T18:22:35 RA (deg): 171.3151434516058 deg Dec (deg): 3.628401594817846 deg

Orbit start: 2017-09-13T19:28:40 Orbit end: 2017-09-13T20:29:50
Aim Time: 2017-09-13T19:59:15
Aim time: 2017-09-13T19:59:15 RA (deg): 171.3753715490367 deg Dec (deg): 3.6027445744902167 deg

Orbit start: 2017-09-13T21:05:20 Orbit end: 2017-09-13T22:06:30
Aim Time: 2017-09-13T21:35:55
Aim time: 2017-09-13T21:35:55 RA (deg): 171.43559871997257 deg Dec (deg): 3.577082413524341 deg

Orbit start: 2017-09-13T22:42:00 Orbit end: 2017-09-13T23:43:10
Aim Time: 2017-09-13T23:12:35
Aim time: 2017-09-13T23:12:35 RA (deg): 171.49582498809883 deg Dec (deg): 3.551415139473964 deg

Orbit start: 2017-09-14T00:18:40 Orbit end: 2017-09-14T01:19:50
Aim Time: 2017-09-14T00:49:15
Aim time: 2017-09-14T00:49:15 RA (deg): 171.556050377021 deg Dec (deg): 3.5257427799295926 deg

Orbit start: 2017-09-14T01:55:20 Orbit end: 2017-09-14T02:56:30
Aim Time: 2017-09-14T02:25:55
Aim time: 2017-09-14T02:25:55 RA (deg): 171.61627491025928 deg Dec (deg): 3.5000653625181024 deg

Orbit start: 2017-09-14T03:32:00 Orbit end: 2017-09-14T04:33:20
Aim Time: 2017-09-14T04:02:40
Aim time: 2017-09-14T04:02:40 RA (deg): 171.6765505278821 deg Dec (deg): 3.474360772700875 deg

Orbit start: 2017-09-14T05:08:40 Orbit end: 2017-09-14T06:10:00
Aim Time: 2017-09-14T05:39:20
Aim time: 2017-09-14T05:39:20 RA (deg): 171.7367734192945 deg Dec (deg): 3.4486733182845675 deg

Orbit start: 2017-09-14T06:45:20 Orbit end: 2017-09-14T07:46:40
Aim Time: 2017-09-14T07:16:00
Aim time: 2017-09-14T07:16:00 RA (deg): 171.79699552511318 deg Dec (deg): 3.4229808891266287 deg

Orbit start: 2017-09-14T08:22:00 Orbit end: 2017-09-14T09:23:20
Aim Time: 2017-09-14T08:52:40
Aim time: 2017-09-14T08:52:40 RA (deg): 171.8572168685288 deg Dec (deg): 3.3972835130024457 deg

Orbit start: 2017-09-14T09:58:40 Orbit end: 2017-09-14T11:00:00
Aim Time: 2017-09-14T10:29:20
Aim time: 2017-09-14T10:29:20 RA (deg): 171.91743747265608 deg Dec (deg): 3.3715812177221207 deg

Orbit start: 2017-09-14T11:35:30 Orbit end: 2017-09-14T12:36:40
Aim Time: 2017-09-14T12:06:05
Aim time: 2017-09-14T12:06:05 RA (deg): 171.97770927392142 deg Dec (deg): 3.3458518676631885 deg

Orbit start: 2017-09-14T13:12:10 Orbit end: 2017-09-14T14:13:20
Aim Time: 2017-09-14T13:42:45
Aim time: 2017-09-14T13:42:45 RA (deg): 172.03792846790213 deg Dec (deg): 3.32013981346965 deg

Orbit start: 2017-09-14T14:48:50 Orbit end: 2017-09-14T15:50:00
Aim Time: 2017-09-14T15:19:25
Aim time: 2017-09-14T15:19:25 RA (deg): 172.09814699147296 deg Dec (deg): 3.2944229237971934 deg

Orbit start: 2017-09-14T16:25:30 Orbit end: 2017-09-14T17:26:40
Aim Time: 2017-09-14T16:56:05
Aim time: 2017-09-14T16:56:05 RA (deg): 172.15836486742774 deg Dec (deg): 3.268701226603889 deg

Orbit start: 2017-09-14T18:02:10 Orbit end: 2017-09-14T19:03:20
Aim Time: 2017-09-14T18:32:45
Aim time: 2017-09-14T18:32:45 RA (deg): 172.21858211848098 deg Dec (deg): 3.2429747498850263 deg

Orbit start: 2017-09-14T19:38:50 Orbit end: 2017-09-14T20:40:00
Aim Time: 2017-09-14T20:09:25
Aim time: 2017-09-14T20:09:25 RA (deg): 172.27879876726846 deg Dec (deg): 3.217243521672911 deg

Orbit start: 2017-09-14T21:15:30 Orbit end: 2017-09-14T22:16:40
Aim Time: 2017-09-14T21:46:05
Aim time: 2017-09-14T21:46:05 RA (deg): 172.3390148363467 deg Dec (deg): 3.1915075700373032 deg

Orbit start: 2017-09-14T22:52:10 Orbit end: 2017-09-14T23:53:20
Aim Time: 2017-09-14T23:22:45
Aim time: 2017-09-14T23:22:45 RA (deg): 172.39923034819873 deg Dec (deg): 3.1657669230832437 deg


In [12]:



Out[12]:
$[168.88111,~4.6901735] \; \mathrm{{}^{\circ}}$

Sanity check: Reproduce the 2016-07-26 pointing.

Based on the IDL version of this code, when the aim time was 2016-07-26 19:53:15.00 the NP was 8.86 degrees and the RA and Dec were 126.04630 and 19.33532 deg, respectively for an offset of +1000 arcseconds West and +150 arcseconds North of the center of the Sun.


In [8]:
aim_time = '2016-07-26T19:53:15.00'
offset = [1000, 150]*u.arcsec
sky_pos = planning.get_sky_position(aim_time, offset)
print(sky_pos)


[ 126.04053869   19.33666449] deg

In [9]:
np = planning.get_nustar_roll(aim_time, 0)
print(np)


8.865884432089102 deg