Exemple #1
0
def calculate(binning=1):
    out = None

    for i in range(NRUN):

        print("Run {}/{}".format(i + 1, NRUN))

        importlib.reload(dual_video_simulator)  #recreates iterator

        #reset seed... because we use seed(0) in dual_video_simulator
        seed(i)

        t1, t2 = dual_video_simulator.t1, dual_video_simulator.t2

        video = multiply(dual_video_simulator.video, window_video)

        #: if the intesity of light source flickers you can normalize each frame to the intensity of the frame
        #video = normalize_video(video)

        #: perform rfft2 and crop results, to take only first kimax and first kjmax wavenumbers.
        fft = rfft2(video, kimax=51, kjmax=0)

        #: you can also normalize each frame with respect to the [0,0] component of the fft
        #: this it therefore equivalent to  normalize_video
        #fft = normalize_fft(fft)

        #: now perform auto correlation calculation with default parameters and show live
        data, bg, var = iccorr_multi(fft,
                                     t1,
                                     t2,
                                     level_size=16,
                                     binning=binning,
                                     period=PERIOD,
                                     auto_background=True)
        #perform normalization and merge data

        #5 and 7 are redundand, but we are calulating it for easier indexing
        for norm in (1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15):

            fast, slow = normalize_multi(data, bg, var, norm=norm, scale=True)

            #we merge with binning (averaging) of linear data enabled/disabled
            x, y = log_merge(fast, slow, binning=binning)

            if out is None:
                out = np.empty(shape=(NRUN, 16) + y.shape, dtype=y.dtype)
                out[0, norm] = y
            else:
                out[i, norm] = y

    return x, out
from cddm.multitau import iccorr_multi, normalize_multi, log_merge
import matplotlib.pyplot as plt

from conf import PERIOD

import cross_correlate_multi_live
import importlib
importlib.reload(cross_correlate_multi_live)  #recreates fft iterator

t1, t2 = cross_correlate_multi_live.t1, cross_correlate_multi_live.t2
fft = cross_correlate_multi_live.fft

#: now perform auto correlation calculation with default parameters and show live
data, bg, var = iccorr_multi(fft,
                             t1,
                             t2,
                             period=PERIOD,
                             chunk_size=128,
                             auto_background=True)
i, j = 4, 15

#: plot the results
for norm in (1, 2, 3, 5, 6, 7, 9, 10, 11, 13, 14, 15):
    fast, slow = normalize_multi(data, bg, var, norm=norm, scale=True)
    x, y = log_merge(fast, slow)
    plt.semilogx(x, y[i, j], label="norm = {}".format(norm))

plt.xlabel("t")
plt.ylabel("G / Var")
plt.legend()
plt.show()
Exemple #3
0
#:perform the actual multiplication
video = multiply(video, window_video)

#: if the intesity of light source flickers you can normalize each frame to the intensity of the frame
#video = normalize_video(video)

#: perform rfft2 and crop results, to take only first kimax and first kjmax wavenumbers.
fft = rfft2(video, kimax = KIMAX, kjmax = KJMAX)

#: you can also normalize each frame with respect to the [0,0] component of the fft
#: this it therefore equivalent to  normalize_video
#fft = normalize_fft(fft)

fft = play_threaded(fft)

if __name__ == "__main__":
    import os.path as p

    #we will show live calculation with the viewer
    viewer = MultitauViewer(scale = True)
    
    #initial mask parameters
    viewer.k = 15
    viewer.sector = 30
    
    #: now perform auto correlation calculation with default parameters and show live
    data, bg, var = iccorr_multi(fft, t1, t2, period = PERIOD, viewer = viewer)


    viewer.show()
from cddm.video import mask
from cddm.multitau import iccorr_multi
from cddm.viewer import MultitauViewer

from examples.mask_array import mask as m
import examples.cross_correlate_multi_live as cross_correlate_multi_live
import importlib
importlib.reload(cross_correlate_multi_live)  #recreates fft iterator

t1, t2 = cross_correlate_multi_live.t1, cross_correlate_multi_live.t2
fft = cross_correlate_multi_live.fft

fft_masked = mask(fft, mask=m)

data, bg, var = iccorr_multi(fft_masked,
                             t1,
                             t2,
                             period=cross_correlate_multi_live.PERIOD)

#: or this
#data, bg, var = iccorr_multi(fft, t1, t2, period = cross_correlate_multi_live.PERIOD,
#                             mask = m)

#: inspect the data
viewer = MultitauViewer(scale=True, mask=m)
viewer.set_data(data, bg, var)
viewer.set_mask(k=25, angle=0, sector=180)
viewer.plot()
viewer.show()