Skip to content

Commit

Permalink
Continue working on docstrings for polar transform class
Browse files Browse the repository at this point in the history
Finished structure for parameters list to allow for multi-line, clear, concise descriptions.

Currently working on writing the documentation for the two conversion functions
  • Loading branch information
addisonElliott committed Mar 5, 2018
1 parent 7622af6 commit 0217663
Show file tree
Hide file tree
Showing 7 changed files with 202 additions and 103 deletions.
Binary file added docs/source/_static/centerAnnotations.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions docs/source/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.field-list p {
margin: 1em 0;
}
4 changes: 0 additions & 4 deletions docs/source/code.rst

This file was deleted.

35 changes: 20 additions & 15 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
import sys
sys.path.insert(0, os.path.abspath('../../'))

def setup(app):
app.add_stylesheet('css/custom.css')


# -- General configuration ------------------------------------------------

Expand All @@ -37,7 +40,8 @@
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinxcontrib.napoleon']
'numpydoc']
# 'sphinxcontrib.napoleon']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down Expand Up @@ -89,7 +93,8 @@
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
# html_theme = 'sphinx_rtd_theme'
html_theme = 'classic'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand All @@ -107,15 +112,15 @@
#
# This is required for the alabaster theme
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
html_sidebars = {
'**': [
'about.html',
'navigation.html',
'relations.html', # needs 'show_related': True theme option to display
'searchbox.html',
'donate.html',
]
}
# html_sidebars = {
# '**': [
# 'about.html',
# 'navigation.html',
# 'relations.html', # needs 'show_related': True theme option to display
# 'searchbox.html',
# 'donate.html',
# ]
# }


# -- Options for HTMLHelp output ------------------------------------------
Expand Down Expand Up @@ -174,8 +179,8 @@
'Miscellaneous'),
]




# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
intersphinx_mapping = {'https://docs.python.org/': None,
'numpy': ('http://docs.scipy.org/doc/numpy/', None),
'scipy': ('http://docs.scipy.org/doc/scipy/reference/', None),
'matplotlib': ('http://matplotlib.sourceforge.net/', None)}
2 changes: 2 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Welcome to polar-transform's documentation!
:maxdepth: 2
:caption: Contents:

modules



Indices and tables
Expand Down
4 changes: 2 additions & 2 deletions docs/source/polarTransform.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
polarTransform module
=====================
Documentation for the Code
==========================

.. automodule:: polarTransform
:members:
Expand Down
257 changes: 175 additions & 82 deletions polarTransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ def getCartesianPoints2(r, theta, center):


def getPolarPoints(xy, center):
"""
:param xy: Test
:param center: Test
:return: Test
"""
if xy.ndim == 2:
cX, cY = xy[:, 0] - center[0], xy[:, 1] - center[1]
else:
Expand Down Expand Up @@ -137,6 +131,41 @@ def getPolarPointsImage(points, settings):


def getCartesianPointsImage(points, settings):
"""
:param path: The path of the file to wrap
:type path: str
:param path2: The path of the file to wrap
:type path2: :class:`str`, :class:`float`, :class:`bool`, :class:`tuple` of :class:`int`, :class:`list` of
:class:`int`, optional
:param path3: The path of the file to wrap
:type path3: str
:type path3: float
:type path3: ``bool``
:type path3: ImageTransform
:param path4: The path of the file to wrap
Make this a bit longer to see how things goes.
| Double enter here
* list
* list
* list
* list
| Another text
:type path4: :class:`numpy.ndarray`
:param field_storage: The :class:`FileStorage` instance to wrap
:type field_storage: FileStorage
:param temporary: Whether or not to delete the file when the File
instance is destructed
:type temporary: bool
:returns: A buffered writable file descriptor
:rtype: BufferedFileStorage
"""
# Convert points to NumPy array
points = np.asanyarray(points)

