-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevent72_functions.py
More file actions
48 lines (40 loc) · 1.36 KB
/
event72_functions.py
File metadata and controls
48 lines (40 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
"""
Created on Fry May 20 13:37:06 2022
@author: ronjaebner
definitions of functions for model of the 7.2 collaboration
"""
import numpy as np
from numpy import pi
def find_ampl_base_neu(data, idx0, T, dt, t_vec):
# Amplitude calculated by (max-min)/2 within one period (moving window)
# Baseline calculated by (max+min)/2 within one period (moving window)
prec = 10000
Period = T
TimeStep = dt
FrameStep = Period/TimeStep*(2/11)
FrameWidth = Period/TimeStep
i_end = len(t_vec)- FrameWidth
i = idx0 + 0.5*FrameWidth
a_t=np.zeros_like(t_vec)
b_t=np.zeros_like(t_vec)
t =np.zeros_like(t_vec)
while i<i_end:
int_0 = int(i- 0.5*FrameWidth)
int_1 = int(i+ 0.5*FrameWidth)
#
a_t[int(i)] = prec*(max(data[int_0:int_1]) - min(data[int_0:int_1]))/2
b_t[int(i)] = prec*(max(data[int_0:int_1]) + min(data[int_0:int_1]))/2
t[int(i)] = i
#
i+=FrameStep
##
A_t = a_t[t != 0]/prec
B_t = b_t[t != 0]/prec
T = t[t != 0]*dt/1000
return A_t, B_t , T
def safe_matrices(var,name_dir, scn_name, name_var):
name_file= (name_dir + '72event_' + scn_name
+ "_"+ name_var)
np.savetxt(name_file, var,delimiter=",")
return