Skip to content

Commit

Permalink
add rytov and base propagators
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Feb 6, 2019
1 parent cb53785 commit a391039
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
5 changes: 5 additions & 0 deletions cellsino/propagators/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .rytov import Rytov

available = [Rytov]

dictionary = {"rytov": Rytov}
35 changes: 35 additions & 0 deletions cellsino/propagators/base_propagator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import abc

import numpy as np

from ..elements import Sphere


class BasePropagator(object):
__metaclass__ = abc.ABCMeta

def __init__(self, phantom, wavelength, pixel_size, grid_size):
"""Base propagator
Notes
-----
- The origin of the coordinate system is the center of the grid.
For even grid sizes, the origin is between two pixels. For odd
grid sizes the origin coincides with the center pixel.
"""
self.phantom = phantom
self.wavelength = wavelength
self.pixel_size = pixel_size
self.grid_size = grid_size
self.center = np.array(self.grid_size) / 2 - .5

def propagate(self):
field = np.ones(self.grid_size, dtype=np.complex256)
for element in self.phantom:
if isinstance(element, Sphere):
field *= self.propagate_sphere(element)
return field

@abc.abstractmethod
def propagate_sphere(self, sphere):
pass
18 changes: 18 additions & 0 deletions cellsino/propagators/rytov.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import qpsphere

from .base_propagator import BasePropagator


class Rytov(BasePropagator):
"""Rytov approximation"""

def propagate_sphere(self, sphere):
center = self.center + sphere.points[0]/self.pixel_size
qpi = qpsphere.models.rytov(radius=sphere.radius,
sphere_index=sphere.object_index,
medium_index=sphere.medium_index,
wavelength=self.wavelength,
pixel_size=self.pixel_size,
grid_size=self.grid_size,
center=center)
return qpi.field
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
license="MIT",
description=description,
long_description=open('README.rst').read() if exists('README.rst') else '',
install_requires=["qpimage",
install_requires=["h5py>=2.7.0",
"qpimage",
"qpsphere",
"numpy>=1.12.0",
],
Expand Down

0 comments on commit a391039

Please sign in to comment.