in reply to Re^4: Quick script to check data logger data
in thread Quick script to check data logger data
If you're into IRC, then next time you feel you might benefit from using PDL but don't feel 100% clear on where to start, do feel free to join #pdl on irc.perl.org and ask questions! A lightweight way to do so is on the MetaCPAN page for various PDL modules, with the "Chat with us" link.use strict; use warnings; use PDL; use PDL::FFTW3; use PDL::Graphics::Simple; my $filePath = $ARGV[0] // "testData.txt"; my @data = do { open my $fh, $filePath or die "Can't open $filePath: $ +!"; local $/; split /\s+/, <$fh> }; sub spectrum {my ($d)=@_; my $hn=$d->dim(0)-1; my $a2=$d->abs2/(($hn*2)**2); $a2->slice([1,$hn-1])*=2; $a2; } my $spectrum = spectrum(rNfft1 pdl(\@data)); $spectrum = $spectrum->slice('1:-1'); # Remove DC signal component line pdl($spectrum); print "ret> "; <STDIN>;
|
---|