fixed the averaging in heasoft->psdlag translation to handle n values in a single bin

This commit is contained in:
othocaeS 2016-07-14 11:24:47 -04:00
parent 30c5ec9803
commit 2fc8861683

View File

@ -47,18 +47,28 @@ while (<>) {
# This mess to average measurements occuring at the same time coordinate # This mess to average measurements occuring at the same time coordinate
$this_t = "$t𝓃.$t𝜀"; $this_t = "$t𝓃.$t𝜀";
if ($this_t == $last_t) { if ($this_t == $last_t) {
if ($heap_count == 0) {
if ( $linetoprint =~ /([0-9\.]+)\s+([0-9e\-\.]+)\s+([0-9e\-\.]+)/ ) { if ( $linetoprint =~ /([0-9\.]+)\s+([0-9e\-\.]+)\s+([0-9e\-\.]+)/ ) {
$new_flux_μ = ($flux_μ + $2)/2; $new_flux_μ = $flux_μ + $2;
# Could just take the max error # Could just take the max error
# $new_flux_σ = max($flux_σ,$3); # $new_flux_σ = max($flux_σ,$3);
# Average error seems fair # Average error seems fair
$new_flux_σ = ($flux_σ + $3)/2; $new_flux_σ = $flux_σ + $3;
$linetoprint="$this_t $new_flux_μ $new_flux_σ";
$num_avg++; $num_avg++;
} }
else { die "Malformed data"; } else { die "Malformed data"; }
} }
else { else {
$new_flux_μ += $flux_μ;
$new_flux_σ += $flux_σ;
}
$heap_count++;
}
else {
$new_flux_μ /= $heap_count;
$new_flux_σ /= $heap_count;
$linetoprint="$this_t $new_flux_μ $new_flux_σ";
our $heap_count = 0;
say $linetoprint; say $linetoprint;
$linetoprint = "$t𝓃.$t𝜀 $flux_μ $flux_σ"; $linetoprint = "$t𝓃.$t𝜀 $flux_μ $flux_σ";
} }