Skip to content

Commit

Permalink
CPU time monitoring + minor fixes + process names
Browse files Browse the repository at this point in the history
  • Loading branch information
Elisa-Visentin committed Sep 22, 2023
1 parent c9feb52 commit 58245ec
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
4 changes: 4 additions & 0 deletions nsb_scripts/LSTnsb.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,17 @@ def main():
if ii % mod == 0:
a, b, c = calculate_noise_parameters(simtel, run_list[ii], lst_config)
noise.append(a)
if len(noise)==0:
return
a = sum(noise) / len(noise)
std = np.std(noise)
logger.info(f"Run n. {run_number}, nsb average (all) {a}, std {std}")
subrun_ok = []
for sr in range(0, len(noise)):
if np.abs(noise[sr] - a) < 3 * std:
subrun_ok.append(noise[sr])
if len(subrun_ok)==0:
return
a = sum(subrun_ok) / len(subrun_ok)
logger.info(f"Run n. {run_number}, nsb average (w/o outliers) {a}")
for j in range(0, len(nsb)):
Expand Down
8 changes: 4 additions & 4 deletions nsb_scripts/nsb_coincident_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def linking_bash_lst(scripts_dir, target_dir, LST_runs, nsb, date, source):
f.write(
"#SBATCH -J "
+ target_dir.split("/")[-2:][1]
+ "_coincidence"
+ "_coincidence_"
+ str(nsb)
+ "\n"
)
Expand All @@ -241,7 +241,7 @@ def linking_bash_lst(scripts_dir, target_dir, LST_runs, nsb, date, source):
"export LOG=$OUTPUTDIR/logs/coincidence_${SLURM_ARRAY_TASK_ID}.log\n"
)
f.write(
f"conda run -n magic-lst python {scripts_dir}/lst1_magic_event_coincidence.py --input-file-lst $SAMPLE --input-dir-magic $INM --output-dir $OUTPUTDIR --config-file {target_dir}/config_coincidence.yaml >$LOG 2>&1"
f"time conda run -n magic-lst python {scripts_dir}/lst1_magic_event_coincidence.py --input-file-lst $SAMPLE --input-dir-magic $INM --output-dir $OUTPUTDIR --config-file {target_dir}/config_coincidence.yaml >$LOG 2>&1"
)
f.close()

Expand Down Expand Up @@ -298,13 +298,13 @@ def main():
print(
"Process name: "
+ target_dir.split("/")[-2:][1]
+ "_coincidence"
+ "_coincidence_"
+ str(nsblvl)
)
print(
"To check the jobs submitted to the cluster, type: squeue -n "
+ target_dir.split("/")[-2:][1]
+ "_coincidence"
+ "_coincidence_"
+ str(nsblvl)
)

Expand Down
2 changes: 1 addition & 1 deletion nsb_scripts/nsb_level.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def bash_scripts(run, config, source):
f.write("ulimit -a\n\n")

f.write(
f"conda run -n magic-lst python LSTnsb.py -c {config} -i {run} > {source}_nsblog_{run}.log 2>&1 \n\n"
f"time conda run -n magic-lst python LSTnsb.py -c {config} -i {run} > {source}_nsblog_{run}.log 2>&1 \n\n"
)
f.close()

Expand Down
2 changes: 1 addition & 1 deletion nsb_scripts/nsb_merge_M1_M2_night.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def merge(scripts_dir, target_dir, source):
if not os.path.exists(MAGIC_DL1_dir + f"/Merged/Merged_{i}/logs"):
os.mkdir(f"{MAGIC_DL1_dir}/Merged/Merged_{i}/logs")
f.write(
f"conda run -n magic-lst python {scripts_dir}/merge_hdf_files.py --input-dir {MAGIC_DL1_dir}/Merged/{i}/Merged --output-dir {MAGIC_DL1_dir}/Merged/Merged_{i} >{MAGIC_DL1_dir}/Merged/Merged_{i}/logs/merge_night_{i}.log \n"
f"time conda run -n magic-lst python {scripts_dir}/merge_hdf_files.py --input-dir {MAGIC_DL1_dir}/Merged/{i}/Merged --output-dir {MAGIC_DL1_dir}/Merged/Merged_{i} >{MAGIC_DL1_dir}/Merged/Merged_{i}/logs/merge_night_{i}.log \n"
)

