mirror of
https://asciireactor.com/otho/psdlag-agn.git
synced 2024-11-24 17:15:06 +00:00
added script to prepare HEASOFT data
This commit is contained in:
parent
65fff39c71
commit
902908cda3
@ -8,9 +8,9 @@ use Switch;
|
|||||||
|
|
||||||
use constant PI => 4 * atan2(1, 1);
|
use constant PI => 4 * atan2(1, 1);
|
||||||
|
|
||||||
# Enables debug output.
|
# Enables various levels of output.
|
||||||
our $debug=1;
|
our $verbose=1;
|
||||||
our $verbosedebug=0;
|
our $debug=0;
|
||||||
|
|
||||||
|
|
||||||
# This section locates the output data of interest in a
|
# This section locates the output data of interest in a
|
||||||
@ -38,7 +38,7 @@ while(<$outputfile>) {
|
|||||||
$star_bytenum_2 = tell($outputfile);
|
$star_bytenum_2 = tell($outputfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($verbosedebug) {
|
if ($debug) {
|
||||||
say encode($charset,"Final set found between lines "),
|
say encode($charset,"Final set found between lines "),
|
||||||
$star_linenum_1,
|
$star_linenum_1,
|
||||||
" and ",
|
" and ",
|
||||||
@ -56,7 +56,7 @@ $bin_bounds_line = <$outputfile>;
|
|||||||
$bin_bounds_line =~ s/^#\s*(.*)$/$1/;
|
$bin_bounds_line =~ s/^#\s*(.*)$/$1/;
|
||||||
#$line =~ /
|
#$line =~ /
|
||||||
@bin_bounds = split /\s/,$bin_bounds_line;
|
@bin_bounds = split /\s/,$bin_bounds_line;
|
||||||
if ($verbosedebug) {
|
if ($debug) {
|
||||||
print encode($charset,"Found bin boundaries: ");
|
print encode($charset,"Found bin boundaries: ");
|
||||||
foreach (@bin_bounds) {print encode($charset,"$_ ");}
|
foreach (@bin_bounds) {print encode($charset,"$_ ");}
|
||||||
say encode($charset," ");
|
say encode($charset," ");
|
||||||
@ -84,7 +84,7 @@ foreach (@bin_bounds) {
|
|||||||
$numbins = keys %function_bin;
|
$numbins = keys %function_bin;
|
||||||
say encode($charset,"$numbins frequency bins captured in output.");
|
say encode($charset,"$numbins frequency bins captured in output.");
|
||||||
|
|
||||||
if($debug) {
|
if($verbose) {
|
||||||
say encode($charset,"freq μ freq σ");
|
say encode($charset,"freq μ freq σ");
|
||||||
while (each %function_bin ) {
|
while (each %function_bin ) {
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
@ -102,7 +102,7 @@ increments to designate the data being captured.
|
|||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
if ($debug) {
|
if ($verbose) {
|
||||||
say encode($charset,"");
|
say encode($charset,"");
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
" New Curve -- Source PSD");
|
" New Curve -- Source PSD");
|
||||||
@ -120,7 +120,7 @@ foreach ( sort { $a <=> $b } keys %function_bin ) {
|
|||||||
# }
|
# }
|
||||||
$function_bin{$_}{"source_PSD_μ"} = $μ;
|
$function_bin{$_}{"source_PSD_μ"} = $μ;
|
||||||
$function_bin{$_}{"source_PSD_σ"} = $σ;
|
$function_bin{$_}{"source_PSD_σ"} = $σ;
|
||||||
if ($debug) {
|
if ($verbose) {
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
"freq = " .
|
"freq = " .
|
||||||
sprintf('%.3f',$_) .
|
sprintf('%.3f',$_) .
|
||||||
@ -131,7 +131,7 @@ foreach ( sort { $a <=> $b } keys %function_bin ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($debug) {
|
if ($verbose) {
|
||||||
say encode($charset,"");
|
say encode($charset,"");
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
" New Curve -- Reprocessed PSD");
|
" New Curve -- Reprocessed PSD");
|
||||||
@ -148,7 +148,7 @@ foreach ( sort { $a <=> $b } keys %function_bin ) {
|
|||||||
# }
|
# }
|
||||||
$function_bin{$_}{"reproc_PSD_μ"} = $μ;
|
$function_bin{$_}{"reproc_PSD_μ"} = $μ;
|
||||||
$function_bin{$_}{"reproc_PSD_σ"} = $σ;
|
$function_bin{$_}{"reproc_PSD_σ"} = $σ;
|
||||||
if ($debug) {
|
if ($verbose) {
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
"freq = " .
|
"freq = " .
|
||||||
sprintf('%.3f',$_) .
|
sprintf('%.3f',$_) .
|
||||||
@ -160,7 +160,7 @@ foreach ( sort { $a <=> $b } keys %function_bin ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($debug) {
|
if ($verbose) {
|
||||||
say encode($charset,"");
|
say encode($charset,"");
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
" New Curve -- Cross Spectra PSD");
|
" New Curve -- Cross Spectra PSD");
|
||||||
@ -177,7 +177,7 @@ foreach ( sort { $a <=> $b } keys %function_bin ) {
|
|||||||
# }
|
# }
|
||||||
$function_bin{$_}{"cc_PSD_μ"} = $μ;
|
$function_bin{$_}{"cc_PSD_μ"} = $μ;
|
||||||
$function_bin{$_}{"cc_PSD_σ"} = $σ;
|
$function_bin{$_}{"cc_PSD_σ"} = $σ;
|
||||||
if ($debug) {
|
if ($verbose) {
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
"freq = " .
|
"freq = " .
|
||||||
sprintf('%.3f',$_) .
|
sprintf('%.3f',$_) .
|
||||||
@ -188,7 +188,7 @@ foreach ( sort { $a <=> $b } keys %function_bin ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($debug) {
|
if ($verbose) {
|
||||||
say encode($charset,"");
|
say encode($charset,"");
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
" New Curve -- Phase Difference φ");
|
" New Curve -- Phase Difference φ");
|
||||||
@ -204,7 +204,7 @@ foreach ( sort { $a <=> $b } keys %function_bin ) {
|
|||||||
}
|
}
|
||||||
$function_bin{$_}{"φdiff_μ"} = $μ;
|
$function_bin{$_}{"φdiff_μ"} = $μ;
|
||||||
$function_bin{$_}{"φdiff_σ"} = $σ;
|
$function_bin{$_}{"φdiff_σ"} = $σ;
|
||||||
if ($debug) {
|
if ($verbose) {
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
"freq = " .
|
"freq = " .
|
||||||
sprintf('%.3f',$_) .
|
sprintf('%.3f',$_) .
|
||||||
@ -217,7 +217,7 @@ foreach ( sort { $a <=> $b } keys %function_bin ) {
|
|||||||
$σ = $σ/(2*PI*$_);
|
$σ = $σ/(2*PI*$_);
|
||||||
$function_bin{$_}{"timelag_μ"} = $μ;
|
$function_bin{$_}{"timelag_μ"} = $μ;
|
||||||
$function_bin{$_}{"timelag_σ"} = $σ;
|
$function_bin{$_}{"timelag_σ"} = $σ;
|
||||||
if ($debug) {
|
if ($verbose) {
|
||||||
say encode($charset,
|
say encode($charset,
|
||||||
" timelag: μ = " .
|
" timelag: μ = " .
|
||||||
sprintf('%10.3e',$μ) .
|
sprintf('%10.3e',$μ) .
|
||||||
@ -229,7 +229,7 @@ foreach ( sort { $a <=> $b } keys %function_bin ) {
|
|||||||
|
|
||||||
say encode($charset,"");
|
say encode($charset,"");
|
||||||
|
|
||||||
if($verbosedebug) {
|
if($debug) {
|
||||||
while (each %function_bin ) {
|
while (each %function_bin ) {
|
||||||
print encode($charset,$_ . ": ");
|
print encode($charset,$_ . ": ");
|
||||||
while ( my ($key,$value) = each %{$function_bin{$_}} ) {
|
while ( my ($key,$value) = each %{$function_bin{$_}} ) {
|
||||||
|
41
scripts/round_time.pl
Executable file
41
scripts/round_time.pl
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/usr/local/bin/perl
|
||||||
|
use feature say;
|
||||||
|
use utf8;
|
||||||
|
use feature qw/switch/;
|
||||||
|
open(my $file,$ARGV[0]) or die("could not open file");
|
||||||
|
|
||||||
|
$keep = 1;
|
||||||
|
# Add two because need to read more digits for rounding.
|
||||||
|
$keep += 2;
|
||||||
|
$throw = 5 - $keep;
|
||||||
|
|
||||||
|
<$file>;
|
||||||
|
while (<$file>) {
|
||||||
|
$_ =~ /^.{8}\s+([0-9]{4})\s+([0-9]{5})\.([0-9]{$keep})[0-9]{$throw}(.*)/;
|
||||||
|
$λ = $1;
|
||||||
|
$t𝓃 = $2; # characteristic
|
||||||
|
$t𝜀 = $3; # mantissa
|
||||||
|
$vals = $4;
|
||||||
|
if ($t𝜀 =~ /([0-9])([0-9])([0-9])/) {
|
||||||
|
$t𝜀 = $1;
|
||||||
|
given($2) {
|
||||||
|
when (/[6-8]/) { $t𝜀 += 1; }
|
||||||
|
when (/5/) { $t𝜀 += 1 if (!($2 == 0)); }
|
||||||
|
}
|
||||||
|
if ($t𝜀 > 9) {
|
||||||
|
$t𝓃 += 1;
|
||||||
|
$t𝜀 = 0;
|
||||||
|
}
|
||||||
|
# For rounding when even rules
|
||||||
|
#say $2 % 2;
|
||||||
|
#if (!($2%2 == 0) ) {
|
||||||
|
# $t𝜀 = $t𝜀 + 1;
|
||||||
|
#}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
die "Malformed data encountered";
|
||||||
|
}
|
||||||
|
say "$λ\t$t𝓃.$t𝜀$vals";
|
||||||
|
}
|
||||||
|
close($file);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user