MCPcopy Create free account
hub / github.com/NanoComp/meep / pixel_volume

Function pixel_volume

python/binary_partition_utils.py:103–117  ·  view source on GitHub ↗

Computes the number of pixels contained in a 2D or 3D grid_volume object. NOTE: This assumes that z=0 means 2D simulation and z>0 means 3D. Args: grid_volume: a meep grid_volume object Returns: The 2D or 3D number of pixels in the grid_volume.

(grid_volume: mp.grid_volume)

Source from the content-addressed store, hash-verified

101
102
103def pixel_volume(grid_volume: mp.grid_volume) -> int:
104 """Computes the number of pixels contained in a 2D or 3D grid_volume object.
105
106 NOTE: This assumes that z=0 means 2D simulation and z>0 means 3D.
107
108 Args:
109 grid_volume: a meep grid_volume object
110
111 Returns:
112 The 2D or 3D number of pixels in the grid_volume.
113 """
114 if grid_volume.nz() > 0: # we're in a 3D simulation
115 return grid_volume.nx() * grid_volume.ny() * grid_volume.nz()
116 else: # 2D simulation
117 return grid_volume.nx() * grid_volume.ny()
118
119
120def get_total_volume(

Callers 2

get_total_volumeFunction · 0.85

Calls 3

nzMethod · 0.80
nxMethod · 0.80
nyMethod · 0.80

Tested by

no test coverage detected