diff options
author | tlatorre <tlatorre@uchicago.edu> | 2019-07-12 10:28:31 -0500 |
---|---|---|
committer | tlatorre <tlatorre@uchicago.edu> | 2019-07-12 10:28:31 -0500 |
commit | 3c3720143201915729759478c7e7e36c71ac3bbd (patch) | |
tree | fe9af4c0f502c6638393ed3c792dc40f7c7660b8 /utils/plot-energy | |
parent | 80490012a62eff5ca61fff3ea1e8f2a5537523b0 (diff) | |
download | sddm-3c3720143201915729759478c7e7e36c71ac3bbd.tar.gz sddm-3c3720143201915729759478c7e7e36c71ac3bbd.tar.bz2 sddm-3c3720143201915729759478c7e7e36c71ac3bbd.zip |
fix a couple of bugs in plot-energy
This commit fixes two small bugs in the plotting scripts. First, after the HDF5
commit I wasn't correctly computing the particle ID string which I had been
using before which was needed in order to plot things correctly. Second, I
realized that the dataframe groupby function first() actually selects the first
non-null column from each group! What I really wanted was the first row from
each group, so all instances of .first() were updated to .nth(0).
See https://stackoverflow.com/questions/20067636/pandas-dataframe-get-first-row-of-each-group.
Diffstat (limited to 'utils/plot-energy')
-rwxr-xr-x | utils/plot-energy | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/utils/plot-energy b/utils/plot-energy index 4a8521b..969cc4b 100755 --- a/utils/plot-energy +++ b/utils/plot-energy @@ -149,7 +149,9 @@ if __name__ == '__main__': fits['psi'] /= fits.merge(ev,on=['run','gtid'])['nhit'] fits['ke'] = fits['energy1'] - fits['id'] = fits['id1'] + fits['id2']*100 + fits['id3']*10000 + fits['id'] = fits['id1'] + fits.loc[fits['n'] == 2, 'id'] = fits['id1']*100 + fits['id2'] + fits.loc[fits['n'] == 3, 'id'] = fits['id1']*10000 + fits['id2']*100 + fits['id3'] fits['theta'] = fits['theta1'] # Make sure events are in order. We use run number and GTID here which @@ -347,10 +349,10 @@ if __name__ == '__main__': michel = michel[~nan_michel] # get the best fit - prompt = prompt.sort_values('fmin').groupby(['run','gtid']).first() - atm = atm.sort_values('fmin').groupby(['run','gtid']).first() - michel_best_fit = michel.sort_values('fmin').groupby(['run','gtid']).first() - muon_best_fit = muons.sort_values('fmin').groupby(['run','gtid']).first() + prompt = prompt.sort_values('fmin').groupby(['run','gtid']).nth(0) + atm = atm.sort_values('fmin').groupby(['run','gtid']).nth(0) + michel_best_fit = michel.sort_values('fmin').groupby(['run','gtid']).nth(0) + muon_best_fit = muons.sort_values('fmin').groupby(['run','gtid']).nth(0) muons = muons[muons.id == 22] # require r < 6 meters |