-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path032d_1D_simu_plts_Orig_SpNReg_6_fields.R
223 lines (148 loc) · 6.1 KB
/
032d_1D_simu_plts_Orig_SpNReg_6_fields.R
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#============
# 20 Feb.2024
#============
# Aim:
# Use the simu results from 032c to plot the corresponding plts for
# SIGMA, SIGMA_inv, with B_original and B_SpN+Reg,
# SIGMA_inv with thres
# Method:
# SG_SG_inv results from 032c
# SG_SG_inv_6_a01d05_TriWave_Orig_Thres
# SG_SG_inv_6_a01d05_Wend_Orig_Thres
# SG_SG_inv_6_a01d05_TriWave_SpNReg_Thres
# SG_SG_inv_6_a01d05_Wend_SpNReg_Thres
# Settings:
# p = 6
# ds = 0.05, D = [-1, 1]
# A = 0.1, dlt = 0.5
#==========
# Settings
#==========
#------------------------------------
# Location, displacements, distance
#------------------------------------
#ds <- 0.1 # for with SpN plts
ds <- 0.05 # for w/o SpN plts, esp. SIGMA; also try for plts with SpN
# ds = 0.05 has better visualization effect for both with, w/o SpN
s <- seq(-1 + ds/2, 1 - ds/2, by = ds)
str(s) # num [1:20]; num [1:40]
# displacements between pairs of points
# a vector quantity has magnitude and direction
H <- outer(s, s, FUN = "-")
H <- t(H)
str(H) # num [1:20, 1:20]; num [1:40, 1:40]
# distance
# a scalar quantity
D_vec <- as.double(c(abs(H)))
str(D_vec) # num [1:400]; num [1:1600]
#----------------
# data structure
#----------------
p = 6
hierarchy_data6 <- data.frame(
node_id = c(1, 2, 3, 3, 4, 4, 5, 6, 6, 6),
par_id = c(NA, 1, c(2, 1), c(2, 3), 4, c(1, 3, 5))
)
#========
# Plots
#========
# B_Origin: Tri-Wave
plt_Sig(SG_SG_inv_6_a01d05_TriWave_Orig_Thres$SIGMA, p = 6)
#plt_Sig(SG_SG_inv_6_a01d05_TriWave_Orig_Thres$SIGMA_inv, p = 6)
plt_Sig(log(abs(SG_SG_inv_6_a01d05_TriWave_Orig_Thres$SIGMA_inv)), p = 6)
# B_Origin: Wendland
plt_Sig(SG_SG_inv_6_a01d05_Wend_Orig_Thres$SIGMA, p = 6)
#plt_Sig(log(SG_SG_inv_6_a01d05_Wend_Orig_Thres$SIGMA_inv), p = 6)
plt_Sig(log(abs(SG_SG_inv_6_a01d05_Wend_Orig_Thres$SIGMA_inv)), p = 6)
# B_SpN+Reg: Tri-Wave
plt_Sig(SG_SG_inv_6_a01d05_TriWave_SpNReg_Thres$SIGMA, p = 6)
#plt_Sig(log(SG_SG_inv_6_a01d05_TriWave_SpNReg_Thres$SIGMA_inv), p = 6)
plt_Sig(log(abs(SG_SG_inv_6_a01d05_TriWave_SpNReg_Thres$SIGMA_inv)), p = 6)
# B_SpN+Reg: Wendland
plt_Sig(SG_SG_inv_6_a01d05_Wend_SpNReg_Thres$SIGMA, p = 6)
#plt_Sig(log(SG_SG_inv_6_a01d05_Wend_SpNReg_Thres$SIGMA_inv), p = 6)
plt_Sig(log(abs(SG_SG_inv_6_a01d05_Wend_SpNReg_Thres$SIGMA_inv)), p = 6)
#--------------------------
# plot functions with Main
#--------------------------
Plot_SG_TW_Main <- function(Sigma, p) {
# to reverse order of cols in Sigma
rev_Sigma <- Sigma[, ncol(Sigma):1]
# Plot the matrix with reversed y-axis scale
par(mar = c(3, 3, 5.5, 1), cex.main = 2)
image(1:nrow(Sigma), 1:ncol(Sigma), rev_Sigma,
#main = expression(atop(Sigma, atop("Tri-wave (Orig); p = 6")))
main = expression(atop(Sigma, atop("Tri-wave (SpN + Reg)",
atop("p = 6; Reg = 1e-9"))))
)
}
## Origin Tri-Wave SG
Plot_SG_TW_Main(SG_SG_inv_6_a01d05_TriWave_Orig_Thres$SIGMA, p = 6)
## SpN+Reg Tri-Wave SG
Plot_SG_TW_Main(SG_SG_inv_6_a01d05_TriWave_SpNReg_Thres$SIGMA, p = 6)
Plot_SG_Inv_TW_Main <- function(Sigma, p) {
# to reverse order of cols in Sigma
rev_Sigma <- Sigma[, ncol(Sigma):1]
# Plot the matrix with reversed y-axis scale
par(mar = c(3, 3, 5.5, 1), cex.main = 2)
image(1:nrow(Sigma), 1:ncol(Sigma), rev_Sigma,
#main = expression(atop(Sigma^{-1}~ (log), atop("Tri-wave(Orig); Thres = 1e-3")))
main = expression(atop(Sigma^{-1}~ (log), atop("Tri-wave (SpN + Reg)",
atop("Reg = 1e-9; Thres = 1e-3"))))
)
}
# Origin Tri-Wav SG_inv
Plot_SG_Inv_TW_Main(log(abs(SG_SG_inv_6_a01d05_TriWave_Orig_Thres$SIGMA_inv)), p = 6)
## SpN+Reg Tri-Wave SG_inv
Plot_SG_Inv_TW_Main(log(abs(SG_SG_inv_6_a01d05_TriWave_SpNReg_Thres$SIGMA_inv)), p = 6)
Plot_SG_Main_Wend <- function(Sigma, p) {
# to reverse order of cols in Sigma
rev_Sigma <- Sigma[, ncol(Sigma):1]
# Plot the matrix with reversed y-axis scale
par(mar = c(3, 3, 5.5, 1), cex.main = 2)
image(1:nrow(Sigma), 1:ncol(Sigma), rev_Sigma,
#main = expression(atop(Sigma, atop("Wendland (Orig); p = 6")))
main = expression(atop(Sigma, atop("Wendland (SpN + Reg)",
atop("p = 6; Reg = 1e-9"))))
)
}
# Origin Wend SG
Plot_SG_Main_Wend(SG_SG_inv_6_a01d05_Wend_Orig_Thres$SIGMA, p = 6)
## SpN+Reg Wend SG_inv
Plot_SG_Main_Wend(SG_SG_inv_6_a01d05_Wend_SpNReg_Thres$SIGMA, p = 6)
Plot_SG_Inv_Main_Wend <- function(Sigma, p) {
# to reverse order of cols in Sigma
rev_Sigma <- Sigma[, ncol(Sigma):1]
# Plot the matrix with reversed y-axis scale
par(mar = c(3, 3, 5.5, 1), cex.main = 2)
image(1:nrow(Sigma), 1:ncol(Sigma), rev_Sigma,
#main = expression(atop(Sigma^{-1}~ (log), atop("Wendland (Orig); Thres = 1e-3")))
main = expression(atop(Sigma^{-1}~ (log), atop("Wendland (SpN + Reg)",
atop("Reg = 1e-9; Thres = 1e-3"))))
)
}
# # Origin Wend SG_inv
Plot_SG_Inv_Main_Wend(log(abs(SG_SG_inv_6_a01d05_Wend_Orig_Thres$SIGMA_inv)), p = 6)
## SpN+Reg Wend SG_inv
Plot_SG_Inv_Main_Wend(log(abs(SG_SG_inv_6_a01d05_Wend_SpNReg_Thres$SIGMA_inv)), p = 6)
#-----------------------
# Side by side with main
#-----------------------
# Original
jpeg(paste0(image.path, "SG_SGinv_TW_WL_Orig_sbs.jpeg"),
width = 10, height = 9, units = "in", res = 300)
par(mfrow = c(2, 2))
Plot_SG_TW_Main(SG_SG_inv_6_a01d05_TriWave_Orig_Thres$SIGMA, p = 6)
Plot_SG_Inv_TW_Main(log(abs(SG_SG_inv_6_a01d05_TriWave_Orig_Thres$SIGMA_inv)), p = 6)
Plot_SG_Main_Wend(SG_SG_inv_6_a01d05_Wend_Orig_Thres$SIGMA, p = 6)
Plot_SG_Inv_Main_Wend(log(abs(SG_SG_inv_6_a01d05_Wend_Orig_Thres$SIGMA_inv)), p = 6)
dev.off()
## SpN + Reg
jpeg(paste0(image.path, "SG_SGinv_TW_WL_SpNReg_sbs.jpeg"),
width = 10, height = 9, units = "in", res = 300)
par(mfrow = c(2, 2))
Plot_SG_TW_Main(SG_SG_inv_6_a01d05_TriWave_SpNReg_Thres$SIGMA, p = 6)
Plot_SG_Inv_TW_Main(log(abs(SG_SG_inv_6_a01d05_TriWave_SpNReg_Thres$SIGMA_inv)), p = 6)
Plot_SG_Main_Wend(SG_SG_inv_6_a01d05_Wend_SpNReg_Thres$SIGMA, p = 6)
Plot_SG_Inv_Main_Wend(log(abs(SG_SG_inv_6_a01d05_Wend_SpNReg_Thres$SIGMA_inv)), p = 6)
dev.off()