2016-06-20 18:26:27 +00:00
|
|
|
#!/usr/local/bin/perl
|
|
|
|
|
|
|
|
use utf8;
|
|
|
|
use Encode qw(encode decode);
|
|
|
|
use feature 'say';
|
|
|
|
use locale;
|
|
|
|
use Switch;
|
|
|
|
|
|
|
|
|
|
|
|
# Enables debug output.
|
|
|
|
our $debug=0;
|
|
|
|
|
|
|
|
|
|
|
|
# This section locate the output data of interest in a
|
|
|
|
# psdlab output file.
|
|
|
|
if (!${^UTF8LOCALE}) {
|
|
|
|
say encode($charset,"You are not using UTF-8 encoding. :(");
|
|
|
|
}
|
|
|
|
my $charset=$ENV{LANG};
|
|
|
|
our $outputfilename=decode($charset,$ARGV[0]);
|
|
|
|
open $outputfile,'<',$outputfilename or die $!;
|
|
|
|
|
|
|
|
my $star_linenum_1=0;
|
|
|
|
my $star_linenum_2=0;
|
|
|
|
my $star_bytenum_1=0;
|
|
|
|
my $star_bytenum_2=0;
|
|
|
|
|
|
|
|
my $linenum=0;
|
|
|
|
while(<$outputfile>) {
|
|
|
|
$linenum++;
|
|
|
|
if ($_ =~ /^\*+$/) {
|
|
|
|
$star_linenum_1=$star_linenum_2;
|
2016-06-20 21:04:44 +00:00
|
|
|
$star_linenum_2 = $linenum;
|
2016-06-20 18:26:27 +00:00
|
|
|
$star_bytenum_1=$star_bytenum_2;
|
2016-06-20 21:04:44 +00:00
|
|
|
#$star_bytenum_2 = $outputfile.tell();
|
|
|
|
$star_bytenum_2 = tell($outputfile);
|
2016-06-20 18:26:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($debug) {
|
|
|
|
say encode($charset,"Final set found between lines "),
|
|
|
|
$star_linenum_1,
|
|
|
|
" and ",
|
|
|
|
$star_linenum_2;
|
|
|
|
|
|
|
|
say encode($charset,"Final set found between bytes "),
|
|
|
|
$star_bytenum_1,
|
|
|
|
" and ",
|
|
|
|
$star_bytenum_2;
|
|
|
|
}
|
|
|
|
seek($outputfile,$star_bytenum_1,0);
|
|
|
|
<$outputfile>;
|
|
|
|
$bin_bounds_line = <$outputfile>;
|
|
|
|
#say $bin_bounds_line;
|
|
|
|
$bin_bounds_line =~ s/^#\s*(.*)$/$1/;
|
|
|
|
#$line =~ /
|
|
|
|
@bin_bounds = split /\s/,$bin_bounds_line;
|
|
|
|
if ($debug) {
|
|
|
|
print encode($charset,"Found bin boundaries: ");
|
|
|
|
foreach (@bin_bounds) {print encode($charset,"$_ ");}
|
|
|
|
say encode($charset," ");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# These arrays store the various quantities of interest.
|
2016-06-20 21:10:41 +00:00
|
|
|
@freq_coords_mean = [];
|
2016-06-20 18:26:27 +00:00
|
|
|
@freq_coords_err = [];
|
2016-06-20 21:10:41 +00:00
|
|
|
@arr_power_curve_source_mean = [];
|
2016-06-20 21:04:44 +00:00
|
|
|
@arr_power_curve_source_err = [];
|
2016-06-20 21:10:41 +00:00
|
|
|
@arr_power_curve_reprocessed_mean = [];
|
2016-06-20 21:04:44 +00:00
|
|
|
@arr_power_curve_reprocessed_err = [];
|
2016-06-20 21:10:41 +00:00
|
|
|
@arr_cross_correlation_power_curve_mean = [];
|
2016-06-20 21:04:44 +00:00
|
|
|
@arr_cross_correlation_power_curve_err = [];
|
2016-06-20 21:10:41 +00:00
|
|
|
@arr_phase_difference_mean = [];
|
2016-06-20 21:04:44 +00:00
|
|
|
@arr_phase_difference_err = [];
|
2016-06-20 21:10:41 +00:00
|
|
|
@arr_time_lag_mean = [];
|
2016-06-20 21:04:44 +00:00
|
|
|
@arr_time_lag_err = [];
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
|
|
# This captures the frequency bins.
|
|
|
|
my $upper_bound = 0;
|
|
|
|
my $lower_bound = 0;
|
|
|
|
foreach (@bin_bounds) {
|
|
|
|
$lower_bound = $upper_bound;
|
|
|
|
$upper_bound = $_;
|
|
|
|
if ($lower_bound == 0) {next}
|
2016-06-20 21:10:41 +00:00
|
|
|
my $mean = ($upper_bound + $lower_bound)/2;
|
2016-06-20 18:26:27 +00:00
|
|
|
my $err = ($upper_bound - $lower_bound)/2;
|
2016-06-20 21:10:41 +00:00
|
|
|
#say ($mean,":",$err);
|
|
|
|
push(@freq_coords_mean,$mean);
|
2016-06-20 18:26:27 +00:00
|
|
|
push(@freq_coords_err,$err);
|
|
|
|
}
|
|
|
|
|
2016-06-20 21:10:41 +00:00
|
|
|
$numbins = scalar @freq_coords_mean;
|
2016-06-20 18:26:27 +00:00
|
|
|
say encode($charset,"$numbins frequency boundaries captured.");
|
|
|
|
|
|
|
|
|
|
|
|
# This section collects the various quantities. The mode counter
|
|
|
|
# increments to designate the data being captured.
|
|
|
|
my $mode=0;
|
|
|
|
while (<$outputfile>) {
|
|
|
|
next if $_ =~ /\*+/;
|
|
|
|
switch ($mode) {
|
2016-06-20 21:04:44 +00:00
|
|
|
case 0 {
|
2016-06-20 21:10:41 +00:00
|
|
|
our $power_curve_source_mean = my $power_curve_source_err = $_;
|
|
|
|
$power_curve_source_mean =~ s/^([\-\+e0-9\.]+)+\s+[\-\+e0-9\.]+\s*$/$1/;
|
|
|
|
$power_curve_source_err =~ s/^[\-\+e0-9\.]+\s+([\-\+e0-9\.]+)\s*$/$1/;
|
2016-06-20 18:26:27 +00:00
|
|
|
if ($debug) {
|
|
|
|
say encode($charset,"");
|
|
|
|
say encode($charset," New Bin");
|
|
|
|
say encode($charset,"─────────────────────────────────────────────────");
|
|
|
|
print encode($charset,"Driving light curve power from $_");
|
2016-06-20 21:10:41 +00:00
|
|
|
say encode($charset,"Average: $power_curve_source_mean, Err: $power_curve_source_err");
|
2016-06-20 18:26:27 +00:00
|
|
|
}
|
2016-06-20 21:10:41 +00:00
|
|
|
push(@arr_power_curve_source_mean,$power_curve_source_mean);
|
|
|
|
push(@arr_power_curve_source_err,$power_curve_source_err);
|
2016-06-20 18:26:27 +00:00
|
|
|
$mode++;
|
|
|
|
}
|
2016-06-20 21:04:44 +00:00
|
|
|
case 1 {
|
2016-06-20 21:10:41 +00:00
|
|
|
my $power_curve_reprocessed_mean = my $power_curve_reprocessed_err = $_;
|
|
|
|
$power_curve_reprocessed_mean =~ s/^([\-\+e0-9\.]+)+\s+[\-\+e0-9\.]+\s*$/$1/;
|
|
|
|
$power_curve_reprocessed_err =~ s/^[\-\+e0-9\.]+\s+([\-\+e0-9\.]+)\s*$/$1/;
|
2016-06-20 18:26:27 +00:00
|
|
|
if ($debug) {
|
|
|
|
print encode($charset,"Reprocessed light curve power from $_");
|
2016-06-20 21:10:41 +00:00
|
|
|
say encode($charset,"Average: $power_curve_reprocessed_mean, Err: $power_curve_reprocessed_err");
|
2016-06-20 18:26:27 +00:00
|
|
|
}
|
2016-06-20 21:10:41 +00:00
|
|
|
push(@arr_power_curve_reprocessed_mean,$power_curve_reprocessed_mean);
|
|
|
|
push(@arr_power_curve_reprocessed_err,$power_curve_reprocessed_err);
|
2016-06-20 18:26:27 +00:00
|
|
|
$mode++;
|
|
|
|
}
|
2016-06-20 21:04:44 +00:00
|
|
|
case 2 {
|
2016-06-20 21:10:41 +00:00
|
|
|
my $cross_correlation_power_curve_mean = my $cross_correlation_power_curve_err = $_;
|
|
|
|
$cross_correlation_power_curve_mean =~ s/^([\-\+e0-9\.]+)+\s+[\-\+e0-9\.]+\s*$/$1/;
|
|
|
|
$cross_correlation_power_curve_err =~ s/^[\-\+e0-9\.]+\s+([\-\+e0-9\.]+)\s*$/$1/;
|
2016-06-20 18:26:27 +00:00
|
|
|
if ($debug) {
|
|
|
|
print encode($charset,"Cross-Correlation from $_");
|
2016-06-20 21:10:41 +00:00
|
|
|
say encode($charset,"Average: $cross_correlation_power_curve_mean, Err: $cross_correlation_power_curve_err");
|
2016-06-20 18:26:27 +00:00
|
|
|
}
|
2016-06-20 21:10:41 +00:00
|
|
|
push(@arr_cross_correlation_power_curve_mean,$cross_correlation_power_curve_mean);
|
|
|
|
push(@arr_cross_correlation_power_curve_err,$cross_correlation_power_curve_err);
|
2016-06-20 18:26:27 +00:00
|
|
|
$mode++;
|
|
|
|
}
|
2016-06-20 21:04:44 +00:00
|
|
|
case 3 {
|
2016-06-20 21:10:41 +00:00
|
|
|
my $phase_difference_mean = my $phase_difference_err = $_;
|
|
|
|
$phase_difference_mean =~ s/^([\-\+e0-9\.]+)\s+[\-\+e0-9\.]+\s*$/$1/;
|
|
|
|
$phase_difference_err =~ s/^[\-\+e0-9\.]+\s+([\-\+e0-9\.]+)\s*$/$1/;
|
2016-06-20 18:26:27 +00:00
|
|
|
if ($debug) {
|
|
|
|
print encode($charset,"Phase different from $_");
|
2016-06-20 21:10:41 +00:00
|
|
|
say encode($charset,"Average: $phase_difference_mean, Err: $phase_difference_err");
|
2016-06-20 18:26:27 +00:00
|
|
|
}
|
2016-06-20 21:10:41 +00:00
|
|
|
push(@arr_phase_difference_mean,$phase_difference_mean);
|
|
|
|
push(@arr_phase_difference_err,$phase_difference_err);
|
|
|
|
my %freqrecord = ( "arr_power_curve_source_mean" => arr_power_curve_source_mean);
|
2016-06-20 18:26:27 +00:00
|
|
|
$mode = 0;
|
2016-06-20 20:43:25 +00:00
|
|
|
}
|
2016-06-20 18:26:27 +00:00
|
|
|
} # End switch
|
|
|
|
}
|
|
|
|
|
2016-06-20 21:10:41 +00:00
|
|
|
$numvals = scalar @arr_power_curve_source_mean;
|
2016-06-20 21:04:44 +00:00
|
|
|
say encode($charset,"Retrieved $numvals sets of quantities.");
|
|
|
|
|
2016-06-20 21:10:41 +00:00
|
|
|
# This section builds the records
|
|
|
|
foreach(@freq_coords_mean) {
|
2016-06-20 21:04:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
open($datafile,'>',"tmp.sourcePSD") or die $!;
|
|
|
|
open($datafile,'>',"tmp.reprocPSD") or die $!;
|
|
|
|
|
2016-06-20 21:10:41 +00:00
|
|
|
# foreach(@freq_coords_mean)
|
2016-06-20 21:04:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-20 18:26:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
=pod
|
|
|
|
Tried to set up the program to find the boundaries on its own.
|
|
|
|
Should return to complete the program this way; just a syntax
|
|
|
|
problem.
|
|
|
|
|
|
|
|
#while (<$outputfile>) {say $_;}
|
|
|
|
#while (<$outputfile> =~ /^[^#]+(.*)$/) {}
|
|
|
|
#if (eof($outputfile)) {
|
|
|
|
# say encode($charset,"Could not scrape values of energy bin boundaries.");
|
|
|
|
# exit 9;
|
|
|
|
#}
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#$thing = <$outputfile>;
|
|
|
|
#say encode($charset,"$thing");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# switch ($val) {
|
|
|
|
# case 1 { print encode($charset,"number 1" )}
|
|
|
|
# case "a" { print encode($charset,"string a" )}
|
|
|
|
# case [1..10,42] { print encode($charset,"number in list" )}
|
|
|
|
# case (@array) { print encode($charset,"number in list" )}
|
|
|
|
# case /\w+/ { print encode($charset,"pattern" )}
|
|
|
|
# case qr/\w+/ { print encode($charset,"pattern" )}
|
|
|
|
# case (%hash) { print encode($charset,"entry in hash" )}
|
|
|
|
# case (\%hash) { print encode($charset,"entry in hash" )}
|
|
|
|
# case (\&sub) { print encode($charset,"arg to subroutine" )}
|
|
|
|
# else { print encode($charset,"previous case not true" )}
|
|
|
|
# }
|