Data/Analysis/TekTDS.pm

filter: Statementstmt 72.7% 163 / 224 Branchbran 51.2% 41 / 80 Conditioncond 33.3% 9 / 27 MC/DCmcdc 22.2% 4 / 18 Subroutinesub 93.7% 15 / 16 Podpod 100% 2 / 2 totaltotal 63.7% 234 / 367 SCAR 53.8
CC
59
Cov
64%
Analyze
75.0
_PrintSummary
72.0
_extractWaveform
11.8
CRAP 216.7
« Instrument/Cryogenic_SMS.pm ↑ Summary Moose/Instrument/Lakeshore340.pm »
1 package Lab::Data::Analysis::TekTDS;
2 #ABSTRACT: Analysis routine for Tektronix TDS1000/TDS2000/etc. scopes
3 2 $Lab::Data::Analysis::TekTDS::VERSION = '3.881';
4 2 ▶use v5.20;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use Lab::SCPI;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 2 ▶use Lab::Instrument::TDS2024B;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Lab::Data::Analysis;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Clone qw(clone);
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our @ISA = ("Lab::Data::Analysis");
16  
17 2 our $DEBUG = 0;
18  
19 # default config values, copied to $self->{CONFIG} initially
20  
21 2 our $DEFAULT_CONFIG = {};
22  
23  
24 sub new {
25 1 ▶ my $proto = shift;
Subroutine new: called CC=2 SCAR=7.1
Pod documented
26 1 ▶ my $class = ref($proto) || $proto;
Condition33%1/3
ref $proto || $proto
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $proto || $proto
ref $proto $proto
Truth table33%1/3
A || B
A= ref $protoB= $proto
ABresult
1X1
011
000
27 1 my $self = {};
28 1 bless $self, $class;
29  
30 1 my ( $stream, $tail )
31 = Lab::Data::Analysis::_check_args( \@_, qw(stream) );
32  
33 1 $self->{STREAM} = $stream; # hash of stream fileheader info
34  
35 1 return $self;
36 }
37  
38  
39 sub Analyze {
40 1 ▶ my $self = shift;
Subroutine Analyze: called CC=40 SCAR=43.2
Pod documented
41 1 my $event = shift;
42  
43 # handle analysis options
44 1 my $option = shift;
45 1 ▶ $option = {} unless defined $option && ref($option) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $option and ref $option eq "HASH" 0 1 1
Condition33%1/3
defined $option and ref $option eq "HASH"
!ll&&!rl&&r
001
MC/DC0%0/2
defined $option and ref $option eq "HASH"
defined $option ref $option eq "HASH"
Truth table33%1/3
A and B
A= defined $optionB= ref $option eq "HASH"
ABresult
0X0
100
111
46 1 ▶ $option->{dropraw} = 0 unless exists $option->{dropraw};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $option->{"dropraw"} 1 0 1
47 1 ▶ $option->{interpolate} = 1 unless exists $option->{interpolate};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $option->{"interpolate"} 1 0 1
48 1 ▶ $option->{print_summary} = 0 unless exists $option->{print_summary};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $option->{"print_summary"} 1 0 1
49  
50 1 my $stream = $self->{STREAM}->{NUMBER};
51  
52 1 my $a = {};
53 1 $a->{MODULE} = 'TekTDS';
54 1 $a->{RAW} = {};
55 1 $a->{RAW}->{CHAN} = {};
56 1 $a->{CHAN} = {};
57 1 $a->{COMMENT} = [];
58 1 $a->{RUN} = $event->{RUN};
59 1 $a->{EVENT} = $event->{EVENT};
60 1 $a->{STREAM} = $stream;
61 1 $a->{OPTIONS} = clone($option);
62  
63 # event->{ANALYZE}->{stream#}->{TekTDS}->{analysis stuff}?
64  
65 1 foreach my $c ( @{ $event->{STREAM}->{$stream}->{COMMENT} } ) {
66 0 push( @{ $a->{COMMENT} }, $c );
67 }
68  
69 1 my $ch;
70 1 my $seq = [];
71 1 foreach my $g ( @{ $event->{STREAM}->{$stream}->{GPIB} } ) {
72 21 my $str = substr( $g, 1 );
73 21 ▶ next if $str =~ /^\d+/;
Branch: 1 branch
BranchTrueFalseTotal
if $str =~ /^\d+/u 6 15 21
74 15 $seq = scpi_parse_sequence( $str, $seq );
75 }
76 1 ▶ print "seq = ", Dumper($seq), "\n", if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $Lab::Data::Analysis::TekTDS::DEBUG 0 1 1
77  
78 my $fseq = scpi_flat(
79 $seq,
80 $Lab::Instrument::TDS2024B::fields{scpi_override}
81 1 );
82 1 ▶ print "fseq = ", Dumper($fseq), "\n" if $DEBUG;
Branch: 1 branch
BranchTrueFalseTotal
if $Lab::Data::Analysis::TekTDS::DEBUG 0 1 1
83  
84 1 ▶ for ( my $j = 0; exists( $fseq->[$j] ); $j++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fseq->[$j]) 36 1 37
85 36 ▶ if ( exists( $fseq->[$j]->{'DAT:SOU'} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $fseq->[$j]{"DAT:SOU"}) 2 34 36
86 2 $ch = $fseq->[$j]->{'DAT:SOU'};
87 $a->{RAW}->{CHAN}->{$ch} = {}
88 2 ▶ unless exists $a->{RAW}->{CHAN}->{$ch};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $a->{"RAW"}{"CHAN"}{$ch} 1 1 2
89 2 ▶ $a->{CHAN}->{$ch} = {} unless exists $a->{CHAN}->{$ch};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $a->{"CHAN"}{$ch} 1 1 2
90 2 $a->{CHAN}->{$ch}->{CHAN} = $ch;
91 2 $a->{RAW}->{CHAN}->{$ch}->{CHAN} = $ch;
92 }
93  
94 36 foreach my $k ( keys( %{ $fseq->[$j] } ) ) {
95 36 ▶ print "\$fseq->[$j]->{$k} = '", $fseq->[$j]->{$k}, "'\n"
Branch: 1 branch
BranchTrueFalseTotal
if $Lab::Data::Analysis::TekTDS::DEBUG 0 36 36
96 if $DEBUG;
97 36 ▶ if ( $k =~ /^(DAT|WFMP|CURV)/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($k =~ /^(DAT|WFMP|CURV)/u) 25 11 36
98 25 $a->{RAW}->{CHAN}->{$ch}->{$k} = $fseq->[$j]->{$k};
99 }
100 }
101  
102 }
103 1 ▶ print Dumper($a) if $DEBUG > 2;
Branch: 1 branch
BranchTrueFalseTotal
if $Lab::Data::Analysis::TekTDS::DEBUG > 2 0 1 1
104 1 ▶ $self->_PrintSummary( $a, $option ) if $option->{print_summary};
Branch: 1 branch
BranchTrueFalseTotal
if $option->{"print_summary"} 0 1 1
105  
106 1 foreach $ch ( keys( %{ $a->{RAW}->{CHAN} } ) ) {
107 1 my $id = $a->{RAW}->{CHAN}->{$ch}->{'WFMP:WFI'};
108 1 my $x0 = $a->{RAW}->{CHAN}->{$ch}->{'WFMP:XZE'};
109 1 my $y0 = $a->{RAW}->{CHAN}->{$ch}->{'WFMP:YZE'};
110 1 my $dx = $a->{RAW}->{CHAN}->{$ch}->{'WFMP:XIN'};
111 1 my $xoff = $a->{RAW}->{CHAN}->{$ch}->{'WFMP:PT_O'};
112 1 my $xun = $a->{RAW}->{CHAN}->{$ch}->{'WFMP:XUN'};
113 1 my $dy = $a->{RAW}->{CHAN}->{$ch}->{'WFMP:YMU'};
114 1 my $yoff = $a->{RAW}->{CHAN}->{$ch}->{'WFMP:YOF'};
115 1 my $yun = $a->{RAW}->{CHAN}->{$ch}->{'WFMP:YUN'};
116 1 my $j0 = $a->{RAW}->{CHAN}->{$ch}->{'DAT:STAR'};
117 1 my $j1 = $a->{RAW}->{CHAN}->{$ch}->{'DAT:STOP'};
118 1 my $enc = $a->{RAW}->{CHAN}->{$ch}->{'DAT:ENC'};
119 1 my $wd = $a->{RAW}->{CHAN}->{$ch}->{'DAT:WID'};
120 1 my $d = $a->{RAW}->{CHAN}->{$ch}->{'CURV'};
121  
122 1 $id =~ s/^\"(.*)\"/$1/;
123 1 $a->{CHAN}->{$ch}->{ID} = $id;
124 1 $xun =~ s/^\"(.*)\"/$1/;
125 1 $yun =~ s/^\"(.*)\"/$1/;
126 1 $a->{CHAN}->{$ch}->{Xunit} = $xun;
127 1 $a->{CHAN}->{$ch}->{Yunit} = $yun;
128 1 $a->{CHAN}->{$ch}->{DX} = $dx;
129 1 $a->{CHAN}->{$ch}->{X} = [];
130  
131 1 my (@dat) = _extractWaveform( $enc, $wd, $d );
132 1 my ( $ymin, $ymax );
133 1 ▶ if ( $a->{RAW}->{CHAN}->{$ch}->{'WFMP:PT_F'} eq 'Y' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->{'RAW'}{'CHAN'}{$ch}{'WFMP:PT_F'} eq 'Y') { } 1 0 1
134 1 $a->{CHAN}->{$ch}->{Y} = [];
135 1 $a->{CHAN}->{$ch}->{START} = $j0;
136 1 $a->{CHAN}->{$ch}->{STOP} = $j1;
137 1 ▶ for ( my $j = 0; $j <= $#dat; $j++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#dat) 2500 1 2501
138 2500 $a->{CHAN}->{$ch}->{X}->[ $j + $j0 ]
139 = $x0 + $dx * ( $j - $xoff );
140 2500 my $y = $y0 + $dy * ( $dat[$j] - $yoff );
141 2500 $a->{CHAN}->{$ch}->{Y}->[ $j + $j0 ] = $y;
142 2500 ▶ $ymin = $y unless defined $ymin && $y > $ymin;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ymin and $y > $ymin 125 2375 2500
Condition100%3/3
defined $ymin and $y > $ymin
!ll&&!rl&&r
11242375
MC/DC100%2/2
defined $ymin and $y > $ymin
defined $ymin $y > $ymin
Truth table100%3/3
A and B
A= defined $yminB= $y > $ymin
ABresult
0X0
100
111
143 2500 ▶ $ymax = $y unless defined $ymax && $y < $ymax;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ymax and $y < $ymax 109 2391 2500
Condition100%3/3
defined $ymax and $y < $ymax
!ll&&!rl&&r
11082391
MC/DC100%2/2
defined $ymax and $y < $ymax
defined $ymax $y < $ymax
Truth table100%3/3
A and B
A= defined $ymaxB= $y < $ymax
ABresult
0X0
100
111
144 }
145 }
146 else { #envelope
147 0 $a->{CHAN}->{$ch}->{Y0} = [];
148 0 $a->{CHAN}->{$ch}->{Y1} = [];
149 0 $a->{CHAN}->{$ch}->{START} = $j0;
150 0 $a->{CHAN}->{$ch}->{STOP} = $j0 + $#dat / 2;
151 0 ▶ for ( my $j = 0; $j <= $#dat; $j += 2 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($j <= $#dat) 0 0 0
152 0 $a->{CHAN}->{$ch}->{X}->[ $j / 2 + $j0 ]
153 = $x0 + $dx * ( $j - $xoff );
154 0 my $y = $y0 + $dy * ( $dat[$j] - $yoff );
155 0 $a->{CHAN}->{$ch}->{Y0}->[ $j / 2 + $j0 ] = $y;
156 0 ▶ $ymin = $y unless defined $ymin && $y > $ymin;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ymin and $y > $ymin 0 0 0
Condition0%0/3
defined $ymin and $y > $ymin
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ymin and $y > $ymin
defined $ymin $y > $ymin
Truth table0%0/3
A and B
A= defined $yminB= $y > $ymin
ABresult
0X0
100
111
157 0 ▶ $ymax = $y unless defined $ymax && $y < $ymax;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ymax and $y < $ymax 0 0 0
Condition0%0/3
defined $ymax and $y < $ymax
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ymax and $y < $ymax
defined $ymax $y < $ymax
Truth table0%0/3
A and B
A= defined $ymaxB= $y < $ymax
ABresult
0X0
100
111
158  
159 0 $y = $y0 + $dy * ( $dat[ $j + 1 ] - $yoff );
160 0 $a->{CHAN}->{$ch}->{Y1}->[ $j / 2 + $j0 ] = $y;
161 0 ▶ $ymin = $y unless defined $ymin && $y > $ymin;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ymin and $y > $ymin 0 0 0
Condition0%0/3
defined $ymin and $y > $ymin
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ymin and $y > $ymin
defined $ymin $y > $ymin
Truth table0%0/3
A and B
A= defined $yminB= $y > $ymin
ABresult
0X0
100
111
162 0 ▶ $ymax = $y unless defined $ymax && $y < $ymax;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ymax and $y < $ymax 0 0 0
Condition0%0/3
defined $ymax and $y < $ymax
!ll&&!rl&&r
000
MC/DC0%0/2
defined $ymax and $y < $ymax
defined $ymax $y < $ymax
Truth table0%0/3
A and B
A= defined $ymaxB= $y < $ymax
ABresult
0X0
100
111
163 }
164 }
165 1 $a->{CHAN}->{$ch}->{YMIN} = $ymin;
166 1 $a->{CHAN}->{$ch}->{YMAX} = $ymax;
167  
168 1 $a->{CHAN}->{$ch}->{XMIN} = $a->{CHAN}->{$ch}->{X}->[$j0];
169 1 $a->{CHAN}->{$ch}->{XMAX} = $a->{CHAN}->{$ch}->{X}->[$j1];
170  
171 #
172 # creates an anonymous sub that interpolates into the waveform
173 #
174 1 ▶ if ( $option->{interpolate} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($option->{"interpolate"}) 1 0 1
175 $a->{CHAN}->{$ch}->{Yfunc} = sub {
176 2 ▶ use feature 'state';
Subroutine BEGIN: called CC=1 SCAR=0.0
177 10 ▶ state $hchan;
Subroutine __ANON__: called CC=2 SCAR=6.9
178 10 ▶ $hchan = $a->{CHAN}->{$ch} unless defined $hchan;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hchan 1 9 10
179 10 return ( _interpolate( $hchan, @_ ) );
180 1 };
181 1 $a->{CHAN}->{$ch}->{Yfunc}->(0); # initialize state var
182 }
183 }
184 1 ▶ delete( $a->{RAW} ) if $option->{dropraw};
Branch: 1 branch
BranchTrueFalseTotal
if $option->{"dropraw"} 0 1 1
185 1 ▶ $event->{ANALYZE} = {} unless exists $event->{ANALYZE};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $event->{"ANALYZE"} 1 0 1
186  
187 $event->{ANALYZE}->{$stream} = {}
188 1 ▶ unless exists $event->{ANALYZE}->{$stream};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $event->{"ANALYZE"}{$stream} 1 0 1
189  
190 1 $event->{ANALYZE}->{$stream}->{TekTDS} = $a;
191  
192 # push(@{$event->{ANALYZED}},$a);
193 1 return $event;
194 }
195  
196 sub _interpolate {
197 10 ▶ my $h = shift; # hash pointer to {CHAN}->{$ch}
Subroutine _interpolate: called CC=5 SCAR=20.6
198 10 ▶ if ( ref($h) ne 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $h ne "HASH") 0 10 10
199 0 carp("bad hash pointer for wfd interpolation");
200 0 return undef;
201 }
202 10 my $x = shift;
203  
204 10 ▶ return undef if $x < $h->{XMIN} || $x > $h->{XMAX};
Branch: 1 branch
BranchTrueFalseTotal
if $x < $h->{"XMIN"} or $x > $h->{"XMAX"} 0 10 10
Condition33%1/3
$x < $h->{"XMIN"} or $x > $h->{"XMAX"}
l!l&&r!l&&!r
0010
MC/DC0%0/2
$x < $h->{"XMIN"} or $x > $h->{"XMAX"}
$x < $h->{"XMIN"} $x > $h->{"XMAX"}
Truth table33%1/3
A or B
A= $x < $h->{"XMIN"}B= $x > $h->{"XMAX"}
ABresult
1X1
011
000
205  
206 10 my $nx = ( $x - $h->{XMIN} ) / $h->{DX};
207 10 my $nx0 = int($nx);
208 10 my ( $y0, $y1, $ry0, $ry1 );
209 10 ▶ if ( exists( $h->{Y} ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $h->{'Y'}) { } 10 0 10
210 10 $y0 = $h->{Y}->[$nx0];
211 10 $y1 = $h->{Y}->[ $nx0 + 1 ];
212 10 return $y0 + ( $y1 - $y0 ) * ( $nx - $nx0 );
213 }
214 else {
215 0 $y0 = $h->{Y0}->[$nx0];
216 0 $y1 = $h->{Y0}->[ $nx0 + 1 ];
217 0 $ry0 = ( $y1 - $y0 ) * ( $nx - $nx0 );
218  
219 0 $y0 = $h->{Y1}->[$nx0];
220 0 $y1 = $h->{Y1}->[ $nx0 + 1 ];
221 0 $ry1 = ( $y1 - $y0 ) * ( $nx - $nx0 );
222 0 return ( $ry0, $ry1 );
223 }
224 }
225  
226 sub _PrintSummary {
227 0 ▶ my $self = shift;
Subroutine _PrintSummary: not called CC=8 SCAR=42.8
228 0 my $a = shift;
229 0 my $opt = shift;
230  
231 print "TekTDS Analysis Summary: Run ", $a->{RUN},
232 0 " Event ", $a->{EVENT}, " Stream ", $a->{STREAM}, "\n";
233  
234 0 print "\nAnalysis Options:\n";
235 0 foreach my $k ( sort( keys( %{ $a->{OPTIONS} } ) ) ) {
236 0 print "\t $k = ", $a->{OPTIONS}->{$k}, "\n";
237 }
238  
239 0 print "\nDAQ inline comments:\n";
240 0 foreach my $c ( @{ $a->{COMMENT} } ) {
241 0 print "\t \"$c\"\n";
242 }
243  
244 0 print "\nChannels:";
245 0 foreach my $ch ( sort( keys( %{ $a->{RAW}->{CHAN} } ) ) ) {
246 0 print " $ch";
247 }
248 0 print "\n";
249  
250 0 foreach my $ch ( sort( keys( %{ $a->{RAW}->{CHAN} } ) ) ) {
251 0 print "Channel $ch info: \n";
252  
253 0 foreach my $k ( sort( keys( %{ $a->{RAW}->{CHAN}->{$ch} } ) ) ) {
254 0 ▶ next if $k =~ /\?$/;
Branch: 1 branch
BranchTrueFalseTotal
if $k =~ /\?$/u 0 0 0
255 0 ▶ next if $k eq 'CURV';
Branch: 1 branch
BranchTrueFalseTotal
if $k eq "CURV" 0 0 0
256 0 my $key = sprintf( "%-18s", $k );
257 0 print "\t$key : ", $a->{RAW}->{CHAN}->{$ch}->{$k}, "\n";
258 }
259 0 print "\n";
260 }
261  
262 }
263  
264 sub _extractWaveform {
265 1 ▶ my $enc = shift;
Subroutine _extractWaveform: called CC=7 SCAR=24.6
266 1 my $wd = shift;
267 1 my $dat = shift;
268  
269 1 my (@result);
270  
271 1 $enc =~ s/^\s*//;
272  
273 1 ▶ if ( $enc =~ /^ASC/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc =~ /^ASC/iu) { } 0 1 1
274 0 @result = split( /,/, $dat );
275 }
276 else {
277 1 ▶ if ( substr( $dat, 0, 2 ) !~ /^#\d/ ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (substr($dat, 0, 2) =~ /^#\d/u) 0 1 1
278 0 croak("bad binary curve data");
279 }
280 1 my $nx = substr( $dat, 1, 1 );
281 1 my $n = substr( $dat, 2, $nx );
282 1 my $form;
283 1 ▶ if ( $wd == 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wd == 1) { } 1 0 1
284 1 ▶ if ( $enc =~ /^RPB/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc =~ /^RPB/iu) { } 1 0 1
285 1 $form = 'C';
286 }
287 else {
288 0 $form = 'c';
289 }
290 }
291 else {
292 0 ▶ if ( $enc =~ /RPB/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($enc =~ /RPB/iu) { } 0 0 0
293 0 $form = 'S'; # unsigned
294 }
295 else {
296 0 $form = 's'; # RIB signed
297 }
298 0 ▶ if ( $enc =~ /^S/i ) { # LSB first
Branch: 1 branch
BranchTrueFalseTotal
if ($enc =~ /^S/iu) { } 0 0 0
299 0 $form .= '<';
300 }
301 else {
302 0 $form .= '>'; # MSB first
303 }
304 }
305 1 $form .= '*';
306 1 @result = unpack( $form, substr( $dat, $nx + 2 ) );
307 }
308 1 return (@result);
309 }
310  
311 2 1; # End of Lab::Data::Analysis::TekTDS
312  
313 __END__
314  
315 =pod
316  
317 =encoding UTF-8
318  
319 =head1 NAME
320  
321 Lab::Data::Analysis::TekTDS - Analysis routine for Tektronix TDS1000/TDS2000/etc. scopes
322  
323 =head1 VERSION
324  
325 version 3.881
326  
327 =head1 SUBROUTINES/METHODS
328  
329 =head2 new
330  
331 my $a = Lab::Data::Analysis::TekTDS->new(stream=>$stream);
332  
333 create a new TekTDS analysis object; for use by Lab::Data::Analysis
334 code
335  
336 =head2 Analyze
337  
338 my $event = $a->Analyze($event[, optionshash]);
339  
340 Do TekTDS analysis on an event (passed by hashref); the
341 results of the analysis are stored in the hashref, and the
342 hashref is returned.
343  
344 If there is an error, "undef" is returned.
345  
346 The analysis results can be found in
347  
348 $event->{CHAN}->{$channel}->{
349  
350 CHAN => channel name,
351  
352 X => [ ... x values ... typically times ],
353  
354 Yunit => unit for Y scale,
355  
356 Xunit => unit for X scale,
357  
358 ID => ID string describing waveform,
359  
360 START => $jstart ... $X->[$jstart] is first sample
361
362 STOP => $jstop ... $X->[$jstop] is last sample
363  
364 two options:
365  
366 Y => [ ... y values... typically voltages ],
367  
368 or
369  
370 YMIN => [ ... min y values ...], YMAX=> [... max y values..],
371  
372 The YMIN,YMAX arrays are returned for 'envelope' type waveforms.
373  
374 To get the usual time/voltage pairs:
375  
376 for ($j = $ev->{CHAN}->{CH1}->{START};
377
378 $j <= $ev->{CHAN}->{CH1}->{STOP}; $j++) {
379  
380 $t = $ev->{CHAN}->{CH1}->X->[$j];
381  
382 $v = $ev->{CHAN}->{CH1}->Y->[$j];
383  
384 }
385  
386 Analysis options:
387  
388 dropraw => [def: 0] ... drop the raw analysis intermediate results
389 interpolate => [def: 1] ... create a Yfunc interpolation function
390 print_summary => [def: 0] ..print a summary of waveform info
391  
392 =head1 COPYRIGHT AND LICENSE
393  
394 This software is copyright (c) 2023 by the Lab::Measurement team; in detail:
395  
396 Copyright 2016 Charles Lane
397 2017 Andreas K. Huettel
398 2020 Andreas K. Huettel
399  
400  
401 This is free software; you can redistribute it and/or modify it under
402 the same terms as the Perl 5 programming language system itself.
403  
404 =cut
« Instrument/Cryogenic_SMS.pm ↑ Summary Moose/Instrument/Lakeshore340.pm »