isochrones
isochrones copied to clipboard
KeyError when calculating magnitudes for binary stars in isochrones package
I encountered a KeyError
when attempting to calculate magnitudes for binary stars using the isochrones package. The error occurs specifically when accessing the key 'J'
in the props_A
or props_B
dictionaries. This KeyError
prevents the successful calculation of magnitudes for the J-band.
Steps to Reproduce:
- Use the
mist.track.generate
function from the isochrones package to generate synthetic magnitudes for a binary star - Specify the bands to be 'J', 'H', 'K', 'BP', 'RP', and '
- Attempt to access the 'J' key in the
props_A
orprops_B
dictionaries.
Expected Behavior:
The isochrones package should generate the synthetic magnitudes for the specified bands without any KeyError.
Actual Behavior:
A KeyError
is raised for the key 'J' when trying to access the props_A['J']
or props_B['J']
values.
- Operating System:
- Python Version: 3.
- isochrones Package Version: v2
Additional Information:
I have verified that the MIST evolutionary tracks are properly installed and up to date. I have also confirmed that the 'J' band is included in the bands list, matching the available bands in the MIST tracks.
PS: Here is the code snippet I am using:
from isochrones import BinaryStarModel
from isochrones.utils import addmags
distance = 500 # pc
AV = 0.2
mass_A = 1.0
mass_B = 0.5
age = 9.6
feh = 0.0
# Synthetic 2MASS and Gaia magnitudes
bands = ['J', 'H', 'K', 'BP', 'RP', 'G']
props_A = mist.track.generate(mass_A, age, feh, distance=distance, AV=AV,
bands=bands, return_dict=True, accurate=True)
props_B = mist.track.generate(mass_B, age, feh, distance=distance, AV=AV,
bands=bands, return_dict=True, accurate=True)
unc = dict(J=0.02, H=0.02, K=0.02, BP=0.002, RP=0.002, G=0.001)
mags_tot = {b: (addmags(props_A[b], props_B[b]), unc[b]) for b in bands}
# Gaia parallax in mas for a system at 500 pc
parallax = (2, 0.05)
mod_binary = BinaryStarModel(mist, **mags_tot, parallax=parallax, name='demo_binary')
Please let me know if you need any further information or if there are any suggested workarounds for this issue. Thank you for your attention to this matter
Hi, I replaced mags_tot = {b: (addmags(props_A[b], props_B[b]), unc[b]) for b in bands} with mags_tot = {b: (addmags(props_A[b+'_mag'], props_B[b'_mag']), unc[b]) for b in bands}
the DataFrame returned by mist.track.generate() has such keys as 'J_mag', 'G_mag', etc.