Closed Rongjun-ANU closed 10 months ago
Hi @Rongjun-ANU ,
So I looked at your notebook, and there's a lot going on in there. In particular, I'm noticing that you appear to be redefining fields in a number of places that should exist already, like ("gas", "mass")
, and that the other issue is that you are creating a covering grid (which returns 3D NumPy arrays for fields) and re-defining field definitions for the dataset in terms of them.
Field definitions are just functions, so they need to be able to pass the data in whatever shape in comes in and do the required manipulations, preserving the shape of the arrays. Is there a particular reason you have to convert the data to 3D before using pyXSIM? Unless I am misunderstanding the use case, this should not be necessary in most circumstances.
Hi @jzuhone
[('boxlib', 'gasDensity'), ('boxlib', 'gasEnergy'), ('boxlib', 'gasInternalEnergy'), ('boxlib', 'scalar_0'), ('boxlib', 'scalar_1'), ('boxlib', 'scalar_2'), ('boxlib', 'x-GasMomentum'), ('boxlib', 'y-GasMomentum'), ('boxlib', 'z-GasMomentum')]
So that's the reason why I need to define this fields to satisfy the requirement of function make_source_fields
and make_photon
.
Here are the fields included in my data initially:
[('boxlib', 'cell_volume'),
('boxlib', 'dx'),
('boxlib', 'dy'),
('boxlib', 'dz'),
('boxlib', 'gasDensity'),
('boxlib', 'gasEnergy'),
('boxlib', 'gasInternalEnergy'),
('boxlib', 'path_element_x'),
('boxlib', 'path_element_y'),
('boxlib', 'path_element_z'),
('boxlib', 'scalar_0'),
('boxlib', 'scalar_1'),
('boxlib', 'scalar_2'),
('boxlib', 'volume'),
('boxlib', 'x'),
('boxlib', 'x-GasMomentum'),
('boxlib', 'y'),
('boxlib', 'y-GasMomentum'),
('boxlib', 'z'),
('boxlib', 'z-GasMomentum'),
('gas', 'cell_volume'),
('gas', 'dx'),
('gas', 'dy'),
('gas', 'dz'),
('gas', 'path_element_x'),
('gas', 'path_element_y'),
('gas', 'path_element_z'),
('gas', 'volume'),
('gas', 'x'),
('gas', 'y'),
('gas', 'z'),
('index', 'cell_volume'),
('index', 'cylindrical_radius'),
('index', 'cylindrical_theta'),
('index', 'cylindrical_z'),
('index', 'dx'),
('index', 'dy'),
('index', 'dz'),
('index', 'grid_indices'),
('index', 'grid_level'),
('index', 'morton_index'),
('index', 'ones'),
('index', 'ones_over_dx'),
('index', 'path_element_x'),
('index', 'path_element_y'),
('index', 'path_element_z'),
('index', 'radius'),
('index', 'spherical_phi'),
('index', 'spherical_radius'),
('index', 'spherical_theta'),
('index', 'virial_radius_fraction'),
('index', 'volume'),
('index', 'x'),
('index', 'y'),
('index', 'z'),
('index', 'zeros')]
@Rongjun-ANU can you post this dataset somewhere so I can play with it?
@Rongjun-ANU just want to double-check internalEnergy
is indeed in erg and not erg/cm**3?
Hi @jzuhone Sorry for the confusion. The original fields provided in my data are purely values without units. However, when I go to check the place where I compute the temp
(temperature), I think the unit of internalEnergy
should be erg/g
.
Also, I think I have partially solved the indexerror.
I extract some fields (density, mass, temperature, emission_measure) from original object. Then set a new yt object in a new notebook with these fields and still keep the same properties (dim:1281281024, cell size dx=2.3578125e+19, 'cm', i.e. roughly 8pc, etc.). And finally, it works!
The reason why I say I just partially solve it is that I still cannot figure out why the previous codes are not working. However, I suspect the index issue arises when I try to add fields that are supposed to exist. For example, we do have a density field called ('boxlib', 'gasDensity'), but you know it is dimensionless. Also, some functions in pyxsim require a density field named ('gas', 'density'), so I have to extract ('boxlib', 'gasDensity') and times it with the unit (g/cm^3) and add this new yt array as a derived field ('gas', 'density') in my previous ipynb. And probably, such action may cause indexerror.
@Rongjun-ANU gasInternalEnergy
cannot be erg/g because its value is too small for this system--it's more likely to be erg or erg/cm**3.
As I noted before, I would not redefine fields for this dataset using the covering grid extraction, because yt is not expecting that and it breaks a lot of things. I created a notebook that shows how to map your fields to the yt fields:
https://gist.github.com/jzuhone/26e984707be5052ec2c0409f810a91e6
Note that you get all of the fields you need to run pyXSIM in this way. pyXSIM accepts sphere, region, and disk objects from yt, but not covering grids, at least when making photons. You can use covering grids when making X-ray fields, however.
Let me know if you can make a photon list in this way, and let me know if you have any further questions.
Hi @jzuhone , thank you. I can make a photon list now.
Sorry, the previous one was closed by accident
Hi, I meet an index error when using make_photon function in pyxsim
I have loaded a yt object called ds_plt1555000; the shape is 1281281024 I used ad_plt1555000 = ds_plt1555000.all_data()
Here is the issue:
I also found that,
idxs
will change once I rerun the make_photon function. So every time I use make_photon, it generates a different list of indexes and there is always some index greater than 1048576, and this returns indexerror.Finally, Here is the link to my script: https://github.com/Rongjun-ANU/Indexerror/blob/main/Dash-Code.ipynb