-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add script to run gain selection over a list of dates, using the "lst_select_gain" script #141
Conversation
Thanks @marialainez. I have been trying to make it work with sbatch. All attempts of using using for example this function: import dedent
PATH = "PATH=/fefs/aswg/software/gain_selection/bin:$PATH"
def get_sbatch_script(
run_id,
input_file,
output_dir,
log_dir,
ref_time,
ref_counter,
module,
ref_source
):
return dedent(f"""\
#!/bin/bash
#SBATCH -D {log_dir}
#SBATCH -o "gain_selection_{run_id:05d}_%j.log"
#SBATCH --job-name "gain_selection_{run_id:05d}"
#SBATCH --export {PATH}
lst_select_gain {input_file} {output_dir} {ref_time} {ref_counter} {module} {ref_source}
""") for file in input_files:
run_info = run_info_from_filename(file)
job_file = f"gain_selection_{run_info.run:05d}.{run_info.subrun:04d}.sh"
with open(job_file, "w") as f:
f.write(get_sbatch_script(
run_id,
file,
output_dir,
log_dir,
ref_time,
ref_counter,
module,
ref_source
))
sp.run(["sbatch", job_file], check=True) |
osa/scripts/gain_selection.py
Outdated
|
||
def apply_gain_selection(date: str): | ||
run_summary_file = "/fefs/aswg/data/real/monitoring/RunSummary/RunSummary_"+date+".ecsv" | ||
data = ascii.read(run_summary_file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can directly use astropy Tables
-> data = Tables.read(file)
osa/scripts/gain_selection.py
Outdated
run_summary_file = "/fefs/aswg/data/real/monitoring/RunSummary/RunSummary_"+date+".ecsv" | ||
data = ascii.read(run_summary_file) | ||
data.add_index("run_id") | ||
data = data[(data['run_type']=='DATA')] # apply gain selection only to DATA runs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove redundant parenthesis
osa/scripts/gain_selection.py
Outdated
data.add_index("run_id") | ||
data = data[(data['run_type']=='DATA')] # apply gain selection only to DATA runs | ||
|
||
output_dir = "/fefs/aswg/data/real/R0/gain_selected/"+date |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can use f-strings: f"/fefs/aswg/data/real/R0/gain_selected/{date}"
osa/scripts/gain_selection.py
Outdated
for run in data["run_id"]: | ||
|
||
ref_time = data.loc[run]["dragon_reference_time"] | ||
ref_counter = data.loc[run]["dragon_reference_counter"] | ||
module = data.loc[run]["dragon_reference_module_index"] | ||
ref_source = data.loc[run]["dragon_reference_source"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can directly loop over the whole row and extract the values afterward:
for run in data:
run_id = run["run_id"]
ref_time = run["dragon_reference_time"]
ref_counter = run["dragon_reference_counter"]
module = run["dragon_reference_module_index"]
ref_source = run["dragon_reference_source"].upper()
and then I think you would not need to use data.add_index("run_id")
since the table would be already indexed.
Codecov Report
@@ Coverage Diff @@
## main #141 +/- ##
==========================================
+ Coverage 81.74% 81.88% +0.13%
==========================================
Files 51 51
Lines 4838 4995 +157
==========================================
+ Hits 3955 4090 +135
- Misses 883 905 +22
Continue to review full report at Codecov.
|
osa/scripts/gain_selection.py
Outdated
|
||
log.info("Done! No more dates to process.") | ||
|
||
check_failed_jobs(output_basedir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@marialainez, in the current way of checking failed jobs, you need to launch the script again, which will submit jobs again, right? Either we implement a simulate option that allows only for checking job status or the check is done in a separate script independent from the launching-job script.
No description provided.