Installation#

Requirements#

SAGAN requires Python 3.9 or later.

Core Dependencies#

SAGAN depends on the following packages:

  • numpy (≥ 1.20) - Numerical computations

  • scipy (≥ 1.7) - Scientific computing routines

  • matplotlib (≥ 3.4) - Plotting

  • astropy (≥ 5.0) - Astronomical algorithms and models

  • pandas (≥ 1.3) - Data manipulation

Fitting Dependencies#

  • emcee (≥ 3.0) - MCMC sampling

  • dynesty (≥ 1.2) - Nested sampling

  • corner (≥ 2.2) - Corner plots for MCMC results

Analysis Dependencies#

  • extinction (≥ 0.4) - Dust extinction calculations

  • PyAstronomy (≥ 0.18) - Astronomical tools

  • spectres (≥ 2.0) - Spectral resampling

  • multiprocess (≥ 0.70) - Parallel processing

Installation Methods#

From Source#

SAGAN is currently not available on PyPI. Install from source:

  1. Clone the repository:

git clone https://github.com/jyshangguan/SAGAN.git
cd SAGAN
  1. Install in editable mode:

pip install -e .

This installs SAGAN in “editable” mode, meaning changes to the source code will be reflected without needing to reinstall.

With Development Dependencies#

For development, install the additional development tools:

pip install -e ".[dev]"

This includes testing and development tools like pytest and Jupyter.

Verification#

To verify your installation, check the version:

import sagan
print(f"SAGAN version: {sagan.__version__}")

You should see the version number printed (e.g., 0.1.0).

Run a quick test:

import numpy as np
from sagan import Line_Gaussian

# Create an Hα emission line
halpha = Line_Gaussian(
    amplitude=5.0,   # Peak amplitude
    dv=0,           # No velocity shift (km/s)
    sigma=200,      # Velocity dispersion (km/s)
    wavec=6563,     # Hα wavelength (Angstroms)
    name='Halpha'
)

# Evaluate the model
wave = np.linspace(6500, 6600, 100)
flux = halpha(wave)

print(f"Created line model: {halpha.name}")
print(f"Peak flux: {np.max(flux):.3f}")

Troubleshooting#

Common Issues#

Import Error: No module named ‘astropy’

Make sure you have installed all dependencies. Try reinstalling:

pip install -e .

Data Files Not Found

SAGAN includes template data files that should be installed automatically. If you encounter errors about missing data files, try reinstalling:

cd /path/to/SAGAN
pip install -e .

Permission Errors

If you don’t have permission to install to the system Python, use a virtual environment (recommended):

python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
cd /path/to/SAGAN
pip install -e .

Next Steps#

After installation, proceed to the Quick Start Guide guide to learn the basics of using SAGAN for spectral fitting.