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 calling user_create_ray #39

Closed hamogu closed 4 years ago

hamogu commented 4 years ago

User-compiled sources (SourceType="USER") have a function called user_create_ray which is called with a pointer to ray properties (direction, time, and energy). All ray properties used to be undefined before calling this function and the user function could return -1 for energy and time to have |marx| assign energy and time. Now, energy is initialized before user_create_ray is called, to allow user code that assigns locations based on the ray energy. With this change, marx.par must contain a valid specification for the source spectrum, since an energy will be drawn, even if the user source later assigns a different value. For backwards-compatibility, if user_create_ray sets the energy to a negative value, |marx| will assign the energy drawn before to the variable again.

closes #38