Tutorial & Visualisation

Get the data

Import the module:

import H5CosmoKit as ckit

You can download e.g. snapshot_090 (z = 0.00) directly within this notebook.

urls = ["https://users.flatironinstitute.org/~camels/Sims/IllustrisTNG/CV/CV_0/snapshot_090.hdf5"] # extend the list as needed
local_files = ["snapshot_090.hdf5"]

for url, local_file in zip(urls, local_files):
    ckit.download_file(url, local_file)

Density & Temperature

Now that we have the data, we can use the H5CosmoKit package to visualize density and temperature simple with preview().

path = '.'  # Path to the snaps
snapshot_numbers = [90] # list of desired snapfile numbers

ckit.preview(path, snapshot_numbers, 'gas_density')
ckit.preview(path, snapshot_numbers, 'gas_temperature')
_images/79d282af7d23fb4468ee81b2e66a3f9ffcc6a08103f50f6409038715fcd2ad1d.png _images/6375bb900fd6f06ee968ebe5eda700cd71f937cdb359b678fa18267c5ad3ee92.png

For interactive 3D visualization, you can use the preview_3d() function.

subset_size = 300000
ckit.preview_3d(path, snapshot_numbers, 'gas_density', subset_size)
- [View the 3D Density Plot](_static/Snapshot_90_at_z=0.00_gas_density.html)
subset_size = 150000
ckit.preview_3d(path, snapshot_numbers, 'gas_temperature', subset_size)

Soundspeed & Internal Energy

You can visualize the distribution of sound speed or internal energy as a raincloud plot.

ckit.plot_internalenergy_distribution(
    path='/gpfs/data/fs72085/mfo/CAMELS/CV0',
    snapshot_numbers=[32, 44, 60, 90],
    sample_size=50000
)

Raincloud Plot

In addition to visualizing these distributions, you can also fit a polynomial to the median values of the sound speed or internal energy across multiple snapshots using the functions plot_median_soundspeed_with_polynomial_fit() and plot_median_internalenergy_with_polynomial_fit().

ckit.plot_median_internalenergy_with_polynomial_fit(path, snapshot_numbers)

Polynomial Fit

Power Spectra

As power spectra analysis uses Pylians, you might experience difficulties on machines other than Linux and Mac. For more details, visit the Pylians documentation.

f_snap = './snapshot_090.hdf5'
ckit.power_ratio(f_snap)
Using CIC mass assignment scheme with weights
Time taken = 1.498 seconds


Computing power spectrum of the field...
Time to complete loop = 6.31
Time taken = 9.80 seconds

Using CIC mass assignment scheme with weights
Time taken = 1.285 seconds


Computing power spectrum of the field...
Time to complete loop = 6.29
Time taken = 9.20 seconds
_images/60ca29e7f1c83fc89dc9ff7457fb89ef2349c441c7bcdaad96acddb43997812c.png

Phase diagrams

ckit.preview_phase_diagram(path, snapshot_numbers, quantity='temperature')
ckit.preview_phase_diagram(path, snapshot_numbers, quantity='pressure')
ckit.preview_phase_diagram(path, snapshot_numbers, quantity='entropy')
_images/78ae5320934d58695992b422e4d46ecc175f34c7e86affae6e1d2a7a9de308b5.png _images/3e829f3e2b9f84eb91d697220bd6fe32502974adac76e15b1dc32f98e6d63955.png _images/362f50fbdbb458a564ad65b6f904fb4240134c3cf8d0c74c2f1bb0ac0ff86306.png