• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nuclear-multimessenger-astronomy / nmma / 21710444803

05 Feb 2026 11:53AM UTC coverage: 48.565% (+16.3%) from 32.286%
21710444803

push

github

web-flow
Merge pull request #411 from nuclear-multimessenger-astronomy/direct_eos_sampling

ENH: Merge to reach nmma 1.0

3464 of 6955 new or added lines in 48 files covered. (49.81%)

9 existing lines in 5 files now uncovered.

4280 of 8813 relevant lines covered (48.56%)

0.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

9.64
/nmma/post_processing/parser.py
1
from ..em.em_parsing import (
2✔
2
    basic_em_only_parsing, em_time_parsing, em_model_parsing, grb_parsing
3
)
4
def joint_postprocess_parser(parser):
2✔
NEW
5
    parser.add_argument("--outdir", metavar="PATH", required=True)
×
NEW
6
    parser.add_argument("--cred-interval", type=float, default=0.95, 
×
7
        help="Credible interval to be calculated (default: 0.95)")
NEW
8
    parser.add_argument("--seed", type=int, default=42, help="Random seed (default: 42)")
×
NEW
9
    parser.add_argument("-d", "--detections-file", "--detectable")
×
NEW
10
    parser.add_argument("--Nevent", type=int)
×
NEW
11
    parser.add_argument("--N-reordering", type=int, default=100, 
×
12
        help="Number of reodering realisation to be comsidered (default: 100)")
NEW
13
    parser.add_argument("--N-posterior-samples", type=int, default=10000,
×
14
        help="Number of posterior samples to be drawn during the resampling (default: 10000)")
NEW
15
    return parser
×
16

17
def R14_parser(parser):
2✔
NEW
18
    parser.description="Calculate the trend of estimated R14 with GW+EM input"
×
19
    
NEW
20
    parser = joint_postprocess_parser(parser)
×
NEW
21
    parser.add_argument("--label", metavar="NAME", required=True)
×
NEW
22
    parser.add_argument("--R14-true", type=float, default=11.55,
×
23
        help="The true value of Neutron stars's raduis (default:11.55)")
NEW
24
    parser.add_argument("--gwR14trend", required=True,
×
25
        help="Path to the R14trend GW  posterior samples directory, the  file are expected to be in the format of GW_R14trend.dat ")
NEW
26
    parser.add_argument("--GWEMsamples", required=True,
×
27
        help="Path to the GWEM posterior samples directory, the samples files are expected to be in the format of posterior_samples_{i}.dat",)
NEW
28
    parser.add_argument("--Neos", type=int, required=True, help="Number of EOS")
×
NEW
29
    parser.add_argument("--EOS-prior",
×
30
        help="Path to the EOS prior file, if None, assuming fla prior across EOSs")
NEW
31
    parser.add_argument("--EOSpath", required=True, help="The EOS data")
×
NEW
32
    parser.add_argument("--pdet",
×
33
        help="Path to the probability of detection as a function of maximum mass (for correcting selection bias)")
NEW
34
    return parser
×
35
    
36

37
def Hubble_parser(parser): 
2✔
NEW
38
    parser.description="Calculate the combination and seperate trend of estimated Hubble constant with GW and EM input"
×
39

NEW
40
    parser = joint_postprocess_parser(parser)
×
NEW
41
    parser.add_argument("--output-label", metavar="NAME", required=True)
×
NEW
42
    parser.add_argument("--GWsamples", metavar='PATH', required=True, help="Path to the GW posterior samples directory, the samples files are expected to be in the format of posterior_samples_{i}.dat")
×
NEW
43
    parser.add_argument("--EMsamples", metavar='PATH', required=True, help="Same as the GW samples but for EM samples")
×
NEW
44
    parser.add_argument("--injection", metavar='PATH', required=True)
×
NEW
45
    parser.add_argument("--inject-Hubble", metavar='H0', type=float, required=True)
×
NEW
46
    parser.add_argument("--N-prior-samples", type=int,  default=10000, 
×
47
        help="Number of prior samples to be used for resampling (default: 10000)")
NEW
48
    parser.add_argument("--p-value-threshold", type=float, 
×
49
        help="p-value threshold used to remove badly recoved injections")
NEW
50
    return parser
×
51

52
def resampling_parser(parser):
2✔
NEW
53
    parser.description="Inference on binary source parameters with kilonova ejecta posterior and GW source posterior given."
×
54

NEW
55
    parser.add_argument("--outdir", metavar="PATH", required=True)
×
NEW
56
    parser.add_argument("--GWsamples", metavar="PATH", required=True,
×
57
            help="posterior samples file from a previous Bayesian inference run on GW signals.")
NEW
58
    parser.add_argument("--EMsamples", metavar="PATH", required=True,
×
59
            help="posterior samples file from a previous Bayesian inference run on EM signals (e.g. Kilonova inference or Kilonova+GRB inference.")
NEW
60
    parser.add_argument("--EOSpath",metavar="PATH", required=True,
×
61
            help="Path of EOS folder, e.g. 15nsat_cse_uniform_R14 (located: https://zenodo.org/record/6106130#.YoysIHVBwUG)")
