1

I want to pass my dictionary "param1" as the keywords of my function "simulate_x_y"

Here is what I got so far, but I never used dict that way before so I don't no how to link it with my function.

myparam1 = {"amp":1*10**-12, "amp2":1*10**-12, "sfreq":1000, "nse_amp": 1,
          "noise_mu": -1.60350220266e-29, "nse_kappa": 2.49419166853e-13,
          "phase_mu": np.abs(np.deg2rad(45)), "phase_kappa": 10.,
          "n_epochs":120, "epoch_length": 1, "nfft":512, "freq1_start": 150,
          "freq1_end": 220, "freq2_start": 150, "freq1_end": 220}

times = np.arange(0,epoch_length,1/(sfreq))

freq_band1 = np.linspace(freq1_start, freq1_end, times.size)
freq_band2 = np.linspace(freq2_start, freq2_end, times.size)

def simulate_x_y(times, param1['n_epochs'], amp, amp2, freq_band1, freq_band2, phase_mu, phase_kappa, nse_amp, noise_mu, nse_kappa):
    x  = np.zeros((n_epochs, times.size))
    y  = np.zeros((n_epochs, times.size))
    phase_shift_y =  np.random.vonmises(phase_mu, phase_kappa, n_epochs)
    for i in range(0, n_epochs):
        print("Simulating Epoch %s complete"%(i+1))
        for j in xrange(freq1_start,freq1_end):
            x[i] = x[i] + (amp  * np.sin(2 * np.pi * freq_band1 * times))
            y[i] = y[i] + (amp2 * np.sin(2 * np.pi * freq_band2 * times))
        x[i] = x[i] + nse_amp * np.random.normal(loc=noise_mu, scale= nse_kappa, size=times.size)
        y[i] = y[i] + (nse_amp * np.random.normal(loc=noise_mu, scale= nse_kappa, size=times.size)) + phase_shift_y[i]
    return x, y, phase_shift_y

Does anyone know how to do it properly, all my approaches fail because I don't know how to do it. anyone has a code snippet or example in an adequate form for me ?!

Daniel Velden
  • 179
  • 2
  • 17

0 Answers0