def _generateSubHarmonics(self, numberOfSubHarmonics): nSub = 3 lowFreqScreen = np.zeros((self._screenSzInPx, self._screenSzInPx), dtype=np.complex) freqX = bfft.frequencies_x_map(nSub, 1. / nSub) freqY = bfft.frequencies_y_map(nSub, 1. / nSub) freqMod = bfft.frequencies_norm_map(nSub, 1. / nSub) vv = np.arange(self._screenSzInPx) / self._screenSzInPx xx = np.tile(vv, (self._screenSzInPx, 1)) yy = xx.T depth = 0 while depth < numberOfSubHarmonics: depth += 1 phase = self._randomPhase() freqMod /= nSub freqX /= nSub freqY /= nSub modul = self._kolmogorovAmplitudeMap(freqMod) for ix in range(nSub): for jx in range(nSub): sh = np.exp(2 * np.pi * 1j * (xx * freqX[ix, jx] + yy * freqY[ix, jx] + phase[ix, jx])) sh0 = sh.sum() / self._screenSzInPx**2 lowFreqScreen += 1. / nSub**depth * modul[ix, jx] * (sh - sh0) lowFreqScreen *= np.sqrt(0.0228) * self._screenSzInPx**(5. / 6) return lowFreqScreen
def __init__(self, dPupInMeters, r0At500nm, wavelenghtInMeters, dPupInPixels=1024, outerScaleInMeter=1e6): self._pupDiameterInMeters = dPupInMeters self._r0 = r0At500nm self._lambda = wavelenghtInMeters self._pupDiameterInPixels = dPupInPixels self._L0 = outerScaleInMeter self._tb = TurbulentPhase() self._pxSize = self._pupDiameterInMeters / self._pupDiameterInPixels self._spat_freqs = bfft.frequencies_norm_map(self._pupDiameterInPixels, self._pxSize) self._dist = bfft.distances_norm_map(self._pupDiameterInPixels, self._pxSize) self._mapCenter = (np.asarray(self._dist.shape) / 2).astype(np.int) self._psd = self._tb.vonKarmanPowerSpectralDensity( self._r0, self._L0, self._spat_freqs) self._phaseAC = bfft.direct_transform(self._psd).real self._phaseSTF = 2 * ( self._phaseAC[self._mapCenter[0], self._mapCenter[1]] - self._phaseAC) self._kolmSTFInRad2 = 6.88 * ( self._dist / r0AtLambda(self._r0, self._lambda))**(5 / 3)
def testFrequenciesMapEven(self): sz = 100 pixelSize = 1.0 freqs = bfft.frequencies_norm_map(sz, pixelSize) self._checkFrequenciesNormMap(freqs, sz, pixelSize)
def testFrequenciesMapEvenWithPixelSize(self): sizeInPoints = 100 pxSize = 0.1 freqs = bfft.frequencies_norm_map(sizeInPoints, pxSize) self._checkFrequenciesNormMap(freqs, sizeInPoints, pxSize)