f.close()
Expand Down
2 changes: 1 addition & 1 deletion nsb_scripts/nsb_merge_M1_M2_runs.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def merge(scripts_dir, target_dir, source):
):
os.mkdir(f"{MAGIC_DL1_dir}/Merged/{i}/Merged/logs")
f.write(
f"conda run -n magic-lst python {scripts_dir}/merge_hdf_files.py --input-dir {MAGIC_DL1_dir}/Merged/{i}/{r} --output-dir {MAGIC_DL1_dir}/Merged/{i}/Merged --run-wise >{MAGIC_DL1_dir}/Merged/{i}/Merged/logs/merge_{i}.log \n"
f"time conda run -n magic-lst python {scripts_dir}/merge_hdf_files.py --input-dir {MAGIC_DL1_dir}/Merged/{i}/{r} --output-dir {MAGIC_DL1_dir}/Merged/{i}/Merged --run-wise >{MAGIC_DL1_dir}/Merged/{i}/Merged/logs/merge_{i}.log \n"
)

f.close()
Expand Down
4 changes: 2 additions & 2 deletions nsb_scripts/nsb_merge_subruns.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def merge(scripts_dir, target_dir, source):
) # Creating a merged directory for the respective run

f.write(
f"conda run -n magic-lst python {scripts_dir}/merge_hdf_files.py --input-dir {MAGIC_DL1_dir}/M1/{i}/{r} --output-dir {MAGIC_DL1_dir}/Merged/{i}/{r} >{MAGIC_DL1_dir}/Merged/{i}/{r}/logs/merge_M1_{i}_{r}.log \n"
f"time conda run -n magic-lst python {scripts_dir}/merge_hdf_files.py --input-dir {MAGIC_DL1_dir}/M1/{i}/{r} --output-dir {MAGIC_DL1_dir}/Merged/{i}/{r} >{MAGIC_DL1_dir}/Merged/{i}/{r}/logs/merge_M1_{i}_{r}.log \n"
)

if os.path.exists(MAGIC_DL1_dir + "/M2"):
Expand All @@ -103,7 +103,7 @@ def merge(scripts_dir, target_dir, source):
) # Creating a merged directory for the respective run

f.write(
f"conda run -n magic-lst python {scripts_dir}/merge_hdf_files.py --input-dir {MAGIC_DL1_dir}/M2/{i}/{r} --output-dir {MAGIC_DL1_dir}/Merged/{i}/{r} >{MAGIC_DL1_dir}/Merged/{i}/{r}/logs/merge_M2_{i}_{r}.log \n"
f"time conda run -n magic-lst python {scripts_dir}/merge_hdf_files.py --input-dir {MAGIC_DL1_dir}/M2/{i}/{r} --output-dir {MAGIC_DL1_dir}/Merged/{i}/{r} >{MAGIC_DL1_dir}/Merged/{i}/{r}/logs/merge_M2_{i}_{r}.log \n"
)

