From f5f870fe1f5a46faf8c8cbb31808513b5358acb0 Mon Sep 17 00:00:00 2001 From: emilyhunt Date: Fri, 22 Nov 2024 16:25:38 +0100 Subject: [PATCH] Renamed Cluster to SimulatedCluster for clarity --- src/ocelot/simulate/__init__.py | 2 +- src/ocelot/simulate/astrometry.py | 8 ++++---- src/ocelot/simulate/binaries.py | 2 +- src/ocelot/simulate/photometry.py | 8 ++++---- src/ocelot/simulate/selection.py | 4 ++-- src/ocelot/simulate/uncertainties.py | 8 ++++---- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ocelot/simulate/__init__.py b/src/ocelot/simulate/__init__.py index 3d28aa5..2e23987 100644 --- a/src/ocelot/simulate/__init__.py +++ b/src/ocelot/simulate/__init__.py @@ -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 diff --git a/src/ocelot/simulate/astrometry.py b/src/ocelot/simulate/astrometry.py index 28714ed..a40985f 100644 --- a/src/ocelot/simulate/astrometry.py +++ b/src/ocelot/simulate/astrometry.py @@ -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. """ @@ -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), @@ -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) @@ -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) diff --git a/src/ocelot/simulate/binaries.py b/src/ocelot/simulate/binaries.py index 8a6e56a..bc1b8d8 100644 --- a/src/ocelot/simulate/binaries.py +++ b/src/ocelot/simulate/binaries.py @@ -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 diff --git a/src/ocelot/simulate/photometry.py b/src/ocelot/simulate/photometry.py index 1bee8ce..9ffd300 100644 --- a/src/ocelot/simulate/photometry.py +++ b/src/ocelot/simulate/photometry.py @@ -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 @@ -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. """ @@ -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 @@ -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) diff --git a/src/ocelot/simulate/selection.py b/src/ocelot/simulate/selection.py index f181dc2..e4d3291 100644 --- a/src/ocelot/simulate/selection.py +++ b/src/ocelot/simulate/selection.py @@ -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, @@ -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: diff --git a/src/ocelot/simulate/uncertainties.py b/src/ocelot/simulate/uncertainties.py index 8c1adf3..5bd78f8 100644 --- a/src/ocelot/simulate/uncertainties.py +++ b/src/ocelot/simulate/uncertainties.py @@ -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() @@ -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 @@ -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) @@ -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.)