Metadata-Version: 2.5
Name: glass.ext.extend
Version: 0.1.1
Summary: GLASS extension for continuing lightcone simulations to higher redshift
Project-URL: Homepage, https://github.com/glass-dev/glass.ext.extend
Project-URL: Issues, https://github.com/glass-dev/glass.ext.extend/issues
Author: Lorenzo Fusari
License: MIT License
License-File: LICENSE.txt
Keywords: CMB lensing,cosmology,lightcone,lognormal,simulations
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Astronomy
Requires-Python: >=3.11
Requires-Dist: camb<2,>=1.5.9
Requires-Dist: classy>=3.3.4.0
Requires-Dist: cosmology-compat-camb>=0.2.0
Requires-Dist: gaussiancl>=2023.1.post0
Requires-Dist: glass-ext-camb>=2023.6
Requires-Dist: glass-ext-pkdgrav>=0.4
Requires-Dist: glass>=2026.4
Requires-Dist: h5py>=3.15.1
Requires-Dist: healpy>=1.20.1
Requires-Dist: matplotlib>=3.10.1
Requires-Dist: numpy>=2.2.4
Requires-Dist: pyyaml>=6.0.2
Requires-Dist: scipy>=1.15.2
Requires-Dist: transformcl>=2026.1
Provides-Extra: test
Requires-Dist: pytest; extra == 'test'
Description-Content-Type: text/markdown

# GLASS extension for continuing lightcone simulations to higher redshift

This repository contains a GLASS extension that extends an N-body lightcone
simulation to higher redshift. New matter shells are drawn beyond the last
simulated shell, conditional on the shells before them, so that structure stays
correlated across the boundary. With the shells extended to the last scattering
surface, the extension makes a full-sky CMB lensing convergence map.

The method is described in *Conditional random field sampling for high-redshift
extensions of lightcone simulations with application to CMB lensing* (Fusari,
Jeffrey & Joachimi, in prep).

## Installation

Install the package with pip into a new environment:

    pip install glass.ext.extend

The exact versions the results of the paper were produced with are in
`requirements.txt`. With those, a map can be reproduced bit for bit from its
seed.

## Supported simulations

The extension reads a simulation through a loader. It does not detect the kind
of simulation from the directory, so name the loader with `--suite`:

| `--suite`     | Simulation                          |
|---------------|-------------------------------------|
| `gowerstreet` | Gower Street simulations (PKDGRAV3) |
| `cosmogrid`   | CosmoGridV1                         |
| `agora`       | Agora                               |

If your simulation is not in the list, you can write a loader for it. A loader
tells the extension where the matter shells are, what their redshift edges are
and what the cosmology of the simulation is. The modules in
`glass/ext/extend/loaders/` are the examples to start from. Please contribute
your loader back with a pull request.

## Quick start

Point the `glass-extend` command to a simulation directory, on your computer or
on your cluster, and name its loader. For a Gower Street simulation:

    glass-extend --suite gowerstreet --sim /path/to/GowerStreetSims/sim00230

This reads the matter shells of the simulation up to redshift 2, generates the
shells from there to redshift 1100, and writes the CMB lensing convergence map
as a HEALPix FITS file:

    production_runs/gowerstreet_grid_2048_dchi400_sh100_sim00230/kappa_map_0000.fits

It then compares the power spectrum of the map with theory and writes the
figures next to the map. Outputs go under the directory the command is run
from.

## Changing the settings

The defaults are the settings of the paper. The main ones can be changed on the
command line:

    glass-extend --suite gowerstreet --sim /path/to/GowerStreetSims/sim00230 \
        --nside 1024 --num-shells 50 --delta-chi 300 --shift 1.0

- `--nside`: resolution of the shells and of the map (default 2048);
- `--num-shells`: number of generated shells between the simulation and
  redshift 1100 (default 100);
- `--delta-chi`: how far back the shells that condition each new shell reach,
  in Mpc/h (default 400);
- `--shift`: shift of the lognormal distribution of the generated shells
  (default 1, the GLASS default). At a fixed variance a smaller shift gives a
  more skewed matter distribution. The shift must be larger than minus the
  lowest density contrast in the simulation shells, and the command stops with
  a message if it is not.

`glass-extend --help` lists all options.

## Changing the boundary redshift

By default the simulation is used up to redshift 2 and extended from there. To
use the simulation up to another redshift, run the production step on its own
and give the boundary with `--z-max-base`:

    glass-extend-produce --suite gowerstreet \
        --sim-dir /path/to/GowerStreetSims/sim00230 --z-max-base 3

The number of generated shells stays the same, so each of them is thinner for a
higher boundary. `glass-extend-produce` writes the map only. To compare an
existing map with theory, run `glass-extend-validate --input` on its output
directory.

## Tests

    pip install pytest
    pytest

Tests that need simulation data are skipped when the data is absent.
