Chandra-MARX / marx

Chandra X-ray Observatory ray-trace simulator
http://space.mit.edu/cxc/marx/
5 stars 4 forks source link

Assign energy BEFORE user source is called #38

Closed hamogu closed 4 years ago

hamogu commented 4 years ago

suggested by @andrea-belfiore:

I was actually wondering whether there is a way to get (read-only) the value of the energy assigned externally (through the standard spectral model, say XSPEC-style).

I see one can interface directly XSPEC within the plugin and take the XSPEC model parameters as input parameters to the plugin, but it would be much easier (and flexible, as you can change the spectral model without having to write and compile a new plugin) to keep the two things (spectrum and extension) disentangled.

My impression is that the photon energy is determined only after the user plugin is called (conditionally to the *energy=-1 setting, otherwise it takes the energy from the plugin itself).

If you confirm that, then I will fall back on the above option. In which case I'll have to dig out how you encode a simple call to XSPEC as it is ordinarily done by MARX. clues about that?

hamogu commented 4 years ago

in this current structure that's not easily done, but I don't see why I should not assign an energy BEFORE user_create_ray is called. The user source is the free to overwrite that energy or not.

I'll just move this line:

https://github.com/Chandra-MARX/marx/blob/master/marx/libsrc/s-user.c#L205

before user_generate_ray is called (with some minor modifications).

I'll try to get that in before I release the next marx version (7 days from now), but I can't promise. If not, I'll be in the next release.