Snapshots and redshifts

Elisa Tau
  • 6 Feb '21

Hello!

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.
Kind regards,
Elisa.

Dylan Nelson
  • 7 Feb '21

Hello Elisa,

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' )
redshifts.fill(np.nan)

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.

Elisa Tau
  • 10 Feb '21

Dylan,

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?

Dylan Nelson
  • 11 Feb '21

Hi Elisa,

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.

Elisa Tau
  • 5
  • 12 Feb '21

Hi Dylan,

Yes, I know each snapshot has a different corresponding redshift but, for example, when I coded this

uploading Captura de pantalla_2021-02-12_14-10-18.png

I got this in return

uploading Captura de pantalla_2021-02-12_14-10-57.png

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.

Dylan Nelson
  • 15 Feb '21

Hi Elisa,

Sorry the image uploading was broken, should now be fixed. Can you try this again?

Elisa Tau
  • 1
  • 15 Feb '21

Sure!
This one was the first picture:

Captura de pantalla_2021-02-12_14-10-18.png

And this one was the second one:

Captura de pantalla_2021-02-12_14-10-57.png

Dylan Nelson
  • 15 Feb '21

Hi Elisa,

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.

Elisa Tau
  • 1
  • 15 Feb '21

Hi Dylan,

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.

Thanks!

Dylan Nelson
  • 15 Feb '21

Hi Elisa,

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.

Elisa Tau
  • 15 Feb '21

Okay, thank you very much! I will do that.

  • Page 1 of 1