Fix prep scaling and fix comments

tags/nilmtools-1.1.2
Jim Paris 10 years ago
parent
commit
f978823505
1 changed files with 7 additions and 5 deletions
1. +7
-5
src/prep.py

+ 7 - 5 src/prep.pyView File

 @@ -84,7 +84,9 @@ def process(data, interval, args, insert_function, final): # Pull out sinefit data for the entire time range of this block for sinefit_line in client.stream_extract(sinefit_path, data[0, 0], data[rows-1, 0]): # Extract sinefit data to get zero crossing timestamps # Extract sinefit data to get zero crossing timestamps. # t_min = beginning of period # t_max = end of period (t_min, f0, A, C) = [ float(x) for x in sinefit_line.split() ] t_max = t_min + 1e6 / f0 @@ -102,20 +104,20 @@ def process(data, interval, args, insert_function, final): # Perform FFT over those indices N = idx_max - idx_min d = data[idx_min:idx_max, column] F = scipy.fftpack.fft(d) / N F = scipy.fftpack.fft(d) * 2.0 / N # If we wanted more harmonics than we have, pad with zeros # If we wanted more harmonics than the FFT gave us, pad with zeros if N < (nharm * 2): F = r_[F, zeros(nharm * 2 - N)] # Fill output data # Fill output data. out[0, 0] = t_min for k in range(nharm): Fk = F[2 * k + 1] * e**(rotation * 1j * (k+1)) out[0, 2 * k + 1] = -imag(Fk) # Pk out[0, 2 * k + 2] = real(Fk) # Qk # Insert it and continue # Insert this point and continue insert_function(out) processed = idx_max