lynx-x-ray-observatory / soxs

SOXS: Simulated Observations of X-ray Sources
Other
16 stars 3 forks source link

instrument_simulator stops when no photons fall on CCD, can this be changed? #5

Closed benopp99 closed 3 years ago

benopp99 commented 3 years ago

Here's an example. If I'm looping over many galactic halos, making ACIS-I observations of them, and one is a miss, I don't want the loop disrupted.

soxs : [INFO ] 2021-08-10 22:04:50,372 Scattering events with a multi_image-based PSF. soxs : [INFO ] 2021-08-10 22:04:50,860 1070 events were rejected because they do not fall on any CCD. soxs : [INFO ] 2021-08-10 22:04:50,861 Scattering energies with RMF axis-31jan18.rmf. Scattering energies : 100%|█████████████████████████████████████████████████████████████| 115/115 [00:00<00:00, 588.72it/s] soxs : [INFO ] 2021-08-10 22:04:51,059 No backgrounds will be added to this observation. soxs : [INFO ] 2021-08-10 22:04:51,060 Writing events to file IllustrisTNG.1P_27.033.1ks.z0.01.z.grp33.axis_nobg_evt.fits. soxs : [INFO ] 2021-08-10 22:04:51,097 Observation complete. soxs : [INFO ] 2021-08-10 22:04:52,548 Making observation of source in IllustrisTNG.1P_27.033.1ks.z0.01.z.grp33.acisi_nobg_evt.fits. soxs : [INFO ] 2021-08-10 22:04:52,694 Detecting events from source IllustrisTNG.1P_27.033.10ks.z0.01.z.grp33 soxs : [INFO ] 2021-08-10 22:04:52,695 Applying energy-dependent effective area from acisi_aimpt_cy0.arf. soxs : [INFO ] 2021-08-10 22:04:52,696 6 events detected. soxs : [INFO ] 2021-08-10 22:04:52,696 Pixeling events. soxs : [INFO ] 2021-08-10 22:04:52,697 Scattering events with a multi_image-based PSF. soxs : [INFO ] 2021-08-10 22:04:52,786 6 events were rejected because they do not fall on any CCD. soxs : [WARNING ] 2021-08-10 22:04:52,786 No events are within the field of view for this source!!! soxs : [WARNING ] 2021-08-10 22:04:52,787 No events from any of the sources in the catalog were detected! soxs : [INFO ] 2021-08-10 22:04:52,788 No backgrounds will be added to this observation. Traceback (most recent call last): File "test_script_4.py", line 169, in soxs.instrument_simulator(simput_file, Xray_basename + ".acisi_nobg_evt.fits", exp_time, "chandra_acisi_cy0",sky_center, overwrite=True, foreground=False, ptsrc_bkgnd=False, instr_bkgnd=False) File "/srv/conda/envs/notebook/lib/python3.7/site-packages/soxs/instrument.py", line 655, in instrument_simulator raise RuntimeError("No events were detected from source or background!!") RuntimeError: No events were detected from source or background!!

jzuhone commented 3 years ago

You could wrap the call to instrument simulator in a try...except RuntimeError as a workaround for now, but there's probably a better way to do this. Maybe a specific error that can be caught, or simply logging a warning and not writing any event file.

benopp99 commented 3 years ago

A warning would be best, because making an empty file would be helpful.

-Ben

On Tue, Aug 10, 2021 at 5:24 PM John ZuHone @.***> wrote:

You could wrap the call to instrument simulator in a try...except RuntimeError as a workaround for now, but there's probably a better way to do this. Maybe a specific error that can be caught, or simply logging a warning and not writing any event file.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lynx-x-ray-observatory/soxs/issues/5#issuecomment-896376768, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMEF72KD27LVPCQBIYNUVD3T4GYJPANCNFSM5B443YHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

jzuhone commented 3 years ago

I meant logging a warning and not writing a file. Is there anything an empty file would be useful for?

benopp99 commented 3 years ago

Well, probably not. The one case I could think of is in the case of stacking or comparing galactic halos, where there are very few to no photons that taking an empty file and adding backgrounds via other software (SIXTE) could be useful for analysis. This represents a different regime than clusters. But the more I think about it, this is mainly an ACIS-I issue and the above type analysis would be done with bigger mirrors. So, I guess it's not important.

On Tue, Aug 10, 2021 at 6:03 PM John ZuHone @.***> wrote:

I meant logging a warning and not writing a file. Is there anything an empty file would be useful for?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/lynx-x-ray-observatory/soxs/issues/5#issuecomment-896391888, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMEF72JPCSZQQBXXYHFEVGDT4G44RANCNFSM5B443YHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&utm_campaign=notification-email .

jzuhone commented 3 years ago

This is fixed in https://github.com/lynx-x-ray-observatory/soxs/commit/50450d7f4d492ec375dedc90b7338f59846260d5.