Skip to main content

Package for PDF calculations in Large Deviation Theory

Project description

pyLDT-cosmo

Python code to generate matter PDF predictions in Large Deviation Theory for LCDM and alternative cosmologies

Installation and testing

(1) If not yet available on your machine, install julia (all platforms: download it from julialang.org; for macOS only you can alternatively

brew install --cask julia 

with Homebrew)

(2) make sure your system has a recent pip installation by running

python -m pip install --upgrade pip

(3) for a clean install of pyLDT create a virtual environment first. I will use virtualenvwrapper, but conda or any other environment manager will do (see installation note below for conda users). For more details on how to install and configure virtualenvwrapper visit https://virtualenvwrapper.readthedocs.io/en/latest/index.html

(4) Once virtualenvwrapper is setup, create simultaneously a project and an environment (e.g., pyLDTenv) typing in terminal

mkproject pyLDTenv 

If the envornment is not yet activated, type

workon pyLDTenv 

This should take you directly into the pyLDTenv directory associated with the pyLDTenv project.

(5) Install PyJulia by running

python3 -m pip install julia

(6) To install the Julia packages required by PyJulia launch a Python REPL and run the following code

>>> import julia 
>>> julia.install() 

(7) Install diffeqpy by running

pip install diffeqpy

(8) To install Julia packages required for diffeqpy, open up the Python interpreter and run

>>> import diffeqpy
>>> diffeqpy.install()

(9) Now run

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pyLDT-cosmo 

hopefully at this stage all remaining Python dependencies will be automatically installed too

(10) To check everything is working as expected install pytest by issuing the command

pip install pytest 

and run

pytest --pyargs pyLDT_cosmo 

A test routine starts cruching the numbers (it should take about 80 sec.) and if pyLDT-cosmo is correctly installed it should give 1 passed tests

Note for Conda users

First make sure to install pip in your conda environment with

conda install pip

Replace all subsequent 'pip install' commands with 'python -m pip install' so that packages are installed using the virtual enviroment's pip.

Owing to an incompatibility between PyJulia and Conda, PyJulia cannot be properly initialised out-of-the-box. As a workaround pyLDT-cosmo will automatically disable the precompilation cache mechanism in Julia, which inevitably slows down loading and usage of Julia packages. As a result, loading pyLDT-cosmo can take up to 3x longer in a conda envirnoment and PDF calculations can easily double their execution time.

Models

Currently available cosmological models include:

Einstein-de Sitter spherical evolution is assumed for all cases.

If interested in implementing other modified gravity models:

  • Follow the installation steps (1)-(8) above

  • Clone this Git repo into the newly created environment

  • Move into the pyLDT-cosmo directory and install pyLDT-cosmo in developer (or editable) mode with

      pip install -e .
    
  • Then add the relevant linear theory equations and methods to the following modules:

    • growth_eqns.py
    • solve_eqns.py
    • compute_pk.py
    • pyLDT.py

    Track f(R) gravity (or nDGP gravity) for an example.

Jupyter notebook

Go to https://github.com/mcataneo/pyLDT-cosmo/tree/main and download the example jupyter notebook showing how to use pyLDT-cosmo. Move the notebook into the pyLDTenv directory. To fully exploit the notebook functionalities you'll need to 'pip install matplotlib' first.

A word on loading and computing time

pyLDT-cosmo is partly based on the Julia programming language, which uses a Just-In-Time (JIT) compiler to improve runtime performance. However, this feature comes at the expense of slow library loading when compared to pure or pre-compiled Python packages. On a modern computer pyLDT-cosmo takes about 80 seconds to load. After that computation is very efficient, taking only ~3 seconds to derive the matter PDF's simultaneuosly for all models, redshifts and smoothing radii.

That's all! Have fun!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyLDT-cosmo-0.4.9.tar.gz (17.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyLDT_cosmo-0.4.9-py3-none-any.whl (21.0 kB view details)

Uploaded Python 3

File details

Details for the file pyLDT-cosmo-0.4.9.tar.gz.

File metadata

  • Download URL: pyLDT-cosmo-0.4.9.tar.gz
  • Upload date:
  • Size: 17.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.6.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.7

File hashes

Hashes for pyLDT-cosmo-0.4.9.tar.gz
Algorithm Hash digest
SHA256 cfaf1efc46a1b5e3e49d2a519a987962ec376df23e42062dd352603f9c20fea9
MD5 ea7298e990df1449d902376ebbd5e469
BLAKE2b-256 2156b006b2d9e0b319979c330b8bf1876aac22af8bfee1297921eabc3e5607f4

See more details on using hashes here.

File details

Details for the file pyLDT_cosmo-0.4.9-py3-none-any.whl.

File metadata

  • Download URL: pyLDT_cosmo-0.4.9-py3-none-any.whl
  • Upload date:
  • Size: 21.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.6.1 requests/2.23.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.7

File hashes

Hashes for pyLDT_cosmo-0.4.9-py3-none-any.whl
Algorithm Hash digest
SHA256 6f3c0bdb5b6b725b6b90f8d0bcb6e05f62f314af511036a0d3b8f798ed5da6f6
MD5 d3e9dd31ba9d4b63befab2328d9ed5c3
BLAKE2b-256 a4e02b99b0e82eae31fff44823e941fc3b6e4fd9f8832bbb4f8420eb4014476c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page