Skip to content

Commit

Permalink
fix dumping lstchain tuned configs in dedicated script (#479)
Browse files Browse the repository at this point in the history
* fix dumping lstchain tuned configs in dedicated script
- dump with indents
- rm tmp configs to avoid overwrite issue

* test issue doc

* Delete docs/examples/NSB_levels.ipynb

* Delete lstchain_config.json

* test file included by mistake

* file included by mistake
  • Loading branch information
vuillaut authored Aug 19, 2024
1 parent f59aa5b commit 5e0ea9a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions lstmcpipe/config/paths_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ def load_pointings(self, join_type='inner'):
Returns
-------
'astropy.table.QTable`
"""
tabs = {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ def dump_plus_copy_node_to_create_new_table(
astropy_table_to_copy : astropy table to be copied
newparent_pointer : newparent copy_node parameter
newname_pointer : newname copy_node parameter
tmp_name : [str] flag to identify the temportal table and make it unique (necessary when simultaneous reorganizers
are run in the same dir)
tmp_name : [str] flag to identify the temportal table and make it unique (necessary when simultaneous reorganizers are run in the same dir)
overwrite : overwrite parameter of the copy_node method
"""
input_filename = input_filename.split("___")[0]
Expand Down
9 changes: 7 additions & 2 deletions lstmcpipe/scripts/generate_nsb_levels_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def dump_lstchain_nsb_config(nsb_tuning_ratio):
new_config["waveform_nsb_tuning"]["nsb_tuning_ratio"] = nsb_tuning_ratio
json_filename = lstchain_config_name(nsb_tuning_ratio)
with open(json_filename, 'w') as f:
json.dump(new_config, f)
json.dump(new_config, f, indent=4)
logger.info(f"Dumped lstchain configuration file: {json_filename}")


Expand Down Expand Up @@ -124,6 +124,7 @@ def main():
for nsb_tuning_ratio in nsb_tuning_ratios:
logger.info(f"Working on ratio {nsb_tuning_ratio}")
dump_lstchain_nsb_config(nsb_tuning_ratio)
tmp_lstchain_config = "tmp_lstchain_config.json"
command = [
"lstmcpipe_generate_config",
"PathConfigAllSkyFull",
Expand All @@ -132,9 +133,13 @@ def main():
"-o",
lstmcpipe_config_filename(nsb_tuning_ratio),
"--dec_list",
dec_list
dec_list,
"--lstchain_conf",
tmp_lstchain_config
]
subprocess.run(command, check=True)
# Delete tmp_lstchain_config (the lstchain configs with nsb tuning are already dumped)
subprocess.run(["rm", tmp_lstchain_config], check=True)
logger.info(f"Generated lstmcpipe configuration file: {lstmcpipe_config_filename(nsb_tuning_ratio)}")


Expand Down
2 changes: 2 additions & 0 deletions lstmcpipe/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,11 @@ def run_command(*args):
args: str or iter
`Shell` is forced to True, thus a single string (shell cmd) is expected.
Returns
-------
(subprocess.Popen.stdout).strip('\n')
"""
cmd = sp.Popen(args, shell=True, stdout=sp.PIPE, stderr=sp.STDOUT, encoding='utf-8')
stdout, _ = cmd.communicate()
Expand Down

0 comments on commit 5e0ea9a

Please sign in to comment.