f.close()
Expand Down
10 changes: 5 additions & 5 deletions nsb_scripts/nsb_setting_up_config_and_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def lists_and_bash_gen_MAGIC(
Below we create a bash script that links the MAGIC data paths to each subdirectory.
"""

process_name = target_dir.split("/")[-2:][0] + target_dir.split("/")[-2:][1]
process_name = target_dir.split("/")[-2:][0] +"_"+ target_dir.split("/")[-2:][1]

f = open(f"{source}_linking_MAGIC_data_paths.sh", "w")
f.write("#!/bin/sh\n\n")
Expand Down Expand Up @@ -231,7 +231,7 @@ def lists_and_bash_gen_MAGIC(
"export LOG=$OUTPUTDIR/logs/real_0_1_task${SLURM_ARRAY_TASK_ID}.log\n"
)
f.write(
f"conda run -n magic-lst python {scripts_dir}/magic_calib_to_dl1.py --input-file $SAMPLE --output-dir $OUTPUTDIR --config-file "
f"time conda run -n magic-lst python {scripts_dir}/magic_calib_to_dl1.py --input-file $SAMPLE --output-dir $OUTPUTDIR --config-file "
+ target_dir
+ "/config_step1.yaml >$LOG 2>&1\n"
)
Expand Down Expand Up @@ -280,7 +280,7 @@ def lists_and_bash_gen_MAGIC(
"export LOG=$OUTPUTDIR/logs/real_0_1_task${SLURM_ARRAY_TASK_ID}.log\n"
)
f.write(
f"conda run -n magic-lst python {scripts_dir}/magic_calib_to_dl1.py --input-file $SAMPLE --output-dir $OUTPUTDIR --config-file "
f"time conda run -n magic-lst python {scripts_dir}/magic_calib_to_dl1.py --input-file $SAMPLE --output-dir $OUTPUTDIR --config-file "
+ target_dir
+ "/config_step1.yaml >$LOG 2>&1\n"
)
Expand Down Expand Up @@ -388,11 +388,11 @@ def main():

print("*** Reducing DL0 to DL1 data***")
print(
"Process name: ", target_dir.split("/")[-2:][0] + target_dir.split("/")[-2:][1]
"Process name: ", target_dir.split("/")[-2:][0] +"_"+ target_dir.split("/")[-2:][1]
)
print(
"To check the jobs submitted to the cluster, type: squeue -n",
target_dir.split("/")[-2:][0] + target_dir.split("/")[-2:][1],
target_dir.split("/")[-2:][0] +"_"+ target_dir.split("/")[-2:][1],
)

directories_generator(
Expand Down
8 changes: 4 additions & 4 deletions nsb_scripts/nsb_stereo_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def bash_stereo(scripts_dir, target_dir, nsb, source):
f = open(f"{source}_StereoEvents_{nsb}_{nightLST.split('/')[-1]}.sh", "w")
f.write("#!/bin/sh\n\n")
f.write("#SBATCH -p short\n")
f.write("#SBATCH -J " + process_name + "_stereo" + str(nsb) + "\n")
f.write("#SBATCH -J " + process_name + "_stereo_" + str(nsb) + "\n")
f.write(f"#SBATCH --array=0-{process_size}\n")
f.write("#SBATCH -N 1\n\n")
f.write("ulimit -l unlimited\n")
Expand All @@ -158,7 +158,7 @@ def bash_stereo(scripts_dir, target_dir, nsb, source):
f.write("SAMPLE=${SAMPLE_LIST[${SLURM_ARRAY_TASK_ID}]}\n")
f.write("export LOG=$OUTPUTDIR/logs/stereo_${SLURM_ARRAY_TASK_ID}.log\n")
f.write(
f"conda run -n magic-lst python {scripts_dir}/lst1_magic_stereo_reco.py --input-file $SAMPLE --output-dir $OUTPUTDIR --config-file {target_dir}/config_stereo.yaml >$LOG 2>&1"
f"time conda run -n magic-lst python {scripts_dir}/lst1_magic_stereo_reco.py --input-file $SAMPLE --output-dir $OUTPUTDIR --config-file {target_dir}/config_stereo.yaml >$LOG 2>&1"
)
f.close()

Expand Down Expand Up @@ -205,12 +205,12 @@ def main():

print("***** Submitting processess to the cluster...")
print(
"Process name: " + target_dir.split("/")[-2:][1] + "_stereo" + str(nsblvl)
"Process name: " + target_dir.split("/")[-2:][1] + "_stereo_" + str(nsblvl)
)
print(
"To check the jobs submitted to the cluster, type: squeue -n "
+ target_dir.split("/")[-2:][1]
+ "_stereo"
+ "_stereo_"
+ str(nsblvl)
)

Expand Down

0 comments on commit 58245ec

Please sign in to comment.