bbrozyna / light-propagation

Python lib to calculate diffraction structures and light propagation
MIT License
1 stars 2 forks source link

Backing Data Structure #3

Closed micdol closed 2 years ago

micdol commented 2 years ago

All the calculations should be carried out on single data structure as input/output.

This structure:

I am not sure whether all of that make sens but maybe it will be easier to discuss if you see usage I have in mind

re = propagation.load(re = 're.png', im = 0)
im = propagation.load(re = 0, im = 'im.png')

field = re + im
init_field = field #deep copy? 

#dummy ASD
propagation.fft(field, inplace=true)
field = field * propagation.kernel(distance = 0.3)
propagation.ifft(field, inplace=true)

#but also
propagator = propagation.get_propagator_for(type = 'ASD')
back_propagated_field = propagator.propagate(field, distance = -0.3, inplace = false)

assert back_propagated_field == init_field

I am wondering where to draw a line between which math operations should be members of field class and which should be utility methods in the propagation namespace. I'd consider cv::Mat as a good reference.

Some other properties to consider

field.intensity() -> [re**2+im**2, 1]? field.abs() -> #[sqrt(re**2 + im**2, 1]? field.re() -> #[re, 0] field.im() -> #[0, im] field.arg() -> [atan2(im/re), 1]??? so mod 2π, how would it differ from field.phase() should you decide on adding that one?

bbrozyna commented 2 years ago

Good ideas, will be done in : #2 in light_prop/lightfield.py