I am studying a population of galaxies and I am currently focusing on their dark matter fraction through their evolution history. I have already calculated it using the Tree function in JupyterLab in order to track the galaxies down from z=0 to higher redshifts. Now I would like to plot this dark matter fraction as a function of the redshift, but I have only been able to do it as a function of the snapshots. Therefore, I would like to know if there is a way of turning the number of snapshots into their corresponding redshifts so to make the Fdm vs. z plot by linking these two values.
Thanks in advance.
Yes it's useful to get this mapping from the snapshot headers, and save it for all subsequent uses. You should do this once per simulation, as the snapshot number<->redshift mapping can differ between simulations. For instance,
redshifts = np.zeros( max_num_snapshots, dtype='float32' )
for i in range(max_num_snapshots):
h = load_snapshot_header(basePath,i)
redshifts[i] = h['Redshift']
with h5py.File('redshifts_%s.hdf5' % simname,'w') as f:
f['redshifts'] = redshifts
When you need this mapping, you can check if the file already exists, and if so load it and use it, otherwise create it on demand.
Thank you for your help! I have another question regarding this because when I did what you told me I got the same redshift for different snapshots. Is it because, for example, redshifts with values such as 0.01, 0.1, etc, will appear only as z=0?
I am not entirely sure what you mean: each snapshot has a different redshift. The final snapshot will always have z=0 or a very small number e.g. z=1e-15.
Yes, I know each snapshot has a different corresponding redshift but, for example, when I coded this
I got this in return
I know that every snapshot between the 99th and the 50th corresponds to z's between 0 and 1, but I got z=0 plenty of times as a result instead of different values. That's why I wanted to know if my procedure was correct.
Sorry the image uploading was broken, should now be fixed. Can you try this again?
This one was the first picture:
And this one was the second one:
You should delete the line with append, this is redundant. Also I would change the empty_like to np.zeros(len(numsnap), dtype='float32') to be more explicit.
Thank you for the suggestions, I will change those things. But regarding the output, is it okay that I get, for example, z=0 for different snapshot numbers instead of getting z=0, z=0.1, z=0.2, etc?
And I have another question. Is it possible to know at which redshift did a merger occur? I am trying to see in which snapshots did each merger of every one of the considered galaxies occur, but I have not had any luck in linking the number of mergers' information with the time at which they happened.
If my idea is not clear enough, let me know and I will explain it some other way.
No, that is a bug. There is only one snapshot with z=0. Once you fix these parts of the script it should be better.
Okay, thank you very much! I will do that.