Skip to content

Commit

Permalink
add camels multifield hack
Browse files Browse the repository at this point in the history
  • Loading branch information
Leander Thiele committed Sep 2, 2024
1 parent ca4df0a commit 84a22bd
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 2 deletions.
89 changes: 89 additions & 0 deletions Hack/CAMELS_multifield.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "150df1a2-c83d-4c55-999c-7d744fb4ac6f",
"metadata": {},
"source": [
"# CAMELS multifield hack: inferring cosmology from images of the Universe"
]
},
{
"cell_type": "markdown",
"id": "f67dd0b1-0b91-4d79-a5b6-1398d2a045fc",
"metadata": {},
"source": [
"There are results from two different simulation codes available, namely **IllustrisTNG** and **SIMBA**.\n",
"These codes produce quite different looking universes!\n",
"\n",
"For each code, 1000 simulations are available. These have been run in 25 Mpc/h sidelength boxes.\n",
"Each simulation has been post-processed into 15 2d-images.\n",
"\n",
"There are two \"observables\" available, namely total matter density, `Mtot`, and electron pressure, `P`.\n",
"These are in principle observable, through weak gravitational lensing and the thermal Sunyaev-Zel'dovich effect, respectively.\n",
"\n",
"Each simulation is described by 6 parameters.\n",
"The first two are cosmological parameters, $\\Omega_m$ (matter density) and $\\sigma_8$ (matter clustering amplitude).\n",
"The remaining four are astrophysical parameters. These describe how the simulation code deals with things like AGN and supernova feedback. We don't understand these processes very well in the real universe.\n",
"\n",
"It follows an example how to read the data. Make sure you download the data or connect them to your google colab instance, and adapt the path accordingly. Data may be found in the [google drive](https://drive.google.com/drive/u/1/folders/13ySEme-B8XDMYgTZ8_rVpMarRUUGYbTw), `CAMELS_multifield` directory."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4b941cf0-7505-4c09-a98b-473c28c7476d",
"metadata": {},
"outputs": [],
"source": [
"import numpy as np"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "565d3909-48a7-46e3-84a6-302a7ddd6fd3",
"metadata": {},
"outputs": [],
"source": [
"base = 'TODO'\n",
"\n",
"# IllustrisTNG or SIMBA\n",
"simcode = 'IllustrisTNG'\n",
"\n",
"# Mtot or P\n",
"field = 'Mtot'\n",
"\n",
"# these have length 1000\n",
"Omega_m, sigma_8, SN1, AGN1, SN2, AGN2 = np.loadtxt(f'params_LH_{simcode}.txt', unpack=True)\n",
"\n",
"# The 2D images\n",
"# 1st dimension corresponds to parameter values,\n",
"# 2nd dimension are different maps for a given simulation,\n",
"# 3rd and 4th dimension are the image dimensions\n",
"imgs = np.load(f'Maps_{field}_{simcode}_LH_z=0.00.npy').reshape(1000, 15, 256, 256)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
15 changes: 15 additions & 0 deletions Hack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,18 @@ Find a set of variable to construct the best model of the magnitude at maximum o
[Data](https://drive.google.com/drive/folders/1kz94LOxBTEpKeNBrG56K8rs9sp2u9Y8M?usp=sharing)

Contact person: Makoto Uemura

## Using CNNs to infer the fundamental parameters of the Universe

For this hack, we're using the CAMELS multifield data set.
The data is in the `CAMELS_multifield` directory in the google drive linked above.

Please see the [notebook](CAMELS_multifield.ipynb) for a quick explanation of the data format.

Use the available data to train a CNN to infer the underlying cosmological parameters
from the images.

How well does your trained network generalize? For example, if you train on the IllustrisTNG
simulations and test on SIMBA, are the inferred cosmological parameters correct?

contact person: Leander Thiele
4 changes: 2 additions & 2 deletions Lecture_Day2_Thiele/hands_on.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -348,9 +348,9 @@
"At the very least, you should use an explicit generator and seed.\n",
"Working with implicit, global generators is **strongly discouraged**.\n",
"\n",
"These things become especially important when your projects require multi-processing.\n",
"These things become especially important when your projects require parallelism.\n",
"\n",
"*NOTE* that in principle we're using global state when implicity initializing the model weights. In practice, this is usually fine since the model is "
"*NOTE* that in principle we're using global state when implicity initializing the model weights. In practice, this is usually fine since the model is initialized in the main process before potential parallelism occurs."
]
},
{
Expand Down

0 comments on commit 84a22bd

Please sign in to comment.