Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Multi Scale Causality
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FROGE Ewen
Multi Scale Causality
Commits
ccd27a30
Commit
ccd27a30
authored
9 months ago
by
FROGE Ewen
Browse files
Options
Downloads
Patches
Plain Diff
Replace Main.py
parent
86362879
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
TE_filters/Main.py
+21
-13
21 additions, 13 deletions
TE_filters/Main.py
with
21 additions
and
13 deletions
TE_filters/Main.py
+
21
−
13
View file @
ccd27a30
...
...
@@ -43,11 +43,17 @@ Modane = np.fromfile(fid, dtype='>f')[:N]
fbm_signal
,
_
=
synthmrw
(
dim
=
1
,
N
=
N
,
H
=
1
/
3
,
lambda2
=
0
)
# Placeholder for FBM
fbm_signal
=
fbm_signal
[:,
0
]
fgn_signal
=
np
.
diff
(
fbm_signal
,
axis
=
0
)
scales
=
[
10
,
20
]
# Define your scales
positions
=
[
'
causal
'
,
'
symmetric
'
,
'
anticausal
'
]
signals
=
[
'
fgn_signal
'
,
'
fbm_signal
'
,
'
Modane
'
]
max_lag_factor
=
2
# We will vary lag up to 10 times the largest scale
# fbm_signal_flip=np.flip(fbm_signal)
# fgn_signal_flip=np.flip(fgn_signal)
# Modane_flip=np.flip(Modane)
# flipped_signals=['fgn_signal_flip','fbm_signal_flip','Modane_flip']
# Prepare results dictionary
results
=
{}
...
...
@@ -144,7 +150,7 @@ def box_BP_kernel(scale_high,position,scale_low=None ):
kernel_low
=
np
.
zeros
(
size
)
kernel_low
[
np
.
where
(
np
.
abs
(
x
)
<=
scale_low
)]
=
1
kernel_high
=
np
.
zeros
(
size
)
kernel_high
[
np
.
where
(
np
.
abs
(
x
)
<=
scale_
low
)]
=
1
kernel_high
[
np
.
where
(
np
.
abs
(
x
)
<=
scale_
high
)]
=
1
if
position
==
'
causal
'
:
kernel_low
[:
size
//
2
]
=
0
kernel_high
[:
size
//
2
]
=
0
...
...
@@ -220,12 +226,14 @@ def box_kernel(scale, position):
kernel_functions
=
{
'
increment
'
:
increment_kernel
,
'
gaussian
'
:
gaussian_kernel
,
'
gabor
'
:
gabor_kernel
,
'
box
'
:
box_kernel
,
'
box_HP
'
:
box_HP_kernel
,
'
gaussian_HP
'
:
gaussian_HP_kernel
,
#'increment': increment_kernel,
#'gaussian': gaussian_kernel,
#'gabor': gabor_kernel,
#'box': box_kernel,
#'box_HP': box_HP_kernel,
#'gaussian_HP': gaussian_HP_kernel,
'
box_BP
'
:
box_BP_kernel
,
'
gaussian_BP
'
:
gaussian_BP_kernel
,
}
...
...
@@ -281,7 +289,7 @@ for kernel_type in kernel_types:
fig
,
axes
=
plt
.
subplots
(
3
,
3
,
figsize
=
(
20
,
22
))
fig
.
suptitle
(
f
'
Transfer Entropy Analysis -
{
kernel_type
.
capitalize
()
}
'
,
fontsize
=
30
)
for
i
,
sgn
in
enumerate
(
[
'
fbm_signal
'
,
'
fgn_signal
'
,
'
Modane
'
]
):
for
i
,
sgn
in
enumerate
(
signals
):
for
j
,
position
in
enumerate
(
positions
):
ax
=
axes
[
i
,
j
]
ax
.
set_title
(
f
'
{
sgn
.
capitalize
()
}
-
{
position
.
capitalize
()
}
'
,
fontsize
=
26
)
...
...
@@ -307,9 +315,9 @@ for kernel_type in kernel_types:
# %%
# Impulse Response Plotting
#kernel_types=['
increment','
box','gaussian','gabor']
kernel_types
=
[
'
box_HP
'
,
'
gaussian_HP
'
]
#
kernel_types=['box_BP','gaussian_BP']
#kernel_types=['box','gaussian','gabor']
#
kernel_types=['
increment','
box_HP','gaussian_HP']
kernel_types
=
[
'
box_BP
'
,
'
gaussian_BP
'
]
impulse
=
np
.
zeros
(
100
)
...
...
@@ -332,7 +340,7 @@ for i, kernel_type in enumerate(kernel_types):
ax
.
legend
(
fontsize
=
24
)
plt
.
tight_layout
(
rect
=
[
0
,
0
,
1
,
0.95
])
plt
.
savefig
(
'
/users2/local/e22froge/codes/TE_Filter/Impulse_responses_
H
P.pdf
'
,
bbox_inches
=
'
tight
'
)
plt
.
savefig
(
'
/users2/local/e22froge/codes/TE_Filter/Impulse_responses_
B
P.pdf
'
,
bbox_inches
=
'
tight
'
)
plt
.
show
()
#%%
...
...
@@ -353,7 +361,7 @@ for i, kernel_type in enumerate(kernel_types):
ax
.
legend
(
fontsize
=
24
)
plt
.
tight_layout
(
rect
=
[
0
,
0
,
1
,
0.95
])
plt
.
savefig
(
'
/users2/local/e22froge/codes/TE_Filter/Kernels_
H
P.pdf
'
,
bbox_inches
=
'
tight
'
)
plt
.
savefig
(
'
/users2/local/e22froge/codes/TE_Filter/Kernels_
B
P.pdf
'
,
bbox_inches
=
'
tight
'
)
plt
.
show
()
# %%
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment