Skip to content

Commit

Permalink
Adding an on-the-fly test for emin, emax.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikibonacci committed Oct 2, 2024
1 parent 5cbfd91 commit 0831b4d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/aiidalab_qe_vibroscopy/utils/euphonic/intensity_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,17 +301,17 @@ def produce_bands_weigthed_data(
)

# duplication from euphonic/cli/utils.py
if args.emin is None:
if args.e_min is None:
# Subtract small amount from min frequency - otherwise due to unit
# conversions binning of this frequency can vary with different
# architectures/lib versions, making it difficult to test
emin_room = 1e-5 * ureg("meV").to(modes.frequencies.units).magnitude
args.emin = min(np.min(modes.frequencies.magnitude - emin_room), 0.0)
if args.emax is None:
args.emax = np.max(modes.frequencies.magnitude) * 1.05
if args.emin >= args.emax:
args.e_min = min(np.min(modes.frequencies.magnitude - emin_room), 0.0)
if args.e_max is None:
args.e_max = np.max(modes.frequencies.magnitude) * 1.05
if args.e_min >= args.e_max:
raise ValueError(
"Maximum energy ({args.emax}) should be greater than minimum ({args.emin}). "
f"Maximum energy ({args.e_max}) should be greater than minimum ({args.e_min}). "
)

modes.frequencies_unit = args.energy_unit
Expand Down

0 comments on commit 0831b4d

Please sign in to comment.