Simulations as a tool

Links:

Simulating RHESSI Images

RHESSI Simulation Control Parameters

Using Eventlist Files


hsi_switch, /sim
spp = [1.0, 3.0, 400.0, 2.0]
nphot = fltarr(1)
model = {gaussian_source_str}
model.amplitude = 1.0
model.xysigma = [0.001, 0.001]
model.xypos = [0.0, 0.0]

  o = hsi_eventlist(sim_ut_ref = '20-feb-2002 09:50:00')
  o -> set, sim_nbuff = 1.0e6
  o -> set, sim_spec_pars = spp
  o -> set, sim_spec_model = 'f_bpow'
  o -> set, /sim_use_spectrum
  o -> set, sim_a2d_index_mask = [0, 0, 0, 1, 0, 0, 0, 0, 0, intarr(18)]
  o -> set, sim_background = 0
  o -> set, sim_xyoffset = [910.0, 335.0]
  o -> set, sim_model = model
  o -> set, sim_energy_band = [3.0, 100.0]
  ev = o -> getdata(sim_time_range = [0.0, 4.0], /quiet)
  nphot = n_elements(ev.time)
  o -> Write, 'hsi_test.fits', time_range = [0, 0], energy_band = [0, 0]

  os = hsi_spectrum(ev_filename = 'hsi_test.fits', /quiet)
  os -> set, sp_energy_binning = 3.0+findgen(98)
  os -> set, sp_time_interval = 4.0
  os -> set, seg_index_mask = [0, 0, 0, 1, 0, 0, 0, 0, 0, intarr(9)]
  os -> set, time_range = [0, 0]
  sp = os -> getdata(xyoffset = [910.0, 335.0])
  If(sp[0] eq -1 or total(sp) eq 0) Then message, 'Bad spectrum'
  os -> filewrite, /fits, /build, srmfile = srmfile, simplify = 0, $
    specfile = specfile, srmatrix = srmatrix, _extra = _extra

  tr = o -> get(/sim_ut_ref) + [0.0, 4.0]
  o1 = ospex(/no_gui, /quiet)
  o1 -> set, spex_specfile = specfile
  o1 -> set, spex_drmfile = srmfile
  o1 -> set, spex_fit_time_interval = tr
  d1 = o1 -> getdata(class = 'spex_data')
  i1 = o1 -> get()              ;gives info parameters

;no background
  o1 -> set, spex_erange = [6.0, 100.0]
  o1 -> set, fit_function = 'bpow'
  o1 -> set, fit_comp_free = [1, 1, 0, 0]
  o1 -> set, spex_fit_manual = 0
  o1 -> set, mcurvefit_itmax = 25
  o1 -> set, fit_comp_param = 1.2*spp[*, j]
  o1 -> dofit
  o1 -> plot_spectrum, /show_fit
  p1 = o1 -> get(/fit_comp_param)
  p1x = p1

save, nphot, p1x, spp, file = 'simple_sim_spec.sav'

End

21-Oct-2004, jmm