Simulating Images

From RHESSI Wiki

Revision as of 22:47, 5 November 2008 by Schriste (Talk | contribs)
Jump to: navigation, search

This document gives some examples of how to simulate RHESSI images and eventlist files. The control parameters used are documented in the simulation control document . Read about eventlist files in Using Eventlist Files Note that it is not ncessary to create an eventlist file in order to do a simulation; you are still able to simulate images directly using the image object, and all of the simulation control parameters documented in the simulation control document can still be used directly from the hsi_image object. You do need to use the eventlist object if you want to save the data. The old method of using simulated telemetry packets, via the routines HSI_SIM_FLARE and HSI_SIM_FILE, is obsolete. The pre-launch simulated data files are obsolete; the packet reader does not read these files correctly any more.

Simple Simulation

Here is a simple example. First, call hsi_switch and set /sim,/aspect_sim

hsi_switch, /sim, /aspect_sim

Then, create the object, if you want to save the data in a file, create an hsi_eventlist object. If you don't want to save the data, then create an image or spectrum, or lightcurve object, depending on what you want. (Note that if you want to use a true aspect solution, and not a simulated one, you must save the eventlist in a file). You can set control parameters here or by using separate calls to that objects set method. Here we will simulate 4 seconds of data, the default, for the default source, which is a double gaussian source located at position [600.0, 200.0] but change the reference time.

o = hsi_eventlist(sim_ut_ref='2-jul-2003 02:20:00')

The getdata method returns the simulated eventlist.

ev = o -> getdata(sim_xyoffset = [600.0, 200.0])

To save the data, use the write method, with time_range=[0,0], energy_band=[0,0] to insure that all of the data is written to the file:

o -> Write, 'hsi_test.fits', time_range=[0, 0], energy_band=[0, 0]

To recover the image, or spectrum, create the object, set the filename with the ev_filename control parameter, and use getdata():

img_obj = hsi_image(ev_filename = 'hsi_test.fits')
image = img_obj -> getdata(xyoffset = [600.0, 200.0])

Note that we set the xyoffset in the image object. This is always necessary when using simulated data, otherwise the software will set the xyoffset to the nearest flare value.

Note also that you never want to set any sim_ control parameter for this image object. Setting a sim_ control parameter will cause the object to start a new simulation, even though you passed in a filename. This may change, but for now you need to be careful.

To see your image, try the plot method.

img_obj -> plot

All of the hsi_image methods and control parameters can be used as usual. For example, if you want to use the CLEAN algorithm, just set the image_alg control parameter.

img_obj -> getdata(image_alg = 'CLEAN')

Using the true aspect solution

In the above example, we used a simulated aspect solution for the simulation and for the image. For many applications, you might want to use the actual aspect solution obtained directly from the data. Here's how to do that: First set hsi_switch, /sim, or hsi_switch, /sim, /aspect_flight, then create the object. This ensures that the hsi_eventlist object knows that it wants to simulate the data, and not look for it in the level 0 data, but the aspect solution will know that it needs to obtain the solution from the level 0 data.

hsi_switch, /sim, /aspect_flight
o = hsi_eventlist(sim_ut_ref = '2-jul-2003 02:20:00')

Next call getdata, and write the eventlist file

ev = o -> getdata()
o -> Write, 'hsi_test_1.fits', time_range = [0, 0], energy_band = [0, 0]

Getting the image back out is the same as before, but as of 15-oct-2004, you need a call to hsi_switch in order for the aspect solution to be found correctly. You also will get a bunch of error messages of the form:

 HSI_EVENTLIST::SET: You are setting simulation parameters even though you
                have not selected Simulations (via $HSI_USE_SIM).  Not
                setting parameters.

Ignore those messages. This should be fixed in the future.

Now simply make the image.

img_obj = hsi_image(ev_filename = 'hsi_test_1.fits')
image = img_obj -> getdata()

new hsi_switch

The major new development in the sim software is the ability to use the true aspect solution, instead of the original simulated aspect solution. This is controlled using the routine hsi_switch; if the call is:

hsi_switch, /sim, /aspect_sim

Then the eventlist and the aspect solution are simulated.

To use a simulated eventlist and a true aspect solution, call

hsi_switch, /sim, /aspect_flight

Or

hsi_switch, /sim

To reset to the default behavior, which is eventlist from packets, and aspect solution from packets, call:

hsi_switch, /flight, /aspect_flight

Or

hsi_switch

Note that a call to hsi_switch always resets the environment, and the default for both eventlist and aspect data is to use the flight data, i.e., from the packets. This means that if you make two calls:

hsi_switch, /sim
hsi_switch, /aspect_sim

You'll end up with a simulated aspect solution, but a non-simulated eventlist, and the programs will crash. So please be sure to pass keywords for both the aspect solution and eventlist in the hsi_switch calls.


Originally written 16-Oct-2004, jmm Imported --Schriste 21:52, 5 November 2008 (UTC)

References

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox