@@ -38,14 +38,54 @@ dfs_table = DataFrame[] # not sorted
3838for iwk in 1 : num_work
3939 dir = joinpath (output_dir, " wk_$iwk " )
4040 print (" $iwk /$num_work " )
41+
42+ # read results table
4143 f = joinpath (dir, " result_table.csv" )
4244 if isfile (f)
4345 println (" reading $f " )
4446 df = CSV. read (f, DataFrame; normalizenames= true , missingstring= [" " , " NA" , " NaN" ])
45- push! (dfs_table, df )
47+ rename! (df, :flux_loss => :flux_loss_max )
4648 else
4749 println (" skipped; could not find $f " )
50+ continue
51+ end
52+
53+ # add extra columns to dataframe
54+ df[! , " flux_loss_med" ] = zeros (Float64, nrow (df))
55+ df[! , " flux_toa" ] = zeros (Float64, nrow (df))
56+ df[! , " flux_boa" ] = zeros (Float64, nrow (df))
57+
58+ # read log file
59+ f = joinpath (dir, " wk_$iwk .log" )
60+ lines = readlines (f)
61+ ipt = 0
62+ for (il,line) in enumerate (lines)
63+ if startswith (line," [ INFO ] Grid point" )
64+ ipt += 1
65+ end
66+ if startswith (line," [ INFO ] total flux at TOA =" )
67+ if contains (lines[il- 2 ]," Solver timed-out before" )
68+ df[ipt,:flux_loss_med ] = parse (Float64, split (lines[il- 4 ][19 : end ],r" \s +" )[2 ])
69+ df[ipt,:succ ] = convert (Float64,- 2 )
70+
71+ elseif contains (lines[il- 1 ]," (singular jacobian) " )
72+ df[ipt,:flux_loss_med ] = 1e9 # not recorded
73+ df[ipt,:succ ] = convert (Float64,- 3 )
74+
75+ elseif contains (lines[il- 1 ]," (maximum iterations) " )
76+ df[ipt,:flux_loss_med ] = parse (Float64, split (lines[il- 2 ][19 : end ],r" \s +" )[2 ])
77+ df[ipt,:succ ] = convert (Float64,- 4 )
78+
79+ else
80+ df[ipt,:flux_loss_med ] = parse (Float64, split (lines[il- 2 ][19 : end ],r" \s +" )[2 ])
81+ end
82+ df[ipt,:flux_toa ] = parse (Float64, split (lines[il][34 : end ],r" \s +" )[2 ])
83+ df[ipt,:flux_boa ] = parse (Float64, split (lines[il+ 1 ][34 : end ],r" \s +" )[2 ])
84+ # println("Wk$iwk updated row $ipt ($(df[ipt,:succ])) with $(df[ipt,:flux_loss_med]), $(df[ipt,:flux_toa]), $(df[ipt,:flux_boa]) W/m^2")
85+ end
4886 end
87+
88+ push! (dfs_table, df)
4989end
5090combined = reduce ((a,b)-> vcat (a,b; cols= :union ), dfs_table)
5191outpath = joinpath (output_dir, " consolidated_table.csv" )
0 commit comments