1 from Timba.TDL import *
2 from Timba.Meq import meq
3
4 Settings.forest_state.cache_policy = 100;
5
6 def _define_forest (ns):
7
8 # create a constant node with value 5
9 ns.const << Meq.Constant(5)
10
11 # Now we sum the value of the constant over the number of cells
12 # in our domain. Since we have 8 cells (4 x 2) the 'sumup' node
13 # has value 40. i.e. we have essentially 'assigned' a value of 5
14 # to every cell
15 ns.sumup << Meq.Sum(ns.const)
16
17 # The mean value of a group of cells, all of which have the value 5
18 # will be 5!
19 ns.mean << Meq.Mean(ns.const)
20
21 # the standard deviation will be zero!
22 ns.stddev << Meq.StdDev(ns.const)
23
24 # the Meq.ReqSeq (Request Sequencer) node enables us
25 # to perform a number of separate requests in sequence.
26 # If this node had a parent, it would return the contents
27 # of the ns.multiply node, as we give the result_index
28 # a value of 2 (zero-based) so we return the contents of the
29 # third node.
30 ns.reqseq << Meq.ReqSeq(ns.sumup, ns.mean, ns.stddev, result_index=2)
31
32 def _test_forest (mqs,parent):
33
34 # we create a time-frequency 'domain' with range 0 to 2 in
35 # frequency and 0 to 1 in time. Then we split
36 # the domain into a 4 x 2 "cells' array in frequency and
37 # time. The frequency range will be split into 4 increments,
38 # while the time range will be split into 2 increments.
39
40 cells = meq.cells(meq.domain(0,2,0,1),num_freq=4,num_time=2);
41
42 # execute request
43 request = meq.request(cells,rqtype='e1')
44 a = mqs.meq('Node.Execute',record(name='reqseq',request=request),wait=True);
45
46 # The following is the testing branch, executed when the script is run directly
47 # via 'python script.py'
48
49 if __name__ == '__main__':
50 # from Timba.Meq import meqds
51 Timba.TDL._dbg.set_verbose(5);
52 ns = NodeScope();
53 _define_forest(ns);
54 # resolves nodes
55 ns.Resolve();
