Skip to content
Snippets Groups Projects
Commit a8566ff6 authored by tomrink's avatar tomrink
Browse files

snapshot..

parent 6b83ae44
No related branches found
No related tags found
No related merge requests found
...@@ -435,13 +435,14 @@ def make_histogram(values, edges): ...@@ -435,13 +435,14 @@ def make_histogram(values, edges):
return h return h
def normalize(data, param, mean_std_dict, add_noise=False, noise_scale=0.01, seed=None, copy=True): def normalize(data, param, mean_std_dict, copy=True):
if copy:
data = data.copy()
if mean_std_dict.get(param) is None: if mean_std_dict.get(param) is None:
return data return data
if copy:
data = data.copy()
shape = data.shape shape = data.shape
data = data.flatten() data = data.flatten()
...@@ -449,15 +450,26 @@ def normalize(data, param, mean_std_dict, add_noise=False, noise_scale=0.01, see ...@@ -449,15 +450,26 @@ def normalize(data, param, mean_std_dict, add_noise=False, noise_scale=0.01, see
data -= mean data -= mean
data /= std data /= std
if add_noise: not_valid = np.isnan(data)
data[not_valid] = 0
data = np.reshape(data, shape)
return data
def add_noise(data, noise_scale=0.01, seed=None, copy=True):
if copy:
data = data.copy()
shape = data.shape
data = data.flatten()
if seed is not None: if seed is not None:
np.random.seed(seed) np.random.seed(seed)
rnd = np.random.normal(loc=0, scale=noise_scale, size=data.size) rnd = np.random.normal(loc=0, scale=noise_scale, size=data.size)
data += rnd data += rnd
not_valid = np.isnan(data)
data[not_valid] = 0
data = np.reshape(data, shape) data = np.reshape(data, shape)
return data return data
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment