Skip to content

Commit

Permalink
Edit make banksim to allow external injection file (#4808)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
divyajyoti09 authored Sep 4, 2024
1 parent ec82874 commit 8a5f9ea
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
15 changes: 13 additions & 2 deletions bin/pycbc_make_banksim
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
15 changes: 13 additions & 2 deletions docs/banksim.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8a5f9ea

Please sign in to comment.