Skip to content

Commit

Permalink
Merge pull request #38 from broulston/SB2-Update
Browse files Browse the repository at this point in the history
SB2 update for v2.0 of PyHammer (https://arxiv.org/abs/2006.01199)
  • Loading branch information
broulston authored Jun 3, 2020
2 parents f426c57 + 085321c commit 1d5ae1f
Show file tree
Hide file tree
Showing 257 changed files with 25,214 additions and 210 deletions.
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,18 @@
resources/runbefore
PyHammerResults*
temp_input_*
*.csv
*.csv
.DS_Store
guess_type.txt
measure_temp_Halpha.py
PyHammer.app/Contents/Info.plist
PyHammer.app/Contents/MacOS/applet
PyHammer.app/Contents/PkgInfo
PyHammer.app/Contents/Resources/applet.icns
PyHammer.app/Contents/Resources/applet.rsrc
PyHammer.app/Contents/Resources/description.rtfd/TXT.rtf
PyHammer.app/Contents/Resources/Scripts/main.scpt
PyHammer.app/Icon
resources/PyHammer.scpt
resources/templates/allspec.txt
PyHammer.app/Icon
19 changes: 15 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,37 @@
# PyHammer

[![GitHub release](https://img.shields.io/github/release/BU-hammerTeam/PyHammer.svg)](https://github.com/BU-hammerTeam/PyHammer/releases/latest)
[![GitHub commits](https://img.shields.io/github/commits-since/BU-hammerTeam/PyHammer/v1.2.0.svg)](https://github.com/BU-hammerTeam/PyHammer/commits/master)
[![GitHub commits](https://img.shields.io/github/commits-since/BU-hammerTeam/PyHammer/v2.0.0.svg)](https://github.com/BU-hammerTeam/PyHammer/commits/master)
[![GitHub issues](https://img.shields.io/github/issues/BU-hammerTeam/PyHammer.svg)](https://github.com/BU-hammerTeam/PyHammer/issues)
[![license](https://img.shields.io/github/license/BU-hammerTeam/PyHammer.svg)](https://github.com/BU-hammerTeam/PyHammer/blob/master/license.txt)
[![Python Supported](https://img.shields.io/badge/Python%20Supported-3-brightgreen.svg)](conda)
[![Maintenance](https://img.shields.io/maintenance/yes/2018.svg)]()
[![Maintenance](https://img.shields.io/maintenance/yes/2020.svg)]()
[![Powered by Astropy](https://img.shields.io/badge/powered%20by-AstroPy-orange.svg?style=flat)](http://www.astropy.org)

### A Python Spectral Typing Suite

PyHammer is a tool developed to allow rapid and automatic spectral classification of stars according to the Morgan-Keenan classification system. Working in the range of 3,650 - 10,200 Angstroms, the automatic spectral typing algorithm compares important spectral lines to template spectra and determines the best matching spectral type, ranging from O to L type stars. This tool has the additional features that it can determine a star's metallicity ([Fe/H]) and radial velocity shifts. Once the automatic classification algorithm has run, PyHammer provides the user an interface for determining spectral types visually by comparing their spectra to provided templates.

Version 2.0.0 of PyHammer adds the ability to spectral type double-lined spectroscopic binaries (SB2). This updates adds new SB2 templates which were constructed in natural units (i.e. ergs /s /Å) using GaiaDR2 distances. This is done using a library of luminosity normalized spectra. This library was created from a combination of the [MaStar](https://www.sdss.org/surveys/mastar/) survey from [SDSS-IV](https://www.sdss.org) and the [Pickles+1998](https://ui.adsabs.harvard.edu/abs/1998PASP..110..863P/abstract) library. The Pickles library was used for OBAF stars while MaStar and SDSS was used for the GKM, C, WD stars.

Modeled after [The Hammer: An IDL Spectral Typing Suite][thehammer] published in [Covey et al. 2007][covey+07] available on [GitHub][hammerGitHub].

See the [PyHammer Wiki](https://github.com/BU-hammerTeam/PyHammer/wiki) for more information on how to install and use this program.

Information on how the luminosity spectra are added to create SB2 templates can be found in the [Roulston+2020][Roulston_arXiv] paper.

### Publications

PyHammer is detailed in our accepted Astrophysical Journal Supplements [Kesseli et al. (2017)][apjs].
PyHammer 1.0.0 is detailed in our accepted Astrophysical Journal Supplements [Kesseli et al. (2017)][Kesseli_apjs].

PyHammer 2.0.0 is detailed in our upcoming Astrophysical Journal Supplements [Roulston et al. (2020)][Roulston_arXiv]

![GUI](./resources/PyHammer2_GUI.png?raw=true)

[thehammer]: http://myweb.facstaff.wwu.edu/~coveyk/thehammer.html
[covey+07]: http://adsabs.harvard.edu/abs/2007AJ....134.2398C
[hammerGitHub]: https://github.com/jradavenport/TheHammer
[pyhammerwiki]: https://github.com/BU-hammerTeam/PyHammer/wiki
[apjs]: http://iopscience.iop.org/article/10.3847/1538-4365/aa656d/pdf
[Kesseli_apjs]: http://iopscience.iop.org/article/10.3847/1538-4365/aa656d/pdf
[Roulston_arXiv]: https://arxiv.org/abs/2006.01199
[SB2_GitHub]: https://github.com/broulston/SB2
408 changes: 361 additions & 47 deletions eyecheck.py
100644 → 100755

Large diffs are not rendered by default.

Empty file modified gui_utils.py
100644 → 100755
Empty file.
88 changes: 88 additions & 0 deletions measure_allTemps_Indices.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# %load_ext autoreload
# %autoreload 2

import numpy as np

from pyhamimports import *
from spectrum import Spectrum
import glob
from tqdm import tqdm
from subprocess import check_output

datestr = check_output(["/bin/date","+%F"])
datestr = datestr.decode().replace('\n', '')

singleTemp_dir = "resources/templates/"
SB2Temp_dir = "resources/templates_SB2/"

singleTemp_list = np.array([os.path.basename(x)
for x in glob.glob(singleTemp_dir + "*.fits")])
singleTemp_list.sort()

SB2Temp_list = np.array([os.path.basename(x)
for x in glob.glob(SB2Temp_dir + "*.fits")])
SB2Temp_list.sort()

# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 = O, B, A, F, G, K, M, L, C, WD
single_letter_specTypes = np.array(['O', 'B', 'A', 'F', 'G', 'K', 'M', 'L', 'C', 'W'])
specTypes = np.array(['O', 'B', 'A', 'F', 'G', 'K', 'M', 'L', 'C', 'WD'])

new_tempLines_0 = np.empty(singleTemp_list.size, dtype=int)
new_tempLines_1 = np.empty(singleTemp_list.size, dtype=int)
new_tempLines_2 = np.empty(singleTemp_list.size, dtype=np.float64)
new_tempLines_3 = np.ones(singleTemp_list.size, dtype=int) * 5
new_tempLines_4 = []

for ii in range(singleTemp_list.size):
new_tempLines_0[ii] = np.where(
single_letter_specTypes == singleTemp_list[ii][0])[0][0]
if new_tempLines_0[ii] == 9:
new_tempLines_1[ii] = singleTemp_list[ii][2]
else:
new_tempLines_1[ii] = singleTemp_list[ii][1]
if len(singleTemp_list[ii].replace("_", " ").split()) == 1:
new_tempLines_2[ii] = 0.
else:
new_tempLines_2[ii] = np.float64(
singleTemp_list[ii].replace("_", " ").split()[1])

spec = Spectrum()
ftype = None
print("Measuring lines for single star templates:")
for ii in tqdm(range(singleTemp_list.size)):
message, ftype = spec.readFile(singleTemp_dir + singleTemp_list[ii], ftype)
spec._lines = spec.measureLines()
lines = np.array(list(spec._lines.values()))[
np.argsort(list(spec._lines.keys()))]
new_tempLines_4.append(lines)

SB2_index_start = new_tempLines_0.max() + 1 # 10
new_tempLines_0 = np.append(new_tempLines_0, np.arange(
SB2_index_start, SB2_index_start + SB2Temp_list.size, step=1))
new_tempLines_1 = np.append(new_tempLines_1, np.zeros(SB2Temp_list.size))
new_tempLines_2 = np.append(new_tempLines_2, np.zeros(SB2Temp_list.size))
new_tempLines_3 = np.append(new_tempLines_3, np.ones(SB2Temp_list.size) * 5)
# new_tempLines_4 = new_tempLines_4

spec = Spectrum()
ftype = None
print("Measuring lines for SB2 templates:")
for ii, filename in enumerate(tqdm(SB2Temp_list)):
# temp_list = []
message, ftype = spec.readFile(SB2Temp_dir + filename, ftype)
measuredLines = spec.measureLines()
spec._lines = measuredLines
lines = np.array(list(spec._lines.values()))[
np.argsort(list(spec._lines.keys()))]
linesLabels = np.array(list(spec._lines.keys()))[
np.argsort(list(spec._lines.keys()))]
# temp_list.append(lines)
new_tempLines_4.append(lines)

new_tempLines = [new_tempLines_0, new_tempLines_1,
new_tempLines_2, new_tempLines_3, new_tempLines_4]

pklPath = os.path.join(spec.thisDir, 'resources',
f'tempLines_{datestr}.pickle')
with open(pklPath, 'wb') as pklFile:
pickle.dump(new_tempLines, pklFile)
6 changes: 5 additions & 1 deletion pyhamimports.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# Look at version specific information
import sys
ver = sys.version_info # Get Python version
ver = sys.version_info # Get Python version
if ver.major != 3:
sys.exit('Python 3 is required to run PyHammer.')
# We need a function to determine which modules
Expand All @@ -21,6 +21,7 @@

# Some basic python libraries
import os
import re
import getopt
import numpy as np
from numpy import ma
Expand All @@ -35,6 +36,9 @@
import pickle
import csv
from collections import OrderedDict
from scipy.optimize import curve_fit
from tqdm import tqdm
import warnings

# Check which PyQt version the user may have
# installed and import the appropriate content
Expand Down
Loading

0 comments on commit 1d5ae1f

Please sign in to comment.