Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/delete-branch-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ jobs:
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Cleanup
run: |
gh extension install actions/gh-actions-cache

REPO=${{ github.repository }}
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"

echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH -L 100 | cut -f 1 )

## Setting this to not fail the workflow while deleting cache keys.
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
Expand All @@ -30,4 +30,4 @@ jobs:
done
echo "Done"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN apt-get install -y \
cmake \
liblapacke-dev \
liblapack-dev \
libblas-dev
libblas-dev

RUN cd build && cmake .. && make

Expand Down
3 changes: 1 addition & 2 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import nmma

extensions = ["myst_parser", "sphinx_copybutton","sphinx_github_changelog"]
extensions = ["myst_parser", "sphinx_copybutton", "sphinx_github_changelog"]
myst_enable_extensions = [
"amsmath",
"colon_fence",
Expand Down Expand Up @@ -58,7 +58,6 @@
author = "The NMMA Team"



version = nmma.__version__
release = version

Expand Down
10 changes: 6 additions & 4 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Install parallel-bilby:

.. code::

conda install -c conda-forge parallel-bilby
pip install parallel-bilby

.. note::

Expand All @@ -161,7 +161,7 @@ specifc instructions below)

.. code::

conda install -c conda-forge pymultinest
conda install conda-forge::pymultinest

.. warning::

Expand All @@ -184,14 +184,14 @@ requirements.txt file which are necessary for NMMA:

.. code::

pip install .
pip install -e .

.. note::

There is an issue pip installing ``pyfftw`` on arm64 Mac systems; see the dedicated section below for a solution. If any package appeared to have an issue installing, you can first check by attempting to install it again using pip:

.. code::

pip install keras, tensorflow
pip install importlib_resources
pip install extinction
pip install dill
Expand All @@ -201,6 +201,8 @@ requirements.txt file which are necessary for NMMA:
pip install sncosmo
pip install scikit-learn
pip install joblib
pip install keras
pip install tensorflow
conda install -c conda-forge p-tqdm

.. note::
Expand Down
55 changes: 27 additions & 28 deletions doc/joint_inference.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Multi-messenger inference

A joint inference on gravitational-wave and electromagnetic signals requires NMMA to run on a supercomputer cluster because large memory space are required and need to be shared across many CPU cores. Here, we consider a full joint inference on the binary neutron star merger observed on 17th August 2017.
A joint inference on gravitational-wave and electromagnetic signals requires NMMA to run on a supercomputer cluster because large memory space are required and need to be shared across many CPU cores. Here, we consider a full joint inference on the binary neutron star merger observed on 17th August 2017.

In order to run a multi-messenger inference, we need to follow to main steps:

Expand All @@ -27,11 +27,11 @@ Moreover, a prior on all observed messengers is required and needs to be tailore

**Electroamagnetic data and models**

In order to not only sample on gravitational-wave data, we provide further electromagnetic signal related flags. The flag `with-grb=True` will turn on the sampling on a GRB data. As NMMA currently only includes one GRB model, this model does not need to be further specified. If `with-grb=False`, a joint inference of GW+KN data is possible, excluding the GRB part. With regard to the kilonova model, we need to provide a specific model under `kilonova-model`, its respective reduced model grid (if applicable) under `kilonova-model-svd` and a `kilonova-interpolation-type` which can be either `sklearn_gp` or `tensorflow`. The `light-curve-data` flag should include both GRB and kilonova data if a joint inference on GW-GRB-KN is desired (meaning use: `with-grb=True`) or should just include the kilonova data if a GW-KN inference is targeted (meaning use: `with-grb=False`). The kilonova start/end time and time steps apply to both the GRB and kilonova model which will generate light curves during the inference to match the observed data provided.
In order to not only sample on gravitational-wave data, we provide further electromagnetic signal related flags. The flag `with-grb=True` will turn on the sampling on a GRB data. As NMMA currently only includes one GRB model, this model does not need to be further specified. If `with-grb=False`, a joint inference of GW+KN data is possible, excluding the GRB part. With regard to the kilonova model, we need to provide a specific model under `kilonova-model`, its respective reduced model grid (if applicable) under `kilonova-model-svd` and a `kilonova-interpolation-type` which can be either `sklearn_gp` or `tensorflow`. The `light-curve-data` flag should include both GRB and kilonova data if a joint inference on GW-GRB-KN is desired (meaning use: `with-grb=True`) or should just include the kilonova data if a GW-KN inference is targeted (meaning use: `with-grb=False`). The kilonova start/end time and time steps apply to both the GRB and kilonova model which will generate light curves during the inference to match the observed data provided.

**Including EOS information**

NMMA enables to include nuclear information by using equations-of-state (EOS) and sample over the EOS during the inference. In order to include a set of EOSs, each EOS.dat file needs to include information on Mass, Radius and Tidal deformability. For the example shown in the `config.ini` file below, we see that `Neos = 5000` meaning that we include 5000 EOS.dat files each containing information on mass, radius and tidal deformability. We also see that a constraint from NICER measurements has been folded in and thus the `eos-weight` reflects this in a weighting. The EOS set should be sorted according to this weighting in order to reduce runtime for the sampling on the EOSs.
NMMA enables to include nuclear information by using equations-of-state (EOS) and sample over the EOS during the inference. In order to include a set of EOSs, each EOS.dat file needs to include information on Mass, Radius and Tidal deformability. For the example shown in the `config.ini` file below, we see that `Neos = 5000` meaning that we include 5000 EOS.dat files each containing information on mass, radius and tidal deformability. We also see that a constraint from NICER measurements has been folded in and thus the `eos-weight` reflects this in a weighting. The EOS set should be sorted according to this weighting in order to reduce runtime for the sampling on the EOSs.

**Running the config.ini generation**

Expand All @@ -40,9 +40,9 @@ In order to prepare the joint inference, a `config.ini` file is required which s
################################################################################
## Data generation arguments
################################################################################

trigger_time = 1187008882.43

################################################################################
## Detector arguments
################################################################################
Expand All @@ -52,15 +52,15 @@ In order to prepare the joint inference, a `config.ini` file is required which s
channel_dict = {H1=LOSC-STRAIN, L1=LOSC-STRAIN, V1=LOSC-STRAIN}
data_dict = {H1=data/GW170817/H-H1_LOSC_CLN_16_V1-1187007040-2048.gwf, L1=data/GW170817/L-L1_LOSC_CLN_16_V1-1187007040-2048.gwf, V1=data/GW170817/V-V1_LOSC_CLN_16_V1-1187007040-2048.gwf}
duration = 128

################################################################################
## Calibration arguments
################################################################################

calibration-model = CubicSpline
spline-calibration-nodes = 10
spline-calibration-envelope-dict = {H1:data/GW170817/Feb-20-2018_O2_LHO_GPSTime_1187008882_C02_RelativeResponseUncertainty_FinalResults.txt, L1:data/GW170817/Feb-20-2018_O2_LLO_GPSTime_1187008882_C02_RelativeResponseUncertainty_FinalResults.txt, V1:data/GW170817/V_calibrationUncertaintyEnvelope_magnitude5p1percent_phase40mraddeg20microsecond.txt}

################################################################################
## Job submission arguments
################################################################################
Expand All @@ -75,24 +75,24 @@ In order to prepare the joint inference, a `config.ini` file is required which s
distance-marginalization=False
phase-marginalization=False
time-marginalization=False

################################################################################
## Prior arguments
################################################################################

prior-file = GW170817_AT2017gfo_GRB170817A.prior

################################################################################
## Waveform arguments
################################################################################

frequency-domain-source-model = lal_binary_neutron_star
waveform_approximant = IMRPhenomPv2_NRTidalv2

################################################################################
## EM arguments
################################################################################

binary-type=BNS
light-curve-data=data/AT2017gfo-GRB170817A/AT2017gfo_GRB170817A.dat
kilonova-model=Bu2019lm
Expand All @@ -107,22 +107,22 @@ In order to prepare the joint inference, a `config.ini` file is required which s
kilonova-interpolation-type=sklearn_gp
grb-resolution=12
with-grb=True

################################################################################
## EOS arguments
################################################################################
with-eos=True

with-eos=True
eos-data=eos/with_NICER_J0740/EOS_024_uniform_5k_sorted
Neos=5000
eos-weight=eos/with_NICER_J0740/EOS_sorted_weight.dat


The joint inference generation can be performed by running:

nmma-generation config.ini

This will generate a `GW170817-AT2017gfo-GRB170817A_data_dump.pickle` file under `outdir/data/` which need to be provided for the joint inference function `nmma-analysis`.
This will generate a `GW170817-AT2017gfo-GRB170817A_data_dump.pickle` file under `outdir/data/` which need to be provided for the joint inference function `nmma-analysis`.

