diff options
author | tlatorre <tlatorre@uchicago.edu> | 2020-09-07 12:26:30 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2020-09-07 12:26:30 -0500 |
commit | 8c2dba79a018e91dc8cf607499cea4d975776cd1 (patch) | |
tree | aacd10ea5fc4fd73ef3d51b9a41b0ab0ed9db601 | |
parent | fd231f3d5472ff43044ee57ff3ac5fb37f85da5b (diff) | |
download | sddm-8c2dba79a018e91dc8cf607499cea4d975776cd1.tar.gz sddm-8c2dba79a018e91dc8cf607499cea4d975776cd1.tar.bz2 sddm-8c2dba79a018e91dc8cf607499cea4d975776cd1.zip |
update plot-muons script so it works outside the utils/ directory
-rwxr-xr-x | utils/sddm/plot_energy.py | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/utils/sddm/plot_energy.py b/utils/sddm/plot_energy.py index a4b7005..0ba4076 100755 --- a/utils/sddm/plot_energy.py +++ b/utils/sddm/plot_energy.py @@ -22,6 +22,8 @@ from .dc import DC_MUON, DC_JUNK, DC_CRATE_ISOTROPY, DC_QVNHIT, DC_NECK, DC_FLAS from . import grouper, print_warning, AV_RADIUS, PSUP_RADIUS, read_hdf import pandas as pd from scipy.misc import logsumexp +from os.path import exists, join +from os import environ EPSILON = 1e-10 @@ -383,9 +385,27 @@ def get_dx(row): else: return 0 +def find_file(filename): + """ + Returns the full path to `filename` by searching the current working + directory and the path specified by the environment variable SDDM_DATA. + + If the file isn't found in either place, just returns the filename. + """ + if exists(filename): + return filename + + if 'SDDM_DATA' in environ: + path = join(environ['SDDM_DATA'],filename) + + if exists(path): + return path + + return filename + def dx_to_energy(dx): lines = [] - with open("../src/muE_water_liquid.txt") as f: + with open(find_file("muE_water_liquid.txt")) as f: for i, line in enumerate(f): if i < 10: continue |