Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 49 additions & 7 deletions spisea/synthetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,10 @@ def _make_star_systems_table(self, mass, isMulti, sysMass):
# effect is so small
# Convert nan_to_num to avoid errors on greater than, less than comparisons
star_systems_phase_non_nan = np.nan_to_num(star_systems['phase'], nan=-99)
bad = (star_systems_phase_non_nan > 5) & (star_systems_phase_non_nan < 101) & (star_systems_phase_non_nan != 9) & (star_systems_phase_non_nan != -99)
bad = np.where( (star_systems_phase_non_nan > 5) & (star_systems_phase_non_nan < 101) &
(star_systems_phase_non_nan != 9) & (star_systems_phase_non_nan != -99))
star_systems['phase'][bad] = 5


#####
# Make Remnants
# Note: Some models already have WDs in them. If they do, then they shouldn't
Expand Down Expand Up @@ -443,11 +443,7 @@ def _make_companions_table(self, star_systems, compMass):

companions['e'] = self.imf._multi_props.random_e(np.random.rand(N_comp_tot))
companions['i'], companions['Omega'], companions['omega'] = self.imf._multi_props.random_keplarian_parameters(
np.random.rand(N_comp_tot),
np.random.rand(N_comp_tot),
np.random.rand(N_comp_tot)
)

np.random.rand(N_comp_tot),np.random.rand(N_comp_tot),np.random.rand(N_comp_tot))

# Make an array that maps system index (ii), companion index (cc) to
# the place in the 1D companions array.
Expand Down Expand Up @@ -1122,6 +1118,7 @@ def __init__(self, logAge, AKs, distance,
'ubv,R', 'ubv,I'],
verbose=False):
self.metallicity = metallicity
self.verbose=verbose

# Make the iso_dir, if it doesn't already exist
if not os.path.exists(iso_dir):
Expand Down Expand Up @@ -1223,6 +1220,12 @@ def __init__(self, logAge, AKs, distance,

self.make_photometry(rebin=rebin, vega=vega, comp_filters=comp_filters)

# Drop filters in the saved file that we don't actually want here
all_filters = ['m_'+get_filter_col_name(f) for f in filters]
drop_columns = [col for col in self.points.columns if (col[:2]=='m_' and
(col not in all_filters))]
self.points.remove_columns(drop_columns)

return

def make_photometry(self, rebin=True, vega=vega, comp_filters=None):
Expand Down Expand Up @@ -2042,3 +2045,42 @@ def calc_ab_vega_filter_conversion(filt_str):

return vega_mag_ab

def calc_st_vega_filter_conversion(filt_str):
"""
Function to calculate the conversion between
ST and Vega magnitudes for a given filter:
m_ST - m_vega

Note: this conversion is just the vega magnitude in
ST system

Parameters:
-----------
filt_str: string
Filter identification string
"""
# Get filter info
filt = get_filter_info(filt_str)

# Interpolate the filter function to be the exact same sampling as the
# vega spectrum
c = 2.997*10**18 # A / s
filt_interp = scipy.interpolate.interp1d(filt.wave, filt.throughput, kind='linear', bounds_error=False,
fill_value=0)
s_interp = filt_interp(vega.wave)

# Calculate the numerator
diff = np.diff(vega.wave)
numerator = np.sum(vega.flux[:-1] * s_interp[:-1] * diff)

# Now we need to intergrate the filter response for the denominator
denominator = np.sum(s_interp[:-1] * diff)
# Fλ must be in erg cm–2 sec–1 Å–1

# Calculate vega AB magnitude. This is the conversion
vega_mag_st = -2.5 * np.log10(numerator / denominator) - 21.1

print('For {0}, m_st - m_vega = {1}'.format(filt_str, vega_mag_st))

return vega_mag_st