-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathEvaluateProcessing.r
47 lines (36 loc) · 1.51 KB
/
EvaluateProcessing.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
##The program to process the data in Evaluate.Out of DSSAT output files.
EvaluateProcessing<-function(WD, OD, CropName, RoundOfGLUE, ModelRunNumber)
{
eval(parse(text=paste("File<-readLines('",OD,"/Evaluate_output.txt',n=-1)",sep = '')));
FileLength<-length(File);
#print(FileLength);
TitleLine = grep("@RUN",File)
FrameTitle<-File[TitleLine]
FrameData<-c();
##Read the titles of the predictions, which is located in the 3rd line of the evaluate output.
#FrameData<-c(); ##Creat an empty frame to store the selected data.
TreatmentNumber<-(FileLength-TitleLine);##Get the number of treatments.
#print(TreatmentNumber);
#SummaryFrame<-data.frame()
for (j in 1:TreatmentNumber)
{
n=TitleLine+j;
FrameData=rbind(FrameData,File[n]);##Combine the results in one matrix.
}
#The if statement had to change because it was only writing the evaluate header
# during the first model run -- this does not work in this parallelized version
#if(ModelRunNumber!=1)
if(file.exists(paste0(OD,'/EvaluateFrame_',RoundOfGLUE,'.txt')))
{
EvaluateFrame<-FrameData;
eval(parse(text = paste('write(EvaluateFrame, "',OD,'/EvaluateFrame_',
RoundOfGLUE,'.txt", append = T)',sep="")));
#Write the data as a frame file, where repair the treatment names as an entity (" ").
} else
{
EvaluateFrame<-rbind(FrameTitle,FrameData);
eval(parse(text = paste('write(EvaluateFrame, "',OD,'/EvaluateFrame_',
RoundOfGLUE,'.txt", append = F)',sep="")));
}
rm(File);
}