Metadata-Version: 2.4
Name: galform_analysis
Version: 0.1.0
Summary: A modular Python framework for reading and analyzing GALFORM HDF5 simulation outputs.
Author-email: Oscar Hickman <oscar.hickman17@alumni.imperial.ac.uk>
License: MIT License
        
        Copyright (c) 2026 Oscar Hickman
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/OscarHickman/galform_analysis
Project-URL: Repository, https://github.com/OscarHickman/galform_analysis
Project-URL: Issues, https://github.com/OscarHickman/galform_analysis/issues
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.23.0
Requires-Dist: scipy>=1.7.0
Requires-Dist: matplotlib>=3.3.0
Requires-Dist: polars>=1.0.0
Requires-Dist: h5py>=3.0.0
Requires-Dist: seaborn>=0.11.0
Requires-Dist: Corrfunc>=2.3.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Provides-Extra: science
Requires-Dist: astropy>=4.0; extra == "science"
Requires-Dist: hmf>=3.0; extra == "science"
Requires-Dist: packaging>=20.0; extra == "science"
Requires-Dist: deprecation>=2.0; extra == "science"
Requires-Dist: halotools>=0.7.0; extra == "science"
Dynamic: license-file

# galform_analysis

[![CI](https://github.com/OscarHickman/galform_analysis/actions/workflows/ci.yml/badge.svg)](https://github.com/OscarHickman/galform_analysis/actions/workflows/ci.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)


A modular Python framework designed for the efficient reading and analysis of GALFORM HDF5 simulation outputs. This library provides standardized tools for processing large-scale galaxy formation data, from low-level HDF5 I/O to high-level astronomical probes.

## Core Features

- **Standardized I/O**: Robust loaders for GALFORM `galaxies.hdf5` files with support for different output versions.
- **Data Aggregation**: Tools to scan simulation directories and aggregate data across subvolumes using high-performance `polars` dataframes.
- **Mass Functions**: Computation of Stellar Mass Functions (SMF), Halo Mass Functions (HMF), and Halo Occupation Distribution (HOD).
- **Correlation Functions**: Estimators for 2-point, 3-point, and N-point correlation functions (2PCF/NPCF) including subvolume-weighted corrections for convergence analysis.
- **Redshift-Space Distortions**: Estimators for anisotropic clustering ($\xi(s, \mu)$) and multipoles ($\xi_0, \xi_2, \xi_4$).
- **Simulation Management**: Built-in configurations for major N-body simulations including L800, Millennium I/II, COLIBRE, and FLAMINGO.

## Installation

Install the package in your Python environment:

```bash
uv pip install -e .
```

### Dependencies
The library requires `numpy`, `scipy`, `matplotlib`, `polars`, `h5py`, `seaborn`, and `Corrfunc`. These are automatically managed during installation.

## Quick Start

The following example demonstrates how to load a simulation configuration and read galaxy data:

```python
from galform_analysis import SimulationConfig, config
from galform_analysis.readers.loaders import read_snapshot_data

# 1. Access simulation-specific constants (box size, cosmology, etc.)
sim = SimulationConfig('L800')
print(f"Simulation: {sim.name}, Box Size: {sim.box_size} Mpc/h")

# 2. Configure the data location
config.set_base_dir('/path/to/Galform_Out/L800/model_name')

# 3. Load snapshot data for a specific subvolume
data = read_snapshot_data('iz271', ivol=0)
mstar = data['mstar']  # Stellar masses in M_sun/h
```

## Simulation Metadata

Configurations for supported simulations are stored centrally in `galform_analysis/sim_configs/`. This allows for dynamic access to cosmological parameters and volume metadata:

```python
from galform_analysis import SimulationConfig

flamingo = SimulationConfig('FLAMINGO')
omega_m = flamingo.omega_m
h0 = flamingo.h0
```

## Documentation & Examples

Refer to the `examples/` directory for interactive Jupyter notebooks:
- `examples/readers/load_snapshot.ipynb`: Introduction to data loading.
- `examples/analysis/mass_functions/smf_example.ipynb`: Plotting Stellar Mass Functions.
- `examples/analysis/correlation/correlation_example.ipynb`: Computing clustering statistics.

## Testing & Quality Standards

The project maintains high code quality through automated linting and comprehensive testing:

```bash
# Run the test suite
pytest tests

# Check code style
ruff check galform_analysis
```

## Author

Oscar Hickman
