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

minor...

parent 3f8cb659
No related branches found
No related tags found
No related merge requests found
...@@ -324,4 +324,30 @@ def make_times(dt_str_0, dt_str_1=None, format_code='%Y-%m-%d_%H:%M', num_steps= ...@@ -324,4 +324,30 @@ def make_times(dt_str_0, dt_str_1=None, format_code='%Y-%m-%d_%H:%M', num_steps=
def make_histogram(values, edges): def make_histogram(values, edges):
h = np.histogram(values, bins=edges) h = np.histogram(values, bins=edges)
return h return h
\ No newline at end of file
def normalize(data, param, mean_std_dict, add_noise=False, noise_scale=1.0, seed=None):
if mean_std_dict.get(param) is None:
return data
shape = data.shape
data = data.flatten()
mean, std, lo, hi = mean_std_dict.get(param)
data -= mean
data /= std
if add_noise:
if seed is not None:
np.random.seed(seed)
rnd = np.random.normal(loc=0, scale=noise_scale, size=data.size)
data += rnd
not_valid = np.isnan(data)
data[not_valid] = 0
data = np.reshape(data, shape)
return data
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment