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

Improve GetEnergy – Robust Error Handling, Efficiency, and Clarity #7

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

stanislc
Copy link

@stanislc stanislc commented Feb 5, 2025

Summary

Key Improvements in GetEnergy.py

1️⃣ Robust Error Handling
•Added try-except blocks when loading bias shift files (b_shift.dat, c_shift.dat, etc.) to handle missing files gracefully.
•Checks if required directories (analysis[i]/data) exist before attempting to read files.
•Properly detects whether the script is running in flattening or production mode, exiting with an error if neither is met.

2️⃣ Improved Efficiency & Memory Optimization
• Optimized File Loading & Loop Structure
• Reduced redundant calculations by restructuring loops.
• Now detects production vs. flattening mode automatically

3️⃣ Better Readability & Maintainability
• Improved directory path handling using formatted strings instead of manual concatenation.
• More Descriptive Variable Names

Small improvement in GetEnergy.py: Put scaling factors into the function definition to allow manipulation

Updated documentation and allow selection of different cutoffs
The main purpose is reading Lambda files from various runs is to capture data from different execution scenarios. For example, runs “run1,” “run2,” and “run3” may have only 1 execution, while runs “run4” and “run5” may have multiple replicates.

a) Error handling for nbshift, checking the existence of directories
b) Automatic detection of flattening vs production phase for each run
c) reading lambda files in loops over range(NF) & range(nrep) changed to lambda_files
d) simplified logic for reading relevant frames
@stanislc stanislc marked this pull request as draft February 20, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant