optimize_pso#
- pyebsdindex.pcopt.optimize_pso(pats, indexer=None, PC0=None, batch=False, search_limit=0.2, early_exit=0.0001, nswarmparticles=30, pswarmpar=None, niter=50, return_cost=False, verbose=1)[source]#
Optimize pattern center (PC) (PCx, PCy, PCz) in the convention of the
indexer.vendorwith particle swarms.- Parameters:
- pats
numpy.ndarray EBSD pattern(s), of shape
(n detector rows, n detector columns), or(n patterns, n detector rows, n detector columns).- indexer
pyebsdindex.ebsd_index.EBSDIndexer EBSD indexer instance storing all relevant parameters for band detection.
- PC0
list,optional Initial guess of PC. If not given,
indexer.PCis used. Ifindexer.vendoris"EMSOFT", the PC must be four numbers, the final number being the pixel size.- batchbool,
optional Default is
Falsewhich indicates the fit for a set of patterns should be optimized using the cumulative fit for all the patterns, and one PC will be returned. IfTrue, then an optimization is run for each individual pattern, and an array of PC values is returned.- search_limit
float,optional Default is 0.2 for all PC values, and sets the +/- limit for the optimization search.
- early_exit: float, optional
Default is 0.0001 for all PC values, and sets a value for which the optimum is considered converged before the number of iterations is reached. The optimiztion will exit early if the velocity and distance of all the swarm particles is less than the early_exit value.
- nswarmparticles
int,optional Number of particles in a swarm. Default is 30.
- pswarmpar
dict,optional Particle swarm parameters “c1”, “c2”, and “w” with defaults 3.5, 3.5, and 0.8, respectively.
- niter
int,optional Number of iterations. Default is 50.
- return_costs: bool, optional
Set to True to return the cost value as well as the optimum fit PC.
- verbose
int,optional Whether to print the parameters and progress of the optimization (>= 1) or not (< 1). Default is to print.
- pats
- Returns:
numpy.ndarrayOptimized PC.