Note that as of nustardas verion 1.6.0 you can now set the "runsplitsc" keyword to automatically split the CHU combinations for mode06 into separate data files.
These files will be stored in the event_cl output directory and have filenames like: nu20201001001A06_chu2_N_cl.evt
Use the Observation Report Notebook example to see how to do this.
Load the python libraries that we're going to use:
In [1]:
import sys
from os.path import *
import os
# For loading the NuSTAR data
from astropy.io import fits
# Load the NuSTAR python libraries
from nustar_pysolar import convert, utils
In [2]:
#infile = '/Users/bwgref/science/solar/july_2016/data/20201002001/event_cl/nu20201002001B06_chu3_N_cl.evt'
infile = '/Users/bwgref/science/solar/data/Sol_16208/20201002001/event_cl/nu20201002001B06_chu3_N_cl.evt'
hdulist = fits.open(infile)
evtdata = hdulist[1].data
hdr = hdulist[1].header
hdulist.close()
Variation on what we did to setup the pointing.
Note that this can take a little bit of time to run (~a minute or two).
The important optin here is how frequently one wants to recompute the position of the Sun. The default is once every 5 seconds.
Note that this can take a while (~minutes), so I recommend saving the output as a new FITS file (below).
In [ ]:
reload(convert)
(newdata, newhdr) = convert.to_solar(evtdata, hdr)
In [ ]:
# # Make the new filename:
(sfile, ext)=splitext(infile)
outfile=sfile+'_sunpos.evt'
# Remove output file if necessary
if isfile(outfile):
print(outfile, 'exists! Removing old version...')
os.remove(outfile)
fits.writeto(outfile, newdata, newhdr)
In [3]:
convert.convert_file(infile)
In [ ]: