Regularizers¶
PtyLab.Regularizers
¶
std(field, aleph=0.01)
¶
min_std(*args, **kwargs)
¶
TV(field, aleph=0.001)
¶
Calculate Total Variation of a field.
Parameters¶
field: np.ndarray Optical field to process aleph: float Tiny constant to avoid dividing by zero
Returns¶
TV_value: float Total variation of the field.
Source code in PtyLab/Regularizers/__init__.py
metric_at(object_estimate, dz, dx, wavelength, ss=(slice(None, None), slice(None, None)), intensity_only=False, return_propagated=False, average_by_power=True, metric=TV, savemem=True)
¶
Return the value of a metric function over a range of distances given by dz.
Note on savemem
When savemem == False, the entire field is propagated and only afterwards a slice is extracted. This is the right way to do it for larger propagation distances. However, for small propagation distances a lot of time can be saved by only propagating the sliced area in the original, and for autofocusing typically only small amounts of propagation are required.
Parameters¶
object_estimate: np.ndarray the field that has to be propagated dz: np.ndarray Distances to propagate to dx: float Pixel size of the field wavelength: float Wavelength to be propagated at ss: Union[slice, slice] The region to propagate. intensity_only: bool Wether to only asses the intensity or the complex field return_propagated: bool If true, returns the propagated field average_by_power: bool Divide metric by the average intensity for every distance metric: Callable or string The quality metric to be employed. Should have signature function(x, eps) and return a single floating point number. Alternatively, one can provide 'TV', 'STD' or 'MIN_STD' as a metric and it will be mapped to the corresponding functions in this module. savemem: Save memory. Default true
Returns¶
Source code in PtyLab/Regularizers/__init__.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |