aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortlatorre <tlatorre@uchicago.edu>2020-12-27 13:35:33 -0600
committertlatorre <tlatorre@uchicago.edu>2020-12-27 13:35:33 -0600
commitc71532924c8c2be07026041b7cd62819e90e8c64 (patch)
tree86f12eb947cdd7ebc7d32d79b60c2d3bef1d1f96
parentff7f5117095f451f5b62f9b3caec6a5d21bdd891 (diff)
downloadsddm-c71532924c8c2be07026041b7cd62819e90e8c64.tar.gz
sddm-c71532924c8c2be07026041b7cd62819e90e8c64.tar.bz2
sddm-c71532924c8c2be07026041b7cd62819e90e8c64.zip
reduce memory usage
-rwxr-xr-xutils/chi22
-rw-r--r--utils/sddm/plot_energy.py2
-rw-r--r--utils/sddm/renormalize.py9
3 files changed, 9 insertions, 4 deletions
diff --git a/utils/chi2 b/utils/chi2
index fec97a7..c883deb 100755
--- a/utils/chi2
+++ b/utils/chi2
@@ -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):
"""