lynx-x-ray-observatory / soxs

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

Simput Catalogue Issues in SOXS. #7

Closed benopp99 closed 2 years ago

benopp99 commented 2 years ago

Hi John- I'm trying to make a simput catalogue file that holds separate photon lists for CXB and Galforeground, like I used to do with the older SOXS (see example below).  

I think the new SOXS works with SIMPUT catalogue objects, and I'm generating separate simput files for the 2 background, but I can't seem to do the appending to simput file that I wish to hold 3 phlists (2 in addition to the original one).  

I get the following error:  

mclovin > python3 ~/pythonCode/Soxs_scripts/make_bkgds_v2.py EAGLE_halo.406.10ks.z0.01.z_simput_bkgd.fits 41 10
soxs : [WARNING  ] 2022-01-13 23:57:16,698 The 'response_path' option in the SOXS configuration is deprecated and has been replaced with 'soxs_data_dir'. Please update your configuration accordingly.
soxs : [INFO     ] 2022-01-13 23:57:30,514 Appending this source to hold_cxb_simput.fits.
Done make_point_sources_file
soxs : [INFO     ] 2022-01-13 23:57:30,609 Creating 1448383 energies from this spectrum.
soxs : [INFO     ] 2022-01-13 23:57:30,867 Finished creating energies.
soxs : [INFO     ] 2022-01-13 23:57:31,827 Appending this source to hold_Galfrgd_simput.fits.
Done make foreground file
Traceback (most recent call last):
  File "/home/extboppe/pythonCode/Soxs_scripts/make_bkgds_v2.py", line 44, in <module>
    simput.append(cxb_src)#,src_filename=simput_file)
  File "/home/extboppe/.local/lib/python3.6/site-packages/soxs/simput.py", line 273, in append
    self.src_names = np.append(self.src_names, source.name)
AttributeError: 'SimputCatalog' object has no attribute 'name'

I've tried several permutations of this and I get this confusing error.  I attach the code.  Below is what old simput files with bkgdadded look like.  I guess I have to attach my script file directly in the text here:

Thanks as always, Ben 


###########
import soxs
from soxs.background.foreground import hm_astro_bkgnd
import os 
import sys
# change these as needed, this needs to be the SIMPUT file 
# which links to the phlist file for your source
simput_prefix = "my_galaxy"

simput_file = sys.argv[1]
haloid = sys.argv[2]
exp_ksec = sys.argv[3]

# change these as needed
nH = 0.02
area = 3000.0
t_exp = (float(exp_ksec), "ks")
fov = (66.0, "arcmin") # a bit bigger than 1 degree
sky_center = [0.0, 0.0]

cxb_simput = "hold_cxb_simput.fits"
Galfrgd_simput = "hold_Galfrgd_simput.fits"

#Make the point sources

cxb_src = soxs.make_point_sources_file(cxb_simput, "pt_src", t_exp, 
                             fov, sky_center, nH=nH, 
                             area=area, prng=int(haloid), overwrite=True)

print("Done make_point_sources_file")

# Make the galactic foreground
frgnd = hm_astro_bkgnd.to_spectrum(fov) 
square1deg = soxs.FillFOVModel(sky_center[0], sky_center[1], fov)

Galfgrd_src = soxs.SimputPhotonList.from_models("frgnd", frgnd, square1deg,
                                    t_exp, area)

soxs.SimputCatalog.from_source(Galfrgd_simput, Galfgrd_src,overwrite=True) # overwrite=True)

print("Done make foreground file")

simput = soxs.SimputCatalog.from_file(simput_file)

simput.append(cxb_src)#,src_filename=simput_file,overwrite=True)
simput.append(Galfrgd_src)#,src_filename=simput_file,overwrite=True)

print("Finished appending background")
###########

death > ls -trl
total 34161
-rw-r--r-- 1 extboppe ari  6189120 Oct 15  2019 EAGLE_halo.406.10ks.z0.01.z_phlist.fits
-rw-r--r-- 1 extboppe ari    11520 Oct 15  2019 EAGLE_halo.406.10ks.z0.01.z_simput.fits
-rw-r--r-- 1 extboppe ari    11520 Nov 25  2019 EAGLE_halo.406.10ks.z0.01.z.bkgdadded_simput.fits
-rw-r--r-- 1 extboppe ari  6145920 Dec  7  2019 pt_src_phlist.fits
-rw-r--r-- 1 extboppe ari 28915200 Dec  7  2019 frgnd_phlist.fits
death > dmlsit 
death > dmlist EAGLE_halo.406.10ks.z0.01.z.bkgdadded_simput.fits 
Option (data): 
 
--------------------------------------------------------------------------------
Data for Table Block SRC_CAT
--------------------------------------------------------------------------------
 
ROW    SRC_ID     RA                   DEC                  E_MIN                E_MAX                FLUX                 SPECTRUM                                                                           IMAGE                                                                              SRC_NAME
 
     1          1                    0                    0     0.10454302742777        11.6091392239      8.810733107E-13 EAGLE_halo.406.10ks.z0.01.z_phlist.fits[PHLIST,1]                                  EAGLE_halo.406.10ks.z0.01.z_phlist.fits[PHLIST,1]                                  EAGLE_halo.406.10ks.z0.01.z                                                       
     2          2                    0                    0     0.10143975031124         9.9994520727      2.074609323E-11 pt_src_phlist.fits[PHLIST,1]                                                       pt_src_phlist.fits[PHLIST,1]                                                       pt_src                                                                            
     3          3                    0                    0     0.10000010341776         2.5109786180      1.823602435E-11 frgnd_phlist.fits[PHLIST,1]                                                        frgnd_phlist.fits[PHLIST,1]                                                        frgnd  ```                                                                   
jzuhone commented 2 years ago

Hi @benopp99,

For future reference, you can enclose a code block in two ``` pieces. I did that for your above example--but make sure to do it in the future.

See also here:

https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks

benopp99 commented 2 years ago

Hi John- Yes, I did that submission rather fast and didn't look up those quotes.

Is such an issue worth putting on the github, or should I just e-mail you directly?

Thanks, Ben

On Fri, Jan 14, 2022 at 11:50 AM John ZuHone @.***> wrote:

Hi @benopp99 https://github.com/benopp99,

For future reference, you can enclose a code block in two ``` pieces. I did that for your above example--but make sure to do it in the future.

See also here:

https://docs.github.com/en/github/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks

— Reply to this email directly, view it on GitHub https://github.com/lynx-x-ray-observatory/soxs/issues/7#issuecomment-1013372600, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMEF72LFW42KMD3W7RRWGELUWBV6XANCNFSM5L5KFOBQ . 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&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

jzuhone commented 2 years ago

@benopp99 github is better.

Your problem is here:

cxb_src = soxs.make_point_sources_file(cxb_simput, "pt_src", t_exp, 
                             fov, sky_center, nH=nH, 
                             area=area, prng=int(haloid), overwrite=True)

The returned object here is a SimputCatalog, not a SimputSource, so you can't append it later like you are trying to do. If you want to append the point sources to the catalog in simput_file, do this:

###########
import soxs
from soxs.background.foreground import hm_astro_bkgnd
import os 
import sys
# change these as needed, this needs to be the SIMPUT file 
# which links to the phlist file for your source
simput_prefix = "my_galaxy"

simput_file = sys.argv[1]
haloid = sys.argv[2]
exp_ksec = sys.argv[3]

# change these as needed
nH = 0.02
area = 3000.0
t_exp = (float(exp_ksec), "ks")
fov = (66.0, "arcmin") # a bit bigger than 1 degree
sky_center = [0.0, 0.0]

cxb_simput = "hold_cxb_simput.fits"
Galfrgd_simput = "hold_Galfrgd_simput.fits"

#Make the point sources

simput = soxs.make_point_sources_file(simput_file, "pt_src", t_exp, 
                             fov, sky_center, nH=nH, append=True, src_filename=cxb_simput,
                             area=area, prng=int(haloid), overwrite=True)

print("Done make_point_sources_file")

# Make the galactic foreground
frgnd = hm_astro_bkgnd.to_spectrum(fov) 
square1deg = soxs.FillFOVModel(sky_center[0], sky_center[1], fov)

Galfgrd_src = soxs.SimputPhotonList.from_models("frgnd", frgnd, square1deg,
                                    t_exp, area)

print("Done make foreground file")

simput.append(Galfrgd_src,src_filename=Galfrgd_simput,overwrite=True)

print("Finished appending background")
###########
benopp99 commented 2 years ago

Okay, got it. Thanks.

-Ben

On Fri, Jan 14, 2022 at 12:28 PM John ZuHone @.***> wrote:

@benopp99 https://github.com/benopp99 github is better.

Your problem is here:

cxb_src = soxs.make_point_sources_file(cxb_simput, "pt_src", t_exp, fov, sky_center, nH=nH, area=area, prng=int(haloid), overwrite=True)

The returned object here is a SimputCatalog, not a SimputSource, so you can't append it later like you are trying to do. If you want to append the point sources to the catalog in simput_file, do this:

########### import soxs from soxs.background.foreground import hm_astro_bkgnd import os import sys

change these as needed, this needs to be the SIMPUT file

which links to the phlist file for your source

simput_prefix = "my_galaxy"

simput_file = sys.argv[1] haloid = sys.argv[2] exp_ksec = sys.argv[3]

change these as needed

nH = 0.02 area = 3000.0 t_exp = (float(exp_ksec), "ks") fov = (66.0, "arcmin") # a bit bigger than 1 degree sky_center = [0.0, 0.0]

cxb_simput = "hold_cxb_simput.fits" Galfrgd_simput = "hold_Galfrgd_simput.fits"

Make the point sources

simput = soxs.make_point_sources_file(simput_file, "pt_src", t_exp, fov, sky_center, nH=nH, append=True, src_filename=cxb_simput, area=area, prng=int(haloid), overwrite=True)

print("Done make_point_sources_file")

Make the galactic foreground

frgnd = hm_astro_bkgnd.to_spectrum(fov) square1deg = soxs.FillFOVModel(sky_center[0], sky_center[1], fov)

Galfgrd_src = soxs.SimputPhotonList.from_models("frgnd", frgnd, square1deg, t_exp, area)

print("Done make foreground file")

simput.append(Galfrgd_src,src_filename=Galfrgd_simput,overwrite=True)

print("Finished appending background") ###########

— Reply to this email directly, view it on GitHub https://github.com/lynx-x-ray-observatory/soxs/issues/7#issuecomment-1013397288, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMEF72MLNQNYONBZSQBYCSDUWB2MFANCNFSM5L5KFOBQ . 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&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>