manoharan-lab / holopy

Hologram processing and light scattering in python
GNU General Public License v3.0
133 stars 50 forks source link

How to define composite scatterers #414

Open zengqingwei519 opened 1 year ago

zengqingwei519 commented 1 year ago

s1 = Sphere(center=(15, 5, 5), n = 1.59, r = 2.0) s2 = Sphere(center=(10, 5, 5), n = 1.59, r = 1.5) collection = Spheres([s1, s2]) particles = Scatterers([s1,s2])

holo = calc_holo(detector, particles, medium_index, illum_wavelen, illum_polarization, theory=Mie)

Define with Spheres is ok. However, problems occur with Scatterers. Traceback (most recent call last): File "Holo_drops.py", line 21, in holo = calc_holo(detector, particles, medium_index, illum_wavelen, illum_polarization, theory=Mie) File "E:/3_ResWork/4_Particle_HO/Hologram_scattering/HoloPy-win\holopy\scattering\interface.py", line 205, in calc_holo scattered_field = imageformer.calculate_scattered_field(scatterer, uschema) File "E:/3_ResWork/4_Particle_HO/Hologram_scattering/HoloPy-win\holopy\scattering\imageformation.py", line 32, in calculate_scattered_field if scatterer.center is None: AttributeError: 'Scatterers' object has no attribute 'center'

Could anyone tell me how to define composite scatterers with Scatterers function?

vnmanoharan commented 9 months ago

Sorry for the very late response. Scatterers is really meant as a base class for other classes, like Spheres, which define the center property. Spheres should work fine in the example you show. If you want to make composite scatterers out of other objects, you can use Scatterers to do that, but you can't calculate holograms from a general Scatterers object because we currently have no theory that can be applied to a collection of heterogeneous objects.

This should be better documented.