diff options
-rwxr-xr-x | utils/chi2 | 2 | ||||
-rw-r--r-- | utils/sddm/plot_energy.py | 2 | ||||
-rw-r--r-- | utils/sddm/renormalize.py | 9 |
3 files changed, 9 insertions, 4 deletions
@@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (c) 2019, Anthony Latorre <tlatorre at uchicago> # # This program is free software: you can redistribute it and/or modify it diff --git a/utils/sddm/plot_energy.py b/utils/sddm/plot_energy.py index bdce750..391fa66 100644 --- a/utils/sddm/plot_energy.py +++ b/utils/sddm/plot_energy.py @@ -489,7 +489,7 @@ def get_events(filenames, merge_fits=False, nhit_thresh=None, mc=False): mcgn = pd.concat([read_hdf(filename, "mcgn") for filename in filenames],ignore_index=True) if len(mcgn): mcgn = mcgn.groupby("evn").first().reset_index() - mcgn['unique_id'] = mcgn.apply(get_unique_id,axis=1) + mcgn['unique_id'] = mcgn.apply(get_unique_id,axis=1).astype(np.dtype("S8")) ev = pd.merge(ev,mcgn[['evn','unique_id']],on=['evn'],how='left') # Delete columns we never use diff --git a/utils/sddm/renormalize.py b/utils/sddm/renormalize.py index 55d09da..f39ee91 100644 --- a/utils/sddm/renormalize.py +++ b/utils/sddm/renormalize.py @@ -115,8 +115,13 @@ def read_mcpl_df(filename): data.append((run,evn,nu,energy,r,cc,unique_id)) run, evn, nu, energy, r, cc, unique_id = zip(*data) - return add_flux_weight(pd.DataFrame({'run':run,'evn':evn,'nu_id':nu,'nu_energy':energy,'nu_r':r,'cc':cc,'unique_id':unique_id})) - + # Note: We first create a temporary column "unique_id_tmp" and then cast it + # to a new column because of what appears to be a bug in pandas. If I try + # to cast it in-place it doesn't work. + mcpl = add_flux_weight(pd.DataFrame({'run':run,'evn':evn,'nu_id':nu,'nu_energy':energy,'nu_r':r,'cc':cc,'unique_id_tmp':unique_id})) + mcpl['unique_id'] = mcpl.unique_id_tmp.astype(np.dtype("S8")) + del mcpl['unique_id_tmp'] + return mcpl def load_mcpl_files(filenames): """ |