Skip to content

Commit

Permalink
Merge pull request #11 from sfarrens/testing
Browse files Browse the repository at this point in the history
updated documentation
  • Loading branch information
sfarrens committed Feb 15, 2020
2 parents 3094a15 + 1585591 commit 2a280dc
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 48 deletions.
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
numpy>=1.14.1
modopt>=1.4.2
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
with open(infopath) as open_file:
exec(open_file.read(), release_info)

with open('requirements.txt') as open_file:
install_requires = open_file.read()


setup(
name='sf_tools',
author='sfarrens',
Expand All @@ -18,7 +22,7 @@
url='https://github.com/sfarrens/sf_tools',
download_url='https://github.com/sfarrens/sf_tools',
packages=find_packages(),
install_requires=['numpy>=1.14.1', 'future>=0.16.0', 'modopt>=1.1.4'],
install_requires=install_requires,
license='MIT',
description='Tools for image analysis, signal processing and statistics.',
long_description=release_info["__about__"],
Expand Down
42 changes: 25 additions & 17 deletions sf_tools/image/distort.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ def downsample(image, factor):
Parameters
----------
image : np.ndarray
image : numpy.ndarray
Input image array
factor : int
Downsampling factor
Returns
-------
np.ndarray downsampled image array
numpy.ndarray
Downsampled image array
Raises
------
Expand Down Expand Up @@ -65,12 +66,13 @@ def resize_even_image(image):
Parameters
----------
image : np.ndarray
image : numpy.ndarray
Input image array
Returns
-------
np.ndarray resized image array
numpy.ndarray
Resized image array
"""

Expand All @@ -85,14 +87,15 @@ def roll_2d(data, roll_rad=(1, 1)):
Parameters
----------
data : np.ndarray
data : numpy.ndarray
Input 2D data array
roll_rad : tuple
Roll radius in each dimension
Returns
-------
np.ndarray rolled array
numpy.ndarray
Rolled array
"""

Expand All @@ -106,12 +109,13 @@ def rot_and_roll(data):
Parameters
----------
data : np.ndarray
data : numpy.ndarray
Input 2D data array
Returns
-------
np.ndarray rotated and rolled array
numpy.ndarray
Rotated and rolled array
"""

Expand All @@ -132,7 +136,8 @@ def gen_mask(kernel_shape, image_shape):
Returns
-------
np.ndarray boolean mask
numpy.ndarray
Boolean mask
"""

Expand Down Expand Up @@ -163,7 +168,8 @@ def roll_sequence(data_shape):
Returns
-------
list of roll radii
list
Roll radii
"""

Expand All @@ -183,12 +189,13 @@ def kernel_pattern(kernel_shape, mask):
----------
kernel_shape : tuple
Shape of kernel
mask : np.ndarray
mask : numpy.ndarray
Boolean mask
Returns
-------
np.ndarray kernel pattern
numpy.ndarray
Kernel pattern
"""

Expand Down Expand Up @@ -231,7 +238,8 @@ def rearrange_kernel(kernel, data_shape=None):
Returns
-------
np.ndarray rearanged matrix of kernel elements
numpy.ndarray
Rearanged matrix of kernel elements
"""

Expand Down Expand Up @@ -275,14 +283,14 @@ def pad_shift(image, shift):
Parameters
----------
image : np.ndarray
image : numpy.ndarray
Input image
shift : tuple
Shift in x and y axes
Returns
-------
np.ndarray
numpy.ndarray
Padded image
"""
Expand All @@ -300,14 +308,14 @@ def recentre(image, pos):
Parameters
----------
image : np.ndarray
image : numpy.ndarray
Input image
pos : tuple
Pos in x and y axes
Returns
-------
np.ndarray
numpy.ndarray
Recentred image
"""
Expand Down
18 changes: 10 additions & 8 deletions sf_tools/image/quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,17 @@ def nmse(image1, image2, metric=np.mean):
Parameters
----------
image1 : np.ndarray
image1 : numpy.ndarray
First image (or stack of images) to be analysed (original image)
image2 : np.ndarray
image2 : numpy.ndarray
Second image (or stack of images) to be analysed (reconstructed image)
metric : function
Metric to be apllied to NMSE results (default is 'np.mean')
Metric to be apllied to NMSE results (default is 'numpy.mean')
Returns
-------
float NMSE value or metric value(s)
float
NMSE value or metric value(s)
Raises
------
Expand Down Expand Up @@ -95,17 +96,18 @@ def e_error(image1, image2, metric=np.mean):
Parameters
----------
image1 : np.ndarray
image1 : numpy.ndarray
First image to be analysed (original image)
image2 : np.ndarray
image2 : numpy.ndarray
Second image to be analysed (reconstructed image)
metric : function
Metric to be apllied to ellipticity error results (default is
'np.mean')
'numpy.mean')
Returns
-------
float ellipticity error value or metric value(s)
float
Ellipticity error value or metric value(s)
Raises
------
Expand Down
24 changes: 13 additions & 11 deletions sf_tools/image/shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@ def ellipticity_atoms(data, offset=0):
Parameters
----------
data : np.ndarray
data : numpy.ndarray
Input data array, the image to be analysed
offset : int, optional
Shape projection offset (default is '0')
Returns
-------
np.ndarray of the image ellipticity components
numpy.ndarray
Image ellipticity components
See Also
--------
Expand Down Expand Up @@ -102,7 +103,7 @@ def shape_project(shape, offset=0, return_norm=False):
Parameters
----------
shape : list, tuple or np.ndarray
shape : list, tuple or numpy.ndarray
List of image dimensions
offset : int, optional
Shape projection offset (default is '0')
Expand All @@ -112,7 +113,8 @@ def shape_project(shape, offset=0, return_norm=False):
Returns
-------
np.ndarray of shape projection components
numpy.ndarray
Shape projection components
See Also
--------
Expand Down Expand Up @@ -185,16 +187,16 @@ class Ellipticity():
Parameters
----------
data : np.ndarray
data : numpy.ndarray
Input data array, the image to be analysed
sigma : int, optional
Estimation error (default is '1000')
centroid : np.ndarray, optional
centroid : numpy.ndarray, optional
Centroid positions [x, y] of the input image (defualt is 'None')
moments : np.ndarray, optional
moments : numpy.ndarray, optional
Quadrupole moments [[q00, q01], [q10, q11]] of the input image
(defualt is 'None')
ellip_type : str {'chi', 'epsilon'}, optional
ellip_type : {'chi', 'epsilon'}, optional
Ellipticity type (default is 'chi')
Examples
Expand Down Expand Up @@ -284,7 +286,7 @@ def _update_weights(self):
(2 * self._sigma ** 2))

def _update_centroid(self):
"""Update the centroid
r"""Update the centroid
This method updates the centroid value using the current weights.
Expand Down Expand Up @@ -349,7 +351,7 @@ def _get_centroid(self, n_iter=10):
self._get_moments()

def _get_moments(self):
""" Calculate the quadrupole moments
r""" Calculate the quadrupole moments
This method calculates the quadrupole moments.
Expand Down Expand Up @@ -378,7 +380,7 @@ def _get_moments(self):
self._get_ellipse()

def _get_ellipse(self):
"""Calculate the ellipticities
r"""Calculate the ellipticities
This method cacluates ellipticities from quadrupole moments.
Expand Down
18 changes: 11 additions & 7 deletions sf_tools/image/stamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def patch_centres(data_shape, layout):
Returns
-------
np.ndarray array of patch centres
numpy.ndarray array of patch centres
"""

Expand All @@ -57,7 +57,7 @@ def postage_stamp(data, pos, pixel_rad):
Parameters
----------
data : np.ndarray
data : numpy.ndarray
Input data array
pos : tuple
Position of postage stamp centre
Expand All @@ -66,7 +66,8 @@ def postage_stamp(data, pos, pixel_rad):
Returns
-------
np.ndarray rearanged matrix of kernel elements
numpy.ndarray
Rearanged matrix of kernel elements
Notes
-----
Expand Down Expand Up @@ -115,7 +116,8 @@ def pixel_pos(array_shape):
Returns
-------
list of pixel positions
list
Pixel positions
"""

Expand All @@ -131,7 +133,7 @@ class FetchStamps(object):
Parameters
----------
data : np.ndarray
data : numpy.ndarray
Input 2D data array
pixel_rad : tuple
Pixel radius in each dimension
Expand Down Expand Up @@ -248,7 +250,8 @@ def _stamp(self, pos, func=None, *args):
Returns
-------
np.ndarray postage stamp array or result of func
numpy.ndarray
Postage stamp array or result of func
Raises
------
Expand Down Expand Up @@ -280,7 +283,8 @@ def scan(self, func=None, *args, **kwargs):
Returns
-------
np.ndarray postage stamp arrays or results of func
numpy.ndarray
Postage stamp arrays or results of func
"""

Expand Down

0 comments on commit 2a280dc

Please sign in to comment.