From cf2904048660cbbb2185fe7b7e225983cb73a7cc Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 28 Jan 2026 19:42:46 -0500 Subject: [PATCH 1/4] use cosmic-settings.json to get defaults --- cogsworth/utils.py | 42 +++++++++++++++++------------------------- 1 file changed, 17 insertions(+), 25 deletions(-) diff --git a/cogsworth/utils.py b/cogsworth/utils.py index 204794e..4e73990 100644 --- a/cogsworth/utils.py +++ b/cogsworth/utils.py @@ -1,7 +1,6 @@ -import matplotlib.pyplot as plt -import matplotlib as mpl import numpy as np -from copy import copy +from importlib.resources import files +import json __all__ = ["kstar_translator", "evol_type_translator", "default_BSE_settings", @@ -67,29 +66,21 @@ ] -default_BSE_settings = {'xi': 1.0, 'bhflag': 1, 'neta': 0.5, 'windflag': 3, 'wdflag': 1, 'alpha1': 1.0, - 'pts1': 0.001, 'pts3': 0.02, 'pts2': 0.01, 'epsnov': 0.001, 'hewind': 0.5, - 'ck': 1000, 'bwind': 0.0, 'lambdaf': 0.0, 'mxns': 3.0, 'beta': -1.0, 'tflag': 1, - 'acc2': 1.5, 'grflag': 1, 'remnantflag': 4, 'ceflag': 0, 'eddfac': 1.0, - 'ifflag': 0, 'bconst': 3000, 'sigma': 265.0, 'gamma': -2.0, 'pisn': 45.0, - 'natal_kick_array': [[-100.0, -100.0, -100.0, -100.0, 0.0], - [-100.0, -100.0, -100.0, -100.0, 0.0]], 'bhsigmafrac': 1.0, - 'polar_kick_angle': 90, 'qcrit_array': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, - 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0], - 'cekickflag': 2, 'cehestarflag': 0, 'cemergeflag': 0, 'ecsn': 2.25, - 'ecsn_mlow': 1.6, 'aic': 1, 'ussn': 0, 'sigmadiv': -20.0, 'qcflag': 5, - 'eddlimflag': 0, 'fprimc_array': [2.0/21.0, 2.0/21.0, 2.0/21.0, 2.0/21.0, - 2.0/21.0, 2.0/21.0, 2.0/21.0, 2.0/21.0, - 2.0/21.0, 2.0/21.0, 2.0/21.0, 2.0/21.0, - 2.0/21.0, 2.0/21.0, 2.0/21.0, 2.0/21.0], - 'bhspinflag': 0, 'bhspinmag': 0.0, 'rejuv_fac': 1.0, 'rejuvflag': 0, 'htpmb': 1, - 'ST_cr': 1, 'ST_tide': 1, 'bdecayfac': 1, 'rembar_massloss': 0.5, 'kickflag': 5, - 'zsun': 0.014, 'bhms_coll_flag': 0, 'don_lim': -1, 'acc_lim': -1, 'binfrac': 1.0, - 'rtmsflag': 0, 'wd_mass_lim': 1} - - def get_default_BSE_settings(): - return copy(default_BSE_settings) + """Get a copy of the default BSE settings from the COSMIC settings JSON file""" + cosmic_settings = json.loads((files("cosmic") / "data" / "cosmic-settings.json").read_text()) + defaults = {} + # loop through settings to find bse + for cat in cosmic_settings: + if cat["category"] != "bse": + continue + + # go through each setting, finding the default option + for setting in cat["settings"]: + for option in setting["options"]: + if option.get("default", False): + defaults[setting["name"]] = option["name"] + return defaults def translate_COSMIC_tables(tab, kstars=True, evol_type=True, label_type="short", replace_columns=True): @@ -146,5 +137,6 @@ def translate_COSMIC_tables(tab, kstars=True, evol_type=True, label_type="short" def list_BSE_defaults(): # pragma: no cover """Print the default BSE settings cogsworth assumes for running COSMIC.""" + default_BSE_settings = get_default_BSE_settings() for k, v in default_BSE_settings.items(): print(f"{k}: {v}") From dc0389c397124d1800c4b661cab6f71c536d192d Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Wed, 28 Jan 2026 19:44:25 -0500 Subject: [PATCH 2/4] update version/changelog --- cogsworth/_version.py | 2 +- docs/modules/changelog.rst | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cogsworth/_version.py b/cogsworth/_version.py index 0c11bab..ad45aa3 100644 --- a/cogsworth/_version.py +++ b/cogsworth/_version.py @@ -1 +1 @@ -__version__ = "3.5.1" +__version__ = "3.5.3" diff --git a/docs/modules/changelog.rst b/docs/modules/changelog.rst index 357ef77..f33571a 100644 --- a/docs/modules/changelog.rst +++ b/docs/modules/changelog.rst @@ -4,6 +4,12 @@ Full changelog This page tracks all of the changes that have been made to ``cogsworth``. We follow the standard versioning convention of A.B.C, where C is a patch/bugfix, B is a large bugfix or new feature and A is a major new breaking change. B/C are backwards compatible but A changes may be breaking. +3.5.3 +===== +This version is released to coincide with the release of COSMIC v3.6.2 + +- Enhancement: Use default BSE settings based on the cosmic-settings.json + 3.5.1 ===== - Enhancement: Avoid pickling static arguments unnecessarily when evolving orbits, this should speed things up and reduce memory usage. From 9be4bbacff6e50d66f4c26dd855819f6aa6e2113 Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Fri, 30 Jan 2026 13:09:15 -0500 Subject: [PATCH 3/4] handle arrays, add binfrac --- cogsworth/utils.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cogsworth/utils.py b/cogsworth/utils.py index 4e73990..aa8196a 100644 --- a/cogsworth/utils.py +++ b/cogsworth/utils.py @@ -80,6 +80,19 @@ def get_default_BSE_settings(): for option in setting["options"]: if option.get("default", False): defaults[setting["name"]] = option["name"] + + # ensure array settings are converted from strings to lists + for setting in ["qcrit_array", "natal_kick_array", "fprimc_array"]: + # this one requires special handling because of the fractions + if setting == "fprimc_array": + parts = defaults[setting].strip("[]").split(",") + defaults[setting] = [float(p.split("/")[0]) / float(p.split("/")[1]) for p in parts] + else: + defaults[setting] = json.loads(defaults[setting]) + + # set binfrac default if not present + if "binfrac" not in defaults: + defaults["binfrac"] = 0.5 return defaults From d9b56ff74512889257d1f224633b43325a6fd28d Mon Sep 17 00:00:00 2001 From: Tom Wagg Date: Fri, 30 Jan 2026 13:09:23 -0500 Subject: [PATCH 4/4] pin to latest COSMIC --- setup.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.cfg b/setup.cfg index 8f6afbc..2fee9b2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -25,7 +25,7 @@ install_requires = scipy >= 1.8 pandas >= 2.1 gala >= 1.11.0 - cosmic-popsynth >= 3.6.1 + cosmic-popsynth >= 3.6.2 [options.package_data] * = *.npy, *.npz