-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from broulston/SB2-Update
SB2 update for v2.0 of PyHammer (https://arxiv.org/abs/2006.01199)
- Loading branch information
Showing
257 changed files
with
25,214 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Large diffs are not rendered by default.
Oops, something went wrong.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.