Commit c6d64be0 authored by Ruxandra Cojocaru's avatar Ruxandra Cojocaru

Added det_dist resources to setup.py. Small fixes in func.py and test_func.py....

Added det_dist resources to setup.py. Small fixes in func.py and test_func.py. Cleaned func.py (no XSVT functions)
parent e1840906
*.pyc
*.log
swarp/output/
swarp/func_full.py
......@@ -8,10 +8,16 @@ git clone https://gitlab.esrf.fr/cojocaru/swarp
cd swarp
For python2 (first install python-pip):
pip install .
Alternative: sudo python setup.py install
For python3 (first install python3-pip):
python3 -m pip install .
## How to run the code (for now)
python waveFront.py image1 image2 file.ini
......
......@@ -34,10 +34,10 @@ import sys
try:
from setuptools import setup
print('imported setuptools setup')
print('imported setuptools -> setup')
except ImportError:
from distutils.core import setup
print('imported distutils.core setup')
print('imported distutils.core -> setup')
def get_readme():
......@@ -63,7 +63,9 @@ def get_requirements():
continue
line = line.strip('\n')
requirements.append(line)
print(requirements)
print('install_requires: ' + str(requirements))
return requirements
......@@ -99,12 +101,13 @@ def main():
],
package_data={
'swarp.resources': [
'det_dist/*.edf',
'disto_maps/img_distoH.dat',
'disto_maps/img_distoV.dat',
'flats/*.edf',
'image1.edf',
'image2.edf',
'test_wf.ini'
'test_input.ini'
],
},
classifiers=[
......
This diff is collapsed.
......@@ -61,7 +61,7 @@ class FuncTestCase(unittest.TestCase):
self.assertFalse(func.test_warn(assertion, verbose = False))
def test_ROI_select(self):
def test_roi_select(self):
"""Test if ROI applied correctly to input image"""
image = np.random.rand(20, 20)
......@@ -69,24 +69,25 @@ class FuncTestCase(unittest.TestCase):
ROI2 = [5, 10, 4, 11]
ROI3 = [7, 17, 3, 16]
for ROI in [ROI1, ROI2, ROI3]:
ROI = np.array(ROI)
shape_exp = (ROI[1] - ROI[0] + 1, ROI[3] - ROI[2] + 1)
shape_out = func.ROI_select(image, ROI).shape
shape_out = func.roi_select(image, ROI).shape
self.assertEqual(shape_out, shape_exp)
def test_ROI_recalc(self):
def test_roi_recalc(self):
"""Test if we obtain expected recalculated ROI"""
ROI = [1, 20, 1, 20]
ROI = np.array([1, 20, 1, 20])
ROI_IO1 = np.array([[1, 1, 1, 1], [1, 1, 1, 1]])
ROI_IO2 = np.array([[1, 20, 1, 20], [1, 20, 1, 20]])
ROI_IO3 = np.array([[2, 19, 1, 21], [1, 18, 1, 20]])
#~ ROI_IO4 = [[30, 40, 10, 15], []] # no overlap, gives error
roi_IO1 = np.array([[1, 1, 1, 1], [1, 1, 1, 1]])
roi_IO2 = np.array([[1, 20, 1, 20], [1, 20, 1, 20]])
roi_IO3 = np.array([[2, 19, 1, 21], [1, 18, 1, 20]])
#~ roi_IO4 = [[30, 40, 10, 15], []] # no overlap, gives error
for ROI_IO in [ROI_IO1, ROI_IO2, ROI_IO3]:
np.testing.assert_array_equal(func.ROI_recalc(ROI, ROI_IO[0]),
ROI_IO[1])
for roi_IO in [roi_IO1, roi_IO2, roi_IO3]:
np.testing.assert_array_equal(roi_IO[1],
func.roi_recalc(ROI, roi_IO[0]))
def test_crop_rect(self):
"""Test if cropperd image has expected shape"""
......@@ -104,19 +105,30 @@ class FuncTestCase(unittest.TestCase):
def test_plane_fit(self):
"""Is the input of a perfect plane equal to the output (offset = 0)?"""
a = 1
b = 2
c = 3
d = 4
x = np.linspace(0, 20, num = 20)
y = np.linspace(0, 20, num = 20)
a = 1.0
b = 2.0
c = 3.0
d = 4.0
unit = 1.5
steps = 20
x = np.linspace(0, unit*steps, num = steps+1)
y = np.linspace(0, unit*steps, num = steps+1)
X, Y = np.meshgrid(x, y)
input_plane = (d - a * X - b * Y) / c
input_plane = (a * X + b * Y + c) / d
input_plane = np.around(input_plane - np.mean(input_plane),
decimals = 4)
# Test fitted plane
np.testing.assert_array_equal(input_plane,
np.around(func.plane_fit(input_plane),
np.around(func.plane_fit(input_plane)[0],
decimals = 4))
# Test slope in X (horizontal) direction
np.testing.assert_array_equal(a / d * unit,
np.around(func.plane_fit(input_plane)[1],
decimals = 4))
# Test slope in Y (vertical) direction
np.testing.assert_array_equal(b / d * unit,
np.around(func.plane_fit(input_plane)[2],
decimals = 4))
#~ def test_mask_builder(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment