Skip to content

Commit 1d5ae1f

Browse files
authored
Merge pull request #38 from broulston/SB2-Update
SB2 update for v2.0 of PyHammer (https://arxiv.org/abs/2006.01199)
2 parents f426c57 + 085321c commit 1d5ae1f

257 files changed

Lines changed: 25214 additions & 210 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,18 @@
22
resources/runbefore
33
PyHammerResults*
44
temp_input_*
5-
*.csv
5+
*.csv
6+
.DS_Store
7+
guess_type.txt
8+
measure_temp_Halpha.py
9+
PyHammer.app/Contents/Info.plist
10+
PyHammer.app/Contents/MacOS/applet
11+
PyHammer.app/Contents/PkgInfo
12+
PyHammer.app/Contents/Resources/applet.icns
13+
PyHammer.app/Contents/Resources/applet.rsrc
14+
PyHammer.app/Contents/Resources/description.rtfd/TXT.rtf
15+
PyHammer.app/Contents/Resources/Scripts/main.scpt
16+
PyHammer.app/Icon
17+
resources/PyHammer.scpt
18+
resources/templates/allspec.txt
19+
PyHammer.app/Icon

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
# PyHammer
22

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

1011
### A Python Spectral Typing Suite
1112

1213
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.
1314

15+
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.
16+
1417
Modeled after [The Hammer: An IDL Spectral Typing Suite][thehammer] published in [Covey et al. 2007][covey+07] available on [GitHub][hammerGitHub].
1518

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

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

20-
PyHammer is detailed in our accepted Astrophysical Journal Supplements [Kesseli et al. (2017)][apjs].
25+
PyHammer 1.0.0 is detailed in our accepted Astrophysical Journal Supplements [Kesseli et al. (2017)][Kesseli_apjs].
26+
27+
PyHammer 2.0.0 is detailed in our upcoming Astrophysical Journal Supplements [Roulston et al. (2020)][Roulston_arXiv]
28+
29+
![GUI](./resources/PyHammer2_GUI.png?raw=true)
2130

2231
[thehammer]: http://myweb.facstaff.wwu.edu/~coveyk/thehammer.html
2332
[covey+07]: http://adsabs.harvard.edu/abs/2007AJ....134.2398C
2433
[hammerGitHub]: https://github.com/jradavenport/TheHammer
2534
[pyhammerwiki]: https://github.com/BU-hammerTeam/PyHammer/wiki
26-
[apjs]: http://iopscience.iop.org/article/10.3847/1538-4365/aa656d/pdf
35+
[Kesseli_apjs]: http://iopscience.iop.org/article/10.3847/1538-4365/aa656d/pdf
36+
[Roulston_arXiv]: https://arxiv.org/abs/2006.01199
37+
[SB2_GitHub]: https://github.com/broulston/SB2

eyecheck.py

100644100755
Lines changed: 361 additions & 47 deletions
Large diffs are not rendered by default.

gui_utils.py

100644100755
File mode changed.

measure_allTemps_Indices.py

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# %load_ext autoreload
2+
# %autoreload 2
3+
4+
import numpy as np
5+
6+
from pyhamimports import *
7+
from spectrum import Spectrum
8+
import glob
9+
from tqdm import tqdm
10+
from subprocess import check_output
11+
12+
datestr = check_output(["/bin/date","+%F"])
13+
datestr = datestr.decode().replace('\n', '')
14+
15+
singleTemp_dir = "resources/templates/"
16+
SB2Temp_dir = "resources/templates_SB2/"
17+
18+
singleTemp_list = np.array([os.path.basename(x)
19+
for x in glob.glob(singleTemp_dir + "*.fits")])
20+
singleTemp_list.sort()
21+
22+
SB2Temp_list = np.array([os.path.basename(x)
23+
for x in glob.glob(SB2Temp_dir + "*.fits")])
24+
SB2Temp_list.sort()
25+
26+
# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 = O, B, A, F, G, K, M, L, C, WD
27+
single_letter_specTypes = np.array(['O', 'B', 'A', 'F', 'G', 'K', 'M', 'L', 'C', 'W'])
28+
specTypes = np.array(['O', 'B', 'A', 'F', 'G', 'K', 'M', 'L', 'C', 'WD'])
29+
30+
new_tempLines_0 = np.empty(singleTemp_list.size, dtype=int)
31+
new_tempLines_1 = np.empty(singleTemp_list.size, dtype=int)
32+
new_tempLines_2 = np.empty(singleTemp_list.size, dtype=np.float64)
33+
new_tempLines_3 = np.ones(singleTemp_list.size, dtype=int) * 5
34+
new_tempLines_4 = []
35+
36+
for ii in range(singleTemp_list.size):
37+
new_tempLines_0[ii] = np.where(
38+
single_letter_specTypes == singleTemp_list[ii][0])[0][0]
39+
if new_tempLines_0[ii] == 9:
40+
new_tempLines_1[ii] = singleTemp_list[ii][2]
41+
else:
42+
new_tempLines_1[ii] = singleTemp_list[ii][1]
43+
if len(singleTemp_list[ii].replace("_", " ").split()) == 1:
44+
new_tempLines_2[ii] = 0.
45+
else:
46+
new_tempLines_2[ii] = np.float64(
47+
singleTemp_list[ii].replace("_", " ").split()[1])
48+
49+
spec = Spectrum()
50+
ftype = None
51+
print("Measuring lines for single star templates:")
52+
for ii in tqdm(range(singleTemp_list.size)):
53+
message, ftype = spec.readFile(singleTemp_dir + singleTemp_list[ii], ftype)
54+
spec._lines = spec.measureLines()
55+
lines = np.array(list(spec._lines.values()))[
56+
np.argsort(list(spec._lines.keys()))]
57+
new_tempLines_4.append(lines)
58+
59+
SB2_index_start = new_tempLines_0.max() + 1 # 10
60+
new_tempLines_0 = np.append(new_tempLines_0, np.arange(
61+
SB2_index_start, SB2_index_start + SB2Temp_list.size, step=1))
62+
new_tempLines_1 = np.append(new_tempLines_1, np.zeros(SB2Temp_list.size))
63+
new_tempLines_2 = np.append(new_tempLines_2, np.zeros(SB2Temp_list.size))
64+
new_tempLines_3 = np.append(new_tempLines_3, np.ones(SB2Temp_list.size) * 5)
65+
# new_tempLines_4 = new_tempLines_4
66+
67+
spec = Spectrum()
68+
ftype = None
69+
print("Measuring lines for SB2 templates:")
70+
for ii, filename in enumerate(tqdm(SB2Temp_list)):
71+
# temp_list = []
72+
message, ftype = spec.readFile(SB2Temp_dir + filename, ftype)
73+
measuredLines = spec.measureLines()
74+
spec._lines = measuredLines
75+
lines = np.array(list(spec._lines.values()))[
76+
np.argsort(list(spec._lines.keys()))]
77+
linesLabels = np.array(list(spec._lines.keys()))[
78+
np.argsort(list(spec._lines.keys()))]
79+
# temp_list.append(lines)
80+
new_tempLines_4.append(lines)
81+
82+
new_tempLines = [new_tempLines_0, new_tempLines_1,
83+
new_tempLines_2, new_tempLines_3, new_tempLines_4]
84+
85+
pklPath = os.path.join(spec.thisDir, 'resources',
86+
f'tempLines_{datestr}.pickle')
87+
with open(pklPath, 'wb') as pklFile:
88+
pickle.dump(new_tempLines, pklFile)

pyhamimports.py

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

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

2222
# Some basic python libraries
2323
import os
24+
import re
2425
import getopt
2526
import numpy as np
2627
from numpy import ma
@@ -35,6 +36,9 @@
3536
import pickle
3637
import csv
3738
from collections import OrderedDict
39+
from scipy.optimize import curve_fit
40+
from tqdm import tqdm
41+
import warnings
3842

3943
# Check which PyQt version the user may have
4044
# installed and import the appropriate content

0 commit comments

Comments
 (0)