diff options
author | Edoardo Pasca <edo.paskino@gmail.com> | 2019-06-21 22:22:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-21 22:22:42 +0100 |
commit | 57b81fd1fe64cac63194386b383d40707e5bbdf0 (patch) | |
tree | 263758227e439764bff880c5e438bc505f54d4c4 /Wrappers/Python/test | |
parent | 35b485ff2918c173b0483bb6c62f700467d7782e (diff) | |
download | framework-plugins-57b81fd1fe64cac63194386b383d40707e5bbdf0.tar.gz framework-plugins-57b81fd1fe64cac63194386b383d40707e5bbdf0.tar.bz2 framework-plugins-57b81fd1fe64cac63194386b383d40707e5bbdf0.tar.xz framework-plugins-57b81fd1fe64cac63194386b383d40707e5bbdf0.zip |
Reorganise processors (#24)
* add test phase
* updated test
* removed unused import
* updated test
Diffstat (limited to 'Wrappers/Python/test')
-rw-r--r-- | Wrappers/Python/test/__init__.py | 0 | ||||
-rwxr-xr-x | Wrappers/Python/test/test_Processors.py | 55 |
2 files changed, 55 insertions, 0 deletions
diff --git a/Wrappers/Python/test/__init__.py b/Wrappers/Python/test/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Wrappers/Python/test/__init__.py diff --git a/Wrappers/Python/test/test_Processors.py b/Wrappers/Python/test/test_Processors.py new file mode 100755 index 0000000..0c43126 --- /dev/null +++ b/Wrappers/Python/test/test_Processors.py @@ -0,0 +1,55 @@ +# -*- coding: utf-8 -*-
+"""
+Created on Tue Apr 30 14:39:20 2019
+
+@author: ofn77899
+"""
+
+import sys
+import unittest
+import numpy
+from ccpi.framework import DataProcessor
+from ccpi.framework import DataContainer
+from ccpi.framework import ImageData
+from ccpi.framework import AcquisitionData
+from ccpi.framework import ImageGeometry
+from ccpi.framework import AcquisitionGeometry
+from timeit import default_timer as timer
+from ccpi.io.reader import NexusReader
+from ccpi.processors import CenterOfRotationFinder
+from ccpi.plugins.processors import AcquisitionDataPadder
+import wget
+import os
+import math
+
+class TestDataProcessor(unittest.TestCase):
+ def setUp(self):
+ wget.download('https://github.com/DiamondLightSource/Savu/raw/master/test_data/data/24737_fd.nxs')
+ self.filename = '24737_fd.nxs'
+
+ def tearDown(self):
+ os.remove(self.filename)
+
+ def test_AcquisitionDataPadder(self):
+ reader = NexusReader(self.filename)
+ ad = reader.get_acquisition_data_whole()
+ print (ad.geometry)
+ cf = CenterOfRotationFinder()
+ cf.set_input(ad)
+ print ("Center of rotation", cf.get_output())
+ self.assertAlmostEqual(86.25, cf.get_output())
+
+ adp = AcquisitionDataPadder(acquisition_geometry=cf.get_input().geometry,center_of_rotation=cf.get_output(),pad_value=0)
+ adp.set_input(ad)
+ padded_data = adp.get_output()
+ print ("Padded data shape", padded_data.shape)
+ print (" " , padded_data.dimension_labels)
+ idx = None
+ for k,v in padded_data.dimension_labels.items():
+ if v == AcquisitionGeometry.HORIZONTAL:
+ idx = k
+
+ padded_axis = padded_data.shape[idx]
+ self.assertEqual(padded_axis , math.ceil(cf.get_output() * 2))
+ numpy.save("pippo.npy" , padded_data.as_array())
+
|