Skip to content

AndriusT/cw_wl_GAN

Repository files navigation

A GAN algorithm to produce weak lensing convergence maps and cosmic web slices:

This repository contains a GAN algorithm that allows producing novel cosmic web slices (overdensity field in 2-D) and weak lensing convergence maps of different redshifts, cosmological parameters and modifications of gravity. In addition, the code allows producing novel, statistically realistic cosmic web slices using the publicly available Illustris data.

The figures below illustrate some of the results produced by our code.

The figure below shows a few GAN-generated cosmic web slices produced using Illustris data. Namely, it shows the dark matter overdensity, gas overdensity and internal (thermal) energy fields correspondingly along with all the three mentioned components combined into an RGB array:

How to run:

Installing the dependencies:

The key python packages used in the attached Jupyter notebooks are the following: tensorflow (1.14.0), cv2 (4.1.2), numpy (1.16.2), matplotlib (3.0.3) and nbodykit (0.3.12). The easiest way to make sure you have the same versions of the mentioned packages is to create a fresh Conda environment as follows:

conda create -n myenv python=3.6
source activate myenv
pip install tensorflow==1.14.0
pip install opencv-python
pip install matplotlib
pip install numpy
conda install -c bccp nbodykit

If you require GPU support, install the GPU version instead: pip install tensorflow-gpu==1.14.0 instead.

Cloning the repository and getting the data:

Clone the repository:

git clone https://github.com/AndriusT/cw_wl_GAN.git

This contains all the key code and the required Jupyter notebooks, however, you still need to download the training data and the saved checkpoint files. Download the files and move then to the ./data and the ./checkpoints folders correspondingly. The files can be extracted using p7zip-full (sudo apt-get install p7zip-full):

cd ./data
7z e data.7z
cd ../checkpoints/
7z x checkpoints.7z

The checkpoints include the most recent results for weak lensing maps with different cosmological parameters along with the cosmic web slices of different redshifts, cosmologies and modified gravity parameters. The data folder includes samples of the training data used to trained our algorithm.

Getting the Illustris data:

To get the Illustris snapshot data (needed in the Preparing_Illustris_data.ipynb notebook), use the following code:

cd ./data/snapdir_135/
wget -nd -nc -nv -e robots=off -l 1 -r -A hdf5 --content-disposition --header="API-Key: your-api-code-here" "http://www.illustris-project.org/api/Illustris-3/files/snapshot-135/?format=api"

Your personal api code has to be added to make this work. To get the code, register at the Illustris website. This will download a z = 0.0 snapshot file (21.8 GB), which can then be used to extract the dark matter and gas overdensity slices.

Citing the code:

If you use these codes in your research, please cite this repository and the corresponding paper:

@ARTICLE{2021MNRAS.tmp.1635T,
       author = {{Tamosiunas}, Andrius and {Winther}, Hans A. and {Koyama}, Kazuya and {Bacon}, David J. and {Nichol}, Robert C. and {Mawdsley}, Ben},
        title = "{Investigating Cosmological GAN Emulators Using Latent Space Interpolation}",
      journal = {\mnras},
     keywords = {large-scale structure of the Universe, software: simulations, hydrodynamics, methods:numerical, Astrophysics - Cosmology and Nongalactic Astrophysics, Astrophysics - Instrumentation and Methods for Astrophysics, Physics - Computational Physics},
         year = 2021,
        month = jul,
          doi = {10.1093/mnras/stab1879},
archivePrefix = {arXiv},
       eprint = {2004.10223},
 primaryClass = {astro-ph.CO},
       adsurl = {https://ui.adsabs.harvard.edu/abs/2021MNRAS.tmp.1635T},
      adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

Also, please cite the cosmoGAN paper, which this work is based on. Also, see the github repository.

Contacting the author:

Contact me in case of any issues with the code.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published