aboutsummaryrefslogtreecommitdiff
path: root/utils/sddm
diff options
context:
space:
mode:
Diffstat (limited to 'utils/sddm')
-rw-r--r--utils/sddm/__init__.py12
-rwxr-xr-xutils/sddm/dc.py9
-rw-r--r--[-rwxr-xr-x]utils/sddm/plot.py0
-rw-r--r--[-rwxr-xr-x]utils/sddm/plot_energy.py0
4 files changed, 21 insertions, 0 deletions
diff --git a/utils/sddm/__init__.py b/utils/sddm/__init__.py
index f213c2b..8bed558 100644
--- a/utils/sddm/__init__.py
+++ b/utils/sddm/__init__.py
@@ -4,6 +4,8 @@ from itertools import izip_longest
import os
import h5py
import pandas as pd
+import numpy as np
+import contextlib
IDP_E_MINUS = 20
IDP_MU_MINUS = 22
@@ -183,3 +185,13 @@ def read_hdf(filename, df):
with h5py.File(filename,'r') as f:
data = f[df][:]
return pd.DataFrame(data)
+
+# from https://stackoverflow.com/questions/2891790/how-to-pretty-print-a-numpy-array-without-scientific-notation-and-with-given-pre
+@contextlib.contextmanager
+def printoptions(*args, **kwargs):
+ original = np.get_printoptions()
+ np.set_printoptions(*args, **kwargs)
+ try:
+ yield
+ finally:
+ np.set_printoptions(**original)
diff --git a/utils/sddm/dc.py b/utils/sddm/dc.py
index 745220b..ee62656 100755
--- a/utils/sddm/dc.py
+++ b/utils/sddm/dc.py
@@ -40,6 +40,15 @@ DC_BREAKDOWN = 0x800
# nans in case an expected value is predicted to be zero.
EPSILON = 1e-10
+def truncnorm_scaled(low,high,loc=0,scale=1,random_state=None):
+ """
+ Just like scipy's truncnorm.rvs() except we auto convert the clip values.
+ """
+ low = np.atleast_1d(low)
+ high = np.atleast_1d(high)
+ a, b = (low - loc)/scale, (high - loc)/scale
+ return truncnorm.rvs(a,b,loc,scale,random_state=random_state)
+
def get_proposal_func(stepsizes, low, high):
"""
Returns a function which produces proposal steps for a Metropolis Hastings
diff --git a/utils/sddm/plot.py b/utils/sddm/plot.py
index 935b26a..935b26a 100755..100644
--- a/utils/sddm/plot.py
+++ b/utils/sddm/plot.py
diff --git a/utils/sddm/plot_energy.py b/utils/sddm/plot_energy.py
index 0ba4076..0ba4076 100755..100644
--- a/utils/sddm/plot_energy.py
+++ b/utils/sddm/plot_energy.py