-
Notifications
You must be signed in to change notification settings - Fork 0
/
fig5_resourceEfficiencyConcatenate.R
69 lines (53 loc) · 2.14 KB
/
fig5_resourceEfficiencyConcatenate.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
rm(list=ls())
################################
# Load workspace and libraries #
################################
load('data/0_finalData.RData')
########################################
# Concatenate resource efficiency send #
########################################
resEff_regional <- as.data.frame(cbind(rep(NA,360)))
column_index = 1
for (i in c(999,98,96,94,92,9,8,7,6,5,4,3,2,1))
{
filepath <- paste0('data/resource_efficiency0',i,'_send.txt')
resEff <- read.csv(filepath,header=F,sep=' ')
resEff[2:ncol(resEff)] <- 1/resEff[2:ncol(resEff)]
resEffReg <- cbind(resEff[1],resEff[2:ncol(resEff)])
is.na(resEffReg) <- do.call(cbind,lapply(resEffReg, is.infinite))
resEff[resEff==0] <- NA
column_new <- paste0('slope',seq(1:360))
colnames(resEffReg) <- c('scanid',column_new)
resEffReg <- merge(resEffReg, QA_df, by='scanid')
for (j in 2:(length(column_new)+1)){
resEff_regional[j-1,column_index] <- mean(resEffReg[[j]],na.rm=T)
print(paste0(i,'_',j))
}
column_index = column_index+1
}
fileOutName <- paste0('data/resourceEfficiency_regional_send.csv')
write.table(resEff_regional,fileOutName,sep=',',row.names=F)
###########################################
# Concatenate resource efficiency receive #
###########################################
resEff_regional <- as.data.frame(cbind(rep(NA,360)))
column_index = 1
for (i in c(999,98,96,94,92,9,8,7,6,5,4,3,2,1))
{
filepath <- paste0('data/resource_efficiency0',i,'_receive.txt')
resEff <- read.csv(filepath,header=F,sep=' ')
resEff[2:ncol(resEff)] <- 1/resEff[2:ncol(resEff)]
resEffReg <- cbind(resEff[1],resEff[2:ncol(resEff)])
is.na(resEffReg) <- do.call(cbind,lapply(resEffReg, is.infinite))
resEff[resEff==0] <- NA
column_new <- paste0('slope',seq(1:360))
colnames(resEffReg) <- c('scanid',column_new)
resEffReg <- merge(resEffReg, QA_df, by='scanid')
for (j in 2:(length(column_new)+1)){
resEff_regional[j-1,column_index] <- mean(resEffReg[[j]],na.rm=T)
print(paste0(i,'_',j))
}
column_index = column_index+1
}
fileOutName <- paste0('data/resourceEfficiency_regional_receive.csv')
write.table(resEff_regional,fileOutName,sep=',',row.names=F)