Skip to main content

Given a FITS spectrum file, this script fits a Voigt profile to each emission line, facilitating flux calculation and data validity assessment. It generates plots for each line and outputs comprehensive results in both FITS and ECSV formats. These files contain all necessary information for analysis or reproduction.

Project description

spec2flux

About spec2flux

Spec2flux (Spectrum to Flux) aims to accurately calculate the emission line flux of lines in the Far Ultraviolet (FUV) range. This range contains information that can help clue in on exoplanetary atmospheres with the measurements providing insight into FUV radiation from host stars. Integrating UV spectra with X-ray data allows us to estimate the stellar corona, adding to the toolkit of exoplanet atmosphere data.

How it works

The script accomplishes the task of calculating flux by:

  1. Grouping emission lines using a preset tolerance, which can be adjusted if using a different DEM file.
  2. Calculating the Doppler shift by fitting a composite Voigt profile to the strongest emission lines, and comparing Voigt peaks to rest wavelength to calculate.
  3. Iterating through each line, determining if noise, and then calculating the flux either using the Voigt profile or the original data.
  4. Presents a final plot of all of the final emission lines, and exports the calculations as a FITS and ECSV file.

Prerequisites

  • astropy
  • matplotlib
  • scipy
  • seaborn
  • numpy
  • pandas

Installation

  1. Clone the repository

    git clone https://github.com/bellalongo/spec2flux.git
    
  2. Navigate to docs/tutorial.py and adjust spectrum specs, making sure the spectrum is in the docs directory.

  3. Adjust the 'fresh_start' parameter depending on whether you want to adjust calculations on a new run
    (if first run, set to True)

    fresh_start = True
    
  4. Adjust the 'gaussian_smoothing' parameter depending on whether you to smooth the spectrum
    (if first run, set to False)

    gaussian_smoothing = False
    
  5. Run the script:

    python tutorial.py
    

Adjustments

The script can be run on its own without any adjustments, but if the star is a little finicky:

tutorial.py

  • adjust the mask used to isolate emission lines
  • edit header if want different header information

emission_lines.py

  • adjust peak_width in 'peak_width_finder'
  • adjust tolerance used to group emission lines in 'grouping_emission_lines'
  • adjust voigt fit initial parameters

Doppler shift calculation

A plot will appear of the 'best' emission lines, with a Voigt fit fitted to it. Click 'y' if you think the line should be used to calculate Doppler shift (these lines will automatically not be considered as noise), and 'n' if the emission line if not.

doppler calculation example

Determining if noise

All lines not selected for Doppler calculation will appear, some with a Voigt profile fitted if possible to be selected as noise or not noise. Click 'y' if you think the line is noise, and 'n' if the line is not noise.

Not noise: Not noise example

Noise: Not noise example

Final plot

After all emission line selections and calculations have been made, a final plot will appear showing the spectrum and each labeled emission line. Matplotlib gives the ability to zoom into the plot, so please do so to double-check the lines. This plot is saved to the 'plots' folder.

final plot example

Zoomed in: zoom example


Using the data:

Header contains:

  • DATE: date flux was calculated
  • FILENAME: name of the fits file used to for flux calc
  • TELESCP: telescope used to measure spectrum
  • INSTRMNT: active instrument to measure spectrum
  • GRATING: grating used to measure spectrum
  • TARGNAME: name of star used in measurement
  • DOPPLER: doppler shift used to measure flux
  • WIDTH: average peak width of the emissoin lines
  • RANGE: flux range used to isolate emission line
  • WIDTHPXL: average emission line peak width in pixels
  • UPPRLIMIT: upper limit used for noise

Using the data:

ECSV Data: File columns are Ion, Rest Wavelength, Flux, Error, Blended Line, each row representing a grouped emission line.
FITS Data: FITS Table containing the same data as the ECSV file.
Note: Noise is marked as having the negative of the upper limit (3*error) as the flux and an error of 0.

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

spec2flux-0.1.2.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

spec2flux-0.1.2-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file spec2flux-0.1.2.tar.gz.

File metadata

  • Download URL: spec2flux-0.1.2.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for spec2flux-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f243ca36f9f674bac9b4e0edbc5c6768f5e170ec0df6ec0229afdc4000469958
MD5 488d999ac258bcc9c7497565abae9579
BLAKE2b-256 d8fd40dfe614677158983dfeec92dfffb22e0aa714ea35d7dbd0350a23e326a2

See more details on using hashes here.

File details

Details for the file spec2flux-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: spec2flux-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.5

File hashes

Hashes for spec2flux-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 63facdf2863a069ca7d47a6dbfcf7c61864ac2aaca17cf090552adfe637efd81
MD5 ba08e289c555145c7ff8fdc245ba47d7
BLAKE2b-256 d38b4d32b3bc7f9704b00f1977fed7f125350570c4e6e8872ffc4c3bce9a8673

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