RHESSI Command Line Snippets

 

Listed below are snippets of IDL code to do various things with the RHESSI objects.  These snippets show examples of the kinds of things that can be done.  This is by no means a complete list of options  - just samples showing some of the syntax and methods that might help you use the RHESSI data from the command line. 

In most cases, the routines/methods shown below have additional calling arguments that you can find by looking at other more complete documentation, or in the header of the routine.  The full table of RHESSI object parameters is here.

Contents:
Flare List
Observing Summary Object
Image Object
Spectrum Object
Eventlist File
Aspect Solution
Binned Eventlist
Calibrated Eventlist
Point Spread Function
Monitor Rates
 


FLARE LIST

Read flare list into structure and find flares with energies > 7000:

a = hsi_read_flarelist()
index = where (a.energy_hi[1] gt 7000.)
print,a[index].id_number

or

print, hsi_select_flare(energy_hi_range=[7001,1.e7])

flare_struct = hsi_select_flare(energy_hi_range=[7001,1.e7], /struct)    ; returns structure

Find flares that occurred between select times that have a peak countrate > 500:

flare_ids = hsi_whichflare(['2002/9/2 00:00', '2002/9/2 12:00'])
flare_str = hsi_getflare(flare_ids)
index = where (flare_str.peak_countrate gt 500)
print,flare_str[index].id_number

or

print, hsi_select_flare(peak_time_range = ['2002/9/2 00:00', '2002/9/2 12:00'], $
    peak_countrate_range=[501,1.e9])

Get array of structures for flares that were in attenuator state 3 at the peak of the flare:

flare_struct = hsi_select_flare(flag_incl='A3', /struct)

Print list of flare flags (list contains name of flag in FITS file, 2 letter code, and description):

print,hsi_flare_flag_code(/expand,/sort)
 


OBSERVING SUMMARY OBJECT

Plot observing summary rates:

obs_object = hsi_obs_summary()
obs_object -> set, obs_time_interval= $
    [' 20-feb-2002 10:56:00.000', ' 20-feb-2002 11:21:00.000']

obs_object -> plot    ; plots rates
obs_object -> plotman, /corrected    ; plots corrected rates in plotman

Plot modulation variance with night, flare flags:

obs_object -> plotman, class='mod_var', /eclipse, /flare

Notes: Set class_name keyword to 'mod_var', 'roll_period', 'roll_angle', or 'ephem', 'pointing' to plot modulation variance, roll_period, roll_angle, ephemeris, or pointing data.  You can use most of the standard plot keywords (yrange, ylog, ystyle, etc), and either plot or plotman for all of these plots, e.g.,

obs_object -> plotman, yrange=[1,200], /ylog, ystyle=1
obs_object -> plot, class='roll_period'
obs_object -> plotman, class='ephem'

Plot corrected observing summary rates and roll angle manually:

time = obs_object -> getaxis(/ut)
data = obs_object -> getdata(/corrected)
utplot, anytim(time, /ext), data.countrate[0]    ; plots lowest energy band vs time

time = obs_object -> getaxis(/ut, class='roll_angle')
data = obs_object -> getdata(class='roll_angle')
utplot, anytim(time, /ext), data.roll_angle

Print night time intervals on 20-feb-2002:

obs_object -> set, obs_time_interval=[' 20-feb-2002 00:00', ' 21-feb-2002 00:00']
changes = obs_object -> changes()
dn = changes.eclipse_flag
q = where (dn.state eq 1, nq)
for i=0,nq-1 do ptim, [dn.start_times[q[i]], dn.end_times[q[i]]]

Note: type help, dn, /struct to see names of all flags in list


IMAGE OBJECT

Single image:

image_object = hsi_image()
image_object -> set, im_time_interval = ['20-feb-2002 11:06:18', '20-feb-2002 11:06:22']
image_object -> set, im_energy_binning = [3,12]
data = image_object -> getdata()

image_object -> plotman, colortable=5
loadct,3 & image_object -> plot, xrange=[850,950], yrange=[200,300], /limb,/cbar, legend_loc=0, title='', xtitle='', ytitle='', /no_timestamp

image_object -> fitswrite, this_out_filename='hsi_image_test.fits'

Image cube with 7 time bins, 6 energy bins:

image_object -> set, im_time_interval = ['20-feb-2002 11:06:00', '20-feb-2002 11:07:00']
image_object -> set, im_time_bin = 4.
image_object -> set, im_energy_binning=[3,6,12,25,50,100,300]
image_object -> fitswrite
image_object -> plot, t_idx=3, e_idx=2        ; plot 3rd time, 2nd energy
image_object -> plotman, /choose

Read image FITS file into object:

image_object -> set, im_input_fits = 'hsi_image_test.fits'
data = image_object -> getdata()

Read image FITS file without using object:

images = hsi_image_fitsread(fitsfile='hsi_image_test.fits')

Get image x, y, time, energy axes midpoints (use /edges_2, /edges_1, /width for different formats):

xaxis = image_object -> getaxis(xaxis)
yaxis = image_object -> getaxis(/yaxis)
taxis = image_object -> getaxis(/ut)
eaxis = image_object -> getaxis(/energy)


SPECTRUM OBJECT

Set time by specifying width, and energy using code: 

spectrum_object = hsi_spectrum()
spectrum_object-> set, obs_time_interval= [' 20-feb-2002 10:56:00.000', ' 20-feb-2002 11:21:00.000']
spectrum_object-> set, sp_time_interval= .2    ; time bins are .2 seconds wide
spectrum_object-> set, seg_index_mask= [1, 0, 1, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0]    ; use front segments 1,3,4,6,8,9,
spectrum_object -> set, sp_energy_binning=1    ; energy code 1
data = spectrum_object -> getdata()

Set time and energy binning explicitly:

spectrum_object -> set, sp_time_interval = anytim(' 20-feb-2002 11:05:00.000') + findgen(100)*4.
spectrum_object-> set, sp_energy_binning = findgen( 398 ) + 3    ; 1-keV bins from 3 to 400 keV

Get midpoints of time and energy bins (use /edges_2, /edges_1, /width for different formats):

time_bins = spectrum_object -> getaxis (/ut)
energy_bins = spectrum_object -> getaxis (/energy)

Plot using spectrum object plot method:

spectrum_object -> plotman    ; plot spectrum
spectrum_object -> plot, /pl_time, /dim1_sum    ; plot time profile, summing over energy bins
spectrum_object -> plotman, /pl_spec    ;plot spectrogram

Plot flux spectrum and livetime manually:

data = spectrum_object -> getdata(sp_data_unit='flux', /sp_data_structure)     ; other options are 'counts', 'rate'
emid = spectrum_object -> getaxis(/energy)
plot, emid, data[0].flux, /xlog, /ylog, psym=10, yrange=[.001,1.]    ; first time interval only

utplot, anytim ( average(data.ut,1), /ext), data.ltime

Write spectrum and SRM FITS file:

spectrum_object-> filewrite, /buildsrm, all_simplify=0  ;full SRM, default names

Note: use /namedialog to enable widget for picking output file names and locations.  Use srmfile='xxx.fits', specfile='yyy.fits' to name files explicitly.
 


EVENTLIST FILE

Create an eventlist file:

ev_object = hsi_eventlist(obs_time_interval=
ev_object -> set, energy_band=[1800, 2200]
ev_object -> write

Use an eventlist file as input:

o = hsi_image(ev_fiename='hsi_eventlist...
o->set, im_energy_binning=[1800,2200]
image = o->getdata()
 


ASPECT SOLUTION

Get aspect solution used in image object:

aspect = image_object -> getdata(class='hsi_aspect_solution')

Create standalone aspect solution for specified time interval:

aspect_object = hsi_aspect_solution(obs_time_interval=['20-feb-2002 11:06:00', '20-feb-2002 11:07:00']


BINNED EVENTLIST

Binned eventlist returns [9,3] array of pointers. For a valid pointer (in this case [0,0]), get structure and show gaps and livetime:

be = image_object -> getdata(class='hsi_binned_eventlist)
print,  ptr_valid(be)    ;  show which pointers are valid
be00 = *be[0,0]
plot,be00.time, b.gap, yrange=[0,2]
plot,be00.time, b.livetime


CALIBRATED EVENTLIST

Calibrated eventlist returns [9,3] array of pointers.  For valid pointers,

cbe = image_object -> getdata(class='hsi_calib_eventlist')
print, ptr_valid(cbe)


POINT SPREAD FUNCTION

Get point spread function  used in CLEAN image algorithm and plot it:

image_object -> set, image_alg='clean'
psf = image_object -> getdata(class='hsi_psf')
loadct,5 & tvscl, congrid(psf,512,512)
 


MONITOR RATES

monitor_object = hsi_monitor_rate()
monitor_object ->set, obs_time_interval=$
    ['20-feb-2002 11:06:00', '20-feb-2002 11:07:00']
d=monitor_object -> getdata()

 


Kim Tolbert
Last Modified: 26 April 2005