예제 #1
0
 def setUp(self):
     dpath = tempfile.mkdtemp()
     dpath1 = tempfile.mkdtemp()
     pdr = Path(dpath)
     pf1 = File(pdr / 'tmp.txt')
     touch(pf1)
     pf2 = File(pdr / 'tmp2.txt')
     touch(pf2)
     pf3 = File(pdr / 'tmp4.txt')
     touch(pf3)
     with open(str(pf3.path), 'w') as fout:
         print('test3', file=fout)
     self.root = dpath
     self.root1 = dpath1
예제 #2
0
파일: api.py 프로젝트: Randall-Z/DPAD
 def _make_task(self, config, scanner):
     coordinate = []
     t1 = time.time()
     for i in range(config.num_file):
         print(i)
         file_name = config.input_path + str(i) + '.dat'
         if File(file_name).exists and is_file_normal(file_name):
             input_data = np.array(load_data(file_name))
             module_data = get_effective_data(input_data,
                                              scanner.nb_blocks_per_ring)
             corrected_module_data = module_correction(
                 module_data, scanner.nb_blocks_per_ring,
                 np.load(config.relation_moduleid),
                 np.load(config.relation_crystalid))
             corrected_single_data = single_correction(
                 corrected_module_data, scanner.nb_blocks_per_ring,
                 config.time_period, config.search_range,
                 scanner.blocks[0].grid)
             coincidence_data = coincidence_with_time_window(
                 corrected_single_data, config.time_window)
             coordinate.append(
                 coincidence_data.filter_with_energy_window(
                     config.energy_window).get_coordinate(scanner))
     coordinate = hadd_by_row(coordinate)
     t2 = time.time()
     print(t2 - t1)
     output = {
         'fst': coordinate[:, :3],
         'snd': coordinate[:, 3:6],
         'weight': np.ones_like(coordinate[:, 0]),
         'tof': np.ones_like(coordinate[:, 0])
     }
     save_h5(config.output_path, output)
예제 #3
0
 def test_move_file(self):
     file1 = File(self.root + '/tmp2.txt')
     mv(file1, Path(self.root1 + '/tmp2.txt'))
     file2 = File(self.root1 + '/tmp2.txt')
     assert file2.exists and not file1.exists
예제 #4
0
 def test_copy_file(self):
     file1 = File(self.root + '/tmp2.txt')
     cp(file1, Path(self.root1 + '/tmp2.txt'))
     file2 = File(self.root1 + '/tmp2.txt')
     assert file2.exists and file1.exists
예제 #5
0
 def test_delete_file(self):
     file1 = File(self.root + '/tmp2.txt')
     rm(file1)
     assert not file1.exists
예제 #6
0
 def test_create_file(self):
     file1 = File(self.root + '/tmp3.txt')
     touch(file1)
     assert file1.exists
예제 #7
0
 def neg2():
     path3 = Path(self.root + '/sub1')
     assert not File.is_file(path3)
예제 #8
0
 def neg1():
     path2 = Path(self.root + '/tmpx.txt')
     assert not File.is_file(path2)
예제 #9
0
 def pos():
     path1 = Path(self.root + '/tmp.txt')
     assert File.is_file(path1)
예제 #10
0
 def neg():
     file1 = File((Path(self.root) / 'tmpx.txt').abs)
     assert not (file1.exists)
예제 #11
0
 def pos():
     file1 = File((Path(self.root) / 'tmp.txt').abs)
     assert (file1.exists)