Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
fd84030
Currently, the checking infer_from loop is not properly preferring th…
SherelynA Mar 21, 2025
6911257
outline of a test
kelle Mar 24, 2025
7bd4dec
Changed rounding in the dwarf sequence relations because if not it wo…
SherelynA Mar 31, 2025
73f3651
Tried calling two different fixtures, one where we use substellar uni…
SherelynA Mar 31, 2025
cb31395
remove radius tests from just_spectrum
kelle Mar 31, 2025
c91504b
add results to paramaterization
kelle Mar 31, 2025
4a3e2a3
Merge pull request #1 from kelle/radius-fix-kelle
SherelynA Apr 2, 2025
61940e2
Tests work now, but when I run the final test_radius on my console, e…
SherelynA Apr 2, 2025
82b77cb
getting rid of the radius rounding in the relations.py.
SherelynA May 27, 2025
82cffb4
Update tests/test_fundamental_params.py
SherelynA May 27, 2025
5c99a21
Merge remote-tracking branch 'origin/infer_radius_fix' into infer_rad…
SherelynA May 27, 2025
85d7b08
gettind rid of rounding for the values
SherelynA May 28, 2025
5aaf638
cleaning code up from print statements used during testing. Added dif…
SherelynA Jun 3, 2025
c0a893d
I changed the formation of the evaluate funciton in relations.py to u…
SherelynA Jun 3, 2025
3f14fc5
Adding age distribution as a static paramter that can be passed to th…
SherelynA Jun 3, 2025
a2e9581
Adding the age distribution paramter in the instances of evaluation t…
SherelynA Jun 3, 2025
b0daa0d
Taking into account the type of distribution for the age in the evalu…
SherelynA Jun 3, 2025
7787109
tweaking some portion of the age distribution setter
SherelynA Jun 3, 2025
db0b058
got rid of the float in the formatting because it was adding a traili…
SherelynA Jun 6, 2025
790ba97
Fixing spacing in the new code for a normal distribution.
SherelynA Jun 6, 2025
6090e9f
Add code which checks for the age distribution when it calculates the…
SherelynA Jun 6, 2025
34c6ac5
getting rid of random print statements
SherelynA Jun 6, 2025
2c32741
changing the test to have a larger age range and adjusting assert sta…
SherelynA Jun 6, 2025
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
15 changes: 13 additions & 2 deletions sedkit/isochrone.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def age_units(self, unit):
# Get the min and max ages
self.ages = np.array(np.unique(self.data['age']))*self.age_units

def evaluate(self, xval, age, xparam, yparam, plot=False):
def evaluate(self, xval, age, xparam, yparam, distribution, plot=False):
"""Interpolate the value and uncertainty of *yparam* given an
x-value and age range

Expand All @@ -135,6 +135,8 @@ def evaluate(self, xval, age, xparam, yparam, plot=False):
The name of the parameter on the x-axis
yparam: str
The name of the parameter on the y-axis
distribution: str
The type of distribution used for the Monte Carlo approach, either 'uniform' or 'normal'
plot: bool
Plot all isochrones and the interpolated value

Expand Down Expand Up @@ -168,8 +170,17 @@ def evaluate(self, xval, age, xparam, yparam, plot=False):
mu, sigma = xval[0], xval[1] # mean and standard deviation for values on the x-axis
mu_a, sigma_a = age[0].value, age[1].value # mean and standard deviation for the age range provided

# Generate random sample for values on the x-axis
xsample = np.random.normal(mu, sigma, 10000)
ysample = np.random.uniform(mu_a-sigma_a, mu_a+sigma_a, 10000)

# Generate random sample for the age range provided
if distribution == 'uniform':
ysample = np.random.uniform(mu_a-sigma_a, mu_a+sigma_a, 10000)
elif distribution == 'normal':
ysample = np.random.normal(mu_a, sigma_a, 10000)
else:
raise ValueError("Distribution must be set to 'uniform' or 'normal'.")

values_list = []
nan_counter = 0

Expand Down
6 changes: 3 additions & 3 deletions sedkit/relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ def evaluate(self, rel_name, x_val, xunits=None, yunits=None, fit_local=False, p

# Get the relation
full_rel = self.relations[rel_name]
out_xunits = full_rel['xunit'].to(xunits) * xunits if xunits is not None else full_rel['xunit'] or 1
out_yunits = full_rel['yunit'].to(yunits) * yunits if yunits is not None else full_rel['yunit'] or 1

out_xunits = '{:.{p}}'.format(full_rel['xunit'].to(xunits), p=3) * xunits if xunits is not None else full_rel['xunit'] or 1
out_yunits = '{:.{p}}'.format(full_rel['yunit'].to(yunits), p=3) * yunits if yunits is not None else full_rel['yunit'] or 1
# Use local points for relation
if isinstance(fit_local, int) and fit_local is not False:

Expand Down Expand Up @@ -479,7 +479,7 @@ def get_radius(self, spt, plot=False):
fig.triangle([spt], [radius.value], color='red', size=15, legend_label=u.specType(spt))
show(fig)

return radius.round(3), radius_unc.round(3)
return radius, radius_unc

def generate(self, orders):
"""
Expand Down
52 changes: 48 additions & 4 deletions sedkit/sed.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def __init__(self, name='My Target', verbose=True, method_list=None, substellar=
self._membership = None
self._sky_coords = None
self._evo_model = None
self._age_distribution = None

# Static attributes
self.evo_model = None
Expand All @@ -166,6 +167,7 @@ def __init__(self, name='My Target', verbose=True, method_list=None, substellar=
self.multiple = False
self.HRsequence = rel.DwarfSequence()
self.substellar = substellar
self.age_distribution = None

# Dictionary to keep track of references
self._refs = {}
Expand Down Expand Up @@ -1074,6 +1076,33 @@ def evo_model(self, model):
# Set as uncalculated
self.calculated = False

@property
def age_distribution(self):
"""
A getter for the age distribution
"""
return self._age_distribution

@age_distribution.setter
def age_distribution(self, distribution):
"""
A setter for the age distribution

Parameters
----------
distribution: str
The chosen age distribution
"""
if distribution is None:
self._age_distribution = 'uniform'
self.message("Setting age distribution to uniform")
else:
if distribution == 'normal':
self._age_distribution = 'normal'
self.message("Setting age distribution to normal")
else:
raise ValueError("Please use either 'uniform' or 'normal' for age_distribution parameter")

def export(self, parentdir='.', dirname=None, zipped=False):
"""
Exports the photometry and results tables and a file of the
Expand Down Expand Up @@ -1813,6 +1842,9 @@ def infer_logg(self, plot=False):
"""
self._logg = None

# Checking the age distribution
age_distribution = self.age_distribution

# Try model isochrones
if self.evo_model is not None and self.age is not None and self.Lbol_sun is not None:

Expand All @@ -1823,7 +1855,8 @@ def infer_logg(self, plot=False):
if self.Lbol_sun[1] is None:
self.message('Lbol={0.Lbol}. Uncertainties are needed to calculate the surface gravity.'.format(self))
else:
logg = self.evo_model.evaluate(self.Lbol_sun, self.age, 'Lbol', 'logg', plot=plot)
logg = self.evo_model.evaluate(self.Lbol_sun, self.age, 'Lbol', 'logg', distribution=age_distribution,
plot=plot)

# Print a message if None
if logg is None:
Expand All @@ -1848,6 +1881,9 @@ def infer_mass(self, mass_units=q.Msun, plot=False):
"""
self._mass = None

# Checking the age distribution
age_distribution = self.age_distribution

if self.substellar:
mass_units = q.Mjup

Expand All @@ -1862,7 +1898,8 @@ def infer_mass(self, mass_units=q.Msun, plot=False):
self.message('Lbol={0.Lbol}. Uncertainties are needed to calculate the mass.'.format(self))
else:
self.evo_model.mass_units = mass_units
mass = self.evo_model.evaluate(self.Lbol_sun, self.age, 'Lbol', 'mass', plot=plot)
mass = self.evo_model.evaluate(self.Lbol_sun, self.age, 'Lbol', 'mass', distribution=age_distribution,
plot=plot)

# Store the value
self.mass = [mass[0].round(0), mass[1].round(0), mass[2].round(0), mass[3]] if mass is not None else mass
Expand Down Expand Up @@ -1907,6 +1944,9 @@ def infer_radius(self, radius_units=q.Rsun, infer_from='Lbol', plot=False):
"""
self._radius = None

# Checking the age distribution
age_distribution = self.age_distribution

# Change units to Jupiter radii for substellar objects
if self.substellar:
radius_units = q.Rjup
Expand Down Expand Up @@ -1946,7 +1986,8 @@ def infer_radius(self, radius_units=q.Rsun, infer_from='Lbol', plot=False):
self.message('Lbol={0.Lbol}. Uncertainties are needed to calculate the radius.'.format(self))
else:
self.evo_model.radius_units = radius_units
radius = self.evo_model.evaluate(self.Lbol_sun, self.age, 'Lbol', 'radius', plot=plot)
radius = self.evo_model.evaluate(self.Lbol_sun, self.age, 'Lbol', 'radius',
distribution=age_distribution, plot=plot)

# Store the value
self.radius = [radius[0].round(3), radius[1].round(3), radius[2].round(3), radius[3]] if radius is not None else radius
Expand Down Expand Up @@ -2038,6 +2079,9 @@ def infer_Teff(self, teff_units=q.K, plot=False):
"""
self._Teff = None

# Checking the age distribution
age_distribution = self.age_distribution

# Try model isochrones
if self.evo_model is not None and self.age is not None and self.Lbol_sun is not None:

Expand All @@ -2049,7 +2093,7 @@ def infer_Teff(self, teff_units=q.K, plot=False):
self.message('Lbol={0.Lbol}. Uncertainties are needed to calculate the teff.'.format(self))
else:
self.evo_model.teff_units = teff_units
teff = self.evo_model.evaluate(self.Lbol_sun, self.age, 'Lbol', 'teff', plot=plot)
teff = self.evo_model.evaluate(self.Lbol_sun, self.age, 'Lbol', 'teff', distribution=age_distribution, plot=plot)

# Store the value
self.Teff = [teff[0].round(0), teff[1].round(0), teff[2].round(0), teff[3]] if teff is not None else teff
Expand Down
Loading
Loading