-
Notifications
You must be signed in to change notification settings - Fork 0
/
05_01_create_chip_gifs.R
49 lines (38 loc) · 1.61 KB
/
05_01_create_chip_gifs.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
# Make sure that
# 1. destination folder (temp_gif_image_holder) is empty and
# not containing scenes from other volcanoes
# 2. you are in the directory volcano-specific data folder
# (data/volcano/)
good_df <- read.csv('good_df.csv')
chip_files <- sub(x = sub(x = sub(x = good_df$nighttime_volcano_files,
pattern = 'processed/', replacement = 'chips/'),
pattern = '.tif', replacement = '.RData'),
pattern = 'ImageData10', replacement = 'ImageData12')
image_cube_series <- array(dim = c(length(chip_files), 5, 96, 96))
count <- 1
for (chip in chip_files) {
base_file <- chip
for (band in 10:14) {
band_chip <- sub(x = base_file,
pattern = 'ImageData12',
replacement = paste0("ImageData",
as.character(band)))
data <- as.matrix(read.table(band_chip, as.is = TRUE))
image_cube_series[count, band-9, ,] <- data
}
count <- count + 1
}
for (i in 1:length(chip_files)) {
png(paste0("../../temp_gif_image_holder/",
sprintf("%04d", i), ".png"))
date = substr(strsplit(chip_files[i], '_')[[1]][3], start = 4, stop = 11)
image(image_cube_series[i, 3, ,], col = grey(1:10000/10000),
xaxt = 'n', yaxt = 'n',
zlim = c(min(image_cube_series, na.rm = TRUE),
max(image_cube_series, na.rm = TRUE)),
main = paste0('MM-DD-YYYY\n',
substr(date, start = 1, stop = 2), "-",
substr(date, start = 3, stop = 4), "-",
substr(date, start = 5, stop = 8)))
dev.off()
}