Skip to content

HealthyPear/naimatic

Repository files navigation

naimatic

naimatic is a Python package that provides a framework for building and running multiple astrophysical models using naima.

It allows users to define particle distributions, radiative processes, and model configurations in a structured way from a single YAML configuration file, facilitating the fitting and visualization of multiple models.

The implementation is that of a wrapper around naima which defines a configuration schema validated by pydantic and produces the necessary objects by means of factory functions.

If you find naima useful in your research, please cite Zabalza (2015) to acknowledge its use. The BibTeX entry for the paper is:

    @ARTICLE{naima,
       author = {{Zabalza}, V.},
        title = {naima: a Python package for inference of relativistic particle
                 energy distributions from observed nonthermal spectra},
         year = 2015,
      journal = {Proc.~of International Cosmic Ray Conference 2015},
        pages = "922",
       eprint = {1509.03319},
       adsurl = {http://adsabs.harvard.edu/abs/2015arXiv150903319Z},
    }

Requirements

Any Python>=3.9 virtual environment with pip installed.

Installation

pip install https://github.com/HealthyPear/naimatic

Usage

To use naimatic, you start from a configuration file that defines your models, particle distributions, and radiative processes.

Assuming this file is called config.yaml, the usage is as simple as:

naimatic config.yaml

See naimatic -h for more options.

The results from each model will be saved in their own subdirectories under the specified output director.

Examples

Following the examples from naima's documentation, here are the equivalent example configurations that you can use with naimatic.

Fitting a minimal radiative model

output_path: /where/you/want/to/save/your/data

data:
  hess: /path/to/RXJ1713_HESS_2007.dat

models:
  - name: minimal_radiative_model
    overwrite: true
    distance: "1 kpc"
    particle_distribution:
      name: ExponentialCutoffPowerLaw
      amplitude:
        freeze: false
        init_value: 1e30 eV-1
        prior:
          name: uniform
          min: 0 eV-1
          max: inf eV-1
      e_0:
        freeze: true
        init_value: 10 TeV
      alpha:
        freeze: false
        init_value: 3.0
      e_cutoff:
        freeze: false
        log10: true
        init_value: 30 TeV
      beta:
        freeze: true
        init_value: 1.0
    radiative_processes:
      - name: InverseCompton
        seed_photon_fields:
          - "CMB"
    metadata:
      particle_distribution:
        save: true # if true save to blob metadata
        energy_range: np.logspace(11, 15, 100) * u.eV
      total_particle_energy:
        save: true # if true save to blob metadata
        e_min: 1 TeV

mcmc:
  nwalkers: 32
  nburn: 100
  nrun: 20
  threads: 4
  prefit: false
  interactive: false

Fitting IC emission from an electron distribution

output_path: /where/you/want/to/save/your/data

data:
  hess: /path/to/RXJ1713_HESS_2007.dat

models:
  - name: inverse_compton
    overwrite: true
    sed: true
    distance: "1 kpc"
    particle_distribution:
      name: ExponentialCutoffPowerLaw
      amplitude:
        freeze: false
        init_value: 1e30 eV-1
        prior:
          name: uniform
          min: 0 eV-1
          max: inf eV-1
      e_0:
        freeze: true
        init_value: 10 TeV
      alpha:
        freeze: false
        init_value: 3.0
      e_cutoff:
        freeze: false
        log10: true
        init_value: 30 TeV
      beta:
        freeze: true
        init_value: 1.0
    radiative_processes:
      - name: InverseCompton
        seed_photon_fields:
          - "CMB"
          - ["FIR", "26.5 K", "0.415 eV cm-3"]
        Eemin: 100 GeV
    metadata:
      particle_distribution:
        save: true # if true save to blob metadata
        energy_range: np.logspace(11, 15, 100) * u.eV
      total_particle_energy:
        save: true # if true save to blob metadata
        e_min: 1 TeV

mcmc:
  nwalkers: 32
  nburn: 100
  nrun: 20
  threads: 4
  prefit: false
  interactive: false

Fitting Synchrotron and IC emission from an electron distribution

output_path:

data: # Data tables for the model (in order of increasing energy range!)
  suzaku: RXJ1713_Suzaku-XIS.dat
  hess: RXJ1713_HESS_2007.dat

models:
  - name: ElectronSynIC
    overwrite: true
    sed: true
    distance: "1 kpc"
    particle_distribution:
      name: ExponentialCutoffPowerLaw
      amplitude:
        freeze: false
        log10: true
        init_value: 1e33 eV-1
        prior:
          name: uniform
          min: 1 eV-1
          max: inf eV-1
      e_0:
        freeze: true
        init_value: 10 TeV
      alpha:
        freeze: false
        init_value: 2.5
        prior:
          name: uniform
          min: -1
          max: 5
      e_cutoff:
        freeze: false
        log10: true
        init_value: 48 TeV
      beta:
        freeze: true
        init_value: 1.0
    radiative_processes:
      - name: Synchrotron
        B:
          freeze: false
          estimate_from: ["suzaku", "hess"] # 1st soft X-ray, 2nd VHE data
          prior:
            name: uniform
            min: 0 uG
            max: inf uG
      - name: InverseCompton
        seed_photon_fields:
          - "CMB"
          - ["FIR", "26.5 K", "0.415 eV cm-3"]
        Eemin: 100 GeV
    metadata:
      total_particle_energy:
        save: true # if true save to blob metadata
        e_min: 1 TeV

mcmc:
  nwalkers: 32
  nburn: 100
  nrun: 20
  threads: 4
  prefit: true
  interactive: false

Fitting PionDecay emission from a proton distribution

output_path:

data:
  hess: RXJ1713_HESS_2007.dat

models:
  - name: PionDecay
    overwrite: true
    distance: "1.5 kpc"
    particle_distribution:
      name: ExponentialCutoffPowerLaw
      amplitude:
        freeze: false
        log10: true
        init_value: 1e45 TeV-1
        prior:
          name: uniform
          min: 1 TeV-1
          max: inf TeV-1
      e_0:
        freeze: true
        init_value: 1 TeV
      alpha:
        init_value: 1.6
        prior:
          name: uniform
          min: -1
          max: 5
      e_cutoff:
        log10: true
        init_value: 12 TeV
      beta:
        freeze: true
        init_value: 0.54
    radiative_processes:
      - name: PionDecay
        nh: "10 cm-3"
    metadata:
      particle_distribution:
        save: true # if true save to blob metadata
        energy_range: np.logspace(-3, 2, 50) * u.TeV
      total_particle_energy:
        save: true # if true save to blob metadata
        e_min: 1 TeV

mcmc:
  nwalkers: 32
  nburn: 100
  nrun: 20
  threads: 4
  prefit: true
  interactive: false

Multiple radiative processes with same particle distributions

TODO

Multiple radiative processes with different particle distributions

TODO

About

A framework for building and running multiple astrophysical models using naima

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages