Skip to content

foglienimatteo/GaPSE.jl

Repository files navigation

GaPSE - a model for the Galaxy Power Spectrum Estimator

julia-version package-version CI-build size license codecov Stable

GaPSE (Galaxy Power Spectrum Estimator) is a software for cosmological computations written in the Julia Programming Language.

IMPORTANT NOTE: This is a work-in-progress project! As a consequence, currently in this pre-release:

  • it is possible to compute the power spectrum/correlation function multipoles with L=1,2,3,... of the effects we'll show next, but 2 effects among the Galaxy Number Counts multipoles (Newton-Lensing and Lensing-Newton) converge very slowly, so their computation is not still 100% ready. However, the monopole (L=0) computations do not have any problem with quad, and even the GNC sum for higher order multipoles is not affected;
  • The Power Spectrum computations with :twofast do not work properly, you should always prefer :fftog. However, due to the fact that with :fftlog you must specify manually the bias parameter, the Power Spectra of a whole group of terms creates FFT oscillations in the smallest ones. The leading ones and the sum are not however affected.
  • the code functions are well documented; check the github pages website https://foglienimatteo.github.io/GaPSE.jl/stable if you can't see correctly the analytical expressions written in the docstrings;
  • few people used this code, so bugs are behind the corner; do not hesitate to raise the finger to point out them (see in the How to report bugs, suggest improvements and/or contribute section below)!
  • if you use this code, please read the Using this code section below

Table of Contents

Brief description

Measurements of the clustering of galaxies in Fourier space, at low wavenumbers, offer a window into the early Universe via the possible presence of scale dependent bias generated by Primordial Non Gaussianities [1] [2]. On such large scales, a Newtonian treatment of density of density perturbations might not be sufficient to describe the measurements, and a fully relativistic calculation should be employed.

Given the matter Power Spectrum (PS) at redshift $z=0$ and the background quantities for the Universe considered (both read from CLASS outputs), this program can compute:

  • all the 16 TPCFs arising from the Luminosity Distance (LD) perturbations (see Eq.(2.48) of [4]) for an arbitrary multipole order.

  • all the 25 TPCFs concerning the relativistic Galaxy Number Counts (GNC) (see Eq.(2.52) of [4]) for an arbitrary multipole order.

  • all the 20 cross correlations between GNC and LD (and their 20 counterparts LD cross GNC) for an arbitrary multipole order.

  • the PS multipoles of all of them (based on the Yamamoto estimator).

  • the Doppler and matter TPCFs in the plane-parallel approximation.

All these calculations can be performed both with and without a survey window function. The code implements also a toy-survey with azymuthal symmetry.

This project, and the analytical expressions used for the TPCFs, are based on the article of Emanuele Castorina and Enea Di Dio [3].

Installation and Usage

Currently, this package is not in the Julia package registries. There are two main ways to install and use GaPSE on your local machine:

  • the traditional way: you clone this gitrepo locally and you install the librarires that GaPSE needs in a suited Julia enviroment; it requires a compatible Julia version ≥1.8;
  • using a Docker container (experimental): you pull and run the GaPSE container; it requires a Docker installation.

traditional way: Installation

Assuming that you have already installed a coompatible Julia version, the simplest way to install this software is then the following:

  • in the terminal, go to the directory where you want to install this package;

  • clone this repository with Git

    $ git clone https://github.com/foglienimatteo/GaPSE.jl

    or manually download the source code from the url https://github.com/foglienimatteo/GaPSE.jl (Code > Download Zip)

  • go inside the directory of GaPSE ($ cd GaPSE.jl in the shell)

Inside the directory, there is a file called install_gapse.jl, which is a Julia script conceived for downloading and installing all the dependencies of GaPSE. You can run it by typing in the terminal:

     $ julia install_gapse.jl

If there are no error messages at the end of the installations, than GaPSE is corretly configured and you can start to use it!

NOTE: the packages that this script will install are the ones strictly required for GaPSE. The ipynbs we provide need however some more, as Plots, LaTeXStrings and PyPlot (which in turn requires a python kernel with Matplotlib installed); in case you don't have them, run with a terminal in this directory:

$ pip3 install matplotlib
$ julia --activate=. --eval 'using Pkg; for p in ["Plots", "LaTeXStrings", "PyPlot"]; Pkg.add(p); end; Pkg.resolve()'