NEW
62
    parser.add_argument("--Neos", type=int,required=True,help="Number of EOS files used for the inference.")
×
NEW
63
    parser.add_argument("--nlive", type=int, default=1024, help="live number")
×
NEW
64
    parser.add_argument("--GWprior", required=True, help="Prior file used for the GW analysis")
×
NEW
65
    parser.add_argument("--EMprior", required=True, help="Prior file used for the EM eos analysis")
×
NEW
66
    parser.add_argument("--total-ejecta-mass", action='store_true',
×
67
            help="To run with total ejecta mass, if not activated, the two ejecta are consider seperately")
NEW
68
    parser.add_argument("--withNSBH", action='store_true',
×
69
            help="Compute GW-EM-resampling for NSBH source, else: for BNS source.")
NEW
70
    return parser
×
71

72
def maximum_mass_parser(parser):
2✔
NEW
73
    parser.description="Inference on the maximum mass constraint of the EOS when a joint posterior for binary components, ejecta and EOS is provided."
×
74

NEW
75
    parser.add_argument("--outdir", metavar="PATH", required=True)
×
NEW
76
    parser.add_argument("--joint-posterior", required=True,
×
77
        help="Posterior file with chirp mass, eta_star, EOSID, log10_mdisk, log10_mej_dyn as columns.")
NEW
78
    parser.add_argument("--prior", metavar="PATH", required=True,
×
79
        help="Prior specification for chirp mass, eta_star, log10_mdisk, log10_mej_dyn. If use_M_kepler is True, prior file must also contain ratio_R and delta.",
80
    )
NEW
81
    parser.add_argument("--eos-path-macro", metavar="PATH", required=True,
×
82
        help="EOS folder with EOS files in [R, M, Lambda, p_central] format.")
NEW
83
    parser.add_argument("--eos-path-micro", metavar="PATH", required=True,
×
84
        help="EOS folder with EOS files in [n, energy density, pressure, speed of sound squared] format.")
NEW
85
    parser.add_argument( "--use-M-Kepler",  action='store_true',
×
86
        help="If set, it is assumed that the BNS remnant collapsed to a black hole above the Kepler limit.")
NEW
87
    parser.add_argument("--nlive", type=int,  default=1024)
×
88
    
NEW
89
    return parser
×
90

91
def corner_plot_parser(parser):
2✔
NEW
92
    parser.description="Generate corner plot"
×
93

NEW
94
    parser.add_argument("-f", "--posterior-files", nargs="+", required=True,
×
95
        help="CSV file path for posteriors")
NEW
96
    parser.add_argument("-p", "--prior-filename", help="Prior file path for axes labels")
×
NEW
97
    parser.add_argument("-l", "--label-name", nargs="+",
×
98
        help="Legend labels (if in latex, use '$label$') or else just use the posterior file names")
NEW
99
    parser.add_argument("-i", "--injection-json", 
×
100
        help="Injection JSON file path to be used as truth values" )
NEW
101
    parser.add_argument("-n", "--injection-num", type=int,
×
102
        help="Injection number to be used as truth values, only used if injection JSON is provided; equivalent to simulation ID")
103

NEW
104
    parser.add_argument("--bestfit-params",
×
105
        help="Use the values from the bestfit_params.json file to plot the truth on the corner plot; Either use injection JSON or bestfit_params.json, not both" )
106

NEW
107
    parser.add_argument("-o", "--output", help="output file name.")
×
NEW
108
    parser.add_argument("--kwargs", default="{}",
×
109
        help="kwargs to be passed to corner.corner. Eg: {'plot_datapoints': False}, enclose {} in double quotes" )
110

NEW
111
    return parser
×
112

113

114
def lc_marginalisation_parser(parser):
2✔
NEW
115
    parser.description="Summary analysis for nmma injection file"
×
116

NEW
117
    parser = basic_em_only_parsing(parser)
×
NEW
118
    parser = em_time_parsing(parser)
×
NEW
119
    parser = em_model_parsing(parser)
×
NEW
120
    parser = grb_parsing(parser)
×
121

122
    # specific arguments
NEW
123
    parser.add_argument(
×
124
        "--template-file",  help="The template file to be used"
125
    )
NEW
126
    parser.add_argument("--hdf5-file", help="The hdf5 file to be used")
×
NEW
127
    parser.add_argument("--coinc-file",  help="The coinc xml file to be used")
×
NEW
128
    parser.add_argument("-g", "--gps", type=int, default=1187008882)
×
NEW
129
    parser.add_argument("-s", "--skymap")
×
NEW
130
    parser.add_argument("--eos-data", "--eos-dir",  
×
131
        help="EOS file directory in (radius [km], mass [solar mass], lambda)")
NEW
132
    parser.add_argument("-e", "--eos-weights", "--gw170817-eos", type=str)
×
NEW
133
    parser.add_argument("-n", "--Nmarg", type=int, default=100)
×
NEW
134
    parser.add_argument("--generation-seed", type=int, default=42, help="Injection generation seed (default: 42)")
×
NEW
135
    return parser
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc