jzuhone / pyxsim

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

Using Numpy Arrays with Pyxsim #16

Closed aditivijayan closed 5 years ago

aditivijayan commented 5 years ago

Hi John,

I am working with Miao Li (CCA) to use Pyxsim to generate mock X-ray spectra of the simulated CGM. Since we just started, we would like some help with a few basic uses of Pyxism.

1) Just to make sure that we understand the code, we would like to input Pyxsim with a dummy numpy array of density, temperature, metallicity, etc. I wonder how we can construct such an array? Could you share with us some example commands/scripts?

2) I wonder how we can extract information from PhotonLists that are generated, such as photon energies, spatial positions, etc? Again, some exemplary commands would be really helpful.

Many thanks for your help!

jzuhone commented 5 years ago

Hi @aditivijayan,

  1. There is an example using yt to load up some NumPy arrays in a uniformly gridded dataset in memory here: http://hea-www.cfa.harvard.edu/~jzuhone/pyxsim/cookbook/power_law.html

But alternatively if you want to get a feel for how it works you can download the GasSloshing dataset from http://yt-project.org/data and use it with this example:

http://hea-www.cfa.harvard.edu/~jzuhone/pyxsim/cookbook/sloshing.html

  1. PhotonList instances can be accessed like Python dictionaries, and you can access fields like this:
photons["pos"]
photons["vel"]
photons["dx"]
photons["num_photons"]
photons["energy"]

All but the last are NumPy arrays with yt units, and the last one is a list of yt NumPy arrays, each one corresponding to the energies for that particular cell.

Let me know if you have any other issues and good luck!

aditivijayan commented 5 years ago

Dear John

Thank you for the prompt reply! Both the solutions work wonderfully! Thank you!

Regards Aditi

jzuhone commented 5 years ago

Glad to hear it!