Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/brandondube/prysm into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
brandondube committed Sep 2, 2018
2 parents b5861d2 + 4bab899 commit 95b0fbc
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
39 changes: 30 additions & 9 deletions prysm/_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,38 @@ def __init__(self, unit_x, unit_y, phase, phase_unit, spatial_unit, wavelength=N
self.unit_y = unit_y
self.phase = phase
self.wavelength = wavelength
pul, sul = phase_unit.lower(), spatial_unit.lower()
if pul not in self.units:
raise ValueError(f'{pul} not a valid unit, must be in {set(self.units.keys())}')
if sul not in self.units:
raise ValueError(f'{sul} not a valid unit, must be in {set(self.units.keys())}')
self.phase_unit = self.units[phase_unit.lower()]
self.spatial_unit = self.units[spatial_unit.lower()]
self.phase_unit = phase_unit
self.spatial_unit = spatial_unit
self.center_x = len(self.unit_x) // 2
self.center_y = len(self.unit_y) // 2
self.sample_spacing = unit_x[1] - unit_x[0]

@property
def phase_unit(self):
return self._phase_unit

@phase_unit.setter
def phase_unit(self, unit):
unit = unit.lower()
if unit == 'å':
self._phase_unit = unit.upper()
else:
if unit not in self.units:
raise ValueError(f'{unit} not a valid unit, must be in {set(self.units.keys())}')
self._phase_unit = self.units[unit]

@property
def spatial_unit(self):
return self._spatial_unit

@spatial_unit.setter
def spatial_unit(self, unit):
unit = unit.lower()
if unit not in self.units:
raise ValueError(f'{unit} not a valid unit, must be in {set(self.units.keys())}')

self._spatial_unit = self.units[unit]

@property
def slice_x(self):
"""Retrieve a slice through the X axis of the phase.
Expand Down Expand Up @@ -171,7 +192,7 @@ def change_phase_unit(self, to, inplace=True):
new_phase = self.phase / fctr
if inplace:
self.phase = new_phase
self.phase_unit = self.units[to.lower()]
self.phase_unit = to
return self
else:
return new_phase
Expand Down Expand Up @@ -204,7 +225,7 @@ def change_spatial_unit(self, to, inplace=True):
if inplace:
self.unit_x = new_ux
self.unit_y = new_uy
self.spatial_unit = self.units[to.lower()]
self.spatial_unit = to
self.sample_spacing /= fctr
return self
else:
Expand Down
2 changes: 1 addition & 1 deletion prysm/psf.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def plot_encircled_energy(self, axlim=None, npts=50, fig=None, ax=None):
elif axlim is 0:
raise ValueError('computing from 0 to 0 is stupid')
else:
xx = m.linspace(0, axlim, npts)
xx = m.linspace(1e-5, axlim, npts)
yy = self.encircled_energy(xx)

fig, ax = share_fig_ax(fig, ax)
Expand Down

0 comments on commit 95b0fbc

Please sign in to comment.