Cleaning up scatterpy's handling of coordinate inputs

Registered by Vinothan N. Manoharan

Scatterpy needs a simple and consistent way to handle coordinate inputs. Since scatterpy is independent of holopy, we should not assume that the scattered fields and intensities are to be calculated on a grid. For example, to model static light scattering data, the user might be interested in calculating the intensity at fixed angles, which might not be evenly spaced. Even when modeling data on a grid detector, the user might want to only calculate the scattering at a specific, arbitrary subset of pixel positions -- for example, when fitting.

This will involve changes to mieangfuncs.f90 and to ScatteringTheory and derived objects.

mieangfuncs:
Currently mieangfuncs.f90 allows one to calculate the fields (using either Mie or multisphere theories) on an MxNx3 array (kr, theta, phi). It also allows one to select a subset of these points by passing a mask array (MxN). A simpler way to implement both functionalities would be to have mie_fields_sph() and tmatrix_fields_sph() accept a Px3 array, where P is the number of points that are to be calculated. We can then delete the "selection" input to mie_fields_sph() and tmatrix_fields_sph(), since the calling function can simply pass an ndarray of 3-tuples corresponding to the appropriate points.

[Done by JF, 6/11/12]

ScatteringTheory and derived objects:
I recommend removing the phi and theta inputs to ScatteringTheory and instead having the various calc_ functions accept an ndarray of 3-tuples (kr, theta, phi) at which the fields/intensities/holograms should be calculated. This ndarray will be optional. If the user does not pass it to the function, the theory will use the Optics object to determine the detector geometry and use this to calculate the appropriate spherical coordinates. In the future, we can augment the Optics object to handle other kinds of (non-gridlike) detectors.

Fitting to random sets of pixels:
With these changes, it should be possible to implement fitting to random pixels at a higher level. We can eliminate the selection input to the various theory.calc_ functions and implement random fitting in the fit() function instead, perhaps by having fit() accept an argument that specifies what percentage of pixels should be chosen for the fit. Since we now know that random fitting works well, this should be a high priority.

These changes will help eliminate some entanglements between scatterpy and holopy, making it easier to use scatterpy for pure scattering calculations. For example, with the changes to the theory.calc_ functions, the user will be able to calculate form factors much more easily.

tgd 2012-06-10: I agree that the miangfuncs functions should move over to accepting a Px3 list of calculation coordinates. That will make the interface between the python and fortran simpler, cleaner, and more flexible.

currently the optics does not contain enough information to specify the detector fully, namely that it does not include the number of pixels the detector has. I guess there is no real reason you couldn't add it, but there are a few subtleties there, see my new optics blueprint. I do think it is important to keep it easy to calculate a simulated hologram for some detector (since that is one of the most common use cases of scatterpy for us (outside of fitting).

vnm 2012-06-10: scatterpy already uses the Optics object to determine the spherical coordinate grid (in _spherical_grid()), so the implementation of detector geometry in the Optics object is a separate issue, one that does not block this blueprint.

tgd 2012-06-11: Ok, so you are not proposing removing the ability to specify a square or rectangular shape when constructing a theory? If you are just suggesting replace the unused phi and theta inputs (I am not sure if those even work, no one uses them) as an alternative method of sepecifying output, that is not a problem at all.

Blueprint information

Status:
Complete
Approver:
Vinothan N. Manoharan
Priority:
Undefined
Drafter:
Vinothan N. Manoharan
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Implemented
Milestone target:
None
Started by
Tom Dimiduk
Completed by
Tom Dimiduk

Related branches

Sprints

Whiteboard

(?)

Work Items

Work items:
Modify mie_fields_sph() and tmatrix_fields_sph() in mieangfuncs to accept a Px3 array: DONE
Eliminate selection variable in mie_fields_sph() and tmatrix_fields_sph(): DONE
mie_fields_sph and tmatrix_fields_sph replaced with mie_fields and tmatrix_fields: DONE
Fitting Random Subsets of pixels: TODO

This blueprint contains Public information 
Everyone can see this information.