jzuhone / pyxsim

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

Can XrayLightCone work for Illustris simulation? #10

Open tekkamanmaverick opened 6 years ago

tekkamanmaverick commented 6 years ago

Hi John, I want to use the data of Illustris to generate light cone simulations of X-rays. Could I use the XrayLightCone object to do this? If not, could you expand it to Illustris? Thank you.

jzuhone commented 6 years ago

@tekkamanmaverick sorry for the late response.

The XrayLightCone should work for Illustris--if you see any odd behavior or errors please report them.

tekkamanmaverick commented 6 years ago

As you write in your Web page, XrayLightCone only works for Enzo or Gadget-based cosmological simulations. However, Illustris is based on Arepo which is different with Enzo and Gadget. Also your tutorials don't mention Illustris. Could you expand it to Illustris? Thank you.

jzuhone commented 6 years ago

@tekkamanmaverick It does work on Illustris data (I've done it before)--the only problem is that pyXSIM wants a "smoothing length" field to determine the extent of the X-ray emission from each particle, which the Illustris TNG outputs do not have.

You could let yt define a smoothing length field for you. You would need code like this:

from yt.fields.particle_fields import add_nearest_neighbor_field

ds = yt.load("illustris_data.hdf5")

num_neighbors = 64
add_nearest_neighbor_field("PartType0", "particle_position", ds, num_neighbors)
def _smoothing_length(field, data):
    rv = data["PartType0", 'nearest_neighbor_distance_%d' % num_neighbors]
    return rv
ds.add_field(("PartType0", "smoothing_length"), sampling_type="particle",
            function=_smoothing_length, units="code_length")

# Then pyXSIM code happens afterward
tekkamanmaverick commented 6 years ago

According to your codes, XrayLightCone needs parameters for the simulation like 'Enzo_64/64.param' in Enzo which the Illustris outputs do not have. How did you make it ?

jzuhone commented 6 years ago

Hi @tekkamanmaverick, sorry for the delayed reply.

I realize now that this is a bit of a problem--one would need the original AREPO parameter file that the simulation was run with, which I don't think the Illustris folks have made available. I will make a note to see if we can find a way to make the light cones without needing to have that.

tekkamanmaverick commented 6 years ago

Thank you. I hope pyXSIM will be more powerful.

tekkamanmaverick commented 6 years ago

yt : [WARNING ] Field ('PartType0', 'smoothing_length') already exists.

jzuhone commented 6 years ago

@tekkamanmaverick, sorry, what's the context for this last comment? I've seen that warning message before but I'd need to know how you got there, i.e. what version of pyXSIM, what's your script, etc.

tekkamanmaverick commented 6 years ago

In [1]: import yt

In [2]: import pyxsim /work/share/software/miniconda2/lib/python2.7/site-packages/astropy/table/np_utils.py:19: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from . import _np_utils /work/share/software/miniconda2/lib/python2.7/site-packages/astropy/io/ascii/fastbasic.py:9: RuntimeWarning: numpy.dtype size changed, may indicate binary incompatibility. Expected 96, got 88 from . import cparser /work/share/software/miniconda2/lib/python2.7/site-packages/yt/analysis_modules/cosmological_observation/api.py:22: VisibleDeprecationWarning: Development of the LightRay module has been moved to the Trident package. This version is deprecated and will be removed from yt in a future release. See https://github.com/trident-project/trident for further information. from .light_ray.api import \

In [3]: from yt.fields.particle_fields import add_nearest_neighbor_field

In [4]: ds = yt.load('/scratch/Illustris/Illustris-3/snapdir_131/sna ...: p_131.0.hdf5') yt : [INFO ] 2018-07-31 18:02:48,584 Calculating time from 9.537e-01 to be 4.134e+17 seconds yt : [INFO ] 2018-07-31 18:02:48,585 Assuming length units are in kpc/h (comoving) yt : [INFO ] 2018-07-31 18:02:48,692 Parameters: current_time = 4.133936904150802e+17 s yt : [INFO ] 2018-07-31 18:02:48,693 Parameters: domain_dimensions = [2 2 2] yt : [INFO ] 2018-07-31 18:02:48,694 Parameters: domain_left_edge = [0. 0. 0.] yt : [INFO ] 2018-07-31 18:02:48,695 Parameters: domain_right_edge = [75000. 75000. 75000.] yt : [INFO ] 2018-07-31 18:02:48,696 Parameters: cosmological_simulation = 1 yt : [INFO ] 2018-07-31 18:02:48,696 Parameters: current_redshift = 0.04852362998180593 yt : [INFO ] 2018-07-31 18:02:48,696 Parameters: omega_lambda = 0.7274 yt : [INFO ] 2018-07-31 18:02:48,696 Parameters: omega_matter = 0.2726 yt : [INFO ] 2018-07-31 18:02:48,697 Parameters: hubble_constant = 0.704

In [5]: num_neighbors = 64

In [6]: add_nearest_neighbor_field("PartType0", "particle_position", ds, num_nei ...: ghbors) yt : [INFO ] 2018-07-31 18:03:27,867 Allocating for 2.804e+08 particles (index particle type 'all') yt : [INFO ] 2018-07-31 18:04:38,162 Identified 1.316e+07 octs /work/zhangyuning/share/software/miniconda2/lib/python2.7/site-packages/yt/units/yt_array.py:978: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result. ret = super(YTArray, self).getitem(item) /work/zhangyuning/share/software/miniconda2/lib/python2.7/site-packages/yt/fields/fluid_fields.py:201: FutureWarning: Using a non-tuple sequence for multidimensional indexing is deprecated; use arr[tuple(seq)] instead of arr[seq]. In the future this will be interpreted as an array index, arr[np.array(seq)], which will result either in an error or a different result. new_field[slice_3d] = f Out[6]: [('PartType0', 'nearest_neighbor_distance_64')]

In [7]: def _smoothing_length(field, data): ...: rv = data["PartType0", 'nearest_neighbordistance%d' % num_neighbor ...: s] ...: return rv ...:

In [8]: ds.add_field(("PartType0", "smoothing_length"), sampling_type="particle" ...: ,function=_smoothing_length, units="code_length") yt : [WARNING ] 2018-07-31 18:05:37,248 Field ('PartType0', 'smoothing_length') already exists. To override use force_override=True.

The version is 2.1.1.