- if ($c > 1) {
- foreach $r (@$cand) {
- next unless ref $r;
- my $diff = nearest(.1, $qrg - $r->[RQrg]);
- push @deviant, sprintf("$r->[ROrigin]:%+.1f", $diff) if $diff != 0;
- $r->[RSpotData]->[SQrg] = $qrg; # set all the QRGs to the agreed value
+ foreach $r (@$cand) {
+ next unless $r && ref $r;
+ my $diff = $c > 1 ? nearest(.1, $r->[RQrg] - $qrg) : 0;
+ $sk = "SKIM|$r->[ROrigin]|$band";
+ $skimmer = $spots->{$sk};
+ $skimmer->[DBad] ||= 0+0; # stop JSON nulls?
+ $skimmer->[DEviants] ||= []; # ditto
+ if ($diff) {
+ ++$skimmer->[DBad] if $skimmer->[DBad] < $maxdeviants;
+ --$skimmer->[DGood] if $skimmer->[DGood] > 0;
+ push @deviant, sprintf("$r->[ROrigin]:%+.1f", $diff);
+ push @{$skimmer->[DEviants]}, $diff;
+ shift @{$skimmer->[DEviants]} while @{$skimmer->[DEviants]} > $maxdeviants;
+ } else {
+ ++$skimmer->[DGood] if $skimmer->[DGood] < $maxdeviants;
+ --$skimmer->[DBad] if $skimmer->[DBad] > 0;
+ shift @{$skimmer->[DEviants]};