File:SN 2002cx Spectra log.svg
Summary
Description |
English: Supernova 2002cx Spectra. It contains four spectra, one taken 2002-05-17 (Blue), one taken 2002-05-20 (Green), one taken 2002-06-02 (yellow) and one taken 2002-06-06 (red). Flux is normalized so that the area under each spectrum is 1000, and then ploted as log(flux). Spectra are offset from 0 by an integer in order to separate them. The key lists the date the spectrum was taken. Wavelength is in angstroms.
Data is from: Li, Weidong; Filippenko, Alexei V.; Chornock, Ryan et al. (04/2003). "SN 2002cx: The Most Peculiar Known Type Ia Supernova". Publications of the Astronomical Society of the Pacific 115 (806): 453-473. Chicago, Illinois: University of Chicago Press. DOI:10.1086/374200. Retrieved on 2009-06-19. |
||
Date | |||
Source | Own work | ||
Author | Falcorian | ||
Other versions |
![]() |
||
SVG development | |||
Source code | Python code# coding: utf-8
from numpy import array, log
import matplotlib.pyplot as plt
import seaborn as sns
# Set plotting style
sns.set_style("ticks")
labels = ['May 17', 'May 20', 'June 02', 'June 06']
files = [
"sn2002cx-20020517-fast.flm",
"sn2002cx-20020520-fast.flm",
"sn2002cx-20020602-fast.flm",
"sn2002cx-20020606-fast.flm",
]
def normalize_area(wavelengths, fluxes):
"""Takes a binned spectrum as two arrays and returns the flux normalized to
an area of 1000.
Args:
wavelengths (array): The wavelengths of the center of each bin of the
spectrum.
fluxes (array): The flux value for each bin.
Returns:
array: The flux values normalized to have a total area of 1000.
"""
desired_area = 1000
bin_width = wavelengths[1] - wavelengths[0]
area = sum(fluxes) * bin_width
normed_fluxes = (fluxes / area) * desired_area
return normed_fluxes
# Work on spectra
fig, ax = plt.subplots(figsize=(10, 6))
for i, file in enumerate(files):
offset = (len(files) - i) * 3
# Open data
with open(file) as f:
cont = f.read()
cont = cont.splitlines()
# Process data
wavelengths = []
fluxes = []
for line in cont:
if line.startswith('#'):
continue
sline = line.split()
wavelengths.append(float(sline[0]))
fluxes.append(float(sline[1]))
# Normalize the area of the flux
fluxes = array(fluxes)
fluxes = log(normalize_area(wavelengths, fluxes))
fluxes = fluxes + offset
# Plot
plot = plt.plot(wavelengths, fluxes, label=labels[i])
text_y = 10.8 - (2.9 * i)
ax.text(6900, text_y, labels[i], fontsize=20, color=plot[0].get_color())
# Remove y ticks
plt.yticks([])
sns.despine()
plt.xlabel(r'Wavelength (Å)', fontsize=18)
plt.ylabel('Normalized Log(Flux) + Offset', fontsize=18)
plt.title('SN 2002cx Spectra', fontsize=22)
plt.savefig("SN_2002cx_Spectra_log.svg", bbox_inches="tight")
plt.show()
|
Licensing
I, the copyright holder of this work, hereby publish it under the following licenses: This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International, 3.0 Unported, 2.5 Generic, 2.0 Generic and 1.0 Generic license.
You may select the license of your choice. |
|||
|
Category:Astronomical spectra
Category:CC-BY-SA-4.0,3.0,2.5,2.0,1.0
Category:Files by Falcorian
Category:GFDL
Category:License migration redundant
Category:Long file description pages with source data
Category:Pages with syntax highlighting errors
Category:SN 2002cx
Category:SVG astronomy
Category:Self-published work
Category:Valid SVG created with Matplotlib code