Objectification of eventgen functions
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 thegenerator
functions from before. This class acts as a parent class to declare the appropriate API. Subclasses must providervs
,pdf
,jacobian
, andhessian
methods as well as declare the_variates
sampled by this distribution (eg,mass1
andmass2
) and the_params
used to describe the distribution (eg,min_mass
andmax_mass
). - Declared subclasses of
SamplingDistribution
to denote distributions over different types of variates. This includesTimeDistribution
,EccentricityDistribution
,OrientationDistribution
,DistanceDistribution
,RedshiftDistribution
,MassDistribution
, andSpinDistribution
. - Declared
AttributeTransformation
classes, which replace thepost
functions before. These perform basic sanity checks to make sure theEvent
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 withSamplingDistribution
s andAttributeTransformations
.
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
- missing
-
UniformComovingRedshift
andUniformComovingDistance
- missing
pdf
,jacobian
, andhessian
because I need things that aren't readily accessible from the interpolators set up byinit_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
- missing
-
AstroComponentMass
- missing
hessian
because it is a 5x5 matrix and I ran out of steam
- missing
-
ParetoFlatComponentMass
- missing
hessian
because it is a 5x5 matrix and I ran out of steam
- missing
-
IsotropicAlignedSpin
- missing
hessian
because it is a 4x4 matrix that is rather complicated (ie, the actual distribution ofspin1z
andspin2z
is hard)
- missing
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