Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Sonora" brown dwarf templates in eazy format #33

Merged
merged 1 commit into from
Jun 5, 2023
Merged

Conversation

gbrammer
Copy link
Owner

@gbrammer gbrammer commented Jun 5, 2023

Solar-metallicity "Sonora" templates derived from https://zenodo.org/record/1309035 (Marley et al. 2018):
sonora_m0.0.tgz

"""
Sonora
https://zenodo.org/record/1309035
Sonora Cholla
https://zenodo.org/record/4450269
Bobcat
https://zenodo.org/record/5063476
"""

import glob
import os
import numpy as np
import astropy.units as u
from grizli import utils

import eazy

files = glob.glob('spectra/sp_*0')
files.sort()

R = 1000
wR = utils.log_zgrid([1000, 35.e4], 1./R)

for file in files:
    print(file)
    _x = np.loadtxt(file, skiprows=2, unpack=True)
    
    wave = _x[0][::-1]*u.micron
    fnu = _x[1][::-1]*u.erg/u.second/u.cm**2/u.Hz
    flam = fnu * 3.e18 * u.Angstrom/u.second / (wave)**2
    flam = flam.to(u.erg/u.second/u.cm**2/u.Angstrom)
    
    t = eazy.templates.Template(arrays=(wave, flam))
    tr = t.resample(wR, in_place=False)
    
    tab = tr.to_table()
    tab['flux'].format = '.4e'
    
    teff, g = np.cast[int](file.split('t')[2].split('nc')[0].split('g'))
    logg = np.log10(g*100)
    met = file.split('_')[-1]
    
    tab.meta['origfile'] = os.path.basename(file)
    tab.meta['logg'] = logg
    tab.meta['teff'] = teff
    
    out = f'sonora/sonora_t{teff:04d}_g{logg:3.1f}_{met}'
    tab.write(out+'.fits', overwrite=True)

@gbrammer gbrammer merged commit c7ed4c7 into master Jun 5, 2023
@gbrammer gbrammer mentioned this pull request Jun 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant