batch_report.ipf in Igor Pro
Every wave matching a pattern, measured into one table and one figure.
#pragma TextEncoding = "UTF-8"
#pragma rtGlobals = 3
Function BatchReport(String pattern)
String list = WaveList(pattern, ";", "TEXT:0")
Variable n = ItemsInList(list)
if (n == 0)
Printf "nothing matches %s\r", pattern
return -1
endif
NewDataFolder/O root:Report
Make/O/T/N=(n) root:Report:names
Make/O/N=(n)/D root:Report:means, root:Report:sds, root:Report:peaks
WAVE/T names = root:Report:names
WAVE means = root:Report:means
WAVE sds = root:Report:sds
WAVE peaks = root:Report:peaks
Variable i
for (i = 0; i < n; i += 1)
String name = StringFromList(i, list)
WAVE w = $name
WaveStats/Q w
names[i] = name
means[i] = V_avg
sds[i] = V_sdev
peaks[i] = V_max
Printf "%-24s mean %8.4g sd %8.4g\r", name, V_avg, V_sdev
endfor
DoWindow/K ReportTable
Edit/N=ReportTable names, means, sds, peaks
DoWindow/K ReportGraph
Display/N=ReportGraph means vs names
ErrorBars means Y, wave=(sds, sds)
ModifyGraph mode=3, marker=19, rgb=(0, 0, 45000)
Label left, "Mean"
ModifyGraph tkLblRot(bottom)=90, tick(bottom)=3
WaveStats/Q means
TextBox/C/N=overall/A=LT "n = " + num2istr(n)
return 0
End
How it works
- The list of waves is a string, so the loop is over
StringFromList. - Results go into waves, because that is what Igor tables and graphs read.
- The summary is printed and drawn, so it survives leaving the experiment.
Keywords and builtins used here
DisplayDoWindowEditEndErrorBarsFunctionItemsInListLabelMakeModifyGraphNewDataFolderPrintfStringStringFromListTextBoxVariableWAVEWaveListWaveStatsendforendifforiifnum2istrreturnwave
The run, in numbers
- Lines
- 48
- Characters to type
- 1087
- Tokens
- 278
- Three-star pace
- 90 tpm
At the three-star pace of 90 tokens a minute, this run takes about 185 seconds.
Step 2 of 2 in Encore, step 16 of 16 in Waves & analysis.