Skip to content

Commit

Permalink
Renamed Cluster to SimulatedCluster for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyhunt committed Nov 22, 2024
1 parent 567809f commit f5f870f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/ocelot/simulate/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""A package for simulating star clusters."""

from .cluster import Cluster, ClusterParameters # noqa: F401
from .cluster import SimulatedCluster, SimulatedClusterParameters # noqa: F401
import warnings
from ocelot import DATA_PATH

Expand Down
8 changes: 4 additions & 4 deletions src/ocelot/simulate/astrometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from scipy.stats import multivariate_normal


def generate_star_positions(cluster: ocelot.simulate.cluster.Cluster):
def generate_star_positions(cluster: ocelot.simulate.cluster.SimulatedCluster):
"""Generates positions of member stars in polar coordinates relative to the center
of the cluster.
"""
Expand Down Expand Up @@ -40,7 +40,7 @@ def spherical_to_cartesian(radii, thetas, phis):
return x_values, y_values, z_values


def generate_star_velocities(cluster: ocelot.simulate.cluster.Cluster):
def generate_star_velocities(cluster: ocelot.simulate.cluster.SimulatedCluster):
"""Generates the velocities of stars in a cluster."""
distribution = multivariate_normal(
mean=np.zeros(3),
Expand All @@ -51,7 +51,7 @@ def generate_star_velocities(cluster: ocelot.simulate.cluster.Cluster):
return CartesianDifferential(d_x=v_x, d_y=v_y, d_z=v_z, unit=u.m / u.s)


def generate_true_star_astrometry(cluster: ocelot.simulate.cluster.Cluster):
def generate_true_star_astrometry(cluster: ocelot.simulate.cluster.SimulatedCluster):
"""Generates the true values of cluster astrometry (not affected by errors)."""
positions = generate_star_positions(cluster)
velocities = generate_star_velocities(cluster)
Expand Down Expand Up @@ -85,7 +85,7 @@ def generate_true_star_astrometry(cluster: ocelot.simulate.cluster.Cluster):
cluster.cluster["parallax_true"] = 1000 / final_coords.distance.value


def generate_cluster_astrometry(cluster: ocelot.simulate.cluster.Cluster):
def generate_cluster_astrometry(cluster: ocelot.simulate.cluster.SimulatedCluster):
"""Generates the astrometry of clusters."""
generate_true_star_astrometry(cluster)
apply_gaia_astrometric_uncertainties(cluster)
2 changes: 1 addition & 1 deletion src/ocelot/simulate/binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def _recalculate_magnitudes(cluster):
# cluster.cluster = cluster.cluster.drop(columns=["g_flux", "bp_flux", "rp_flux"])


def make_binaries(cluster: ocelot.simulate.cluster.Cluster):
def make_binaries(cluster: ocelot.simulate.cluster.SimulatedCluster):
"""Pairs a simulated cluster up into binaries."""
if not cluster.parameters.binary_stars:
return
Expand Down
8 changes: 4 additions & 4 deletions src/ocelot/simulate/photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
MAXIMUM_METALLICITY = AVAILABLE_METALLICITIES.max()


def load_isochrone(cluster: ocelot.simulate.cluster.Cluster):
def load_isochrone(cluster: ocelot.simulate.cluster.SimulatedCluster):
"""Loads a simulated stellar population at a given age."""
# Check that the requested metallicity is valid
metallicity = cluster.parameters.metallicity
Expand Down Expand Up @@ -73,7 +73,7 @@ def _interpolated_parameter(parameter, isochrone, masses):
return interp1d(isochrone["Mini"], isochrone[parameter], bounds_error=False)(masses)


def create_population(cluster: ocelot.simulate.cluster.Cluster, minimum_mass=0.03):
def create_population(cluster: ocelot.simulate.cluster.SimulatedCluster, minimum_mass=0.03):
"""Samples from a pre-simulated stellar population until the sample population has
the correct mass.
"""
Expand Down Expand Up @@ -120,7 +120,7 @@ def create_population(cluster: ocelot.simulate.cluster.Cluster, minimum_mass=0.0
]


def apply_extinction(cluster: ocelot.simulate.cluster.Cluster):
def apply_extinction(cluster: ocelot.simulate.cluster.SimulatedCluster):
"""Applies extinction to a simulated cluster."""
if cluster.parameters.extinction == 0.0:
cluster.cluster["a_g"] = 0.0
Expand Down Expand Up @@ -148,7 +148,7 @@ def apply_extinction(cluster: ocelot.simulate.cluster.Cluster):


def generate_cluster_photometry(
cluster: ocelot.simulate.cluster.Cluster, field: None | pd.DataFrame = None
cluster: ocelot.simulate.cluster.SimulatedCluster, field: None | pd.DataFrame = None
):
"""Generates a star cluster of given photometry at a given age and extinction."""
create_population(cluster)
Expand Down
4 changes: 2 additions & 2 deletions src/ocelot/simulate/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def subsample_selection_function(


def calculate_selection_function(
cluster: ocelot.simulate.cluster.Cluster,
cluster: ocelot.simulate.cluster.SimulatedCluster,
field: pd.DataFrame,
g_min: int | float = 2,
g_max: int | float = 21,
Expand Down Expand Up @@ -148,7 +148,7 @@ def interpolate_selection_function(


def apply_selection_functions(
cluster: ocelot.simulate.cluster.Cluster, field: None | pd.DataFrame = None
cluster: ocelot.simulate.cluster.SimulatedCluster, field: None | pd.DataFrame = None
):
"""Applies selection functions to a cluster."""
if not cluster.parameters.selection_effects:
Expand Down
8 changes: 4 additions & 4 deletions src/ocelot/simulate/uncertainties.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import warnings


def _closest_gaia_star(cluster: ocelot.simulate.cluster.Cluster, field: pd.DataFrame):
def _closest_gaia_star(cluster: ocelot.simulate.cluster.SimulatedCluster, field: pd.DataFrame):
"""Finds the nearest star in G-band magnitude to a given star."""
field_magnitudes = field["phot_g_mean_mag"].to_numpy()
stars_to_assign = cluster.cluster["g_true"].notna()
Expand All @@ -31,7 +31,7 @@ def _closest_gaia_star(cluster: ocelot.simulate.cluster.Cluster, field: pd.DataF


def _assign_field_uncertainties_to_cluster(
cluster: ocelot.simulate.cluster.Cluster, field: None | pd.DataFrame = None
cluster: ocelot.simulate.cluster.SimulatedCluster, field: None | pd.DataFrame = None
):
if (
not cluster.parameters.photometric_errors
Expand Down Expand Up @@ -87,7 +87,7 @@ def _assign_field_uncertainties_to_cluster(


def apply_gaia_photometric_uncertainties(
cluster: ocelot.simulate.cluster.Cluster, field: None | pd.DataFrame = None
cluster: ocelot.simulate.cluster.SimulatedCluster, field: None | pd.DataFrame = None
):
"""Applies representative Gaia photometric uncertainties to photometry in a cluster."""
_assign_field_uncertainties_to_cluster(cluster, field)
Expand All @@ -102,7 +102,7 @@ def apply_gaia_photometric_uncertainties(
raise NotImplementedError("Cluster photometric errors are not implemented.")


def apply_gaia_astrometric_uncertainties(cluster: ocelot.simulate.cluster.Cluster):
def apply_gaia_astrometric_uncertainties(cluster: ocelot.simulate.cluster.SimulatedCluster):
"""Applies representative Gaia astrometric uncertainties to the astrometry of a
cluster. Assumes that photometric errors have already been applied (which also adds
astrometric uncertainties for each star.)
Expand Down

0 comments on commit f5f870f

Please sign in to comment.