proxtoolbox.experiments.phase package¶
This subpackage contains the phase experiments.
Submodules¶
proxtoolbox.experiments.phase.CDI_Experiment module¶
-
class
proxtoolbox.experiments.phase.CDI_Experiment.
CDI_Experiment
(warmup_iter=0, **kwargs)[source]¶ Bases:
proxtoolbox.experiments.phase.phaseExperiment.PhaseExperiment
CDI experiment class
-
static
getDefaultParameters
()[source]¶ Return the default parameters used by this experiment. The name of the parameters must match the arguments of the __init__() methods of the Experiment class and/or derived classes. Essentially this corresponds to the old config files. This static method must be implemented in the derived classes (the implementation given here only throws an exception). See example below.
Returns: - dictionary
Default parameters to be used for this experiment. Each entry must match an argument from the __init__() methods of the Experiment class and/or derived classes.
Notes
The following shows a typical implementation of this method:
@staticmethod def getDefaultParameters():
- defaultParams = {
- ‘object’: ‘complex’, ‘constraint’: ‘amplitude only’, ‘distance’: ‘far field’, ‘Nx’: 128, ‘Ny’: 128, ‘Nz’: 1, ‘product_space_dimension’: 4, ‘MAXIT’: 6000, ‘TOL’: 5e-5, ‘lambda_0’: 0.85, ‘lambda_max’: 0.85, ‘lambda_switch’: 20, ‘data_ball’: 1e-30, ‘diagnostic’: True, ‘iterate_monitor_name’: ‘FeasibilityIterateMonitor’, ‘verbose’: 1, ‘graphics’: 1, ‘anim’: False
} return defaultParams
-
static
proxtoolbox.experiments.phase.CDP_Experiment module¶
-
class
proxtoolbox.experiments.phase.CDP_Experiment.
CDP_Experiment
(warmup_iter=0, **kwargs)[source]¶ Bases:
proxtoolbox.experiments.phase.phaseExperiment.PhaseExperiment
CDP experiment class
-
static
getDefaultParameters
()[source]¶ Return the default parameters used by this experiment. The name of the parameters must match the arguments of the __init__() methods of the Experiment class and/or derived classes. Essentially this corresponds to the old config files. This static method must be implemented in the derived classes (the implementation given here only throws an exception). See example below.
Returns: - dictionary
Default parameters to be used for this experiment. Each entry must match an argument from the __init__() methods of the Experiment class and/or derived classes.
Notes
The following shows a typical implementation of this method:
@staticmethod def getDefaultParameters():
- defaultParams = {
- ‘object’: ‘complex’, ‘constraint’: ‘amplitude only’, ‘distance’: ‘far field’, ‘Nx’: 128, ‘Ny’: 128, ‘Nz’: 1, ‘product_space_dimension’: 4, ‘MAXIT’: 6000, ‘TOL’: 5e-5, ‘lambda_0’: 0.85, ‘lambda_max’: 0.85, ‘lambda_switch’: 20, ‘data_ball’: 1e-30, ‘diagnostic’: True, ‘iterate_monitor_name’: ‘FeasibilityIterateMonitor’, ‘verbose’: 1, ‘graphics’: 1, ‘anim’: False
} return defaultParams
-
createTestImage
(config) Creates a randomly generated image and masks for comparison with Matlab. These numbers where generated by Matlab's CDP_processor() code using the random number generator seed 1234 (by calling rng(1234) before the image generation code)[source]¶ Creates a randomly generated image and masks for comparison with Matlab. These numbers where generated by Matlab’s CDP_processor() code using the random number generator seed 1234 (by calling rng(1234) before the image generation code)
Returns: - image : ndarray
2-D array of randomly generated complex numbers
- masks : ndarray
2-D array masks
- z0 : ndarray
initial guess
-
static
-
proxtoolbox.experiments.phase.CDP_Experiment.
randn
(d0, d1, ..., dn)¶ Return a sample (or samples) from the “standard normal” distribution.
If positive, int_like or int-convertible arguments are provided, randn generates an array of shape
(d0, d1, ..., dn)
, filled with random floats sampled from a univariate “normal” (Gaussian) distribution of mean 0 and variance 1 (if any of the \(d_i\) are floats, they are first converted to integers by truncation). A single float randomly sampled from the distribution is returned if no argument is provided.This is a convenience function. If you want an interface that takes a tuple as the first argument, use numpy.random.standard_normal instead.
Parameters: - d0, d1, …, dn : int, optional
The dimensions of the returned array, should be all positive. If no argument is given a single Python float is returned.
Returns: - Z : ndarray or float
A
(d0, d1, ..., dn)
-shaped array of floating-point samples from the standard normal distribution, or a single such float if no parameters were supplied.
See also
standard_normal
- Similar, but takes a tuple as its argument.
Notes
For random samples from \(N(\mu, \sigma^2)\), use:
sigma * np.random.randn(...) + mu
Examples
>>> np.random.randn() 2.1923875335537315 #random
Two-by-four array of samples from N(3, 6.25):
>>> 2.5 * np.random.randn(2, 4) + 3 array([[-4.49401501, 4.00950034, -1.81814867, 7.29718677], #random [ 0.39924804, 4.68456316, 4.99394529, 4.84057254]]) #random
-
proxtoolbox.experiments.phase.CDP_Experiment.
random_sample
(size=None)¶ Return random floats in the half-open interval [0.0, 1.0).
Results are from the “continuous uniform” distribution over the stated interval. To sample \(Unif[a, b), b > a\) multiply the output of random_sample by (b-a) and add a:
(b - a) * random_sample() + a
Parameters: - size : int or tuple of ints, optional
Output shape. If the given shape is, e.g.,
(m, n, k)
, thenm * n * k
samples are drawn. Default is None, in which case a single value is returned.
Returns: - out : float or ndarray of floats
Array of random floats of shape size (unless
size=None
, in which case a single float is returned).
Examples
>>> np.random.random_sample() 0.47108547995356098 >>> type(np.random.random_sample()) <type 'float'> >>> np.random.random_sample((5,)) array([ 0.30220482, 0.86820401, 0.1654503 , 0.11659149, 0.54323428])
Three-by-two array of random numbers from [-5, 0):
>>> 5 * np.random.random_sample((3, 2)) - 5 array([[-3.99149989, -0.52338984], [-2.99091858, -0.79479508], [-1.23204345, -1.75224494]])
proxtoolbox.experiments.phase.JWST_Experiment module¶
-
class
proxtoolbox.experiments.phase.JWST_Experiment.
JWST_Experiment
(**kwargs)[source]¶ Bases:
proxtoolbox.experiments.phase.phaseExperiment.PhaseExperiment
JWST experiment class
-
static
getDefaultParameters
()[source]¶ Return the default parameters used by this experiment. The name of the parameters must match the arguments of the __init__() methods of the Experiment class and/or derived classes. Essentially this corresponds to the old config files. This static method must be implemented in the derived classes (the implementation given here only throws an exception). See example below.
Returns: - dictionary
Default parameters to be used for this experiment. Each entry must match an argument from the __init__() methods of the Experiment class and/or derived classes.
Notes
The following shows a typical implementation of this method:
@staticmethod def getDefaultParameters():
- defaultParams = {
- ‘object’: ‘complex’, ‘constraint’: ‘amplitude only’, ‘distance’: ‘far field’, ‘Nx’: 128, ‘Ny’: 128, ‘Nz’: 1, ‘product_space_dimension’: 4, ‘MAXIT’: 6000, ‘TOL’: 5e-5, ‘lambda_0’: 0.85, ‘lambda_max’: 0.85, ‘lambda_switch’: 20, ‘data_ball’: 1e-30, ‘diagnostic’: True, ‘iterate_monitor_name’: ‘FeasibilityIterateMonitor’, ‘verbose’: 1, ‘graphics’: 1, ‘anim’: False
} return defaultParams
-
static
-
proxtoolbox.experiments.phase.JWST_Experiment.
rand
(d0, d1, ..., dn)¶ Random values in a given shape.
Create an array of the given shape and populate it with random samples from a uniform distribution over
[0, 1)
.Parameters: - d0, d1, …, dn : int, optional
The dimensions of the returned array, should all be positive. If no argument is given a single Python float is returned.
Returns: - out : ndarray, shape
(d0, d1, ..., dn)
Random values.
See also
random
Notes
This is a convenience function. If you want an interface that takes a shape-tuple as the first argument, refer to np.random.random_sample .
Examples
>>> np.random.rand(3,2) array([[ 0.14022471, 0.96360618], #random [ 0.37601032, 0.25528411], #random [ 0.49313049, 0.94909878]]) #random
proxtoolbox.experiments.phase.Krueger_Experiment module¶
-
class
proxtoolbox.experiments.phase.Krueger_Experiment.
Krueger_Experiment
(**kwargs)[source]¶ Bases:
proxtoolbox.experiments.phase.phaseExperiment.PhaseExperiment
Krueger experiment class
-
static
getDefaultParameters
()[source]¶ Return the default parameters used by this experiment. The name of the parameters must match the arguments of the __init__() methods of the Experiment class and/or derived classes. Essentially this corresponds to the old config files. This static method must be implemented in the derived classes (the implementation given here only throws an exception). See example below.
Returns: - dictionary
Default parameters to be used for this experiment. Each entry must match an argument from the __init__() methods of the Experiment class and/or derived classes.
Notes
The following shows a typical implementation of this method:
@staticmethod def getDefaultParameters():
- defaultParams = {
- ‘object’: ‘complex’, ‘constraint’: ‘amplitude only’, ‘distance’: ‘far field’, ‘Nx’: 128, ‘Ny’: 128, ‘Nz’: 1, ‘product_space_dimension’: 4, ‘MAXIT’: 6000, ‘TOL’: 5e-5, ‘lambda_0’: 0.85, ‘lambda_max’: 0.85, ‘lambda_switch’: 20, ‘data_ball’: 1e-30, ‘diagnostic’: True, ‘iterate_monitor_name’: ‘FeasibilityIterateMonitor’, ‘verbose’: 1, ‘graphics’: 1, ‘anim’: False
} return defaultParams
-
static
proxtoolbox.experiments.phase.phaseExperiment module¶
-
class
proxtoolbox.experiments.phase.phaseExperiment.
PhaseExperiment
(distance='far field', farfield=True, **kwargs)[source]¶ Bases:
proxtoolbox.experiments.experiment.Experiment
Base class for phase experiments. Concrete phase retrieval experiments should derive from this class
-
reshapeData
(Nx, Ny, Nz)[source]¶ Reshape data based on the given arguments. This method is called during the initialization of the Experiment object, after the call to loadData().
Parameters: - Nx, Ny, Nz: int
The new dimensions to be used.
Notes
TODO: need to revisit this - there shouldn’t be any need for arguments
-