-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb53785
commit a391039
Showing
4 changed files
with
60 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .rytov import Rytov | ||
|
||
available = [Rytov] | ||
|
||
dictionary = {"rytov": Rytov} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters