From 8a5f9ea3cdb3525354dd0084ecb5fab65b69e02e Mon Sep 17 00:00:00 2001 From: Divyajyoti <50514405+divyajyoti09@users.noreply.github.com> Date: Thu, 5 Sep 2024 02:09:02 +0530 Subject: [PATCH] Edit make banksim to allow external injection file (#4808) * functionality to use external inj.xml file in pycbc_make_banksim * updating docs to add the new functionality of using external inj.xml file * Fixing formatting issue --- bin/pycbc_make_banksim | 15 +++++++++++++-- docs/banksim.rst | 15 +++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/bin/pycbc_make_banksim b/bin/pycbc_make_banksim index fa733e6d5d6..3198b1cf0dc 100644 --- a/bin/pycbc_make_banksim +++ b/bin/pycbc_make_banksim @@ -185,8 +185,19 @@ shutil.copy(banksim_prog, 'scripts/pycbc_banksim') os.chmod('scripts/pycbc_banksim', 0o0777) logging.info("Creating injection file") -inj_str = "lalapps_inspinj " + get_ini_opts(confs, "inspinj") + "--output inj.xml" -os.system(inj_str) +if confs.has_section("inspinj"): + logging.info("Using lalapps_inspinj to create injections") + inj_str = "lalapps_inspinj " + get_ini_opts(confs, "inspinj") + "--output inj.xml" + os.system(inj_str) +elif confs.has_section("external_injection"): + logging.info("Using external injection file. Please ensure the file is in sim_inspiral table (.xml) format.") + inj_file_path = confs.get("external_injection", "inj-file") + if inj_file_path == "inj.xml": + pass + else: + os.system("cp {} inj.xml".format(inj_file_path)) +else: + raise ValueError("Need to specify the injection method. Either provide [inspinj] section or [external_injection]") logging.info("Splitting template bank") subprocess.call(['pycbc_splitbank', diff --git a/docs/banksim.rst b/docs/banksim.rst index 94204160796..3b886f31cd2 100644 --- a/docs/banksim.rst +++ b/docs/banksim.rst @@ -26,7 +26,7 @@ Below is an example. .. literalinclude:: ../examples/banksim/banksim_simple.ini -There are four sections that must be present [inspinj], [executables], [workflow], +There are four sections that must be present [inspinj]/[external_injection], [executables], [workflow], and [banksim]. #. inspinj @@ -41,6 +41,17 @@ and [banksim]. determine the actual approximants that will be compared. That is set in the [banksim] section. + If you want to use another method to create injections (Eg. ``pycbc_create_injections``), + instead of using [inspinj], you can name the section [external_injection] and specify the + path of the injection file. + + .. code-block:: bash + + [external_injection] + inj-file = /path/to/inj.xml + + Note: The injection file should be in the sim_inspiral table (.xml) format. + #. executables This section lists the location of the pycbc_banksim script. Make note @@ -61,7 +72,7 @@ and [banksim]. has to calculate fitting factors for. The injection - file generated from the [inspinj] section is split + file generated from the [inspinj] section or provided externally is split into smaller pieces to satisfy this requirement. Note that this option has a direct effect on the memory requirements of each banksim job, as each injection