-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_BESMo_wrapper_analysis.m
74 lines (58 loc) · 2.38 KB
/
run_BESMo_wrapper_analysis.m
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
function [tableOut] = run_BESMo_wrapper_analysis(nameconfigfile_batch, resultsDir, outputDir, forceRemake,forceRemakeBatch , goThroughSubsurfaceLayers,StartAnalysisHour)
% This file is executed by each worker individually
% Get input parameters from the input file:
%[configparams_batch] = read_inputfile(nameconfigfile_batch);
% Get input parameters from the input file:
load(nameconfigfile_batch);
% check if this is one of the old configurations
if exist('RunConfig')
Fnames = fieldnames(RunConfig);
for field=1:size(Fnames,1)
RunParam.(Fnames{field}) = RunConfig.(Fnames{field});
end
end
%RunParam = fkt_generateBatchConstants();
[RunParam] = fkt_generateBatch(RunParam);
%% ========================================
% CREATE FOLDER STRUCTURE AND INPUT FILES:
% set up a folder name for the batch:
batchDirName = RunParam.NameOfBatch;
batchDirPath = strcat(resultsDir,'/',batchDirName);
% % if input number was interpreted as string, convert:
% if ~isnumeric(i)
% i = str2num(i);
% end
for i = 1:length(RunParam.P_Number)
current_run{1,i} = strcat(RunParam.NameOfBatch,'_',int2str(i));
end
% runDir = strcat(batchDirPath,'/',current_run);
% LOGFILE: Where to save the fprintf out?
%fdev = 1; % 1 gives terminal output, (does not work with parfor!)
% else: file output 'current_runi_log.txt'
fdev = fopen(strcat(RunParam.NameOfBatch,'.log'),'w');
% set up a folder name for the analysis:
analysisDirName = strcat(RunParam.NameOfBatch,'_analysis');
analysisDirPath = strcat(outputDir,'/',analysisDirName);
%% ========================================
% DO BATCH ANALYSIS:
%cd(batchDirPath)
if forceRemakeBatch % prevent making new plots
fprintf(fdev, 'Starting Batch Analysis...\n');
disp(strcat('Analysing run: ',RunParam.NameOfBatch));
[tableOut] = fkt_analyzeRuns(batchDirPath, current_run, analysisDirPath, RunParam, RunParam,fdev,forceRemake, goThroughSubsurfaceLayers,StartAnalysisHour);
else
disp(strcat('Skipping analysing runs, no forceRemake: ',RunParam.NameOfBatch));
end
%% Zip result folders:
%cd(baseDir)
%fprintf(fdev, 'Zipping resulting folders...\n');
% zip batch run:
%zip(strcat(batchDirName,'.zip'),batchDirName);
% zip analysis:
%zip(strcat(analysisDirName,'.zip'),analysisDirName);
% Clear variables
clear RunParam
fclose(fdev);
% RESULT: is a .mat file in the run folder. I load these in an other
% script to access the variables saved in there.
end