-
Notifications
You must be signed in to change notification settings - Fork 41
Updating non-LTE, LTE, and AGB stellar libraries #860
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
base: master
Are you sure you want to change the base?
Changes from all commits
3aed432
7875408
90d1069
653b4e0
2a29590
4ff2f81
693e154
4b47bc9
a173edc
2e5e2cc
49e4207
17fd50c
f2e8e75
6e46f03
9aebf66
1d0659c
439a3dc
2f8c6de
a024d69
9f5aa9d
6c964ef
7fd8448
5db671a
10e72b6
4d85c45
ef27fe7
f2c6c36
1d24f44
7b40d9a
2681eb2
eb624a9
3e8c96e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import argparse | ||
| import numpy as np | ||
| import matplotlib.pyplot as plt | ||
|
|
||
| from beast.physicsmodel.stars import stellib | ||
| from helpers import get_stellib_boundaries | ||
|
|
||
| if __name__ == "__main__": # pragma: no cover | ||
|
|
||
| parser = argparse.ArgumentParser() | ||
| parser.add_argument( | ||
| "--grid", | ||
| default="BOSZ2024", | ||
| choices=["Tlusty2025", "BOSZ2024", "Aringer2016", "Kurucz", "Tlusty"], | ||
| help="Grid to show", | ||
| ) | ||
| parser.add_argument("--png", action="store_true", help="save figures to png files") | ||
| args = parser.parse_args() | ||
|
|
||
| if args.grid == "BOSZ2024": | ||
| slib = stellib.BOSZ2024() | ||
| elif args.grid == "Tlusty2025": | ||
| slib = stellib.Tlusty2025() | ||
| elif args.grid == "Aringer2016": | ||
| slib = stellib.Aringer2026() | ||
| elif args.grid == "Kurucz": | ||
| slib = stellib.Kurucz() | ||
| elif args.grid == "Tlusty": | ||
| slib = stellib.Tlusty() | ||
|
|
||
| # useful when new grids are generarted | ||
| # results are used to define the bounding box in a model definition | ||
| bound = get_stellib_boundaries(slib, dlogT=0.0, dlogg=0.0) | ||
| print("Algorithmically generated bounds") | ||
| print(bound) | ||
|
|
||
| # setup the plots | ||
| fontsize = 12 | ||
| font = {"size": fontsize} | ||
| plt.rc("font", **font) | ||
| plt.rc("lines", linewidth=2) | ||
| plt.rc("axes", linewidth=2) | ||
| plt.rc("xtick.major", width=2) | ||
| plt.rc("ytick.major", width=2) | ||
|
|
||
| for cz in np.unique(slib.Z.data): | ||
| gvals = slib.Z.data == cz | ||
| plt.plot(slib.logT[gvals], slib.logg[gvals], "ko") | ||
| plt.plot(bound[:, 0], bound[:, 1], "g-", label="algorithmly generated") | ||
| slib.plot_boundary( | ||
| dlogT=0.0, dlogg=0.0, label="defined in class def", alpha=0.5, color="b" | ||
| ) | ||
| plt.title(f"{args.grid}; z = {cz:.2e}") | ||
| plt.xlabel("log(Teff)") | ||
| plt.ylabel("log(g)") | ||
| plt.legend() | ||
|
|
||
| if args.png: | ||
| plt.savefig(f"slib_coverage_{args.grid}_z_{cz:.2e}.png") | ||
| plt.close() | ||
| else: | ||
| plt.show() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import matplotlib.pyplot as plt | ||
| import numpy as np | ||
| import astropy.units as u | ||
| from astropy.io import ascii | ||
|
|
||
| from helpers import rebin_spectrum | ||
|
|
||
| if __name__ == "__main__": # pragma: no cover | ||
|
|
||
| solar_z = 0.02 | ||
|
|
||
| # read the kurucz spectrum | ||
| # wavelength first | ||
| wave_filename = "/home/kgordon/Python/extstar_data/Models/BOSZ2024/r2000/bosz2024_wave_r2000.txt" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line contains a hardcoded absolute path pointing to your specific directory. To ensure portability across different environments and for other users, please replace this with a relative path or leverage the standard beast data directory configuration paths. Also the corresponding documentation should be provided.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comment above. |
||
| mspec_lte_wave = ascii.read( | ||
| wave_filename, | ||
| format="no_header", | ||
| # fast_reader={"exponent_style": "D"}, | ||
| names=["Wave"], | ||
| ) | ||
|
|
||
| model_filename = "/home/kgordon/Python/extstar_data/Models/BOSZ2024/r2000/m+0.00/bosz2024_ap_t15000_g+4.0_m+0.00_a+0.00_c+0.00_v2_r2000_resam.txt.gz" | ||
| mspec_lte = ascii.read( | ||
| model_filename, | ||
| format="no_header", | ||
| # fast_reader={"exponent_style": "D"}, | ||
| names=["SFlux", "SCont"], | ||
| ) | ||
| mspec_lte["Wave"] = mspec_lte_wave["Wave"] * u.angstrom | ||
|
|
||
| # read the tlusty spectrum | ||
| model_filename = ( | ||
| "/home/kgordon/Python/extstar_data/Models/Tlusty_2023/z100t15000g400v2.spec.gz" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. ;-) |
||
| ) | ||
| # read in the model spectrum | ||
| mspec = ascii.read( | ||
| model_filename, | ||
| format="no_header", | ||
| fast_reader={"exponent_style": "D"}, | ||
| names=["Wave", "SFlux"], | ||
| ) | ||
|
|
||
| # convert the type to float | ||
| mspec["SFlux"] = mspec["SFlux"].astype(float) | ||
|
|
||
| # set the units | ||
| fluxunit = u.erg / (u.s * u.cm * u.cm * u.angstrom) | ||
| mspec["Wave"].unit = u.angstrom | ||
| mspec["SFlux"].unit = fluxunit | ||
|
|
||
| # now extract the wave and flux colums | ||
| mwave = mspec["Wave"] | ||
| mflux = mspec["SFlux"] | ||
|
|
||
| # rebin to R=4000 for speed | ||
| rbres = 4000.0 | ||
| wave_rebin, flux_rebin, npts_rebin = rebin_spectrum( | ||
| mwave.value, mflux.value, rbres, [200.0, 310000.0] | ||
| ) | ||
| wave_rebin *= u.angstrom | ||
| print(len(wave_rebin)) | ||
|
|
||
| # plot | ||
| plt.plot(wave_rebin.to(u.micron), flux_rebin * 4 * np.pi) | ||
| plt.plot(mspec_lte["Wave"].to(u.micron), mspec_lte["SFlux"] * 4 * np.pi) | ||
| plt.yscale("log") | ||
| plt.xscale("log") | ||
| plt.show() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With new models, do we still stick to this old Zsun value? For example, the PARSEC models use Zsun=0.0152.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The solar_z value for each model is different. I've gone back to the papers to figure out the correct value for each grid. This is given with references in each script that generates the grids. We want the absolute metallicity, not relative to solar as each grid uses a different solar value - as the solar value changes with time. Exciting.
I will update this script to compare models from any two stellar libraries using the grids themselves. This is needed to ensure that the scaling is correct for all the models. And provides a great way to compare models from two grids for the same stellar parameters. Will not resolve this comment till the expanded script is ready.