jzuhone / pyxsim

Simulating X-ray observations from astrophysical sources.
http://hea-www.cfa.harvard.edu/~jzuhone/pyxsim
Other
20 stars 8 forks source link

make_source_fields returns empty with TNG clusters #59

Closed MarinePrunier closed 10 months ago

MarinePrunier commented 10 months ago

As part of my PhD project, I am creating X-ray mock observations of galaxy clusters from the Illustris TNG simulation.

I followed the example given in the "X-ray Fields for yt" section of the pyXSIM online documentation to create an emission field. The example uses the yt data : GasSloshing/sloshing_nomag2_hdf5_plt_cnt_0100 and works very well, but when I replace it with an IllustrisTNG cluster, the make_source_fields function returns empty vectors for the 4 fields (X-ray emissivity/luminosity etc.) On the other hand, the make_photons and other functions work well with Illustris TNG data.

Could you tell me if I need to adapt the code given in "X-ray Fields for yt" in some way to generate those fields with TNG data?

Thank you very much!

Code:

ds = yt.load( "cutout_%i.hdf5"%id, default_species_fields="ionized") emin = 0.1 emax = 10.0 nbins = 1000 source_model = pyxsim.CIESourceModel( "apec", emin, emax, nbins, ("gas","metallicity"), temperature_field=("gas","temperature"), emission_measure_field=("gas", "emission_measure"), ) xray_fields = source_model.make_source_fields(ds, 0.5, 7.0)

jzuhone commented 10 months ago

@MarinePrunier can you remove default_species_fields='ionized'? It's not necessary for TNG data. That may be the issue, if not, please post a link to the dataset.

MarinePrunier commented 10 months ago

Thanks a lot for your reply. I tried without default_species_fields='ionized', it still returns an empty vector for the fields.

Here is a link to the dataset along with the code I use to try to generate the fields; https://drive.google.com/drive/folders/1SEHyN29gxUYkDn2cCJhvKk0f0e5kqmfk?usp=sharing

jzuhone commented 10 months ago

@MarinePrunier sorry, I misunderstood your original question.

The issue here is that you are defining a sphere for the fields like this:

sp = ds.sphere(c, (500.0, "kpc"))

which makes sense for the sloshing dataset, but not yours, since the cutout returns a dataset with a largely empty box the center of which is the domain center of the simulation, which is most likely not where the cluster is.

You should take the center coordinates of the halo, which is provided by TNG for each one, and use that as the center of the sphere. The center coordinates of the halo from the TNG project are given in terms of code units (ckpc/h), so you can just do something like this:

c = ds.arr([pos_x, pos_y, pos_z], "code_length")
sp = ds.sphere(c, (500.0, "kpc"))

where here pos_[xyz] are simply the values of the center coordinate.

MarinePrunier commented 10 months ago

Thanks a lot! In fact my only error was that my c variable (for the cluster center coordinate) was written as a string inside the sphere definition : sp = ds.sphere('c', (500.0, "kpc")) instead of sp = ds.sphere(c, (500.0, "kpc")) So I was not centered on the cluster at all. Thank you again.

jzuhone commented 10 months ago

No problem!