diff --git a/plot.sh b/plot.sh index 9b4b55c..688cdf5 100755 --- a/plot.sh +++ b/plot.sh @@ -10,13 +10,10 @@ echo_bands=$(ls analyses/*CM*|sed 's|[^≺]*≺_\(.\{5\}\).*|\1|') # echo Using list of reverberated bands: $echo_bands -echo Propagating tables. -scripts/propagate_tables.sh > /dev/null - case $1 in "PSD"|"psd"|"PSDs"|"PSDS"|"psds") - echo "Producing PSD atlas." gnuplot_file=psd_atlas.gp + scripts/propagate_tables.sh gnuplot_input=$(cat scripts/templates/${gnuplot_file}|perl -pe 's|\n|␤|g') for tabfile in analyses/tables/PSD_*${errtype}*.tab; do @@ -33,9 +30,9 @@ case $1 in ;; "lags"|"lag"|"delay"|"delays") - echo "Producing time delay atlas." gnuplot_file=timelag_atlas.gp gnuplot_input=$(cat scripts/templates/${gnuplot_file}|perl -pe 's|\n|␤|g') + scripts/propagate_tables.sh for tabfile in analyses/tables/timelag_*${errtype}*.tab; do ref_band_extracted=$(basename $tabfile|sed 's|timelag_\([^≺]*\)[_ ]≺[_ ][^≺_ ]*[_ ]{[^_ ]*}.tab|\1|') @@ -51,7 +48,9 @@ case $1 in ;; "tophat") - gnuplot_file="tophat_w_fft.gp" + scripts/tophat_fft.pl + gnuplot scripts/templates/tophat_freqdomain.gp + gnuplot scripts/templates/tophat_timedomain.gp ;; *) diff --git a/pres/img/tophat_freqdomain.pdf b/pres/img/tophat_freqdomain.pdf index dbff5db..8041846 100644 Binary files a/pres/img/tophat_freqdomain.pdf and b/pres/img/tophat_freqdomain.pdf differ diff --git a/pres/img/tophat_timedomain.pdf b/pres/img/tophat_timedomain.pdf index 2808ded..969bfba 100644 Binary files a/pres/img/tophat_timedomain.pdf and b/pres/img/tophat_timedomain.pdf differ diff --git a/scripts/tophat_fft.pl b/scripts/tophat_fft.pl index 297bd13..e4c8f76 100755 --- a/scripts/tophat_fft.pl +++ b/scripts/tophat_fft.pl @@ -23,13 +23,12 @@ my $Δ1=5; # full width my @tophat_list = ([$μ1,$Δ1],[28,8],[15,11]); our $tophat_count = 0; -foreach my $pars (@tophat_list) { +foreach (@tophat_list) { $tophat_count++; # Capture tophat into piddle # Complex Number z(x) = u(x) + iv(x) - my @tophat=tophat(@$pars[0],@$pars[1]); - my $u = pdl(@tophat); + my $u = tophat(@$_[0],@$_[1]); my $v = zeroes($u); $x_coords = $u->xlinvals($xmin,$xmax); @@ -46,25 +45,28 @@ foreach my $pars (@tophat_list) { my $num_elements = nelem($U); say "Found $num_elements elements."; - if ($num_elements % 2 == 0) { - # even number of bins - $f = $U->xlinvals( - -(${num_elements}/2-1)/${num_elements}/${xres}, 1/2/${xres} - )->rotate(-(${num_elements}/2 -1)); - } - else { - #odd number of bins - $f = $U->xlinvals( - -(${num_elements}/2-0.5)/${num_elements}/${xres}, - (${num_elements}/2-0.5)/${num_elements}/${xres} - )->rotate(-(${num_elements}-1)/2); - } + $f = ($num_elements % 2 == 0) ? + $U->xlinvals( + -(${num_elements}/2-1)/${num_elements}/${xres}, + 1/2/${xres} + )->rotate(-(${num_elements}/2 -1)) + : + $U->xlinvals( + -(${num_elements}/2-0.5)/${num_elements}/${xres}, + (${num_elements}/2-0.5)/${num_elements}/${xres} + )->rotate(-(${num_elements}-1)/2); + # Output frequency-domain tophat + wcols $f, $U, $V, "fft${tophat_count}.tab"; # Calculate x offset - my $φdiff = atan2($V,$U); + # This currently multiplies the imaginary component by -1, + # and I really need to figure out why this is necessary for + # proper output. + my $φdiff = atan2(-$V,$U); my $offset = $φdiff/($_2π*$f); + # Output frequency-domain time delay for given tophat wcols $f,$offset,"analyses/tables/tophat_fft${tophat_count}.tab"; } @@ -77,5 +79,5 @@ sub tophat { push @vals, ($x_coord >= ($mean - $halfwidth) && $x_coord <= ($mean + $halfwidth)) ? 1/$width : 0; } - return @vals; + return pdl(@vals); } \ No newline at end of file