NOTE: instead of using the install_gapse.jl script, you can also do the same in a more interactive way, if you prefer:

  • open a Julia REPL session and activate the project; you can achieve that opening the REPL with

    $ julia --activate=.

    or directy inside the REPL entering the Pkg mode (]) and running activate .

  • enter the Pkg mode (if you haven't done in the previous step) typing ] and run instantiate; this command will automatically detect and install all the package dependecies (listed in Project.toml)

  • done! You can exit from the package mode (press the Backspace key on an empty line) and start to use GaPSE

traditional way: Usage

There are three ways in order to use this code:

  • you can write whatever instruction inside the file GaPSE-exe.jl and then run in the command line

      $ julia GaPSE-exe.jl
  • you can open a Julia REPL session, include the code with

       include("<path-to-GaPSE.jl-directory>/src/GaPSE.jl")

    and then use interactively the GaPSE functions

  • you can run the same include("<path-to-GaPSE.jl-directory>/src/GaPSE.jl") command in a Jupyter Notebook, and use the code functions inside it. This is by far the most confortable way.

Some .ipynbs are already provided in the directory ipynbs :

  • we encourage you to follow the ipynbs/TUTORIAL.ipynb file first. The basic structure of the code and the most important functions are there presented;
  • ipynbs/Computations_b1p5-sb0-fevo0.ipynb explains the analytical Primordial Non-Gaussianities model we use here, compute its contribution in the redshift bin $1.0 \leq z \leq 1.5$ and compare it with the GNC effects, all using our toy-model window function with angular opening $\theta_{\rm max} = \pi/2$;
  • ipynbs/Generic_Window.ipynb explains how to use GaPSE with a generic Window Function of your choice;
  • ipynbs/eBOSS_Window.ipynb apply GaPSE on a real case scenario: the eBOSS window function;
  • the ipynbs/Computations_b1p5-sb0-fevo0.jl Julia file its the translation into script of ipynbs/Computations_b1p5-sb0-fevo0.ipynb; you can easily run it from the command line with:
      $ julia Computations_b1p5-sb0-fevo0.jl

The code is well tested and documented: almost each struct/function has a docstring that you can easily access in Julia with ?<name-of-the-struct/function>, and there is an acitive GitHub Pages website with the latest stable documentation.

Docker container: Installation and Usage

The Dockerfile we provide in this directory is the one we used to create the container image corresponding to this GaPSE version.

The images are saved in https://hub.docker.com/repository/docker/matteofoglieni/gapse/general and the tag is the same as the GaPSE version the container refers to + a latin letter (alphabetically orderer), to take into account different version of the Dockerfile which refer to the same GaPSE one. The latest container name is then gapse:0.8.0a.

These containers have already installed all the Julia packages that GaPSE needs (i.e. the ones listed in Project.toml) + come others for the ipynbs (check the Dockerfile itself).

Supposing that you have already installed Docker, so as to use GaPSE as a container:

  • download the image:
    $ sudo docker pull matteofoglieni/gapse:0.8.0a
  • choose a free port where to access the JupyterLab of the container; we will use 10000;
  • run the container with that port:
    $ sudo docker run -d -p 10000:8888 matteofoglieni/gapse:0.8.0a
  • get the logs of the container and copy the Jupyter token (in the following output is 531vbeb08567581944e486d47e1tee15683757086205da68):
    $ sudo docker logs $(sudo docker ps -ql)
    ...
    [I 2023-09-13 12:51:47.960 ServerApp] Jupyter Server 2.7.0 is running at:
    [I 2023-09-13 12:51:47.960 ServerApp] http://7b1ca9747263:8888/lab?token=531vbeb08567581944e486d47e1tee15683757086205da68
    [I 2023-09-13 12:51:47.960 ServerApp]     http://127.0.0.1:8888/lab?token=531vbeb08567581944e486d47e1tee15683757086205da68
    [I 2023-09-13 12:51:47.960 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
    [C 2023-09-13 12:51:47.962 ServerApp] 
        
        To access the server, open this file in a browser:
            file:///home/jovyan/.local/share/jupyter/runtime/jpserver-7-open.html
        Or copy and paste one of these URLs:
            http://7f1ca9847263:8888/lab?token=531vbeb08567581944e486d47e1tee15683757086205da68
            http://127.0.0.1:8888/lab?token=531vbeb08567581944e486d47e1tee15683757086205da68
    [I 2023-09-13 12:51:48.653 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
    ...
  • open a browser of your choice on your local machine and paste as URL http://127.0.0.1:10000/lab?token=531vbeb08567581944e486d47e1tee15683757086205da68 (essentially, you just have to substitute the port 8888 with the one you choose in the URL showed in the previous logs).
  • now you should see a JupyterLab page containing the GaPSE files.

Now you can use GaPSE inside the Jupyter interface as normally!

Quick summary of Docker commands, in case you don't know them:

  • sudo docker ps [-a] : list running containers (all with -a);
  • sudo docker logs <container-name/id> : get the logs of a container;
  • sudo docker start/stop <container-name/id> : start a stopped container/stop a running container;
  • sudo docker rm <container-id/name> : delete a container;
  • sudo docker pull <image> : download a container image;
  • sudo docker run <image> : create a running container from an image;
  • sudo docker image list : list all the local images;
  • sudo docker image rm <image> : delete an image.

Dependencies

GaPSE.jl makes extensive use of the following packages:

Furthermore, the notebooks we provide in ipynbs use:

  • Plots for the pure julian plots;
  • LaTeXStrings for the labels in LaTeX;
  • PyPlot for the julian plots in the python style; this package is based on the Matplotlib Python package, and it requires it in order to run properly.

How to report bugs, suggest improvements and/or contribute

As already mentioned above, this is a WIP project used mostly by the authors themselves, and so bugs are behind the corner. If you discover one of them, or if you would like to make a suggestion about a possible new feature that the code might implement, do not hesitate to contact the authors via email (matteo.foglieni@lrz.de) or fork the repository and open a pull request like follows:

  • fork the project: on the top of the GaPSE.jl Github page, go to Fork > Create a new Fork
  • download your forked repository from your GitHub profile
  • create your branch: in the terminal, run $ git checkout -b feature/<your-feature-name>
  • make the changes/improvements you want in that branch
  • commit your changes in that branch: in the terminal, run $ git commit -m 'added the feature <your-feature-name>'
  • push: in the terminal, run $ git push origin feature/<your-feature-name>
  • open a Pull Request for that branch

Using this code

If you use GaPSE to compute the galaxy power spectrum/correlation function please refer to the two following papers:

If you also use the code to compute the perturbations in the luminosity distance, please refer also to

  • Pantiri, Foglieni, Di Dio, Castorina, The power spectrum of luminosity distance fluctuations in General Relativity (2023) [in preparation]

Licence

This software is under the GNU 3.0 General Public Licence. See the file LICENCE.md.

References

[1] Dalal, Doré et al., Imprints of primordial non-Gaussianities on large-scale structure (2008), American Physical Society, DOI: 10.1103/PhysRevD.77.123514, url: https://journals.aps.org/prd/abstract/10.1103/PhysRevD.77.123514

[2] Slosar, Hirata et al., Constraints on local primordial non-Gaussianity from large scale structure (2008), Journal of Cosmology and Astroparticle Physics, DOI: 10.1088/1475-7516/2008/08/031, url: https://doi.org/10.1088/1475-7516/2008/08/031

[3] Castorina, Di Dio, The observed galaxy power spectrum in General Relativity (2022), Journal of Cosmology and Astroparticle Physics, DOI: 10.1088/1475-7516/2022/01/061, url: https://doi.org/10.1088/1475-7516/2022/01/061

[4] Di Dio, Montanari, Curvature constraints from large scale structure (2016), Journal of Cosmology and Astroparticle Physics, DOI: 10.1088/1475-7516/2016/06/013, url: https://iopscience.iop.org/article/10.1088/1475-7516/2016/06/013

[5] Gebhardt, Jeong et al, Fast and accurate computation of projected two-point functions (2018), American Physical Society, DOI: 10.1103/PhysRevD.97.023504, url: https://link.aps.org/doi/10.1103/PhysRevD.97.023504

About

A Galaxy Power Spectrum Estimator written in Julia

Resources

License

Stars

Watchers

Forks

Packages

No packages published