Expand Down Expand Up @@ -185,64 +214,76 @@ def convertToPolarImage(image, center=None, initialRadius=None, finalRadius=None
settings=None):
"""Convert cartesian image to polar image.
Using a cartesian image, this function creates a polar domain image where the first dimension is radius and
second dimension is the angle. This function is versatile because it allows different starting and stopping
radii and angles to extract the polar region you are interested in.
Parameters
----------
image : (N, M, 3) or (N, M, 4) `numpy.ndarray`
Cartesian image to convert to polar domain
center : `str` or (2,) `list`, `tuple` or `numpy.ndarray` of `int`, optional
Specifies the center in the cartesian image to use as the origin in polar domain.
The center in the cartesian domain will be (0, 0) in the polar domain.
If center is not set, then it will be set to 'middle-middle'
TODO Make a table!
Center can be one of the following string values:
* top-left - Displays Quadrant IV of cartesian image
* top-middle - Displays Quadrant III & IV of cartesian image
* top-right - Displays Quadrant III of cartesian image
* middle-left - Displays Quadrant I & IV of cartesian image
* middle-middle - Displays Quadrant I, II, III & IV of cartesian image
* middle-right - Displays Quadrant II & III of cartesian image
* bottom-left - Displays Quadrant I of cartesian image
* bottom-middle - Displays Quadrant I & II of cartesian image
* bottom-right - Displays Quadrant II of cartesian image
TODO Show an image that is annotated!
The center is set after the image size is set if the image size is None. The center is relative to the
image size.
initialRadius : `int`, optional
XXX
finalRadius : `int`, optional
XXX
initialAngle : `float`, optional
XXX
finalAngle : `float`, optional
XXX
radiusSize : `int`, optional
XXX
angleSize : `int`, optional
XXX
order : `int` (0-5), optional
XXX
border : {'constant', 'nearest', 'wrap', 'reflect'}, optional
XXX
TODO Point to Numpy thing map_coordinates
borderVal : same datatype as image, optional
XXX
TODO Link to image parameter
settings : `ImageTransform`, optional
XXX
Returns
-------
bool
Description of return value
Using a cartesian image, this function creates a polar domain image where the first dimension is radius and
second dimension is the angle. This function is versatile because it allows different starting and stopping
radii and angles to extract the polar region you are interested in.
Parameters
----------
image : (N, M, 3) or (N, M, 4) :class:`numpy.ndarray`
Cartesian image to convert to polar domain
center : :class:`str` or (2,) :class:`list`, :class:`tuple` or :class:`numpy.ndarray` of :class:`int`, optional
Specifies the center in the cartesian image to use as the origin in polar domain. The center in the
cartesian domain will be (0, 0) in the polar domain.
If center is not set, then it will default to ``middle-middle``. If the image size is :obj:`None`, the
center is calculated after the image size is determined.
For relative positioning within the image, center can be one of the string values in the table below. The
quadrant column contains the visible quadrants for the given center. initialAngle and finalAngle must contain
at least one of the quadrants, otherwise an error will be thrown because the resulting cartesian image is blank.
An example cartesian image is given below with annotations to what the center will be given a center string.
.. table:: Valid center strings
:widths: auto
================ =============== ====================
Value Quadrant Location in image
================ =============== ====================
top-left IV 1
top-middle III, IV 2
top-right III 3
middle-left I, IV 4
middle-middle I, II, III, IV 5
middle-right II, III 6
bottom-left I 7
bottom-middle I, II 8
bottom-right II 9
================ =============== ====================
.. image:: _static/centerAnnotations.png
:alt: Center locations for center strings
initialRadius : :class:`int`, optional
XXX
finalRadius : :class:`int`, optional
XXXXX
initialAngle : :class:`float`, optional
XXX
finalAngle : :class:`float`, optional
XXX
radiusSize : :class:`int`, optional
XXX
angleSize : :class:`int`, optional
XXX
order : :class:`int` (0-5), optional
XXXX
border : {'constant', 'nearest', 'wrap', 'reflect'}, optional
Refer to :func:`scipy.ndimage.interpolation.map_coordinates` for description.
TODO Point to Numpy thing map_coordinates
borderVal : same datatype as :any:`image`, optional
XXX
TODO Link to image parameter
settings : :class:`ImageTransform`, optional
XXX
Returns
-------
bool
Description of return value
"""

# Determines whether there are multiple bands or channels in image by checking for 3rd dimension
isMultiChannel = image.ndim == 3

Expand Down Expand Up @@ -370,26 +411,78 @@ def convertToCartesianImage(image, center=None, initialRadius=None,
finalRadius=None, initialAngle=None,
finalAngle=None, imageSize=None, order=3, border='constant',
borderVal=0.0, settings=None):
'''Converts a polar image to the cartesian domain.
:param image: Numpy NxNx3 array
Polar image with origin in lower-left corner.
:param center: Numpy array, list, tuple, str or None
Center of cartesian image where r=0, theta=0 will be placed.
If None, then the center will be automatically determined based on imageSize and/or initial
:param initialRadius: int or None
Start radius of the polar image at which row 0 corresponds to. For example, if initial radius is set to 30, then row 0 of the polar image corresponds to a radius of 30.
:param finalRadius: int or None
End radius of the polar image at which the last row corresponds to. For example, if the final radius is set to 100, then the final row of the polar image corresponds to a radius of 100.
:param initialAngle: float or None
:param finalAngle: float or None
:param imageSize:
:param order:
:param border:
:param borderVal:
:param settings:
:return:
'''
"""Convert polar image to cartesian image.
Using a polar image, this function creates a cartesian image. This function is versatile because it can
automatically calculate an appropiate cartesian image size and center given the polar image. In addition,
parameters for converting to the polar domain are necessary for the conversion back to the cartesian domain.
Parameters
----------
image : (N, M, 3) or (N, M, 4) :class:`numpy.ndarray`
Cartesian image to convert to polar domain
center : :class:`str` or (2,) :class:`list`, :class:`tuple` or :class:`numpy.ndarray` of :class:`int`, optional
Specifies the center in the cartesian image to use as the origin in polar domain. The center in the
cartesian domain will be (0, 0) in the polar domain.
If center is not set, then it will default to ``middle-middle``. If the image size is :obj:`None`, the
center is calculated after the image size is determined.
For relative positioning within the image, center can be one of the string values in the table below. The
quadrant column contains the visible quadrants for the given center. initialAngle and finalAngle must contain
at least one of the quadrants, otherwise an error will be thrown because the resulting cartesian image is blank.
An example cartesian image is given below with annotations to what the center will be given a center string.
.. table:: Valid center strings
:widths: auto
================ =============== ====================
Value Quadrant Location in image
================ =============== ====================
top-left IV 1
top-middle III, IV 2
top-right III 3
middle-left I, IV 4
middle-middle I, II, III, IV 5
middle-right II, III 6
bottom-left I 7
bottom-middle I, II 8
bottom-right II 9
================ =============== ====================
.. image:: _static/centerAnnotations.png
:alt: Center locations for center strings
initialRadius : :class:`int`, optional
XXX
finalRadius : :class:`int`, optional
XXXXX
initialAngle : :class:`float`, optional
XXX
finalAngle : :class:`float`, optional
XXX
radiusSize : :class:`int`, optional
XXX
angleSize : :class:`int`, optional
XXX
order : :class:`int` (0-5), optional
XXXX
border : {'constant', 'nearest', 'wrap', 'reflect'}, optional
Refer to :func:`scipy.ndimage.interpolation.map_coordinates` for description.
TODO Point to Numpy thing map_coordinates
borderVal : same datatype as :any:`image`, optional
XXX
TODO Link to image parameter
settings : :class:`ImageTransform`, optional
XXX
Returns
-------
bool
Description of return value
"""
# Determines whether there are multiple bands or channels in image by checking for 3rd dimension
isMultiChannel = image.ndim == 3

Expand Down

0 comments on commit 0217663

Please sign in to comment.