Commit 71353f02 authored by Ruxandra Cojocaru's avatar Ruxandra Cojocaru

Initial commit

parents
This diff is collapsed.
File added
This diff is collapsed.
File added
This diff is collapsed.
File added
This diff is collapsed.
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
"""
Copyright (C) 2018 European Synchrotron Radiation Facility
This file is part of SWaRP.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Setup file written by R. Cojocaru, starting July 2018.
"""
import os
from setuptools import setup
def read(*paths):
"""Build a file path from *paths* and return the contents."""
with open(os.path.join(*paths), 'r') as f:
return f.read()
setup(
### Metadata
name='SWaRP',
version='1.0.0',
description='x-ray speckle tracking WaveFront Reconstruction Software',
long_description=read('README.rst'),
url='https://gitlab.esrf.fr/cojocaru/PUCCAwfrs',
download_url='https://gitlab.esrf.fr/cojocaru/PUCCAwfrs',
license='MIT',
author='Ruxandra Cojocaru, Sebastien Berujon',
author_email='cojocaru@esrf.fr, sebastien.berujon@esrf.fr',
maintainer='DAU',
maintainer_email='DAU email?',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering :: Physics',
],
### Dependencies
install_requires = ['numpy',
'cv2'
'scipy',
'matplotlib>1.0',
'mpltoolkits',
'pil',
'h5py',
'joblib',
'configobj',
]
#~ dependency_links=[
#~ 'git+https://github.com/Turbo87/utm.git@v0.3.1#egg=utm-0.3.1',
#~ ],
### Contents
packages==['SWaRP'],
scripts=[
'wavefront.py',
'detectordistortion.py',
],
provides=['igor ({})'.format(__version__)],
)
This diff is collapsed.
This diff is collapsed.
energy = 12.4
dist = 400
grid_resol = 4
corr_size = 17
resol_first_pass = 35
half_width_fact = 2
ROI_mode = 'input'
ROI_default1 = '250 1700 250 1700'
ROI_default2 = '250 1700 250 1700'
mode = 1
diff_wf = 1
image_order = 1
undistort = 1
under_sample = 1
pix_size1 = 0.624895612803
pix_size2 = 0.624895612803
integ_meth = 1
path_dark1 = 'none'
path_dark2 = 'none'
prefix_dark1 = 'none'
prefix_dark2 = 'none'
path_flat1 = './testdata/flats/'
path_flat2 = './testdata/flats/'
prefix_flat1 = 'flat'
prefix_flat2 = 'flat'
file_type = 'edf'
dir_out = './output/'
file_horz_disto_map1 = './testdata/disto_maps/img_distoH.dat'
file_vert_disto_map1 = './testdata/disto_maps/img_distoV.dat'
file_horz_disto_map2 = 'none'
file_vert_disto_map2 = 'none'
ROI_default_dd1 = '30 2018 30 2018'
ROI_default_dd2 = 'none'
import unittest
import numpy as np
import func
class FuncTestCase(unittest.TestCase):
"""Tests for `func.py`."""
#~ def test_test_err_false_assert(self):
#~ """Do false assertions successfully trigger an error?"""
#~ for assertion in [3==5]:#, False, 'False', 0]:
#~ with self.assertRaises(SystemError):
#~ func.test_err(assertion)
def test_test_err_true_assert(self):
"""Do true assertions fail to trigger an error?"""
for assertion in [3==3, True, 'string', -1, 1, 5]:
self.assertFalse(func.test_err(assertion, verbose = False))
def test_test_warn_false_assert(self):
"""Do false assertions successfully trigger a warning?"""
for assertion in [3==5, False, 0]:
self.assertTrue(func.test_warn(assertion, verbose = False))
def test_test_warn_true_assert(self):
"""Do true assertions fail to trigger a warning?"""
for assertion in [3==3, True, 'True', 1]:
self.assertFalse(func.test_warn(assertion, verbose = False))
def test_ROI_select(self):
"""Test if ROI applied correctly to input image"""
image = np.random.rand(20, 20)
ROI1 = [2, 18, 2, 18]
ROI2 = [5, 10, 4, 11]
ROI3 = [7, 17, 3, 16]
for ROI in [ROI1, ROI2, ROI3]:
shape_exp = (ROI[1] - ROI[0] + 1, ROI[3] - ROI[2] + 1)
shape_out = func.ROI_select(image, ROI).shape
self.assertEqual(shape_out, shape_exp)
def test_ROI_recalc(self):
"""Test if we obtain expected recalculated ROI"""
ROI = [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
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])
def test_crop_rect(self):
"""Test if cropperd image has expected shape"""
image = np.random.rand(20, 20)
rect1 = [2, 2, 17, 17]
rect2 = [5, 4, 6, 8]
rect3 = [7, 3, 11, 14]
for rect in [rect1, rect2, rect3]:
shape_exp = (rect[3], rect[2])
shape_out = func.crop_rect(image, rect).shape
self.assertEqual(shape_out, shape_exp)
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)
X, Y = np.meshgrid(x, y)
input_plane = (d - a * X - b * Y) / c
input_plane = np.around(input_plane - np.mean(input_plane),
decimals = 4)
np.testing.assert_array_equal(input_plane,
np.around(func.plane_fit(input_plane),
decimals = 4))
#~ class MyTest(unittest.TestCase)
#~
#~ def setUp(self):
#~ self.testdata = open(TESTDATA_FILENAME).read()
#~
#~ def test_something(self):
#~ ....
if __name__ == '__main__':
unittest.main()
This diff is collapsed.
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