2016-07-25 21:18:48 +00:00
|
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
2016-08-10 02:38:11 +00:00
|
|
|
|
# This extracts the gnuplot-ready tables from a psdlag analysis and saves them
|
|
|
|
|
# to temporary files. propogate_tables.sh uses this script to create the
|
|
|
|
|
# tables it saves to analyses/tables.
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
|
|
|
|
use utf8;
|
|
|
|
|
use Encode qw(encode decode);
|
|
|
|
|
use feature 'say';
|
|
|
|
|
use locale;
|
|
|
|
|
use Switch;
|
|
|
|
|
|
2016-06-21 08:56:27 +00:00
|
|
|
|
use constant PI => 4 * atan2(1, 1);
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
2016-06-29 23:35:02 +00:00
|
|
|
|
# Enables various levels of output.
|
|
|
|
|
our $verbose=1;
|
|
|
|
|
our $debug=0;
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
2017-01-25 06:19:52 +00:00
|
|
|
|
if ($debug) { $verbose=1; }
|
|
|
|
|
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
2016-06-21 08:56:27 +00:00
|
|
|
|
# This section locates the output data of interest in a
|
2016-06-20 18:26:27 +00:00
|
|
|
|
# psdlab output file.
|
|
|
|
|
if (!${^UTF8LOCALE}) {
|
|
|
|
|
say encode($charset,"You are not using UTF-8 encoding. :(");
|
|
|
|
|
}
|
|
|
|
|
my $charset=$ENV{LANG};
|
2017-01-11 06:37:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# This program attempts to fill function_bin with the tabulated PSDs
|
|
|
|
|
# and time lags.
|
|
|
|
|
our %function_bin = ();
|
|
|
|
|
|
|
|
|
|
open $freq_file,'<',"freq.out" or die $!;
|
|
|
|
|
open $ref_psd_file,'<',"ref_psd.out" or die $!;
|
|
|
|
|
open $echo_psd_file,'<',"echo_psd.out" or die $!;
|
|
|
|
|
open $crsspctrm_file,'<',"crsspctrm.out" or die $!;
|
|
|
|
|
open $timelag_file,'<',"timelag.out" or die $!;
|
|
|
|
|
|
|
|
|
|
=pod
|
|
|
|
|
|
|
|
|
|
This section collects the various quantities.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
@bin_bounds = split /\s/,<$freq_file>;
|
|
|
|
|
@ref_psd = split /\s/,<$ref_psd_file>;
|
|
|
|
|
@ref_psd_σ = split /\s/,<$ref_psd_file>;
|
|
|
|
|
@echo_psd = split /\s/,<$echo_psd_file>;
|
|
|
|
|
@echo_psd_σ = split /\s/,<$echo_psd_file>;
|
|
|
|
|
@crsspctrm_psd = split /\s/,<$crsspctrm_file>;
|
|
|
|
|
@crsspctrm_psd_σ = split /\s/,<$crsspctrm_file>;
|
|
|
|
|
@timelag = split /\s/,<$timelag_file>;
|
|
|
|
|
@timelag_σ = split /\s/,<$timelag_file>;
|
|
|
|
|
|
2016-06-29 23:35:02 +00:00
|
|
|
|
if ($debug) {
|
2016-06-20 18:26:27 +00:00
|
|
|
|
print encode($charset,"Found bin boundaries: ");
|
|
|
|
|
foreach (@bin_bounds) {print encode($charset,"$_ ");}
|
|
|
|
|
say encode($charset," ");
|
|
|
|
|
}
|
2017-01-11 06:37:12 +00:00
|
|
|
|
my $count = 0;
|
2016-06-20 18:26:27 +00:00
|
|
|
|
my $upper_bound = 0;
|
|
|
|
|
my $lower_bound = 0;
|
|
|
|
|
foreach (@bin_bounds) {
|
|
|
|
|
$lower_bound = $upper_bound;
|
|
|
|
|
$upper_bound = $_;
|
|
|
|
|
if ($lower_bound == 0) {next}
|
2016-06-21 08:56:27 +00:00
|
|
|
|
my $μ = ($upper_bound + $lower_bound)/2;
|
|
|
|
|
my $Δ = ($upper_bound - $lower_bound)/2;
|
|
|
|
|
#say ($μ,":",$Δ);
|
|
|
|
|
# push(@freq_coords_mean,$μ);
|
2017-01-11 06:37:12 +00:00
|
|
|
|
# push(@freq_coords_σ,$Δ);
|
2017-01-25 06:19:52 +00:00
|
|
|
|
$function_bin{$μ} = {"Δ" => $Δ,
|
|
|
|
|
"ref_PSD_μ" => $ref_psd[$count],
|
|
|
|
|
"ref_PSD_σ" => $ref_psd_σ[$count],
|
|
|
|
|
"echo_PSD_μ" => $echo_psd[$count],
|
|
|
|
|
"echo_PSD_σ" => $echo_psd_σ[$count],
|
|
|
|
|
"crsspctrm_μ" => $crosssp_psd[$count],
|
|
|
|
|
"crsspctrm_σ" => $crosssp_psd_σ[$count],
|
|
|
|
|
"timelag_μ" => $timelag[$count],
|
|
|
|
|
"timelag_σ" => $timelag_σ[$count]};
|
2017-01-11 06:37:12 +00:00
|
|
|
|
# $function_bin{$μ}{"φdiff_μ"} = $μ;
|
|
|
|
|
# $function_bin{$μ}{"φdiff_σ"} = $σ;
|
|
|
|
|
# $μ = $μ/(2*PI*$μ);
|
|
|
|
|
# $σ = $σ/(2*PI*$μ);
|
|
|
|
|
$count = $count + 1;
|
2016-06-20 18:26:27 +00:00
|
|
|
|
}
|
|
|
|
|
|
2017-01-11 06:37:12 +00:00
|
|
|
|
close $freq_file;
|
|
|
|
|
close $ref_psd_file;
|
|
|
|
|
close $echo_psd_file;
|
|
|
|
|
close $crsspctrm_file;
|
|
|
|
|
close $timelag_file;
|
|
|
|
|
|
2016-06-21 08:56:27 +00:00
|
|
|
|
$numbins = keys %function_bin;
|
|
|
|
|
say encode($charset,"$numbins frequency bins captured in output.");
|
2016-06-20 21:04:44 +00:00
|
|
|
|
|
2016-06-29 23:35:02 +00:00
|
|
|
|
if($verbose) {
|
2017-01-25 06:19:52 +00:00
|
|
|
|
say encode($charset,"freq μ freq σ ref_PSD_μ ref_PSD_σ echo_PSD_μ echo_PSD_σ timelag_μ timelag_σ");
|
|
|
|
|
|
|
|
|
|
foreach (sort { $a <=> $b } keys %function_bin) {
|
2016-06-21 17:56:59 +00:00
|
|
|
|
say encode($charset,
|
2017-01-25 06:19:52 +00:00
|
|
|
|
sprintf("%f %f %f %f %f %f %f %f ",
|
|
|
|
|
$_,
|
|
|
|
|
$function_bin{$_}{"Δ"},
|
|
|
|
|
$function_bin{$_}{"ref_PSD_μ"},
|
|
|
|
|
$function_bin{$_}{"ref_PSD_σ"},
|
|
|
|
|
$function_bin{$_}{"echo_PSD_μ"},
|
|
|
|
|
$function_bin{$_}{"echo_PSD_σ"},
|
|
|
|
|
$function_bin{$_}{"timelag_μ"},
|
|
|
|
|
$function_bin{$_}{"timelag_σ"}
|
|
|
|
|
));
|
2016-06-21 08:56:27 +00:00
|
|
|
|
}
|
2016-06-20 21:04:44 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-06-21 08:56:27 +00:00
|
|
|
|
say encode($charset,"");
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
2016-06-29 23:35:02 +00:00
|
|
|
|
if($debug) {
|
2016-06-21 08:56:27 +00:00
|
|
|
|
while (each %function_bin ) {
|
|
|
|
|
print encode($charset,$_ . ": ");
|
|
|
|
|
while ( my ($key,$value) = each %{$function_bin{$_}} ) {
|
|
|
|
|
print encode($charset,$key . " => " . $value . "; ");
|
|
|
|
|
}
|
|
|
|
|
say encode($charset,"");
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
2016-06-21 08:56:27 +00:00
|
|
|
|
close($outputfile);
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
2016-07-13 03:28:11 +00:00
|
|
|
|
open($datafile,'>',"tmp.refPSD") or die $!;
|
2016-06-21 08:56:27 +00:00
|
|
|
|
while( each %function_bin) {
|
|
|
|
|
say $datafile
|
|
|
|
|
$_ . " " .
|
2016-07-13 03:28:11 +00:00
|
|
|
|
$function_bin{$_}{"ref_PSD_μ"} . " " .
|
2016-06-21 08:56:27 +00:00
|
|
|
|
$function_bin{$_}{"Δ"} . " " .
|
2016-07-13 03:28:11 +00:00
|
|
|
|
$function_bin{$_}{"ref_PSD_σ"};
|
2016-06-21 08:56:27 +00:00
|
|
|
|
}
|
|
|
|
|
close($datafile);
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
2016-07-13 03:28:11 +00:00
|
|
|
|
open($datafile,'>',"tmp.echoPSD") or die $!;
|
2016-06-21 08:56:27 +00:00
|
|
|
|
while( each %function_bin) {
|
|
|
|
|
say $datafile
|
|
|
|
|
$_ . " " .
|
2016-07-13 03:28:11 +00:00
|
|
|
|
$function_bin{$_}{"echo_PSD_μ"} . " " .
|
2016-06-21 08:56:27 +00:00
|
|
|
|
$function_bin{$_}{"Δ"} . " " .
|
2016-07-13 03:28:11 +00:00
|
|
|
|
$function_bin{$_}{"echo_PSD_σ"};
|
2016-06-21 08:56:27 +00:00
|
|
|
|
}
|
|
|
|
|
close($datafile);
|
|
|
|
|
|
2016-07-13 03:28:11 +00:00
|
|
|
|
open($datafile,'>',"tmp.crsspctrmPSD") or die $!;
|
2016-06-21 08:56:27 +00:00
|
|
|
|
while( each %function_bin) {
|
|
|
|
|
say $datafile
|
|
|
|
|
$_ . " " .
|
2016-07-13 03:28:11 +00:00
|
|
|
|
$function_bin{$_}{"crsspctrm_PSD_μ"} . " " .
|
2016-06-21 08:56:27 +00:00
|
|
|
|
$function_bin{$_}{"Δ"} . " " .
|
2016-07-13 03:28:11 +00:00
|
|
|
|
$function_bin{$_}{"crsspctrm_PSD_σ"};
|
2016-06-21 08:56:27 +00:00
|
|
|
|
}
|
|
|
|
|
close($datafile);
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
2016-06-21 17:56:59 +00:00
|
|
|
|
open($datafile,'>',"tmp.timelag") or die $!;
|
|
|
|
|
while( each %function_bin) {
|
|
|
|
|
say $datafile
|
|
|
|
|
$_ . " " .
|
|
|
|
|
$function_bin{$_}{"timelag_μ"} . " " .
|
|
|
|
|
$function_bin{$_}{"Δ"} . " " .
|
|
|
|
|
$function_bin{$_}{"timelag_σ"};
|
|
|
|
|
}
|
|
|
|
|
close($datafile);
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
|
|
|
|
|
2016-07-13 03:28:11 +00:00
|
|
|
|
#open($datafile,'>',"tmp.echoPSD") or die $!;
|