@@ -449,7 +449,6 @@ function write_ciam(model; outputdir::String=joinpath(@__DIR__, "..", "output"),
449449 for i in 1 : length (vargroup1)
450450 temp = getdataframe (model, :slrcost , vargroup1[i])
451451 missing_names = [j for j in common_order if ! (String (j) in names (temp))]
452- println (" HERE02-5-1 " ,i, " - " , vargroup1[i])
453452
454453 if length (missing_names) >= 1
455454 for name in missing_names
@@ -460,18 +459,10 @@ function write_ciam(model; outputdir::String=joinpath(@__DIR__, "..", "output"),
460459 # have the segments names (`segments`) but missing some/all
461460 # of the country names (`ciam_country`)
462461 if :ciam_country in missing_names && ! (:segments in missing_names)
463- println (" HERE02-5-2-1" )
464- println (" temp" )
465- display (temp)
466- println (" segRgnDict" )
467- display (segRgnDict)
468462 # temp = temp |> @map(merge(_, {ciam_country = segRgnDict[_.segments]})) |> DataFrame
469463 # ^-- broken in v1.6 -> v1.10 Julia update
470464 # v-- works in v1.10 for `missing` cases...?
471465 temp. ciam_country .= coalesce .(temp. ciam_country, [segRgnDict[temp. segments[i]] for i in axes (temp, 1 )])
472- println (" HERE02-5-2-2" )
473- println (" temp" )
474- display (temp)
475466 end
476467
477468 temp[! , :variable ] = fill (String (vargroup1[i]), nrow (temp))
@@ -490,14 +481,11 @@ function write_ciam(model; outputdir::String=joinpath(@__DIR__, "..", "output"),
490481 segID = model[:slrcost , :segID ]
491482 colnames = Symbol .(segID_to_seg (Int64 .(segID), segmap))
492483
493- println (colnames)
494-
484+
495485 for j in 1 : length (vargroup2)
496486
497487 ndim1 = size (model[:slrcost , vargroup2[j]])[3 ]
498488
499- println (" HERE02-6-1 " ,vargroup2[j])
500-
501489 for k in 1 : ndim1
502490
503491 temp = DataFrame (model[:slrcost , vargroup2[j]][:, :, k], :auto )
@@ -521,12 +509,12 @@ function write_ciam(model; outputdir::String=joinpath(@__DIR__, "..", "output"),
521509 temp[! , :segments ] = [String (i) for i in temp[! , :segments ]]
522510 temp[! , :variable ] = fill (String (vargroup2[j]), nrow (temp))
523511
524- temp = temp |> @map (merge (_, {ciam_country = segRgnDict[_. segments]})) |> DataFrame
512+ # temp = temp |> @map(merge(_, {ciam_country = segRgnDict[_.segments]})) |> DataFrame
525513 # ^-- broken in v1.6 -> v1.10 Julia update
526514 # v-- works in v1.10 need to modify for addition as opposed to missing...?
527- # temp. ciam_country .= coalesce.(temp.ciam_country, [segRgnDict[temp.segments[i]] for i in axes(temp, 1)])
528- # CHECK THAT THIS WASN'T SUPPOSED TO BE SOMETHING ELSE AND I ACCIDENTALLY REMOVED THE ORIGINAL CONTEXT
529-
515+ temp[ ! , : ciam_country] .= missing
516+ temp . ciam_country . = coalesce .(temp . ciam_country, [segRgnDict[temp . segments[i]] for i in axes (temp, 1 )])
517+
530518 temp = temp[! , [:time , :ciam_country , :segments , :level , :variable , :value ]]
531519
532520 if j == 1 && k == 1
@@ -537,7 +525,6 @@ function write_ciam(model; outputdir::String=joinpath(@__DIR__, "..", "output"),
537525 end
538526 end
539527
540- println (" HERE02-7" )
541528 # Sum to either region-level, global-level, or leave as seg-level
542529 outdf = [df; df2]
543530 outfile = tag ? " $(runname) _$(sumsegs) _$(rcp_str) _$(tag) .csv" : " $(runname) _$(sumsegs) _$(rcp_str) .csv"
@@ -576,7 +563,9 @@ function write_optimal_costs(model; outputdir::String=joinpath(@__DIR__, "..", "
576563
577564 # 1. Create aggregate adaptation decision DF
578565 temp1 = getdataframe (model, :slrcost => :OptimalCost )
579- temp1 = temp1 |> @map (merge (_, {ciam_country = segRgnDict[_. segments]})) |> DataFrame
566+ # temp1 = temp1 |> @map(merge(_, {ciam_country = segRgnDict[_.segments]})) |> DataFrame
567+ temp1[! ,:ciam_country ] .= missing
568+ temp1. ciam_country .= coalesce .(temp1. ciam_country, [segRgnDict[temp1. segments[i]] for i in axes (temp1,1 )])
580569
581570 temp2 = getdataframe (model, :slrcost => :OptimalLevel )
582571 temp3 = getdataframe (model, :slrcost => :OptimalOption )
@@ -589,8 +578,10 @@ function write_optimal_costs(model; outputdir::String=joinpath(@__DIR__, "..", "
589578
590579 # Replace OptimalOption numeric value with string
591580 lookup = Dict {Any,Any} (- 2.0 => " RetreatCost" , - 1.0 => " ProtectCost" , - 3.0 => " NoAdaptCost" )
592- out = out |> @map (merge (_, {variable = lookup[_. OptimalOption]})) |> DataFrame
593-
581+ # out = out |> @map(merge(_, {variable = lookup[_.OptimalOption]})) |> DataFrame
582+ out[! ,:variable ] .= missing
583+ out. variable .= coalesce .(out. variable, [lookup[out. OptimalOption[i]] for i in axes (out,1 )])
584+
594585 rename! (out, Dict (:OptimalLevel => :level ))
595586 out = out[! , [:time , :ciam_country , :segments , :variable , :level , :OptimalCost ]]
596587
@@ -605,8 +596,10 @@ function write_optimal_costs(model; outputdir::String=joinpath(@__DIR__, "..", "
605596 for i in 1 : length (vars)
606597
607598 temp = getdataframe (model, :slrcost => vars[i])
608- temp = temp |> @map (merge (_, {ciam_country = segRgnDict[_. segments]})) |> DataFrame
609-
599+ # temp = temp |> @map(merge(_, {ciam_country = segRgnDict[_.segments]})) |> DataFrame
600+ temp[! ,:ciam_country ] .= missing
601+ temp. ciam_country .= coalesce .(temp. ciam_country, [segRgnDict[temp. segments[i]] for i in axes (temp,1 )])
602+
610603 temp[! , :variable ] = fill (String (vars[i]), nrow (temp))
611604
612605 temp2 = getdataframe (model, :slrcost => :OptimalLevel )
@@ -618,8 +611,10 @@ function write_optimal_costs(model; outputdir::String=joinpath(@__DIR__, "..", "
618611
619612 # Replace OptimalOption numeric value with string
620613 lookup = Dict {Any,Any} (- 2.0 => " RetreatCost" , - 1.0 => " ProtectCost" , - 3.0 => " NoAdaptCost" )
621- out = out |> @map (merge (_, {AdaptCategory = lookup[_. OptimalOption]})) |> DataFrame
622-
614+ # out = out |> @map(merge(_, {AdaptCategory = lookup[_.OptimalOption]})) |> DataFrame
615+ out[! ,:AdaptCategory ] .= missing
616+ out. AdaptCategory .= coalesce .(out. AdaptCategory, [lookup[out. OptimalOption[i]] for i in axes (out,1 )])
617+
623618 rename! (out, Dict (:OptimalLevel => :level ))
624619 rename! (out, vars[i] => :value )
625620 out = out[! , [:time , :ciam_country , :segments , :AdaptCategory , :variable , :level , :value ]]
@@ -740,6 +735,7 @@ function getTimeSeries(model, ensnum; segIDs=false, rgns=false, sumsegs="global"
740735 # ^-- breaking in v1.6->v1.10 switch. Try:
741736 temp[! ,:ciam_country ] .= missing
742737 temp. ciam_country .= coalesce .(temp. ciam_country, [segRgnDict[temp. segments[i]][1 ] for i in axes (temp,1 )])
738+ # temp[!,:ciam_country] .= coalesce.(temp.ciam_country, [segRgnDict[temp.segments[i]][1] for i in axes(temp, 1)])
743739 temp[! ,:segID ] .= missing
744740 temp. segID .= coalesce .(temp. segID, [segRgnDict[temp. segments[i]][2 ] for i in axes (temp,1 )])
745741
0 commit comments