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.1.tar.gz (15.8 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.1-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: spec2flux-0.1.1.tar.gz
  • Upload date:
  • Size: 15.8 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.1.tar.gz
Algorithm Hash digest
SHA256 45e0457b8a5ac20d5bf001e1e5d9ff2320a1965dd22a618387866ef840849bed
MD5 d543c759a1298e318fb8d7f18251524b
BLAKE2b-256 9e7bd63d9021b7cbbce864a125ea517033ee433a55b24aa3f5edfdad6049a0e7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: spec2flux-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 15.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bff5df778ab1bca36359f6bd5e3c8d2b555580b6d90adeaec1ea691166db214e
MD5 14f1ae12da7a8f5568403be3244da523
BLAKE2b-256 cf37e9b60a18db15e23e67de04e59581126b2168bdea3fb57a96e73a5b3b964b

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