def segments(self):
     pytree = Tree('pytree', self.shot)
     signal = pytree.SIG01
     signal.record = None
     signal.compress_on_put = False
     for i in range(2000):
         signal.putRow(100, Range(1, 1000).data(), DateToQuad("now"))
     pytree.createPulse(self.shot + 2)
     signal.compress_segments = True
     pytree3 = Tree('pytree', self.shot + 2)
     pytree3.compressDatafile()
     self.assertEqual((signal.record == pytree3.SIG01.record).all(), True)
     signal.deleteData()
     # beginning a block set next_row to 0
     signal.beginTimestampedSegment(Int32Array([0, 7]))
     self.assertEqual(str(signal.record), "Build_Signal([], *, [])")
     self.assertEqual(str(signal.getSegment(0)), "Build_Signal([], *, [])")
     # beginning adding row increments next_row to 1
     signal.putRow(1, Int32Array([1]), -1)
     self.assertEqual(str(signal.record), "Build_Signal([1], *, [-1Q])")
     self.assertEqual(str(signal.getSegment(0)),
                      "Build_Signal([1], *, [-1Q])")
     # beginning a new block set next_row back to 0 of the new block
     # the previous block is assumed to be full as the tailing zero could be valid data
     signal.beginTimestampedSegment(Int32Array([0]))
     self.assertEqual(str(signal.record),
                      "Build_Signal([1,7], *, [-1Q,0Q])")
     self.assertEqual(str(signal.getSegment(0)),
                      "Build_Signal([1,7], *, [-1Q,0Q])")
Example #2
0
 def CompressSegments(self):
     from MDSplus import Tree,DateToQuad,ZERO,Int32,Int32Array,Int64Array,Range
     with Tree(self.tree,self.shot+9,'NEW') as ptree:
         node = ptree.addNode('S')
         node.compress_on_put = False
         ptree.write()
     ptree.cleanDatafile()
     ptree.normal()
     te = DateToQuad("now")
     sampperseg = 50
     data = ZERO(Int32Array([sampperseg]),Int32(0))
     numsegs = 128
     for i in range(numsegs):
         t0=te+1;te=t0+sampperseg-1
         node.makeSegment(t0,te,Int64Array(range(t0,te+1)),data+Int32(i))
     node.compress_segments=True
     ptree.createPulse(self.shot+11)
     Tree.compressDatafile(self.tree,self.shot+11)
     ptree1 = Tree(self.tree,self.shot+11)
     node1  = ptree1.S
     self.assertEqual(True,(node.record==node1.record).all())
     self.assertEqual(True,ptree.getDatafileSize()>ptree1.getDatafileSize())
     for i in range(numsegs):
         srt,end = node.getSegmentLimits(i)
         dim = Range(srt,end)
         node.updateSegment(srt,end,dim,i)
         if i%16==0:
             self.assertEqual(dim.decompile(),node.getSegmentDim(i).decompile())
     ptree.compressDatafile()
     ptree.readonly()
     self.assertEqual(numsegs,node1.getNumSegments())
     self.assertEqual(True,ptree.getDatafileSize()<ptree1.getDatafileSize())
     for i in range(numsegs):
         self.assertEqual(node.getSegmentDim(i).data().tolist(),node1.getSegmentDim(i).data().tolist())
Example #3
0
 def test():
     from MDSplus import Tree, DateToQuad, Range
     with Tree('seg_tree', self.shot, 'NEW') as ptree:
         ptree.addNode('S').compress_on_put = False
         ptree.write()
     ptree = Tree(self.tree, self.shot)
     node = ptree.S
     for i in range(200):
         node.putRow(100, Range(1, 100).data(), DateToQuad("now"))
     ptree.createPulse(self.shot + 1)
     node.compress_segments = True
     ptree1 = Tree(self.tree, self.shot + 1)
     ptree1.compressDatafile()
     self.assertEqual((node.record == ptree1.S.record).all(), True)
Example #4
0
 def test():
     from MDSplus import Tree, DateToQuad, ZERO, Int32, Int32Array, Int64Array, Range
     with Tree('seg_tree', self.shot, 'NEW') as ptree:
         node = ptree.addNode('S')
         node.compress_on_put = False
         ptree.write()
     ptree.normal()
     ptree.compressDatafile()
     te = DateToQuad("now")
     sampperseg = 50
     data = ZERO(Int32Array([sampperseg]), Int32(0))
     for i in range(513):
         t0 = te + 1
         te = t0 + sampperseg - 1
         node.makeSegment(t0, te, Int64Array(range(t0, te + 1)),
                          data + Int32(i))
     node.compress_segments = True
     ptree.createPulse(self.shot + 1)
     Tree.compressDatafile(self.tree, self.shot + 1)
     ptree1 = Tree(self.tree, self.shot + 1)
     node1 = ptree1.S
     self.assertEqual(True, (node.record == node1.record).all())
     self.assertEqual(
         True,
         ptree.getDatafileSize() > ptree1.getDatafileSize())
     for i in range(node.getNumSegments()):
         str, end = node.getSegmentLimits(i)
         node.updateSegment(str, end, Range(str, end), i)
     ptree.close()
     ptree.compressDatafile()
     ptree.readonly()
     self.assertEqual(
         True,
         ptree.getDatafileSize() < ptree1.getDatafileSize())
     for i in range(node1.getNumSegments()):
         self.assertEqual(
             node.getSegmentDim(i).data().tolist(),
             node1.getSegmentDim(i).data().tolist())