Skip to main content

A Python package for rotational and instrumental broadening of stellar spectra

Project description

rotins

A Python package for rotational and instrumental broadening of stellar spectra. This is a Python translation of the FORTRAN program used in TLUSTY by Ivan Hubeny et al.

Installation

pip install rotins

Features

  • Rotational broadening with configurable limb darkening coefficient
  • Instrumental broadening using Gaussian profiles
  • Support for both FWHM and spectral resolution parameters
  • Both object-oriented and functional programming interfaces
  • Support for normalized and non-normalized spectra
  • Efficient convolution with proper edge handling

Quick Start

import numpy as np
from rotins import RotIns, rotins

# Load your spectrum (wavelength and flux arrays)
wl = np.loadtxt("spectrum_wl.txt")
flux = np.loadtxt("spectrum_flux.txt")

# Using the class-based interface
broadener = RotIns(vsini=50.0, fwhm=0.1)  # vsini in km/s, fwhm in wavelength units
conv_wl, conv_flux = broadener.broaden(wl, flux)

# Using the functional interface
broaden = rotins(vsini=50.0, fwhm=0.1)
conv_wl, conv_flux = broaden(wl, flux)

Documentation

Class-based Interface

from rotins import RotIns

broadener = RotIns(
    vsini=50.0,           # Rotational velocity in km/s
    fwhm=0.1,            # FWHM in wavelength units
    fwhm_type="fwhm",    # Either "fwhm" or "res"
    limb_coeff=0.6,      # Limb darkening coefficient
    base_flux=1.0,       # Base flux level
)

# Broaden the spectrum
conv_wl, conv_flux = broadener.broaden(
    wl,                  # Wavelength array
    flux,               # Flux array
    lim=(4000, 5000),   # Optional wavelength limits
)

Functional Interface

from rotins import rotins

# Create a broadening function
broaden = rotins(
    vsini=50.0,           # Rotational velocity in km/s
    fwhm=0.1,            # FWHM in wavelength units
    fwhm_type="fwhm",    # Either "fwhm" or "res"
    limb_coeff=0.6,      # Limb darkening coefficient
    base_flux=1.0,       # Base flux level
)

# Apply broadening to multiple spectra
conv_wl1, conv_flux1 = broaden(wl1, flux1)
conv_wl2, conv_flux2 = broaden(wl2, flux2, lim=(4000, 5000))

Parameters

  • vsini: Rotational velocity in km/s. If None or 0.0, no rotational broadening is applied.
  • fwhm: Full Width at Half Maximum in wavelength units (if fwhm_type="fwhm") or resolving power (if fwhm_type="res"). If None or 0.0, no instrumental broadening is applied.
  • fwhm_type: Type of the FWHM parameter. Either "fwhm" for direct wavelength units or "res" for spectral resolution.
  • limb_coeff: Limb darkening coefficient. Default is 0.6 (from SYNSPEC).
  • base_flux: Base flux level. Use 1.0 for normalized spectra, 0.0 for non-normalized spectra.
  • lim: Optional tuple of (min_wavelength, max_wavelength) to limit the broadening range.

Scientific Details

The calculations follow the formulas from:

Gray, D.F., 2008, The Observation and Analysis of Stellar Photospheres, Cambridge University Press, Cambridge, 3rd edition.

Rotational Broadening

The rotational broadening kernel is given by:

G(\Delta\lambda) = \frac{2(1-\epsilon)[1-(\Delta\lambda/\Delta\lambda_0)^2]^{1/2}+(\pi\epsilon/2)[1-(\Delta\lambda/\Delta\lambda_0)^2]}{\pi\Delta\lambda_0(1-\epsilon/3)}

where:

  • \epsilon is the limb darkening coefficient
  • \Delta\lambda_0 = \frac{\lambda v \sin i}{c}
  • c is the speed of light

Instrumental Broadening

Instrumental broadening uses a Gaussian kernel with:

\sigma = \frac{\textrm{FWHM}}{2\sqrt{2\ln 2}}

Contributing

Pull requests are welcome. Please ensure that tests pass and add new tests for new features.

License

MIT License - see the LICENSE file for details.

Citation

If you use this package in your research, please cite:

@software{rotins,
  author = {Krishna, Sriram},
  title = {rotins: A Python package for stellar spectral broadening},
  year = {2022},
  url = {https://github.com/k-sriram/rotins}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rotins-1.0.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rotins-1.0.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file rotins-1.0.0.tar.gz.

File metadata

  • Download URL: rotins-1.0.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for rotins-1.0.0.tar.gz
Algorithm Hash digest
SHA256 28855f5598a153db7500c1e944e43cae55f12736847f480f05cded9fab5eb4eb
MD5 afdd19c5b58d13ffee834171562036fc
BLAKE2b-256 3c2bf841526c02c1da65ad5c10ddef86b80a00ccc3b62849e5d2484069f2ee62

See more details on using hashes here.

File details

Details for the file rotins-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: rotins-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.0

File hashes

Hashes for rotins-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5428880918c8a11fdf9222b39ee700d30752cbbda49171ea07c2186d7b0245b2
MD5 33d9dd4e53572c6cd1bff0e3224cf50b
BLAKE2b-256 64c6f5b9f1ff710696335f471a50292bfe1a38f1dd32bc5c63e6189237e9bf43

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page