mirror of
https://asciireactor.com/otho/psdlag-agn.git
synced 2024-11-22 08:05:08 +00:00
working out problems with tophat fft
This commit is contained in:
parent
7fcedb6ef3
commit
bf88001dc8
@ -12,7 +12,7 @@ my $twoPI = 2*3.1415926539;
|
|||||||
our $xres=.001;
|
our $xres=.001;
|
||||||
our $xmin = 0;
|
our $xmin = 0;
|
||||||
our $xmax = 250;
|
our $xmax = 250;
|
||||||
our $num_bins = ($xmax-$xmin)/$xres;
|
our $xbins = ($xmax-$xmin)/$xres;
|
||||||
|
|
||||||
# tophat parameters
|
# tophat parameters
|
||||||
my $μ1=15;
|
my $μ1=15;
|
||||||
@ -22,7 +22,7 @@ my $Δ2=5; # full width
|
|||||||
my $μ3=15;
|
my $μ3=15;
|
||||||
my $Δ3=5; # full width
|
my $Δ3=5; # full width
|
||||||
|
|
||||||
say "Creating $num_bins bins";
|
say "Creating $xbins bins";
|
||||||
|
|
||||||
# Complex Number z(x) = u(x) + iv(x)
|
# Complex Number z(x) = u(x) + iv(x)
|
||||||
my @th_list=tophat($μ1,$Δ1);
|
my @th_list=tophat($μ1,$Δ1);
|
||||||
@ -34,8 +34,8 @@ foreach (('1','2','3')) {
|
|||||||
|
|
||||||
# Output time-domain tophat
|
# Output time-domain tophat
|
||||||
open $tophattab, '>', "analyses/tables/tophat${$_}.tab";
|
open $tophattab, '>', "analyses/tables/tophat${$_}.tab";
|
||||||
for ($i=0; $i < $num_bins; $i++) {
|
for ($i=0; $i < $xbins; $i++) {
|
||||||
my $x_coord = ($xmax-$xmin)*($i/$num_bins) + $xmin;
|
my $x_coord = ($xmax-$xmin)*($i/$xbins) + $xmin;
|
||||||
say $tophattab "$x_coord $th_list[$i]";
|
say $tophattab "$x_coord $th_list[$i]";
|
||||||
}
|
}
|
||||||
close $tophattab;
|
close $tophattab;
|
||||||
@ -49,6 +49,8 @@ foreach (('1','2','3')) {
|
|||||||
say "Found $num_elements elements.";
|
say "Found $num_elements elements.";
|
||||||
$f = $U->xlinvals(-($num_elements/2-1)/$num_elements/$xres,1/2/$xres)->rotate(-($num_elements/2 -1));
|
$f = $U->xlinvals(-($num_elements/2-1)/$num_elements/$xres,1/2/$xres)->rotate(-($num_elements/2 -1));
|
||||||
|
|
||||||
|
say "$f[1]";
|
||||||
|
|
||||||
my $φdiff = atan2($V,$U);
|
my $φdiff = atan2($V,$U);
|
||||||
my $timelag = $φdiff/($twoPI*$f);
|
my $timelag = $φdiff/($twoPI*$f);
|
||||||
|
|
||||||
@ -60,8 +62,8 @@ sub tophat {
|
|||||||
(my $mean,my $width) = @_;
|
(my $mean,my $width) = @_;
|
||||||
my $halfwidth = $width/2;
|
my $halfwidth = $width/2;
|
||||||
my @vals = ();
|
my @vals = ();
|
||||||
for ($i=0; $i < $num_bins; $i++) {
|
for ($i=0; $i < $xbins; $i++) {
|
||||||
my $x_coord = ($xmax-$xmin)*($i/$num_bins) + $xmin;
|
my $x_coord = ($xmax-$xmin)*($i/$xbins) + $xmin;
|
||||||
if ($x_coord >= ($mean - $halfwidth ) && $x_coord <= ($mean + $halfwidth)) { push @vals, 1/$width; }
|
if ($x_coord >= ($mean - $halfwidth ) && $x_coord <= ($mean + $halfwidth)) { push @vals, 1/$width; }
|
||||||
else { push @vals, 0; }
|
else { push @vals, 0; }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user