**Running the analysis**

Expand All @@ -136,33 +136,32 @@ As detailed above, running the analysis with the command `nmma-analysis --data-d
#PBS -o ./outdir/log_data_analysis/out.txt
#PBS -m abe
#PBS -M <email adress>

module load python
module load mpt
module load mpi4py
source <provide path to venv>

export MPI_UNBUFFERED_STDIO=true
export MPI_LAUNCH_TIMEOUT=240

cd $PBS_O_WORKDIR
mpirun -np 512 omplace -c 0-127:st=4 nmma-analysis --data-dump <absolute path to folder>/outdir/data/GW170817-AT2017gfo-GRB170817A_data_dump.pickle --nlive 1024 --nact 10 --maxmcmc 10000 --sampling-seed 20210213 --no-plot --outdir <absolute path to outdir/result folder>

Note that settings might differ from cluster to cluster and also the installation of NMMA might be changed (conda vs. python installation).
Note that settings might differ from cluster to cluster and also the installation of NMMA might be changed (conda vs. python installation).


**Maximum mass constraint from a joint analysis**

From a joint posterior of GW and lightcurve data from a BNS, one can derive an upper limit on the TOV mass, if one assumes that the remnant collapsed to a black hole. The idea is to determine the posterior distribution on the remnant's mass from the posterior distribution of the individual neutron star masses $m_1$, $m_2$ and the ejecta and compare this to the TOV mass of EOSs.
From a joint posterior of GW and lightcurve data from a BNS, one can derive an upper limit on the TOV mass, if one assumes that the remnant collapsed to a black hole. The idea is to determine the posterior distribution on the remnant's mass from the posterior distribution of the individual neutron star masses $m_1$, $m_2$ and the ejecta and compare this to the TOV mass of EOSs.

This can be done via the command

This can be done via the command

maximum-mass-constraint --outdir <path to folder> --joint-posterior <path to the file with samples from GW+EM analysis> --prior <path to a bilby prior file> --eos-path-macro <path to macroscopic EOS> --eos-path-micro <path to microscopic EOS> [--use-M-Kepler]

The last flag determines whether the remnant mass is compared against the TOV mass or the maximum mass limit for a rotating NS (Kepler limit). The latter is less conservative. The joint posterior should contain the parameters chirp mass, eta_star, log10_mdisk, log10_mej_dyn as named columns. Here, eta_star is $η* = \ln(0.25-η)$ from the symmetric mass ratio $η$. The macroscopic EOS curves must have the central pressure p0 in MeV/fm³ of each NS mass as last column.
The last flag determines whether the remnant mass is compared against the TOV mass or the maximum mass limit for a rotating NS (Kepler limit). The latter is less conservative. The joint posterior should contain the parameters chirp mass, eta_star, log10_mdisk, log10_mej_dyn as named columns. Here, eta_star is $η* = \ln(0.25-η)$ from the symmetric mass ratio $η$. The macroscopic EOS curves must have the central pressure p0 in MeV/fm³ of each NS mass as last column.

If --use-M-Kepler is set, the prior file needs to contain two additional fiducial paramters for the quasi-universal relations:
If --use-M-Kepler is set, the prior file needs to contain two additional fiducial paramters for the quasi-universal relations:

ratio_R = Gaussian(name = "R", mu = 1.255, sigma = 0.024)
delta = Uniform(name="delta", minimum = -0.0125, maximum = 0.0125)

10 changes: 4 additions & 6 deletions doc/lfi_analysis.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Perform Parameter Estimation Using Liklihood Free Inference (LFI)

NMMA is adding machine learning functionality to its currently offered analysis methods. In this initial incorporation, a neural network approach will perform parameter estimation on light curves from BNS events. We will address the limitations first, and then provide an example run.
NMMA is adding machine learning functionality to its currently offered analysis methods. In this initial incorporation, a neural network approach will perform parameter estimation on light curves from BNS events. We will address the limitations first, and then provide an example run.

## Limitations

Expand All @@ -21,18 +21,16 @@ In addition to installing the standard requirements.txt file, you must also run

### Generate a simulation set

First, we will create an injection file that describes our light curves. Running the following command line will generate a json file (injection.json). For Ka2017, this will include the parameters: luminosity_distance, timeshift, log10_mej, log10_vej, log10_Xlan, and geocent_time.
First, we will create an injection file that describes our light curves. Running the following command line will generate a json file (injection.json). For Ka2017, this will include the parameters: luminosity_distance, timeshift, log10_mej, log10_vej, log10_Xlan, and geocent_time.

nmma_create_injection --prior-file ./priors/Ka2017 --eos-file ./example_files/eos/ALF2.dat --binary-type BNS --filename ./output/injection --n-injection 10 --original-parameters --extension json

We can generate light curves using this injection file with the following command. Here, we can define the start and ending time of the light curve, its filters, and we can add ztf-like noise.

lightcurve-generation --model Ka2017 --outdir outdir --outfile-type json --label test --tmin -2 --tmax 20 --dt 0.25 --filters ztfg,ztfr,ztfi --injection ./outdir/injection.json --injection-detection-limit 22.0,22.0,22.0 --ztf-uncertainties

There are two options when running the analysis. One can run it using the injection file directly, which will cause the analysis to generate a light curve on the fly. Or, the command will accept a pre-generated light curve. To run using LFI, the --sampler argument must be neuralnet. In the first example, we call the injection file and pass the first injection to the analysis. In the second, we take the first light curve generated by the injection file. Both of these commands will output a posterior plot to the provided outdir.
There are two options when running the analysis. One can run it using the injection file directly, which will cause the analysis to generate a light curve on the fly. Or, the command will accept a pre-generated light curve. To run using LFI, the --sampler argument must be neuralnet. In the first example, we call the injection file and pass the first injection to the analysis. In the second, we take the first light curve generated by the injection file. Both of these commands will output a posterior plot to the provided outdir.

lightcurve-analysis --sampler neuralnet --model Ka2017 --outdir inferences --label with_inj --prior priors/Ka2017.prior --injection outdir/injection.json --injection-num 0 --dt 0.25

lightcurve-analysis --sampler neuralnet --model Ka2017 --outdir inferences --label with_data --data outdir/test_0.json --prior priors/Ka2017.prior


lightcurve-analysis --sampler neuralnet --model Ka2017 --outdir inferences --label with_data --data outdir/test_0.json --prior priors/Ka2017.prior
4 changes: 2 additions & 2 deletions doc/observing-scenarios-light-curves.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ This document provides a detailed description of how to use the **injections.dat
Running the following command will generate a JSON file (`injection_Bu2019lm.json`) with the BILBY processing of compact binary merger events. Here, we consider binaries of type BNS (Binary Neutron Stars), although NSBH (Neutron Star-Black Hole) is also an option. This injection contains a simulation set of parameters: `luminosity_distance`, `log10_mej_wind`, `KNphi`, `inclination_EM`, `timeshift`, `geocent_time` for the Bu2019lm model.


### Command to Run [nmma-create-injection]:
### Command to Run [nmma-create-injection]:

Run this command to create the JSON injection file:

Expand Down Expand Up @@ -70,4 +70,4 @@ Install `gwpy` in your NMMA environment before splitting the BNS and NSBH event
[paper]: https://doi.org/10.3847/1538-4357/acfcb1

[nmma-create-injection]: https://github.com/nuclear-multimessenger-astronomy/nmma/blob/main/nmma/eos/create_injection.py
[lightcurve-analysis]: https://github.com/nuclear-multimessenger-astronomy/nmma/blob/main/nmma/em/analysis.py
[lightcurve-analysis]: https://github.com/nuclear-multimessenger-astronomy/nmma/blob/main/nmma/em/analysis.py
2 changes: 1 addition & 1 deletion doc/systematics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ In this configuration, the ``sdssu`` and ``ztfr`` filters are sampled together f
type: Uniform
minimum: 0
maximum: 2


Distribution types
==================
Expand Down
2 changes: 1 addition & 1 deletion example_files/lightcurves/AT2017gfo_reduced.dat
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@
2017-08-27T00:00:00.000 ps1::y 20.78000 0.11000
2017-08-27T00:00:00.000 2massj 20.23000 0.10000
2017-08-27T00:00:00.000 2massh 19.66000 0.14000
2017-08-27T00:00:00.000 2massks 18.50000 0.20000
2017-08-27T00:00:00.000 2massks 18.50000 0.20000
2 changes: 1 addition & 1 deletion example_files/multi_config_analysis/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ Me2017_4:
generation-seed: 42
filters: ztfg,ztfr,ztfi
remove-nondetections: True
#process-per-config: 7
#process-per-config: 7
2 changes: 1 addition & 1 deletion example_files/multi_config_analysis/injection.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@
]
}
}
}
}
Loading