forked from ddzumajo/python-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCtmatrix.py
More file actions
59 lines (51 loc) · 2.48 KB
/
Copy pathCtmatrix.py
File metadata and controls
59 lines (51 loc) · 2.48 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
49
50
51
52
53
54
55
56
57
58
59
######################################################
# This scripts computes the matrix of covariances C(t)
######################################################
#Author: DiegoDZ
#Date: Feb 2017
#Run: >> python Ct-matrix.py
#################################################################################################
#################################################################################################
##############################
#Structure of C(t)
##############################
# | (t=1) corr_rhorho corr_rhoe corr_rhog corr_erho corr_ee corr_eg corr_grho corr_ge corr_gg|
# | . |
#C(t)=| . |
# | . |
# | (t=n) corr_rhorho corr_rhoe corr_rhog corr_erho corr_ee corr_eg corr_grho corr_ge corr_gg|
##############################
##############################
import numpy as np
# Load files
corr_rhorho = np.loadtxt('corr_rhorho')
corr_rhoe = np.loadtxt('corr_rhoe')
corr_rhog = np.loadtxt('corr_rhog')
#corr_rhoE = np.loadtxt('corr_rhoE')
corr_erho = np.loadtxt('corr_erho')
corr_ee = np.loadtxt('corr_ee')
corr_eg = np.loadtxt('corr_eg')
#corr_epsilonE = np.loadtxt('corr_epsilonE')
corr_grho = np.loadtxt('corr_grho')
corr_ge = np.loadtxt('corr_ge')
corr_gg = np.loadtxt('corr_gg')
#corr_gE = np.loadtxt('corr_gE')
#corr_Erho = np.loadtxt('corr_Erho')
#corr_Eepsilon = np.loadtxt('corr_Eepsilon')
#corr_Eg = np.loadtxt('corr_Eg')
#corr_EE = np.loadtxt('corr_EE')
# Define variables and arrays
number_correlations_files_rhoe = 4
number_correlations_files_rhoeg = 9
number_nodes = np.sqrt(len(corr_rhorho[0]))
number_snapshots = len(corr_rhorho)
Ct_rhoe = np.zeros((number_snapshots, number_correlations_files_rhoe * number_nodes ** 2))
Ct_rhoeg = np.zeros((number_snapshots, number_correlations_files_rhoeg * number_nodes ** 2))
# Concatenate the rows of the correlations files in order to create the matrix of correlations C(t)
for i in range(number_snapshots):
Ct_rhoe[i,:] = np.hstack((corr_rhorho[i,:], corr_rhoe[i,:], corr_erho[i,:], corr_ee[i,:]))
Ct_rhoeg[i,:] = np.hstack((corr_rhorho[i,:], corr_rhoe[i,:], corr_rhog[i,:], corr_erho[i,:], corr_ee[i,:], corr_eg[i,:], corr_grho[i,:], corr_ge[i,:], corr_gg[i,:]))
# Save C(t) matrix
np.savetxt('Ctmatrix_rhoe', Ct_rhoe)
np.savetxt('Ctmatrix_rhoeg', Ct_rhoeg)
#EOF