@@ -108,7 +108,69 @@ Note that the NDArrays being received are now [4, 2000].
108108
109109The filename is changed to quadEM_HDF5_ROI_001.h5. The resulting file size is 13 MB.
110110
111+ The following is an IDL program to process the data in quadEM_HDF5_001.h5.
112+ The program does the following:
113+
114+ - Reads the dataset /entry/data/data into a variable called `data `.
115+ - Displays information about 'data'.
116+ - Reformats 'data' from a 3-D array with dimensions [11, 2000, 200] to a 2-D array with dimensions [11, 400000].
117+ - Extracts the SumAll data into a variable called 'sum_all', which the 6'th column of 'data'.
118+ - Compute a 'time' array variable which is the time of each sample. It is 400000 points with 50 microseconds per point.
119+ - Plots the first 0.5 seconds (1000 points) of 'sum_all' vs 'time'.
120+ - Computes the absolute value of the FFT of the 'sum_all' variable, which is the power spectrum.
121+ - Sets the first element (0 frequency, i.e. DC offset) to 0.
122+ - Computes the frequency acis, which is 200000 points going from 0 to the Nyquist freqency of 10 kHz.
123+ - Plots the power spectrum vs frequency. Plots only the first 20000 points, which is 0 to 1 kHz, on a vertical log scale.
124+
125+ This is the IDL code:
126+
127+ .. code-block :: idl
128+
129+ ; Program to read HDF5 file for streamed quadEM data, plot it
130+ data = h5_getdata('J:\epics\scratch\quadEM_HDF5_001.h5', '/entry/data/data')
131+ help, data
132+ ; Convert from a 3-D array [11, 2000, 200] to a 2-D array [11, 400000]
133+ data = reform(data, 11, 400000)
134+ ; Extract the SumAll data
135+ sum_all = data[6, *]
136+ ; Compute the time axis, 50 microseconds/sample
137+ time = findgen(400000) * 50e-6
138+ ; Plot the first 0.5 second of data
139+ p1 = plot(time[0:9999], sum_all[0:9999], xtitle='Time (s)', ytitle='Sum of all diodes (nA)', $
140+ title='Time Series', color='blue')
141+ p1.save, 'IDL_HDF5_time_plot.png'
142+ ; Compute the FFT
143+ f = fft(sum_all)
144+ ; Take the absolute value, first half of array
145+ f_abs = (abs(f))[0:199999]
146+ ; Set the DC offset to 0
147+ f_abs[0] = 0
148+ ; Compute the frequency axis. The sampling rate is 20 kHz so the Nyquist frequency is 10 kHz
149+ freq = findgen(200000)/199999. * 10000.
150+ ; Plot the data out to 1 kHz
151+ p2 = plot(freq[0:19999], f_abs[0:199999], xtitle='Frequency (Hz)', ytitle='SumAll Intensity', $
152+ title='Power Spectrum', color='red', /ylog, yrange=[.01,100])
153+ p2.save, 'IDL_HDF5_frequency_plot.png'
154+ end
155+
156+ This is the output when the program is compiled and run:
157+
158+ .. code-block :: idl
159+
160+ IDL> .compile -v 'C:\Scratch\plot_quadem.pro'
161+ IDL> .go
162+ DATA DOUBLE = Array[11, 2000, 200]
163+
164+ This is the time-series plot. The data are highly periodic because the photodiodes were illuminated
165+ by fluorescent lights.
166+
167+ .. figure :: IDL_HDF5_time_plot.png
168+ :align: center
111169
170+ |
112171
172+ This is the frequency plot. The frequency peaks are almost exclusively 60 Hz and its odd and even harmonics.
173+ The odd harmonics are ~10-100 times less than 60Hz, and the even harmonics are ~100-1000 times less than 60 Hz.
113174
114-
175+ .. figure :: IDL_HDF5_frequency_plot.png
176+ :align: center
0 commit comments