@@ -1298,5 +1298,40 @@ def test_cut(self):
1298
1298
self .assertEqual (traces [1 ].nsamples , 236 )
1299
1299
1300
1300
1301
+ class TestPH5APICutTimeStartInMiddleOfSample (LogTestCase ):
1302
+ """
1303
+ This test to make sure the traces return will be at or after the cut
1304
+ """
1305
+ def setUp (self ):
1306
+ super (TestPH5APICutTimeStartInMiddleOfSample , self ).setUp ()
1307
+ self .home = os .getcwd ()
1308
+ self .ph5API_object = ph5api .PH5 (
1309
+ path = os .path .join (
1310
+ self .home , 'ph5/test_data/ph5_cut_start_in_middle_of_sample' ),
1311
+ nickname = 'master.ph5' )
1312
+
1313
+ def tearDown (self ):
1314
+ self .ph5API_object .close ()
1315
+ super (TestPH5APICutTimeStartInMiddleOfSample , self ).tearDown ()
1316
+
1317
+ def test_cut (self ):
1318
+ cut_start_epoch = 1508630400.0
1319
+ cut_end_epoch = 1508716799.0
1320
+ das = self .ph5API_object .query_das_t (
1321
+ das = 'A123' , chan = 1 , sample_rate = 100 , sample_rate_multiplier = 1 ,
1322
+ start_epoch = cut_start_epoch , stop_epoch = cut_end_epoch
1323
+ )
1324
+ das = [x for x in das ]
1325
+ traces = self .ph5API_object .cut (
1326
+ das = 'A123' , chan = 1 , sample_rate = 100 , das_t = das ,
1327
+ start_fepoch = cut_start_epoch , stop_fepoch = cut_end_epoch ,
1328
+ apply_time_correction = True
1329
+ )
1330
+
1331
+ trace_start_epoch = traces [0 ].start_time .epoch (fepoch = True )
1332
+ # make sure trace start at or after cut start
1333
+ self .assertGreaterEqual (trace_start_epoch , cut_start_epoch )
1334
+
1335
+
1301
1336
if __name__ == "__main__" :
1302
1337
unittest .main ()
0 commit comments