diff options
author | Edoardo Pasca <edo.paskino@gmail.com> | 2019-06-13 17:01:15 +0100 |
---|---|---|
committer | Edoardo Pasca <edo.paskino@gmail.com> | 2019-06-13 17:01:15 +0100 |
commit | 1a33bb7fe818920e77c9e2dc38cee2c261479dae (patch) | |
tree | 20a1ab0833f7aa31356aacbedd0c364a4fb07350 /Wrappers | |
parent | ea5cb3395abf3bad04394d44a83d913175fbb963 (diff) | |
parent | b11f9e3c1fbf2181b906b185e1b32314e021d573 (diff) | |
download | framework-1a33bb7fe818920e77c9e2dc38cee2c261479dae.tar.gz framework-1a33bb7fe818920e77c9e2dc38cee2c261479dae.tar.bz2 framework-1a33bb7fe818920e77c9e2dc38cee2c261479dae.tar.xz framework-1a33bb7fe818920e77c9e2dc38cee2c261479dae.zip |
Merge origin/composite_operator_datacontainer into demos
Conflicts:
Wrappers/Python/ccpi/framework/framework.py
Diffstat (limited to 'Wrappers')
-rwxr-xr-x | Wrappers/Python/ccpi/framework/framework.py | 10 | ||||
-rw-r--r-- | Wrappers/Python/ccpi/io/NEXUSDataReader.py | 25 | ||||
-rw-r--r-- | Wrappers/Python/ccpi/io/NEXUSDataWriter.py | 31 |
3 files changed, 48 insertions, 18 deletions
diff --git a/Wrappers/Python/ccpi/framework/framework.py b/Wrappers/Python/ccpi/framework/framework.py index fd0e0d8..acb59ae 100755 --- a/Wrappers/Python/ccpi/framework/framework.py +++ b/Wrappers/Python/ccpi/framework/framework.py @@ -245,12 +245,15 @@ class AcquisitionGeometry(object): source_to_center_dist (if parallel: NaN) center_to_detector_dist (if parallel: NaN) standard or nonstandard (vec) geometry - angles + angles is expected numpy array, dtype - float32 angles_format radians or degrees """ self.geom_type = geom_type # 'parallel' or 'cone' self.dimension = dimension # 2D or 3D - self.angles = angles + if isinstance(angles, numpy.ndarray): + self.angles = angles + else: + raise ValueError('numpy array is expected') num_of_angles = len (angles) self.dist_source_center = dist_source_center @@ -812,8 +815,7 @@ class DataContainer(object): def dot(self, other, *args, **kwargs): '''return the inner product of 2 DataContainers viewed as vectors''' - method = kwargs.get('method', 'reduce') - + method = kwargs.get('method', 'numpy') if method not in ['numpy','reduce']: raise ValueError('dot: specified method not valid. Expecting numpy or reduce got {} '.format( method)) diff --git a/Wrappers/Python/ccpi/io/NEXUSDataReader.py b/Wrappers/Python/ccpi/io/NEXUSDataReader.py index cf67e27..e6d4d3b 100644 --- a/Wrappers/Python/ccpi/io/NEXUSDataReader.py +++ b/Wrappers/Python/ccpi/io/NEXUSDataReader.py @@ -35,9 +35,7 @@ class NEXUSDataReader(object): self.nexus_file = kwargs.get('nexus_file', None) if self.nexus_file is not None: - self.set_up(nexus_file = self.nexus_file, - roi = self.roi, - binning = self.binning) + self.set_up(nexus_file = self.nexus_file) def set_up(self, nexus_file = None): @@ -94,10 +92,20 @@ class NEXUSDataReader(object): dimension_labels = dimension_labels) else: # AcquisitionData + if ds_data.attrs.__contains__('dist_source_center'): + dist_source_center = ds_data.attrs['dist_source_center'] + else: + dist_source_center = None + + if ds_data.attrs.__contains__('dist_center_detector'): + dist_center_detector = ds_data.attrs['dist_center_detector'] + else: + dist_center_detector = None + self._geometry = AcquisitionGeometry(geom_type = ds_data.attrs['geom_type'], dimension = ds_data.attrs['dimension'], - dist_source_center = ds_data.attrs['dist_source_center'], - dist_center_detector = ds_data.attrs['dist_center_detector'], + dist_source_center = dist_source_center, + dist_center_detector = dist_center_detector, pixel_num_h = ds_data.attrs['pixel_num_h'], pixel_size_h = ds_data.attrs['pixel_size_h'], pixel_num_v = ds_data.attrs['pixel_num_v'], @@ -140,4 +148,11 @@ image_data = reader.load_data() print(image_data) ig = reader.get_geometry() print(ig) + +reader = NEXUSDataReader() +reader.set_up(nexus_file = '/home/evelina/test_nexus_ag.nxs') +ad = reader.load_data() +print(ad) +ad = reader.get_geometry() +print(ad) ''' diff --git a/Wrappers/Python/ccpi/io/NEXUSDataWriter.py b/Wrappers/Python/ccpi/io/NEXUSDataWriter.py index f780f79..6f5c0b2 100644 --- a/Wrappers/Python/ccpi/io/NEXUSDataWriter.py +++ b/Wrappers/Python/ccpi/io/NEXUSDataWriter.py @@ -87,8 +87,10 @@ class NEXUSDataWriter(object): if (isinstance(self.data_container, AcquisitionData)): ds_data.attrs['geom_type'] = self.data_container.geometry.geom_type ds_data.attrs['dimension'] = self.data_container.geometry.dimension - ds_data.attrs['dist_source_center'] = self.data_container.geometry.dist_source_center - ds_data.attrs['dist_center_detector'] = self.data_container.geometry.dist_center_detector + if self.data_container.geometry.dist_source_center is not None: + ds_data.attrs['dist_source_center'] = self.data_container.geometry.dist_source_center + if self.data_container.geometry.dist_center_detector is not None: + ds_data.attrs['dist_center_detector'] = self.data_container.geometry.dist_center_detector ds_data.attrs['pixel_num_h'] = self.data_container.geometry.pixel_num_h ds_data.attrs['pixel_size_h'] = self.data_container.geometry.pixel_size_h ds_data.attrs['pixel_num_v'] = self.data_container.geometry.pixel_num_v @@ -138,14 +140,25 @@ writer.write_file() ig = ImageGeometry(voxel_num_x = 100, voxel_num_y = 100) - im = ImageData(array = numpy.zeros((100, 100), dtype = 'float'), geometry = ig) - im_writer = NEXUSDataWriter() -writer.set_up(file_name = '/home/evelina/test_nexus_im.nxs', - data_container = im) - -writer.write_file() -''' +im_writer.set_up(file_name = '/home/evelina/test_nexus_im.nxs', + data_container = im) +im_writer.write_file() + +ag = AcquisitionGeometry(geom_type = 'parallel', + dimension = '2D', + angles = numpy.array([0, 1]), + pixel_num_h = 200, + pixel_size_h = 1, + pixel_num_v = 100, + pixel_size_v = 1) + +ad = ag.allocate() +ag_writer = NEXUSDataWriter() +ag_writer.set_up(file_name = '/home/evelina/test_nexus_ag.nxs', + data_container = ad) +ag_writer.write_file() +'''
\ No newline at end of file |