comparisons = [...
["swop_20230210_35487_09_SD_AM_AC"; "swop_20230210_35487_09_PF_AM_AC"], ...
["swop_20230212_37331_09_SD_AM_xC"; "swop_20230212_37331_09_PF_AM_xC"], ...
["swop_20230304_27012_09_SD_AM_xC"; "swop_20230304_27012_09_NB_AM_xC"], ...
["swop_20230314_24547_09_SD_AM_AC"; "swop_20230314_24547_09_PF_AM_AC"], ...
["swop_20230319_30210_09_SD_AM_xB"; "swop_20230319_30210_09_PF_AM_xB"], ...
...
["swop_20230210_35487_09_SD_AM_AC"; "swop_20230210_35487_09_SD_UM_AC"], ...
["swop_20230212_37331_09_SD_AM_xC"; "swop_20230212_37331_09_SD_UM_xC"], ...
["swop_20230304_27012_09_SD_AM_xC"; "swop_20230304_27012_09_SD_UM_xC"], ...
["swop_20230304_36829_09_SD_AM_xB"; "swop_20230304_36829_09_SD_UM_xB"], ...
...
["swop_20230210_35487_09_SD_AM_AC"; "swop_20230210_35487_09_SD_AM_xA"], ...
["swop_20230314_24547_09_SD_AM_AC"; "swop_20230314_24547_09_SD_AM_xA"], ...
];

direc_root = getenv('GEMINI_SIM_ROOT');

for comp = comparisons
for s = 'AB'
sim.(s) = char(comp(s-64));
direc.(s) = fullfile(direc_root, sim.(s));
[base.(s), pars.(s)] = aurogem.tools.flux_tube_pars(direc.(s));

if not(all(base.(s).zoom == [1.11, 1.00, 1.30]))
    fprintf('Different zoom in %s\n', sim.(s))
end
if not(all(base.(s).panx == [-0.11, 0.20, 0.20]))
    fprintf('Different panx in %s\n', sim.(s))
end
if not(all(base.(s).pany == [0.0, 0.2, 0.2]))
    fprintf('Different pany in %s\n', sim.(s))
end
if not(all(base.(s).ar == [1.6, 1.0, 1.0]))
    fprintf('Different ar in %s\n', sim.(s))
end
if not(all(base.(s).limn == [9.3, 11.6]))
    fprintf('Different limn in %s\n', sim.(s))
end
if not(all(base.(s).limz == [80, 250]))
    fprintf('Different limz in %s\n', sim.(s))
end

tube_names.(s) = cell2mat(fieldnames(pars.(s))');
if mod(length(tube_names.(s)), 3) ~= 0
    fprintf('Not 3 or 6 tubes in %s: %s\n', sim.(s), tube_names.(s))
end

end % s

if not(all(base.A.limj == base.B.limj))
    fprintf('Different limj in %s v %s\n', sim.A, sim.B)
end
if not(all(base.A.limx == base.B.limx))
    fprintf('Different limx in %s v %s\n', sim.A, sim.B)
end
if not(all(base.A.limy == base.B.limy))
    fprintf('Different limy in %s v %s\n', sim.A, sim.B)
end

if not(length(tube_names.A) == length(tube_names.B))
    fprintf('Different number of tube names in %s v %s\n', sim.A, sim.B)
end
if not(all(tube_names.A ==tube_names.B))
    fprintf('Different tube names in %s v %s\n', sim.A, sim.B)
end

tube_fields = fieldnames(pars.A.A);
accept = ["split_factor", "resolution", "kink_check", "kink_range_deg"];
for tn = tube_names.A
    pars_tmp.A = struct2cell(pars.A.(tn));
    pars_tmp.B = struct2cell(pars.B.(tn));
    for i = 1:length(pars_tmp.A)
        if any(tube_fields{i} == accept)
            continue
        end
        if not(all(pars_tmp.A{i} == pars_tmp.B{i}))
            fprintf('%s v %s\n   %s in tube %s:\n', ...
                sim.A, sim.B, tube_fields{i}, tn)
            disp(pars_tmp.A{i})
            disp(pars_tmp.B{i})
        end
    end
end

end % comp
