Skip to content

Commit

Permalink
Merge pull request #52 from bwgref/feature-mosaics
Browse files Browse the repository at this point in the history
Mosaic planning scripts now in planning.py
  • Loading branch information
bwgref authored Sep 25, 2018
2 parents 3619c50 + 03dc5cd commit a0de064
Show file tree
Hide file tree
Showing 6 changed files with 1,701 additions and 220 deletions.
257 changes: 257 additions & 0 deletions notebooks/Mosaic 20180928.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,257 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from nustar_pysolar import planning, io\n",
"import astropy.units as u\n",
"import warnings\n",
"warnings.filterwarnings('ignore')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Download the list of occultation periods from the MOC at Berkeley.\n",
"\n",
"## 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."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"../data/NUSTAR.2018_267.SHADOW_ANALYSIS.txt\n"
]
}
],
"source": [
"fname = io.download_occultation_times(outdir='../data/')\n",
"print(fname)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Download the NuSTAR TLE archive.\n",
"\n",
"This contains every two-line element (TLE) that we've received for the whole mission. We'll expand on how to use this later.\n",
"\n",
"The `times`, `line1`, and `line2` elements are now the TLE elements for each epoch."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"../data/NuSTAR.tle\n"
]
}
],
"source": [
"tlefile = io.download_tle(outdir='../data')\n",
"print(tlefile)\n",
"times, line1, line2 = io.read_tle_file(tlefile)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Here is where we define the observing window that we want to use.\n",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"tstart = '2018-09-27T12:00:00'\n",
"tend = '2018-09-29T12:10:00'\n",
"orbits = planning.sunlight_periods(fname, tstart, tend)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# We want to know how to orient NuSTAR for the Sun.\n",
"\n",
"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).\n",
"\n",
"### This is what you tell the SOC you want the \"Sky PA angle\" to be."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"pa = planning.get_nustar_roll(tstart, 0)\n",
"print(\"NuSTAR Roll angle for Det0 in NE quadrant: {}\".format(pa))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Set up the offset you want to use here:\n",
"\n",
"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.\n",
"\n",
"If you want multiple pointing locations you can either specify an array of offsets or do this \"by hand\" below."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"offset = [0., 0.]*u.arcsec"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Loop over each orbit and correct the pointing for the same heliocentric pointing position.\n",
"\n",
"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."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [],
"source": [
"for ind, orbit in enumerate(orbits):\n",
" midTime = (0.5*(orbit[1] - orbit[0]) + orbit[0])\n",
" sky_pos = planning.get_skyfield_position(midTime, offset, parallax_correction=True)\n",
" print(\"Orbit: {}\".format(ind))\n",
" print(\"Orbit start: {} Orbit end: {}\".format(orbit[0].isoformat(), orbit[1].isoformat()))\n",
" print('Aim time: {} RA (deg): {} Dec (deg): {}'.format(midTime.isoformat(), sky_pos[0], sky_pos[1]))\n",
" print(\"\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# This is where you actually make the Mosaic"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"('Step PA', <Quantity 115.66547856 deg>)\n",
"Orbit start: 2018-09-27T11:47:30 Orbit end: 2018-09-27T12:48:50\n",
"('Dwell per position:', datetime.timedelta(0, 147, 200000))\n",
"\n",
"NuSTAR Roll Angle to get DET0 in top right 25.67 deg\n",
"\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"[#################################] 100% deltat.data\n",
"[#################################] 100% Leap_Second.dat\n"
]
}
],
"source": [
"# Just use the first orbit...or choose one. This may download a ton of deltat.preds, which is a known \n",
"# bug to be fixed.\n",
"\n",
"orbit = orbits[0]\n",
"planning.make_mosaic(orbits[0], write_output=True, make_regions=True)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [default]",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading

0 comments on commit a0de064

Please sign in to comment.