Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit make banksim to allow external injection file #4808

Merged
merged 5 commits into from
Sep 4, 2024
Merged
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
15 changes: 13 additions & 2 deletions bin/pycbc_make_banksim
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably shutil instead of a system command, otherwise this seems fine.

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
Loading