Skip to content

Commit

Permalink
Merge branch 'lessMemory'
Browse files Browse the repository at this point in the history
  • Loading branch information
relleums committed Jun 7, 2024
2 parents 035ee59 + 41be0fa commit 1749f24
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 24 deletions.
42 changes: 20 additions & 22 deletions plenopy/light_field_geometry/LightFieldGeometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def __init__(self, path):
self._read_lixel_positions(os.path.join(path, "lixel_positions.bin"))
self._read_lixel_statistics(os.path.join(path, "lixel_statistics.bin"))
self._calc_pixel_and_paxel_average_positions()
self._init_lixel_polygons()
self.valid_efficiency = self.most_efficient_lixels(0.95)
self._init_time_delay_image()

Expand Down Expand Up @@ -182,27 +181,6 @@ def _read_lixel_positions(self, path):
self.lixel_positions_x = lp[:, 0]
self.lixel_positions_y = lp[:, 1]

def _init_lixel_polygons(self):
s32 = np.sqrt(3) / 2.0

poly_template = np.array(
[
[0, 1],
[-s32, 0.5],
[-s32, -0.5],
[0, -1],
[s32, -0.5],
[s32, 0.5],
]
)
poly_template *= self.lixel_outer_radius

lixel_centers_xy = np.array(
[self.lixel_positions_x, self.lixel_positions_y]
)

self.lixel_polygons = [xy + poly_template for xy in lixel_centers_xy.T]

def most_efficient_lixels(self, fraction):
"""
Returns a boolean mask (shape=[numnper_pixel, number_paxel]) of
Expand Down Expand Up @@ -258,3 +236,23 @@ def __repr__(self):
out += str(self.number_paxel) + " paxel"
out += ")"
return out


def init_lixel_polygons(
lixel_positions_x, lixel_positions_y, lixel_outer_radius
):
s32 = np.sqrt(3) / 2.0
poly_template = np.array(
[
[0, 1],
[-s32, 0.5],
[-s32, -0.5],
[0, -1],
[s32, -0.5],
[s32, 0.5],
]
)
poly_template *= lixel_outer_radius
lixel_centers_xy = np.array([lixel_positions_x, lixel_positions_y])
lixel_polygons = [xy + poly_template for xy in lixel_centers_xy.T]
return lixel_polygons
10 changes: 9 additions & 1 deletion plenopy/plot/light_field_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from matplotlib.collections import PolyCollection
import os
import warnings
from ..light_field_geometry.LightFieldGeometry import init_lixel_polygons


def save_all(light_field_geometry, out_dir, figure_style=splt.FIGURE_16_9):
Expand Down Expand Up @@ -248,8 +249,15 @@ def colored_lixels(
linewidths=None,
):
warnings.warn(DeprecationWarning("Use ax_add_polygons_with_colormap()"))

lixel_polygons = init_lixel_polygons(
lixel_positions_x=lss.lixel_positions_x,
lixel_positions_y=lss.lixel_positions_y,
lixel_outer_radius=lss.lixel_outer_radius,
)

return ax_add_polygons_with_colormap(
polygons=lss.lixel_polygons,
polygons=lixel_polygons,
I=I,
ax=ax,
cmap=cmap,
Expand Down
2 changes: 1 addition & 1 deletion plenopy/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.2.10"
__version__ = "0.2.11"

0 comments on commit 1749f24

Please sign in to comment.