Skip to content

Commit

Permalink
Merge pull request #28 from transientlunatic/update-conversions
Browse files Browse the repository at this point in the history
Update conversions
  • Loading branch information
transientlunatic authored Aug 26, 2024
2 parents 1601ad4 + 7faf90a commit a7f2b60
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion heron/likelihood.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def __call__(self, parameters):
self.logger.info(parameters)

keys = set(parameters.keys())
extrinsic = {"phase", "psi", "ra", "dec", "theta_jn"}
extrinsic = {"phase", "psi", "ra", "dec", "theta_jn", "gpstime", "geocent_time"}
conversions = {"mass_ratio", "total_mass", "luminosity_distance"}
bad_keys = keys - set(self.waveform._args.keys()) - extrinsic - conversions
if len(bad_keys) > 0:
Expand Down
22 changes: 14 additions & 8 deletions heron/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,22 @@ def _convert_luminosity_distance(self, args):
return args

def _convert_mass_ratio_total_mass(self, args):

args["m1"] = (args["total_mass"] / (1 + args["mass_ratio"])).to_value(
u.kilogram
)
args["m2"] = (args["total_mass"] / (1 + 1 / args["mass_ratio"])).to_value(
u.kilogram
)
args["m1"] = (args["total_mass"] / (1 + args["mass_ratio"]))
args["m2"] = (args["total_mass"] / (1 + (1 / args["mass_ratio"])))
# Do these have units?
# If not then we can skip some relatively expensive operations and apply a heuristic.
if isinstance(args["m1"], u.Quantity):
args["m1"] = args["m1"].to_value(u.kilogram)
args["m2"] = args["m2"].to_value(u.kilogram)
if (not isinstance(args["m1"], u.Quantity)) and (args["m1"] < 1000):
# This appears to be in solar masses
args["m1"] *= MSUN_SI
if (not isinstance(args["m2"], u.Quantity)) and (args["m2"] < 1000):
# This appears to be in solar masses
args["m2"] *= MSUN_SI

args.pop("total_mass")
args.pop("mass_ratio")

return args


Expand Down
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ cython
george
nestle
elk-waveform>=0.13
gpytorch
torch
lalsuite
h5py
click
asimov
pesummary
nessai
gpytorch==1.0.1
torch==2.4.0
torchvision==0.5.0
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nestle

sphinx
sphinx-versions
numpydoc
kentigern
nbsphinx
sphinxcontrib-bibtex
numpydoc==1.8.0
nbsphinx==0.9.5

0 comments on commit a7f2b60

Please sign in to comment.