---
title: 'MPDAF: MUSE Python Data Analysis Framework'
url: https://www.emergentmind.com/topics/muse-framework
type: topic
---

# MPDAF: MUSE Python Data Analysis Framework

The MUSE (Multi Unit Spectroscopic Explorer) Python Data Analysis Framework (MPDAF) is a domain-specific software package developed to facilitate the analysis and scientific exploitation of data produced by the MUSE integral-field spectrograph on the ESO VLT. MPDAF provides an integrated environment for manipulating, calibrating, and extracting information from MUSE data products, which are three-dimensional datacubes containing spatial and spectral dimensions.

## 1. Scope and Objectives

MPDAF addresses the complexities inherent to the MUSE instrument, whose datacubes encode $x$, $y$ (spatial) and $\lambda$ (spectral) information for each pixel, accompanied by extensive world coordinate system (WCS), variance, and bad pixel mask metadata. The framework is engineered to:

- Load, manipulate, and analyze MUSE data cubes, images, and spectra while rigorously maintaining associated variances, WCS metadata, and masking information.
- Facilitate astronomical workflows such as subcube extraction, aperture and region-based extraction, image generation by axis summation, automated source detection, and quantitative spectral analysis.
- Support advanced instrument calibration and reduction steps via targeted manipulation of raw or reduced pixel tables.
- Ensure all processing steps preserve the integrity and astrophysical context of the data, in compliance with professional standards for reproducible research.

## 2. Integration with the Python Scientific Stack

MPDAF is layered atop established Python scientific libraries:

| Dependency   | Role in MPDAF                                            |
|--------------|----------------------------------------------------------|
| Numpy        | Core array storage (including masked arrays for variance/masking) and fast numerical computations |
| Scipy        | Provides routines for interpolation, resampling, smoothing, and non-linear optimization in spectral fitting |
| Matplotlib   | Publication-grade visualization of cubes, images, and fitted spectra |
| Astropy      | High-level FITS I/O, WCS manipulation, unit handling, and sky coordinate propagation |

This approach ensures MPDAF packages domain-specific MUSE logic while leveraging robust, well-maintained scientific infrastructure.

## 3. Architecture and Key Modules

MPDAF is organized into three principal modules, each targeting a critical stage of the MUSE data workflow:

| Module Name   | Core Classes or Tools | Functionality                                                                          |
|---------------|----------------------|-----------------------------------------------------------------------------------------|
| mpdaf.obj     | Cube, Image          | Cube/image loading with WCS, extraction (subcube, aperture), masking, spectral analysis |
| mpdaf.sdetect | MUSELET              | Emission line / object detection, source database management, FITS output packaging      |
| mpdaf.drs     | PixTable             | Raw/reduced pixel table handling, filtering for calibration and diagnostic applications  |

### mpdaf.obj

- Provides `Cube` and `Image` classes for high-level manipulation, always preserving essential WCS and mask/variance information.
- Subcube and aperture extraction with arbitrary center and dimension; narrow-band/white-light image creation via summation over arbitrary wavelength intervals.
- Aperture and region-based spectral extraction.
- In-built spectral model fitting (e.g., asymmetric Gaussian fitting of emission lines with extraction of peak, FWHM).

#### Example Code Snippet
```python
from mpdaf.obj import Cube
cube = Cube('DATACUBE-HDFS-v1.34.fits')
center = (-60.56183, 338.2168)  # RA/Dec in degrees
subcube = cube.subcube(center, 10)  # 10" square region
sp = subcube.aperture(center, 1)    # 1" radius spectrum
sp.plot(title='integrated spectrum within 1" radius aperture')
lfit, rfit = sp.gauss_asymfit(lmin=5180, lmax=5260, plot=True)
```
Spectral fitting yields quantitative measurements directly on extracted features (e.g., Lyα line).

### mpdaf.sdetect

- Implements MUSELET (built atop SExtractor) for line emitter detection.
- Aggregates source data (sub-cubes, images, integrated and zoomed spectra, and line parameters) in a single FITS package for synthesis.
- FITS storage schema unifies subcubes, spectral extractions, and derived astrophysical properties for each detected source.

### mpdaf.drs

- Provides access to foundational pixel tables where each row encodes a pixel’s location (CCD, slice, spatial, spectral).
- Facilitates filtering by spatial, spectral, or instrumental criteria to, e.g., diagnose slice-to-slice offsets, crucial for calibration prior to datacube synthesis.

## 4. Use Cases and Workflow Examples

MPDAF is tailored to both scientific investigation and instrument calibration/validation. Notable examples include:

- Extracting a subregion of the Hubble Deep Field South MUSE cube, producing a narrow-band image, masking regions, and calculating integrated Lyα flux and error as a function of aperture radius.
- Assembling a FITS “source package” containing all relevant data products for a detected Lyα emitter: subcube, full/zoomed spectra, emission line parameters (e.g., peak, FWHM), and multiple image modalities (white-light, continuum, narrow-band, and supporting HST images).
- Systematic investigation and error diagnosis of reduced pixel tables for instrument commissioning and calibration (pixel filtering, slice registration, etc.)

## 5. Community, Distribution, and Development

MPDAF was originally developed for the MUSE consortium and is now open-source, with the following support mechanisms:

- Source code and release management via a public git repository.
- Standard installation with pip.
- Comprehensive, example-driven online documentation targeting new and advanced users.
- Community engagement for bug reporting, discussion, and contributions.
- Ongoing, active development—including refinement and extension of key modules such as mpdaf.sdetect—maintains alignment with the evolving needs of MUSE users and the astronomical community.

## 6. Significance and Impact

MPDAF establishes a specialized, technically robust, and community-driven framework for MUSE data analysis. Unlike generic toolkits, its tightly integrated modules maintain astrophysical metadata (WCS, variance, bad pixel information) across all processing stages and support both routine and advanced analysis (from cube manipulation to emission line fitting and automated source detection). Its evolution from internal consortium tool to public resource illustrates its stability and scientific significance. MPDAF is now a cornerstone resource for astronomers pursuing research with MUSE and stands as a model for specialized, open-source data analysis frameworks in precision astronomy.

Source: https://www.emergentmind.com/topics/muse-framework