Skip to content

Objectification of eventgen functions

Reed Essick requested to merge reed.essick/gw_event_gen:objectify into master

Transforms all populations defined as functions within gw_event_gen.eventgen into objects that know how to rvs, pdf, jacobian, and hessian themselves. This involved a major rewrite of most things within gw_event_gen.eventgen as well as bin/generate_events. Specifically, we introduce the following

gw_event_gen.eventgen

  • Declared the SamplingDistribution class, which replace the generator functions from before. This class acts as a parent class to declare the appropriate API. Subclasses must provide rvs, pdf, jacobian, and hessian methods as well as declare the _variates sampled by this distribution (eg, mass1 and mass2) and the _params used to describe the distribution (eg, min_mass and max_mass).
  • Declared subclasses of SamplingDistribution to denote distributions over different types of variates. This includes TimeDistribution, EccentricityDistribution, OrientationDistribution, DistanceDistribution, RedshiftDistribution, MassDistribution, and SpinDistribution.
  • Declared AttributeTransformation classes, which replace the post functions before. These perform basic sanity checks to make sure the Event objects have the required attributes and then computes new attributes based thereon, updating the object in palce.
    • Please note, there are transforms that compute the SNRs and probability of detecting the signal (probablity that the observed network SNR is above a threshold based on a non-central chi-squared survival function)
  • Added logic to check the variates stored in Event class before waveform generation and possibly SNR calculation (assuming a network of detectors).
  • Updated EventGenerator.generate_events classes to play nicely with SamplingDistributions and AttributeTransformations.

Please note, not all population objects are fully implemented (ie, some do not implement their pdf, jacobian, or hessian methods). However, there should be enough functionality here to hit many initial use cases. The objects with missing functionality are

  • MadauDickinsonRedshift
    • missing hessian because I need the derivative of the SRF
  • UniformComovingRedshift and UniformComovingDistance
    • missing pdf, jacobian, and hessian because I need things that aren't readily accessible from the interpolators set up by init_cosmology.
    • I think there's probably a better way to set up the cosmology utilities (ie, this) and I'd suggest we move toward that rather than patching init_cosmology further
  • AstroComponentMass
    • missing hessian because it is a 5x5 matrix and I ran out of steam
  • ParetoFlatComponentMass
    • missing hessian because it is a 5x5 matrix and I ran out of steam
  • IsotropicAlignedSpin
    • missing hessian because it is a 4x4 matrix that is rather complicated (ie, the actual distribution of spin1z and spin2z is hard)

Also, I renamed quite a few things and slightly modified the functionality. This may break other things that rely on eventgen, but I tried to track those down and change them at the same time as much as possible.

bin/generate_events

  • general clean-up and commenting in the code to try to clarify what was instantiated when
  • switched instantiation to use new object-oriented approach implemented in eventgen.

Please note, I removed some functionality (like the corner plots of parameters).

I have also added myself as an author in this repo since this required quite a bit of work to slog through.

testing

I've performed some testing, but almost certainly haven't exercised all functionality. However, the following command should work.

generate_events \
    --Verbose \
    --include-in-network H1 --include-in-network L1 \
    --generate-bns \
    --min-mass1 1.0 --max-mass1 2.0 \
    --min-mass2 1.0 --max-mass2 2.0 \
    --max-redshift 0.1 \
    --num-events 30 \
    --write-output bns.xml.gz
Edited by Reed Essick

Merge request reports