-
Notifications
You must be signed in to change notification settings - Fork 9
/
domain_plot.R
141 lines (113 loc) · 4.8 KB
/
domain_plot.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
source('/g/data/w85/tsunami/CODE/gadi/ptha/propagation/SWALS/plot.R')
library(cptcity)
library(rptha)
#
# Elevation0 only
#
out_dir = 'multidomain_image'
dir.create(out_dir, showWarnings=FALSE)
# Zero contour
zc = readOGR('../sources/figures/zero_contour/zero_contour.shp', layer='zero_contour')
# Add in domain boundaries
md_bbox = get_domain_interior_bbox_in_multidomain('.')
add_bboxes<-function(LWD=1){
plot(zc, add=TRUE)
for(i in 1:length(md_bbox$merged_domain_interior_bbox)){
dx = md_bbox$merged_domain_dx[[i]][1]
# Avoid boxes for the 1 arcmin domains
if(dx > 0.9*1/60) next
LTY=c('dashed', 'solid')[(dx < 0.9*1/7*1/60) + 1]
polygon(md_bbox$merged_domain_interior_bbox[[i]], border='red', lty=LTY, lwd=LWD)
}
}
# Colours for elevation
my_col = cpt("gmt_GMT_globe", n=1000)
ZLIM = c(-11e+03, 6500) # This ensures the shoreline is close to a rapid transition in the colours
# Pacific focus
out_file = paste0(out_dir, '/elevation0_Pacific.png')
png(out_file, width=10, height=8, units='in', res=300)
multidomain_image('.', variable='elevation0', time_index=NULL,
xlim=c(110, 300), ylim=c(-80, 65), zlim=ZLIM,
cols=my_col, clip_to_zlim=TRUE, use_fields=TRUE,
NA_if_stage_not_above_elev=FALSE, buffer_is_priority_domain=FALSE)
add_bboxes()
dev.off()
# Global
out_file = paste0(out_dir, '/elevation0_full_model.png')
png(out_file, width=17.1, height=8, units='in', res=212.504)
multidomain_image('.', variable='elevation0', time_index=NULL,
xlim=c(-40, 320), ylim=c(-80, 65), zlim=ZLIM,
cols=my_col, clip_to_zlim=TRUE, use_fields=TRUE,
NA_if_stage_not_above_elev=FALSE, buffer_is_priority_domain=FALSE)
add_bboxes()
dev.off()
# As above, Greater Sydney Region
out_file = paste0(out_dir, '/elevation0_greater_Sydney.png')
png(out_file, width=8, height=8, units='in', res=300)
multidomain_image('.', variable='elevation0', time_index=NULL,
xlim=c(151.0, 151.532), ylim=c(-34.100, -33.406), zlim=ZLIM/30,
cols=my_col, clip_to_zlim=TRUE, use_fields=TRUE,
NA_if_stage_not_above_elev=FALSE, buffer_is_priority_domain=FALSE,
asp=1/cos(33.5/180*pi))
add_bboxes(LWD=2)
dev.off()
# As above, Australia
out_file = paste0(out_dir, '/elevation0_Australia.png')
png(out_file, width=12, height=8, units='in', res=300)
multidomain_image('.', variable='elevation0', time_index=NULL,
xlim=c(110.0, 160), ylim=c(-45, -10), zlim=ZLIM/2,
cols=my_col, clip_to_zlim=TRUE, use_fields=TRUE,
NA_if_stage_not_above_elev=FALSE, buffer_is_priority_domain=FALSE,
asp=1/cos(30/180*pi))
add_bboxes(LWD=2)
dev.off()
# NSW/VIC
out_file = paste0(out_dir, '/elevation0_NSWVIC.png')
png(out_file, width=12, height=8, units='in', res=300)
multidomain_image('.', variable='elevation0', time_index=NULL,
xlim=c(140.0, 155), ylim=c(-42, -30), zlim=ZLIM/2,
cols=my_col, clip_to_zlim=TRUE, use_fields=TRUE,
NA_if_stage_not_above_elev=FALSE, buffer_is_priority_domain=FALSE,
asp=1/cos(35/180*pi))
add_bboxes(LWD=2)
dev.off()
# WA
out_file = paste0(out_dir, '/elevation0_SWWA.png')
png(out_file, width=12, height=8, units='in', res=300)
multidomain_image('.', variable='elevation0', time_index=NULL,
xlim=c(110.0, 120), ylim=c(-37.5, -29), zlim=ZLIM/2,
cols=my_col, clip_to_zlim=TRUE, use_fields=TRUE,
NA_if_stage_not_above_elev=FALSE, buffer_is_priority_domain=FALSE,
asp=1/cos(32/180*pi))
add_bboxes(LWD=2)
dev.off()
add_parallel_partition<-function(){
# All colours, no grey
COLORS = colors()[grep('gr(a|e)y', colors(), invert = T)]
set.seed(1234)
my_col = sample(COLORS, size=max(md_bbox$domain_images))
# Get an order of polygons from 'coarsest' to 'less coarse' to define plotting order
poly_order = order(unlist(lapply(md_bbox$domain_dx, f<-function(x) x[1])), decreasing=TRUE)
for(i in poly_order) polygon(md_bbox$domain_interior_bbox[[i]], col=my_col[md_bbox$domain_images[i]])
plot(zc, add=TRUE)
}
out_file = paste0(out_dir, '/partition_full_model.png')
png(out_file, width=17.1, height=8, units='in', res=212.504)
plot(c(0, 1), c(0, 1), col=0, xlim=c(-40, 320), ylim=c(-80, 65), asp=1)
add_parallel_partition()
dev.off()
out_file = paste0(out_dir, '/partition_Australia.png')
png(out_file, width=12, height=8, units='in', res=300)
plot(c(0, 1), c(0, 1), col=0, xlim=c(110.0, 160), ylim=c(-45, -10), asp=1/cos(30/180*pi))
add_parallel_partition()
dev.off()
out_file = paste0(out_dir, '/partition_NSWVIC.png')
png(out_file, width=12, height=8, units='in', res=300)
plot(c(0, 1), c(0, 1), col=0, xlim=c(140.0, 155), ylim=c(-42, -30), asp=1/cos(35/180*pi))
add_parallel_partition()
dev.off()
out_file = paste0(out_dir, '/partition_SWWA.png')
png(out_file, width=12, height=8, units='in', res=300)
plot(c(0, 1), c(0, 1), col=0, xlim=c(110.0, 120), ylim=c(-37.5, -29), asp=1/cos(35/180*pi))
add_parallel_partition()
dev.off()