PEARL Procedures rev-distro-2.1.1-1-gf419e92-dirty Igor procedures for the analysis of PEARL data

pearl-data-explorer.ipf
Go to the documentation of this file.
1 #pragma rtGlobals=3 // Use modern global access method and strict wave access.
2 #pragma IgorVersion = 6.1
3 #pragma ModuleName = PearlDataExplorer
4 #pragma version = 1.50
5 #include "pearl-area-import"
6 #include "pearl-area-profiles"
7 #include "pearl-area-display"
8 #include "pearl-compat"
9 #include "pearl-pshell-import"
10 #if exists("MFR_OpenResultFile")
11 #include "pearl-matrix-import"
12 #endif
13
14 // copyright (c) 2013-16 Paul Scherrer Institut
15 //
16 // Licensed under the Apache License, Version 2.0 (the "License");
17 // you may not use this file except in compliance with the License.
18 // You may obtain a copy of the License at
19 // http:///www.apache.org/licenses/LICENSE-2.0
20
31
36
37 static strconstant package_name = "pearl_explorer"
38 static strconstant package_path = "root:packages:pearl_explorer:"
39
40 static strconstant ks_filematch_adh5 = "*.h5"
41 static strconstant ks_filematch_pshell = "psh*.h5"
42 static strconstant ks_filematch_itx = "*.itx"
43 static strconstant ks_filematch_mtrx = "*_mtrx"
44
45 function pearl_data_explorer()
46 init_package()
47 load_prefs()
48 execute /q/z "PearlDataExplorer()"
49 end
50
56 static function init_package()
57
58 dfref savefolder = GetDataFolderDFR()
59 SetDataFolder root:
60 newdatafolder /o/s packages
61 newdatafolder /o/s $package_name
62 if (exists("v_InitPanelDone") == 2)
63 SetDataFolder savefolder
64 return 0
65 endif
66
67 make /o/n=0/t wtFiles
68 make /o/n=0/i wSelectedFiles,wSelectedDatasets
69 make /o/n=0/t wtDatasets
70 make /o/n=0/t wtPositioners,wtDetectors
71 make /o/n=0/i wSelectedPositioners,wSelectedDetectors
72
73 make /o/n=(1,1) preview_image // preview 2D data
74 make /o/n=0 preview_trace // preview 1D data
75 make /o/n=0/t attr_names, attr_values, attr_filter, attr_filter_summary
76
77 // persistent strings and variables. persistent = saved in preferences
78 string /g s_filepath = "" // directory path to be listed
79 string /g s_hdf_options = "" // recently used HDF5 load options
80 string /g s_reduction_params = "" // recently used reduction parameters
81 string /g s_preview_pvs = "" // semicolon-separated list of EPICS PVs to display in preview.
82 // the list items can contain wildcards for StringMatch
83 s_preview_pvs = "*OP:CURRENT*;*Stats*Total*;*KEITHLEY*READOUT;*CADC*"
84
85 // non-persistent strings and variables
86 string /g s_preview_file = "" // file or folder name of the current preview
87 string /g s_preview_source = "" // data source, e.g. EPICS channel name, of the current preview
88 string /g s_profiles_graph = "" // window name of the current preview if the data is two-dimensional
89 string /g s_preview_trace_graph = "" // window name of the current preview if the data is one-dimensional
90 string /g s_file_info = "" // description of selected file
91
92 variable/g v_InitPanelDone = 1
93
94 SetDataFolder savefolder
95 end
96
102 static function save_prefs()
103 dfref saveDF = GetDataFolderDFR()
104 dfref df = $package_path
105 if (DataFolderRefStatus(df) == 1)
106 string fullPath = SpecialDirPath("Packages", 0, 0, 0)
107 fullPath += package_name
108 NewPath/O/C/Q tempPackagePrefsPath, fullPath
109 fullPath += ":preferences.pxp"
110 SetDataFolder df
111 string objects = "attr_filter;attr_filter_summary;s_filepath;s_hdf_options;s_reduction_params;s_preview_pvs"
112 SaveData /O /Q /J=objects fullPath
113 KillPath/Z tempPackagePrefsPath
114 endif
115 SetDataFolder saveDF
116 end
117
118 static function load_prefs()
119 // loads persistent package data from the preferences file
120 // the preferences file is an Igor packed experiment file in a special preferences folder
121 dfref saveDF = GetDataFolderDFR()
122
123 variable result = -1
124 setdatafolder root:
125 NewDataFolder /O/S packages
126 NewDataFolder /O/S $package_name
127 dfref packageDF = GetDataFolderDFR()
128 string fullPath = SpecialDirPath("Packages", 0, 0, 0)
129 fullPath += package_name
130
131 GetFileFolderInfo /Q /Z fullPath
132 if (V_Flag == 0) // Disk directory exists?
133 fullPath += ":preferences.pxp"
134 GetFileFolderInfo /Q /Z fullPath
135 if (V_Flag == 0) // Preference file exist?
136 LoadData /O /R /Q fullPath
137 result = 0
138 endif
139 endif
140
141 if (result == 0)
142 svar /sdfr=packageDF filepath = s_filepath
143 NewPath /O/Z pearl_explorer_filepath, filepath
144 update_filelist()
145 update_datasets()
146 endif
147
148 SetDataFolder saveDF
149 return result
150 end
151
163 static function pearl_file_type(filename)
164 string filename
165
166 if (StringMatch(filename, ks_filematch_pshell))
167 return 1
168 elseif (StringMatch(filename, ks_filematch_adh5))
169 return 2
170 elseif (StringMatch(filename, ks_filematch_itx))
171 return 3
172 #if exists("MFR_OpenResultFile")
173 elseif (StringMatch(filename, ks_filematch_mtrx))
174 return 4
175 #endif
176 else
177 return 0
178 endif
179 end
180
186 static function update_filelist()
187 dfref saveDF = GetDataFolderDFR()
188
189 string all_files
190 wave /t wtFiles = $(package_path + "wtFiles")
191 wave wSelectedFiles = $(package_path + "wSelectedFiles")
192 variable nn
193
194 PathInfo pearl_explorer_filepath
195 if (v_flag == 1)
196 all_files = IndexedFile(pearl_explorer_filepath, -1, "????")
197 nn = ItemsInList(all_files)
198 else
199 all_files = ""
200 nn = 0
201 endif
202
203 make /n=(nn) /t /free wtAllFiles
204 wtAllFiles = StringFromList(p, all_files)
205 Extract /o /t wtAllFiles, wtFiles, pearl_file_type(wtAllFiles[p])
206 Sort /A /R wtFiles, wtFiles
207
208 redimension /n=(numpnts(wtFiles)) wSelectedFiles
209 wSelectedFiles = 0
210
211 setdatafolder saveDF
212 end
213
214 static function update_datasets()
215 // updates the list of imported datasets.
216 // a dataset means any top-level data folder
217 // which includes a string variable named pearl_explorer_import.
218 dfref saveDF = GetDataFolderDFR()
219
220 setdatafolder root:
221 dfref rootdf = GetDataFolderDFR()
222 setdatafolder $package_path
223 dfref privatedf = GetDataFolderDFR()
224
225 wave /t wtDatasets
226 wave wSelectedDatasets
227 variable maxdf = CountObjectsDFR(rootdf, 4)
228 redimension /n=(maxdf) wtDatasets
229
230 variable idf = 0
231 variable ndf = 0
232 string sdf
233
234 do
235 sdf = GetIndexedObjNameDFR(rootdf, 4, idf)
236 if (strlen(sdf) >= 1)
237 setdatafolder rootdf
238 setdatafolder $sdf
239 svar /z importer = pearl_explorer_import
240 if (svar_exists(importer))
241 wtDatasets[ndf] = sdf
242 ndf += 1
243 endif
244 else
245 break
246 endif
247 idf += 1
248 while(1)
249
250 redimension /n=(ndf) wtDatasets, wSelectedDatasets
251 wSelectedDatasets = 0
252 sort wtDatasets, wtDatasets
253
254 setdatafolder saveDF
255 end
256
257 static function preview_file(filename)
258 string filename
259
260 dfref saveDF = GetDataFolderDFR()
261
262 variable ft = pearl_file_type(filename)
263 switch(ft)
264 case 1:
265 wave /z image = preview_pshell_file(filename)
266 break
267 case 2:
268 wave /z image = preview_hdf_file(filename)
269 break
270 case 3:
271 wave /z image = preview_itx_file(filename)
272 break
273 case 4:
274 wave /z image = preview_mtrx_file(filename)
275 break
276 default:
277 wave /z image = $""
278 endswitch
279
280 if (WaveExists(image))
281 string graphname = show_preview_graph(image)
282 // preset ELOG panel - if available
283 if (exists("PearlElog#set_panel_attributes") == 6)
284 string cmd
285 sprintf cmd, "PearlElog#set_panel_attributes(\"\", \"File=%s\")", ParseFilePath(0, filename, ":", 1, 0)
286 execute /Q/Z cmd
287 if (strlen(graphname) > 0)
288 sprintf cmd, "PearlElog#set_panel_graphs(\"\", \"%s\")", graphname
289 execute /Q/Z cmd
290 endif
291 endif
292 endif
293
294 setdatafolder saveDF
295 return 0
296 end
297
309 static function /wave preview_pshell_file(filename)
310 string filename
311
312 dfref saveDF = GetDataFolderDFR()
313
314 setdatafolder $package_path
315 dfref previewDF = GetDataFolderDFR()
316 svar s_preview_file
317 svar s_preview_source
318 svar /z s_file_info
319 if (! svar_exists(s_file_info))
320 string /g s_file_info
321 endif
322
323 dfref tempDF = NewFreeDataFolder()
324 setdatafolder tempDF
325 string dataname
326 dataname = psh5_load_preview("pearl_explorer_filepath", filename)
327
328 s_preview_file = filename
329 s_preview_source = ""
330
331 wave /z data = $dataname
332 if (waveexists(data))
333 duplicate /o data, previewDF:preview_image
334 else
335 print "no data found in file " + filename
336 endif
337
338 if (strlen(s_preview_file) > 0)
339 s_file_info = psh5_load_info("pearl_explorer_filepath", filename)
340 else
341 s_file_info = ""
342 endif
343
344 dfref attrDF = tempDF:attr
345 if (DataFolderRefStatus(attrDF))
346 preview_attributes(attrDF)
347 endif
348
349 setdatafolder saveDF
350 wave /z /sdfr=previewDF preview_image
351 return preview_image
352 end
353
365 static function /wave preview_hdf_file(filename)
366 string filename
367
368 dfref saveDF = GetDataFolderDFR()
369 setdatafolder $package_path
370 svar s_preview_file
371 svar s_preview_source
372 adh5_load_preview("preview_image", "pearl_explorer_filepath", filename)
373 s_preview_file = filename
374 s_preview_source = ""
375 wave /z preview_image
376
377 svar /z s_file_info
378 if (! svar_exists(s_file_info))
379 string /g s_file_info
380 endif
381 if (strlen(s_preview_file) > 0)
382 s_file_info = adh5_load_info("pearl_explorer_filepath", filename)
383 else
384 s_file_info = ""
385 endif
386
387 if (DataFolderExists("attr"))
388 setdatafolder attr
389 preview_attributes(GetDataFolderDFR())
390 setdatafolder ::
391 endif
392
393 setdatafolder saveDF
394 return preview_image
395 end
396
416 static function /wave preview_itx_file(filename)
417 string filename
418
419 dfref saveDF = GetDataFolderDFR()
420 setdatafolder $package_path
421 svar s_preview_file
422 svar s_preview_source
423 wave preview_image
424
425 dfref dataDF = newfreedatafolder()
426 setdatafolder dataDF
427 LoadWave /t/p=pearl_explorer_filepath/q filename
428 s_preview_file = s_filename
429 s_preview_source = ""
430
431 preview_datafolder()
432 preview_attributes(dataDF, include_datawaves=0)
433
434 setdatafolder saveDF
435 return preview_image
436 end
437
452 static function /wave preview_mtrx_file(filename)
453 string filename
454
455 #if exists("MFR_OpenResultFile")
456 dfref saveDF = GetDataFolderDFR()
457 setdatafolder $package_path
458 variable /g V_MatrixFileReaderOverwrite = 1
459 variable /g V_MatrixFileReaderFolder = 0
460 variable /g V_MatrixFileReaderDouble = 0
461 svar s_preview_file
462 svar s_preview_source
463 string datanames
464 string dataname
465 datanames = mtrx_load_preview("preview", "pearl_explorer_filepath", filename)
466 if (strlen(datanames) > 0)
467 s_preview_file = filename
468
469 dataname = StringFromList(0, datanames)
470 wave data = $dataname
471 duplicate /o $dataname, preview_image
472 s_preview_source = StringByKey("Dataset", note(data), "=", "\r")
473
474 svar /z s_file_info
475 if (svar_exists(s_file_info))
476 s_file_info = ""
477 endif
478
479 variable i
480 variable n = ItemsInList(datanames)
481 string s
482 for (i = 0; i < n; i += 1)
483 s = StringFromList(i, datanames)
484 killwaves /z $s
485 endfor
486 endif
487 wave /z preview_image
488 setdatafolder saveDF
489 #else
490 wave /z preview_image = $""
491 #endif
492 return preview_image
493 end
494
495 static function extract_preview_image(data, preview)
496 // extracts a preview image from a wave of arbitrary dimension
497 wave data
498 wave preview
499
500 variable z1, z2
501
502 // extract image
503 switch (WaveDims(data))
504 case 1:
505 redimension /n=(numpnts(data)) preview
506 preview = data[p]
507 break
508 case 2:
509 redimension /n=(dimsize(data, 0), dimsize(data, 1)) preview
510 preview = data
511 break
512 case 3:
513 redimension /n=(dimsize(data, 0), dimsize(data, 1)) preview
514 z1 = floor(DimSize(data, 2) / 2)
515 z2 = z1
516 wave slab = ad_extract_slab(data, nan, nan, nan, nan, z1, z2, "", pscale=1)
517 preview = slab
518 break
519 case 4:
520 // not implemented
521 endswitch
522
523 switch (WaveDims(data))
524 case 4:
525 case 3:
526 case 2:
527 setscale /p y dimoffset(data, 1), dimdelta(data, 1), waveunits(data, 1), preview
528 case 1:
529 setscale /p x dimoffset(data, 0), dimdelta(data, 0), waveunits(data, 0), preview
530 setscale d 0, 0, waveunits(data, -1), preview
531 endswitch
532 end
533
534 static function preview_dataset(datasetname)
535 string datasetname // name of a data folder under root
536
537 dfref saveDF = GetDataFolderDFR()
538
539 if (!DataFolderExists("root:" + datasetname))
540 return -1
541 endif
542 setdatafolder root:
543 setdatafolder $datasetname
544 dfref datadf = GetDataFolderDFR()
545 wave /z data
546
547 setdatafolder $package_path
548 svar s_preview_file
549 svar s_preview_source
550 wave preview_image
551 if (WaveExists(data))
552 s_preview_file = datasetname
553 s_preview_source = ""
554 extract_preview_image(data, preview_image)
555 show_preview_graph(preview_image)
556 else
557 preview_image = nan
558 s_preview_file = datasetname
559 setdatafolder datadf
560 preview_datafolder()
561 show_preview_graph(preview_image)
562 endif
563
564 // attributes
565 setdatafolder datadf
566 if (DataFolderExists("attr"))
567 setdatafolder attr
568 preview_attributes(GetDataFolderDFR())
569 else
570 preview_attributes(GetDataFolderDFR(), include_datawaves=0)
571 endif
572
573 setdatafolder saveDF
574 return 0
575 end
576
577 static function preview_datafolder()
578 // preview data in the current data folder
579 dfref saveDF = GetDataFolderDFR()
580
581 setdatafolder $package_path
582 svar s_preview_file
583 svar s_preview_source
584 svar s_preview_pvs
585 wave preview_image
586
587 setdatafolder saveDF
588
589 // select a wave to display
590 // consider only double-precision waves, i.e. ignore text and other special waves
591 // filter by matching PV name to s_preview_pvs
592 string d_names = WaveList("*", ";", "DP:1")
593 variable nw = ItemsInList(d_names, ";")
594 variable npv = ItemsInList(s_preview_pvs, ";")
595 variable iw, ipv
596 string wname, wnote, pv_name, pv_match
597 for (iw = 0; iw < nw; iw += 1)
598 wname = StringFromList(iw, d_names, ";")
599 wnote = note($wname)
600 pv_name = StringByKey("PV", wnote, "=", "\r")
601 // find matching data wave by PV name
602 for (ipv = 0; ipv < npv; ipv += 1)
603 pv_match = StringFromList(ipv, s_preview_pvs)
604 if (StringMatch(pv_name, pv_match))
605 wave data = $wname
606 s_preview_source = pv_name
607 extract_preview_image(data, preview_image)
608 preview_setscale_x(data, preview_image)
609 npv = 0
610 nw = 0
611 endif
612 endfor
613 endfor
614
615 setdatafolder saveDF
616 end
617
618 static function preview_setscale_x(data, preview)
619 // sets the approximate x scale of OTF data.
620 // requires an Axis1 tag with name of x wave in the wave note.
621 // if any of these conditions is true, the function does not change the scaling:
622 // 1) Axis1 tag or referenced wave is missing.
623 // 2) preview wave is not set to point scaling.
624 // 3) x wave is not monotonic (90% of the steps in the same direction).
625 wave data
626 wave preview
627
628 if ((DimOffset(preview, 0) == 0) && (DimDelta(preview, 0) == 1))
629 string xname = StringByKey("Axis1", note(data), "=", "\r")
630 wave /z xwave = $xname
631 if (WaveExists(xwave))
632 // check for monotonicity
633 variable monotonic = 0
634 duplicate /free xwave, xdiff
635 differentiate /p xwave /D=xdiff
636 duplicate /free xdiff, xflag
637 xflag = xdiff > 0
638 monotonic = sum(xflag) > numpnts(xwave) * 0.9
639 xflag = xdiff < 0
640 monotonic = monotonic || (sum(xflag) > numpnts(xwave) * 0.9)
641 if (monotonic)
642 setscale /i x xwave[0], xwave[numpnts(xwave)-1], waveunits(xwave, -1), preview
643 endif
644 endif
645 endif
646 end
647
648 static function preview_attributes(attr_folder, [dest_folder, attr_filter, include_datawaves, include_infowaves])
649 // copies the first elements of attributes in the specified folder to the preview waves
650 // by default, all existing attributes are copied
651 // if a text wave attr_filter exists in the pear_explorer folder, only the attributes referenced therein are copied
652 // to set up a filter, duplicate the attr_names wave of a template dataset, and remove unwanted items
653 dfref attr_folder // data folder which contains the attribute waves
654 dfref dest_folder // destination folder. the output is written to the attr_names and attr_values waves
655 // default = package folder
656 wave /t attr_filter // list of attributes allowed in the output
657 // default = use attr_filter of package folder
658 variable include_datawaves // 1 (default) = include data waves (any numeric wave which has a PV=name note)
659 // 0 = don't include attributes from data waves
660 variable include_infowaves // 1 (default) = include attributes from info waves (IN, ID, IV, IU)
661 // 0 = don't include attributes from info waves
662
663 dfref saveDF = GetDataFolderDFR()
664 setdatafolder $package_path
665
666 if (ParamIsDefault(dest_folder))
667 dest_folder = GetDataFolderDFR() // package folder
668 endif
669 if (ParamIsDefault(attr_filter))
670 wave /t /z attr_filter
671 endif
672 if (ParamIsDefault(include_datawaves))
673 include_datawaves = 1
674 endif
675 if (ParamIsDefault(include_infowaves))
676 include_infowaves = 1
677 endif
678
679 setdatafolder dest_folder
680 wave /t /z attr_names, attr_values
681 if (!WaveExists(attr_names) || !WaveExists(attr_values))
682 make /n=(1) /o /t attr_names, attr_values
683 endif
684 attr_names = ""
685 attr_values = ""
686
687 setdatafolder attr_folder
688 wave /t /z IN
689 wave /t /z ID
690 wave /t /z IV
691 wave /t /z IU
692
693 // compile list of attributes
694 variable nattr // destination attributes
695 variable iattr
696 variable ninfo // info wave elements
697 variable iinfo
698 variable nw // attribute waves
699 variable iw
700 string sw
701 string ss
702
703 if (WaveExists(IN) && include_infowaves)
704 ninfo = numpnts(IN)
705 else
706 ninfo = 0
707 endif
708 if (include_datawaves)
709 string waves = WaveList("*", ";", "")
710 string exceptions = "ID;IN;IU;IV"
711 waves = RemoveFromList(exceptions, waves)
712 nw = ItemsInList(waves, ";")
713 else
714 nw = 0
715 endif
716
717 if (WaveExists(attr_filter) && (numpnts(attr_filter) >= 1))
718 nattr = numpnts(attr_filter)
719 redimension /n=(nattr) attr_names
720 attr_names = attr_filter
721 else
722 if(ninfo > 0)
723 redimension /n=(ninfo) attr_names
724 attr_names = SelectString(strlen(ID[p]) >= 0, IN[p], ID[p]) // use ID unless empty
725 endif
726
727 nattr = ninfo + nw
728 iattr = ninfo
729 redimension /n=(nattr) attr_names
730 for (iw = 0; iw < nw; iw +=1 )
731 sw = StringFromList(iw, waves, ";")
732 ss = StringByKey("PV", note($sw), "=", "\r")
733 FindValue /text=sw attr_names
734 if ((v_value < 0) && (strlen(ss) >= 0))
735 attr_names[iattr] = sw
736 iattr += 1
737 endif
738 endfor
739 nattr = iattr
740 endif
741 redimension /n=(nattr) attr_names, attr_values
742 sort attr_names, attr_names
743
744 // look up attribute values
745 for (iattr = 0; iattr < nattr; iattr += 1)
746 sw = attr_names[iattr]
747 // try info waves
748 if (ninfo > 0)
749 FindValue /text=sw ID
750 if (v_value >= 0)
751 attr_values[iattr] = IV[v_value]
752 endif
753 FindValue /text=sw IN
754 if (v_value >= 0)
755 attr_values[iattr] = IV[v_value]
756 endif
757 endif
758
759 // override from attribute wave if existent
760 if (nw > 0)
761 switch (WaveType($sw, 1))
762 case 1: // numeric
763 wave /z w = $sw
764 if (WaveExists(w) && (numpnts(w) >= 1))
765 sprintf ss, "%g", w[0]
766 attr_values[iattr] = ss
767 endif
768 break
769 case 2: // text
770 wave /t/z wt = $sw
771 if (WaveExists(wt) && (numpnts(wt) >= 1))
772 attr_values[iattr] = wt[0]
773 endif
774 break
775 endswitch
776 endif
777 endfor
778
779 setdatafolder saveDF
780 end
781
782 static function display_dataset(datasetname)
783 // displays the graph of a loaded dataset in its own window
784 string datasetname // name of a data folder under root
785
786 dfref saveDF = GetDataFolderDFR()
787
788 if (!DataFolderExists("root:" + datasetname))
789 return -1
790 endif
791 setdatafolder root:
792 setdatafolder $datasetname
793 dfref datadf = GetDataFolderDFR()
794 wave /z data
795 if (!WaveExists(data))
796 wave /z data = data1
797 endif
798
799 if (WaveExists(data))
800 switch(WaveDims(data))
801 case 2:
802 ad_display_profiles(data)
803 break
804 case 3:
805 ad_display_slice(data)
806 ad_brick_slicer(data)
807 break
808 endswitch
809 endif
810
811 setdatafolder saveDF
812 return 0
813 end
814
815 function test_attributes_notebook()
816 dfref df = GetDataFolderDFR()
817 wave /t /sdfr=df attr_names
818 wave /t /sdfr=df attr_values
819 attributes_notebook(attr_names, attr_values, GetDataFolder(0))
820 end
821
822 static function attributes_notebook(attr_names, attr_values, title)
823 wave /t attr_names
824 wave /t attr_values
825 string title
826
827 dfref saveDF = GetDataFolderDFR()
828 setdatafolder $package_path
829 wave /t/z attr_filter, attr_filter_summary
830
831 string name = PearlCleanupName("nb_" + title[0,27])
832 if (WinType(name) == 5)
833 Notebook $name selection={startOfFile, endOfFile}
834 Notebook $name text=""
835 else
836 NewNotebook /F=1 /K=1 /N=$name as title
837 GetWindow $name wsize
838 v_right = v_left + 260
839 v_bottom = v_top + 360
840 MoveWindow /W=$name v_left, v_top, v_right, v_bottom
841 Notebook $name tabs={2*72}
842 endif
843
844 // summary
845 if (WaveExists(attr_filter_summary) && (numpnts(attr_filter_summary) >= 1))
846 notebook $name fStyle=1, text="Summary\r\r"
847 notebook $name fStyle=0
848 notebook_add_attributes(name, attr_filter_summary, attr_names, attr_values)
849 notebook $name text="\r"
850 endif
851
852 // all attributes
853 notebook $name fStyle=1, text="All Attributes\r\r"
854 notebook $name fStyle=0
855 notebook_add_attributes(name, $"", attr_names, attr_values)
856 notebook $name selection={startOfFile,startOfFile}, findText={"",1}
857
858 setdatafolder saveDF
859 end
860
861 static function notebook_add_attributes(notebook_name, attr_filter, attr_names, attr_values)
862 string notebook_name
863 wave /t /z attr_filter
864 wave /t attr_names
865 wave /t attr_values
866
867 variable nw = numpnts(attr_names)
868 variable iw
869 string sw
870 string ss
871
872 variable do_filter = WaveExists(attr_filter)
873
874 for (iw = 0; iw < nw; iw += 1)
875 if (do_filter)
876 sw = attr_names[iw]
877 FindValue /text=sw attr_filter
878 else
879 v_value = 0
880 endif
881 if (v_value >= 0)
882 sprintf ss, "%s\t%s\r", attr_names[iw], attr_values[iw]
883 notebook $notebook_name text=ss
884 endif
885 endfor
886 end
887
888 static function /s show_preview_graph(data, [xdata])
889 // displays a preview of one- or two-dimensional data
890 wave data // data to be displayed. must either one-dimensional or two-dimensional
891 wave xdata // positions on x axis
892
893 dfref saveDF = GetDataFolderDFR()
894 setdatafolder $package_path
895
896 svar s_profiles_graph
897 svar s_preview_file
898 svar s_preview_source
899 svar s_preview_trace_graph
900
901 if ((strlen(s_profiles_graph) > 0) && (WinType(s_profiles_graph) == 1))
902 KillWindow $s_profiles_graph
903 endif
904 if ((strlen(s_preview_trace_graph) > 0) && (WinType(s_preview_trace_graph) == 1))
905 KillWindow $s_preview_trace_graph
906 endif
907
908 string graphname
909 if (wavedims(data) == 2)
910 s_profiles_graph = ad_display_profiles(data)
911 ModifyGraph /w=$s_profiles_graph /z wbRGB=(48640,56832,60160)
912 graphname = s_profiles_graph
913 elseif (wavedims(data) == 1)
914 duplicate /o data, preview_trace
915 if (!ParamIsDefault(xdata))
916 duplicate /o xdata, preview_trace_x
917 else
918 duplicate /o data, preview_trace_x
919 preview_trace_x = x
920 setscale d 0, 0, WaveUnits(data, 0), preview_trace_x
921 endif
922 s_preview_trace_graph = display_preview_trace(preview_trace_x, preview_trace)
923 ModifyGraph /w=$s_preview_trace_graph wbRGB=(48640,56832,60160)
924 graphname = s_preview_trace_graph
925 else
926 return ""
927 endif
928
929 string title = "Preview " + s_preview_file
930 if (strlen(s_preview_source) > 0)
931 title = title + " (" + s_preview_source[0,31] + ")"
932 endif
933 dowindow /f/t $graphname, title
934
935 setdatafolder saveDF
936 return graphname
937 end
938
939 static function /s display_preview_trace(xtrace, ytrace)
940 wave xtrace
941 wave ytrace
942
943 display /n=pearl_explorer_1d /k=1 ytrace vs xtrace as "Preview"
944 string graphname = s_name
945 ModifyGraph /w=$graphname rgb[0]=(0,0,0)
946 ModifyGraph /w=$graphname grid=2
947 ModifyGraph /w=$graphname mirror=1
948 ModifyGraph /w=$graphname minor=1
949 ModifyGraph /w=$graphname axThick=0.5
950 ModifyGraph /w=$graphname gridRGB=(52224,52224,52224)
951 ModifyGraph /w=$graphname gridHair=0
952 ModifyGraph /w=$graphname tick=0
953 ModifyGraph /w=$graphname btLen=4
954
955 // axis labels
956 string labels = note(ytrace)
957 string lab
958 lab = StringByKey("AxisLabelX", labels, "=", "\r")
959 if (!strlen(lab))
960 lab = "X"
961 endif
962 Label /w=$graphname bottom lab + " (\\U)"
963 lab = StringByKey("AxisLabelD", labels, "=", "\r")
964 if (!strlen(lab))
965 lab = "value"
966 endif
967 Label /w=$graphname left lab + " (\\U)"
968
969 return s_name
970 end
971
972 static function load_selected_files([options])
973 string options
974
975 dfref saveDF = GetDataFolderDFR()
976 setdatafolder $package_path
977
978 wave wSelectedFiles
979 wave/t wtFiles
980 variable nn = numpnts(wSelectedFiles)
981 variable ii
982 for (ii = 0; ii < nn; ii += 1)
983 if (wSelectedFiles[ii])
984 if (ParamIsDefault(options))
985 load_file(wtFiles[ii])
986 else
987 load_file(wtFiles[ii], options=options)
988 endif
989 endif
990 endfor
991
992 update_datasets()
993 setdatafolder saveDF
994 end
995
996 static function load_file(filename, [options])
997 string filename
998 string options
999
1000 dfref saveDF = GetDataFolderDFR()
1001
1002 variable ft = pearl_file_type(filename)
1003 switch(ft)
1004 case 1:
1005 if (ParamIsDefault(options))
1006 load_pshell_file(filename)
1007 else
1008 load_pshell_file(filename, options=options)
1009 endif
1010 break
1011 case 2:
1012 if (ParamIsDefault(options))
1013 load_hdf_file(filename)
1014 else
1015 load_hdf_file(filename, options=options)
1016 endif
1017 break
1018 case 3:
1019 load_itx_file(filename)
1020 break
1021 case 4:
1022 load_mtrx_file(filename)
1023 break
1024 default:
1025 break
1026 endswitch
1027
1028 setdatafolder saveDF
1029 end
1030
1031 static function prompt_hdf_options(options)
1032 string &options
1033
1034 string mode = StringByKey("mode", options, ":", ";")
1035 string reduction_func = StringByKey("reduction_func", options, ":", ";")
1036
1037 string modes = "load_reduced"
1038 string reduction_functions = adh5_list_reduction_funcs()
1039
1040 if (strlen(mode) == 0)
1041 mode = StringFromList(0, modes, ";")
1042 endif
1043 if (strlen(reduction_func) == 0)
1044 reduction_func = StringFromList(0, reduction_functions, ";")
1045 endif
1046
1047 prompt mode, "Mode", popup, modes
1048 prompt reduction_func, "Reduction Function", popup, reduction_functions
1049 doprompt "HDF5 Loading Options", mode, reduction_func
1050
1051 if (v_flag == 0)
1052 options = ReplaceStringByKey("mode", options, mode, ":", ";")
1053 options = ReplaceStringByKey("reduction_func", options, reduction_func, ":", ";")
1054 endif
1055 return v_flag // 0 = OK, 1 = cancel
1056 end
1057
1070 function prompt_default_process(param)
1071 string &param
1072
1073 return 0
1074 end
1075
1076 function prompt_func_params(func_name, func_param)
1077 string func_name
1078 string &func_param
1079
1080 string prompt_name = "prompt_" + func_name
1081 if (exists(prompt_name) == 6)
1082 funcref prompt_default_process prompt_func = $prompt_name
1083 return prompt_func(func_param)
1084 else
1085 // ignore missing prompt function
1086 return 0
1087 endif
1088 end
1089
1090 static function /df load_pshell_file(filename, [options])
1091 string filename
1092 string options
1093
1094 dfref saveDF = GetDataFolderDFR()
1095 string nickname = ad_suggest_foldername(filename)
1096 string loaded_filename = ""
1097
1098 if (ParamIsDefault(options))
1099 loaded_filename = psh5_load_complete(nickname, "pearl_explorer_filepath", filename)
1100 else
1101 if (strlen(options) == 0)
1102 svar pref_options = $(package_path + "s_hdf_options")
1103 options = pref_options
1104 if (prompt_hdf_options(options) == 0)
1105 // OK
1106 pref_options = options
1107 else
1108 // cancel
1109 options = ""
1110 endif
1111 endif
1112
1113 string mode = StringByKey("mode", options, ":", ";")
1114
1115 strswitch(mode)
1116 case "load_reduced":
1117 string reduction_func = StringByKey("reduction_func", options, ":", ";")
1118 svar pref_params = $(package_path + "s_reduction_params")
1119 string reduction_params = pref_params
1120 if (prompt_func_params(reduction_func, reduction_params) == 0)
1121 pref_params = reduction_params
1122 print reduction_func, reduction_params
1123 psh5_load_reduced(nickname, "pearl_explorer_filepath", filename, $reduction_func, reduction_params)
1124 svar s_filepath
1125 loaded_filename = s_filepath
1126 endif
1127 break
1128 endswitch
1129 endif
1130
1131 dfref dataDF
1132 if (strlen(loaded_filename) > 0)
1133 setdatafolder $("root:" + nickname)
1134 dataDF = GetDataFolderDFR()
1135 string /g pearl_explorer_import = "load_pshell_file"
1136 endif
1137
1138 setdatafolder saveDF
1139 return dataDF
1140 end
1141
1142 static function /df load_hdf_file(filename, [options])
1143 string filename
1144 string options
1145
1146 dfref saveDF = GetDataFolderDFR()
1147 string nickname = ad_suggest_foldername(filename)
1148 string loaded_filename = ""
1149
1150 if (ParamIsDefault(options))
1151 loaded_filename = adh5_load_complete(nickname, "pearl_explorer_filepath", filename)
1152 else
1153 if (strlen(options) == 0)
1154 svar pref_options = $(package_path + "s_hdf_options")
1155 options = pref_options
1156 if (prompt_hdf_options(options) == 0)
1157 // OK
1158 pref_options = options
1159 else
1160 // cancel
1161 options = ""
1162 endif
1163 endif
1164
1165 string mode = StringByKey("mode", options, ":", ";")
1166
1167 strswitch(mode)
1168 case "load_reduced":
1169 string reduction_func = StringByKey("reduction_func", options, ":", ";")
1170 svar pref_params = $(package_path + "s_reduction_params")
1171 string reduction_params = pref_params
1172 if (prompt_func_params(reduction_func, reduction_params) == 0)
1173 pref_params = reduction_params
1174 print reduction_func, reduction_params
1175 loaded_filename = adh5_load_reduced(nickname, "pearl_explorer_filepath", filename, $reduction_func, reduction_params)
1176 endif
1177 break
1178 endswitch
1179 endif
1180
1181 dfref dataDF
1182 if (strlen(loaded_filename) > 0)
1183 setdatafolder $("root:" + nickname)
1184 dataDF = GetDataFolderDFR()
1185 string /g pearl_explorer_import = "load_hdf_file"
1186 endif
1187
1188 setdatafolder saveDF
1189 return dataDF
1190 end
1191
1192 static function /df load_itx_file(filename, [options])
1193 string filename
1194 string options
1195
1196 dfref saveDF = GetDataFolderDFR()
1197 string nickname = itx_suggest_foldername(filename)
1198
1199 if (ParamIsDefault(options))
1200 options = ""
1201 endif
1202
1203 setdatafolder root:
1204 newdatafolder /s/o $("root:" + nickname)
1205 dfref dataDF = GetDataFolderDFR()
1206
1207 // note: some versions of PEARL data files save data to a new data folder,
1208 // and leave the newly created folder as the current folder.
1209 // the free data folder is used by those files which don't create their own data folder.
1210 // this is the new recommended behaviour
1211
1212 LoadWave /t/p=pearl_explorer_filepath/q filename
1213 svar waves = s_wavenames
1214 dfref actDF = GetDataFolderDFR()
1215 if (v_flag > 0)
1216 string /g pearl_explorer_import = "load_itx_file"
1217 endif
1218
1219 if (!DataFolderRefsEqual(actDF, dataDF))
1220 // the file created its own data folder.
1221 // let's kill the pre-allocated folder
1222 setdatafolder dataDF
1223 if (ItemsInList(WaveList("*", ";", ""), ";") == 0)
1224 killdatafolder /z dataDF
1225 endif
1226 endif
1227
1228 setdatafolder saveDF
1229 return actDF
1230 end
1231
1235 static function /df load_mtrx_file(filename, [options])
1236 string filename
1237 string options
1238
1239 dfref saveDF = GetDataFolderDFR()
1240 dfref dataDF = $""
1241
1242 #if exists("MFR_OpenResultFile")
1243 setdatafolder root:
1244 string datasets = ""
1245 datasets = mtrx_load_file("pearl_explorer_filepath", filename)
1246 if (strlen(datasets) > 0)
1247 string /g pearl_explorer_import = "load_mtrx_file"
1248 string s1 = StringFromList(0, datasets)
1249 wave w1 = $s1
1250 dataDF = GetWavesDataFolderDFR(w1)
1251 endif
1252 #endif
1253
1254 setdatafolder saveDF
1255 return dataDF
1256 end
1257
1258 function /s itx_suggest_foldername(filename, [ignoredate,sourcename,unique])
1259 // suggests the name of a data folder based on a file name
1260 // if the file name follows the naming convention source-date-index.extension,
1261 // the function tries to generate the nick name as source_date_index.
1262 // otherwise it's just a cleaned up version of the file name.
1263 string filename // file name, including extension. can also include a folder path (which is ignored)
1264 // the extension is currently ignored, but may be used later to select the parent folder
1265 variable ignoredate // if non-zero, the nick name will not include the date part
1266 // defaults to zero
1267 string sourcename // nick name of the data source
1268 // the function tries to detect the source from the file name
1269 // this option can be used to override auto-detection
1270 // allowed values: sscan, otf
1271 variable unique // if non-zero, the resulting name is made a unique data folder name in the current data folder
1272 // defaults to zero
1273
1274 if (ParamIsDefault(ignoredate))
1275 ignoredate = 0
1276 endif
1277 if (ParamIsDefault(unique))
1278 unique = 0
1279 endif
1280
1281 string basename = ParseFilePath(3, filename, ":", 0, 0)
1282 string extension = ParseFilePath(4, filename, ":", 0, 0)
1283 string nickname
1284
1285 string autosource
1286 if (strsearch(basename, "X03DA_PC", 0, 2) >= 0)
1287 autosource = "sscan"
1288 basename = ReplaceString("_", basename, "-")
1289 ignoredate = 1
1290 elseif (strsearch(basename, "otf", 0, 2) >= 0)
1291 autosource = "otf"
1292 endif
1293 if (ParamIsDefault(sourcename))
1294 sourcename = autosource
1295 endif
1296
1297 variable nparts = ItemsInList(basename, "-")
1298 if (nparts >= 3)
1299 string datepart = StringFromList(nparts - 2, basename, "-")
1300 string indexpart = StringFromList(nparts - 1, basename, "-")
1301 if (ignoredate)
1302 sprintf nickname, "%s_%s", sourcename, indexpart
1303 else
1304 sprintf nickname, "%s_%s_%s", sourcename, datepart, indexpart
1305 endif
1306 else
1307 nickname = PearlCleanupName(basename)
1308 endif
1309
1310 if (unique && CheckName(nickname, 11))
1311 nickname = UniqueName(nickname + "_", 11, 0)
1312 endif
1313
1314 return nickname
1315 end
1316
1317 Window PearlDataExplorer() : Panel
1318 PauseUpdate; Silent 1 // building window...
1319 NewPanel /K=1 /W=(800,0,1530,444) as "PEARL Data Explorer"
1320 ModifyPanel cbRGB=(48640,56832,60160)
1321
1322 GroupBox gb_filepath,pos={8,4},size={224,52},title="file system folder"
1323 TitleBox tb_filepath,pos={20,24},size={174,20},frame=2
1324 TitleBox tb_filepath,variable=root:packages:pearl_explorer:s_filepath,fixedSize=1
1325 Button b_browse_filepath,pos={200,24},size={20,20},proc=PearlDataExplorer#bp_browse_filepath,title="..."
1326 Button b_browse_filepath,fColor=(65280,48896,32768)
1327
1328 GroupBox gb_prefs,pos={240,4},size={58,52},title="prefs",help={"explorer package preferences"}
1329 Button b_save_prefs,pos={252,20},size={32,17},proc=PearlDataExplorer#bp_save_prefs,title="save"
1330 Button b_save_prefs,help={"save preferences of the data explorer package (data file path, attributes filter)"}
1331 Button b_save_prefs,fColor=(65280,48896,32768)
1332 Button b_load_prefs,pos={252,36},size={32,17},proc=PearlDataExplorer#bp_load_prefs,title="load"
1333 Button b_load_prefs,help={"load preferences of the data explorer package"}
1334 Button b_load_prefs,fColor=(65280,48896,32768)
1335
1336 GroupBox gb_filelist,pos={8,64},size={224,372},title="data files"
1337 ListBox lb_files,pos={20,84},size={200,212},proc=PearlDataExplorer#lbp_filelist
1338 ListBox lb_files,listWave=root:packages:pearl_explorer:wtFiles
1339 ListBox lb_files,selWave=root:packages:pearl_explorer:wSelectedFiles,row= 11,mode= 4
1340 TitleBox tb_file_info,pos={20,300},size={198,78},frame=2,fixedSize=1
1341 TitleBox tb_file_info,variable= root:packages:pearl_explorer:s_file_info
1342
1343 Button b_update_filelist,pos={20,386},size={60,20},proc=PearlDataExplorer#bp_update_filelist,title="update list"
1344 Button b_update_filelist,fColor=(65280,48896,32768)
1345 CheckBox cb_file_preview,pos={84,390},size={60,20},title="preview"
1346 CheckBox cb_file_preview,help={"enable/disable automatic preview window when selecting a data file"}
1347 CheckBox cb_file_preview,value=1
1348 Button b_file_prev,pos={176,386},size={20,20},proc=PearlDataExplorer#bp_file_prev,title="\\W646"
1349 Button b_file_prev,help={"previous file"}
1350 Button b_file_prev,fColor=(65280,48896,32768)
1351 Button b_file_next,pos={200,386},size={20,20},proc=PearlDataExplorer#bp_file_next,title="\\W649"
1352 Button b_file_next,help={"next file"}
1353 Button b_file_next,fColor=(65280,48896,32768)
1354
1355 Button b_load_files,pos={20,410},size={76,20},proc=PearlDataExplorer#bp_load_files,title="load complete"
1356 Button b_load_files,help={"load the complete contents from the selected files"}
1357 Button b_load_files,fColor=(65280,48896,32768)
1358 Button b_load_files_opt,pos={100,410},size={76,20},proc=PearlDataExplorer#bp_load_files_opt,title="load reduced"
1359 Button b_load_files_opt,help={"load data from the selected files with options (reduced dimensions)"}
1360 Button b_load_files_opt,fColor=(65280,48896,32768)
1361
1362 // datasets group
1363 GroupBox gb_datasets,pos={240,64},size={224,372},title="datasets"
1364 ListBox lb_datasets,pos={252,84},size={200,300},proc=PearlDataExplorer#lbp_datasets,help={"list of loaded datasets"}
1365 ListBox lb_datasets,listWave=root:packages:pearl_explorer:wtDatasets
1366 ListBox lb_datasets,selWave=root:packages:pearl_explorer:wSelectedDatasets,mode= 1
1367 ListBox lb_datasets,selRow= -1
1368
1369 Button b_update_datasets,pos={252,386},size={60,20},proc=PearlDataExplorer#bp_update_datasets,title="update list"
1370 Button b_update_datasets,help={"update the list of datasets"}
1371 Button b_update_datasets,fColor=(65280,48896,32768)
1372 CheckBox cb_dataset_preview,pos={316,390},size={60,20},title="preview"
1373 CheckBox cb_dataset_preview,help={"enable/disable automatic preview window when selecting a dataset"}
1374 CheckBox cb_dataset_preview,value=0
1375 Button b_dataset_prev,pos={408,386},size={20,20},proc=PearlDataExplorer#bp_dataset_prev,title="\\W646"
1376 Button b_dataset_prev,help={"goto previous dataset"}
1377 Button b_dataset_prev,fColor=(65280,48896,32768)
1378 Button b_dataset_next,pos={432,386},size={20,20},proc=PearlDataExplorer#bp_dataset_next,title="\\W649"
1379 Button b_dataset_next,help={"goto next dataset"}
1380 Button b_dataset_next,fColor=(65280,48896,32768)
1381
1382 Button b_dataset_folder,pos={252,410},size={50,20},proc=PearlDataExplorer#bp_dataset_folder,title="goto DF"
1383 Button b_dataset_folder,help={"set the current data folder of the selected dataset"}
1384 Button b_dataset_folder,fColor=(65280,48896,32768)
1385 Button b_dataset_display,pos={306,410},size={50,20},proc=PearlDataExplorer#bp_dataset_display,title="display"
1386 Button b_dataset_display,help={"display the selected dataset in its own window"}
1387 Button b_dataset_display,fColor=(65280,48896,32768)
1388
1389 GroupBox gb_preview,pos={472,4},size={250,52},title="preview"
1390 TitleBox tb_preview_file,pos={484,24},size={226,20},frame=2
1391 TitleBox tb_preview_file,variable=root:packages:pearl_explorer:s_preview_file,fixedSize=1
1392
1393 GroupBox gb_attributes,pos={472,64},size={250,372},title="attributes"
1394 Button b_attr_notebook,pos={484,386},size={60,20},proc=PearlDataExplorer#bp_attr_notebook,title="notebook"
1395 Button b_attr_notebook,help={"show attribute list in a notebook"}
1396 Button b_attr_notebook,fColor=(65280,48896,32768)
1397
1398 String fldrSav0= GetDataFolder(1)
1399 SetDataFolder root:packages:pearl_explorer:
1400 Edit/W=(484,84,710,384)/HOST=# attr_names,attr_values
1401 ModifyTable format(Point)=1,width(Point)=0,width(attr_names)=103,width(attr_values)=103
1402 ModifyTable statsArea=85
1403 SetDataFolder fldrSav0
1404 RenameWindow #,T0
1405 SetActiveSubwindow ##
1406 EndMacro
1407
1408 static function bp_load_prefs(ba) : ButtonControl
1409 STRUCT WMButtonAction &ba
1410
1411 switch( ba.eventCode )
1412 case 2: // mouse up
1413 load_prefs()
1414 break
1415 case -1: // control being killed
1416 break
1417 endswitch
1418
1419 return 0
1420 End
1421
1422 static function bp_save_prefs(ba) : ButtonControl
1423 STRUCT WMButtonAction &ba
1424
1425 switch( ba.eventCode )
1426 case 2: // mouse up
1427 save_prefs()
1428 break
1429 case -1: // control being killed
1430 break
1431 endswitch
1432
1433 return 0
1434 End
1435
1436 static function bp_browse_filepath(ba) : ButtonControl
1437 STRUCT WMButtonAction &ba
1438
1439 dfref saveDF = GetDataFolderDFR()
1440
1441 switch( ba.eventCode )
1442 case 2: // mouse up
1443 PathInfo /S pearl_explorer_filepath
1444 NewPath /M="select data file folder" /O/Z pearl_explorer_filepath
1445 if (v_flag == 0)
1446 PathInfo /S pearl_explorer_filepath
1447 svar filepath = $(package_path + "s_filepath")
1448 filepath = s_path
1449 update_filelist()
1450 endif
1451 break
1452 case -1: // control being killed
1453 break
1454 endswitch
1455
1456 setdatafolder saveDF
1457 return 0
1458 End
1459
1460 static function bp_update_filelist(ba) : ButtonControl
1461 STRUCT WMButtonAction &ba
1462
1463 switch( ba.eventCode )
1464 case 2: // mouse up
1465 update_filelist()
1466 break
1467 case -1: // control being killed
1468 break
1469 endswitch
1470
1471 return 0
1472 End
1473
1474 static function bp_load_files(ba) : ButtonControl
1475 STRUCT WMButtonAction &ba
1476
1477 switch( ba.eventCode )
1478 case 2: // mouse up
1479 load_selected_files()
1480 break
1481 case -1: // control being killed
1482 break
1483 endswitch
1484
1485 return 0
1486 End
1487
1488 static function bp_load_files_opt(ba) : ButtonControl
1489 STRUCT WMButtonAction &ba
1490
1491 switch( ba.eventCode )
1492 case 2: // mouse up
1493 load_selected_files(options="")
1494 break
1495 case -1: // control being killed
1496 break
1497 endswitch
1498
1499 return 0
1500 End
1501
1502 static function bp_file_next(ba) : ButtonControl
1503 STRUCT WMButtonAction &ba
1504
1505 dfref saveDF = GetDataFolderDFR()
1506
1507 switch( ba.eventCode )
1508 case 2: // mouse up
1509 setdatafolder $package_path
1510 wave /t wtFiles
1511 wave wSelectedFiles
1512 FindValue /i=1 wSelectedFiles
1513 v_value += 1
1514 if (v_value >= numpnts(wtFiles))
1515 v_value = min(numpnts(wtFiles) - 1, 0)
1516 endif
1517 wSelectedFiles = p == v_value
1518 if (v_value >= 0)
1519 variable ifile = v_value
1520 ControlInfo /W=PearlDataExplorer cb_file_preview
1521 if (v_value)
1522 preview_file(wtFiles[ifile])
1523 endif
1524 endif
1525 break
1526 case -1: // control being killed
1527 break
1528 endswitch
1529
1530 setdatafolder saveDF
1531 return 0
1532 End
1533
1534 static function bp_file_prev(ba) : ButtonControl
1535 STRUCT WMButtonAction &ba
1536
1537 dfref saveDF = GetDataFolderDFR()
1538
1539 switch( ba.eventCode )
1540 case 2: // mouse up
1541 setdatafolder $package_path
1542 wave /t wtFiles
1543 wave wSelectedFiles
1544 FindValue /i=1 wSelectedFiles
1545 v_value -= 1
1546 if (v_value < 0)
1547 v_value = numpnts(wtFiles) - 1
1548 endif
1549 wSelectedFiles = p == v_value
1550 if (v_value >= 0)
1551 variable ifile = v_value
1552 ControlInfo /W=PearlDataExplorer cb_file_preview
1553 if (v_value)
1554 preview_file(wtFiles[ifile])
1555 endif
1556 endif
1557 break
1558 case -1: // control being killed
1559 break
1560 endswitch
1561
1562 setdatafolder saveDF
1563 return 0
1564 End
1565
1566 static function lbp_filelist(lba) : ListBoxControl
1567 STRUCT WMListboxAction &lba
1568
1569 Variable row = lba.row
1570 Variable col = lba.col
1571 WAVE/T/Z listWave = lba.listWave
1572 WAVE/Z selWave = lba.selWave
1573
1574 switch( lba.eventCode )
1575 case -1: // control being killed
1576 break
1577 case 1: // mouse down
1578 if (selWave[row])
1579 ControlInfo /W=PearlDataExplorer cb_file_preview
1580 if (v_value)
1581 preview_file(listWave[row])
1582 endif
1583 endif
1584 break
1585 case 3: // double click
1586 break
1587 case 4: // cell selection
1588 case 5: // cell selection plus shift key
1589 break
1590 case 6: // begin edit
1591 break
1592 case 7: // finish edit
1593 break
1594 case 13: // checkbox clicked (Igor 6.2 or later)
1595 break
1596 endswitch
1597
1598 return 0
1599 End
1600
1601 static function bp_update_datasets(ba) : ButtonControl
1602 STRUCT WMButtonAction &ba
1603
1604 switch( ba.eventCode )
1605 case 2: // mouse up
1606 update_datasets()
1607 break
1608 case -1: // control being killed
1609 break
1610 endswitch
1611
1612 return 0
1613 End
1614
1615 static function bp_dataset_folder(ba) : ButtonControl
1616 STRUCT WMButtonAction &ba
1617
1618 switch( ba.eventCode )
1619 case 2: // mouse up
1620 ControlInfo /W=PearlDataExplorer lb_datasets
1621 if (v_value >= 0)
1622 setdatafolder $package_path
1623 wave /t wtDatasets
1624 string dataset = wtDatasets[v_value]
1625 string cmd
1626 sprintf cmd, "setdatafolder root:%s", PossiblyQuoteName(dataset)
1627 execute /q /z cmd
1628 cmd = "setdatafolder :scan1"
1629 execute /q /z cmd
1630 sprintf cmd, "setdatafolder %s", GetDataFolder(1)
1631 print cmd
1632 endif
1633 break
1634 case -1: // control being killed
1635 break
1636 endswitch
1637
1638 return 0
1639 End
1640
1641 static function bp_dataset_display(ba) : ButtonControl
1642 STRUCT WMButtonAction &ba
1643
1644 switch( ba.eventCode )
1645 case 2: // mouse up
1646 ControlInfo /W=PearlDataExplorer lb_datasets
1647 if (v_value >= 0)
1648 setdatafolder $package_path
1649 wave /t wtDatasets
1650 string dataset = wtDatasets[v_value]
1651 display_dataset(dataset)
1652 endif
1653 break
1654 case -1: // control being killed
1655 break
1656 endswitch
1657
1658 return 0
1659 End
1660
1661 static function bp_dataset_next(ba) : ButtonControl
1662 STRUCT WMButtonAction &ba
1663
1664 switch( ba.eventCode )
1665 case 2: // mouse up
1666 ControlInfo /W=PearlDataExplorer lb_datasets
1667 wave /t wtDatasets = $(s_datafolder + s_value)
1668 v_value += 1
1669 if (v_value >= numpnts(wtDatasets))
1670 v_value = min(0, numpnts(wtDatasets) - 1)
1671 endif
1672 ListBox lb_datasets win=PearlDataExplorer, selRow=v_value
1673 if (v_value >= 0)
1674 variable ids = v_value
1675 ControlInfo /W=PearlDataExplorer cb_dataset_preview
1676 if (v_value)
1677 preview_dataset(wtDatasets[ids])
1678 endif
1679 endif
1680 break
1681 case -1: // control being killed
1682 break
1683 endswitch
1684
1685 return 0
1686 End
1687
1688 static function bp_dataset_prev(ba) : ButtonControl
1689 STRUCT WMButtonAction &ba
1690
1691 switch( ba.eventCode )
1692 case 2: // mouse up
1693 ControlInfo /W=PearlDataExplorer lb_datasets
1694 wave /t wtDatasets = $(s_datafolder + s_value)
1695 v_value -= 1
1696 if (v_value < 0)
1697 v_value = max(-1, numpnts(wtDatasets) - 1)
1698 endif
1699 ListBox lb_datasets win=PearlDataExplorer, selRow=v_value
1700 if (v_value >= 0)
1701 variable ids = v_value
1702 ControlInfo /W=PearlDataExplorer cb_dataset_preview
1703 if (v_value)
1704 preview_dataset(wtDatasets[ids])
1705 endif
1706 endif
1707 break
1708 case -1: // control being killed
1709 break
1710 endswitch
1711
1712 return 0
1713 End
1714
1715 static function lbp_datasets(lba) : ListBoxControl
1716 STRUCT WMListboxAction &lba
1717
1718 Variable row = lba.row
1719 Variable col = lba.col
1720 WAVE/T/Z listWave = lba.listWave
1721 WAVE/Z selWave = lba.selWave
1722
1723 switch( lba.eventCode )
1724 case -1: // control being killed
1725 break
1726 case 1: // mouse down
1727 if (row >= 0)
1728 ControlInfo /W=PearlDataExplorer cb_dataset_preview
1729 if (v_value)
1730 preview_dataset(listWave[row])
1731 endif
1732 endif
1733 break
1734 case 3: // double click
1735 break
1736 case 4: // cell selection
1737 case 5: // cell selection plus shift key
1738 break
1739 case 6: // begin edit
1740 break
1741 case 7: // finish edit
1742 break
1743 case 13: // checkbox clicked (Igor 6.2 or later)
1744 break
1745 endswitch
1746
1747 return 0
1748 End
1749
1750 static function bp_attr_notebook(ba) : ButtonControl
1751 STRUCT WMButtonAction &ba
1752
1753 dfref saveDF = GetDataFolderDFR()
1754
1755 switch( ba.eventCode )
1756 case 2: // mouse up
1757 setdatafolder $package_path
1758 svar s_preview_file
1759 wave /t /z attr_names
1760 wave /t /z attr_values
1761 if (WaveExists(attr_names))
1762 attributes_notebook(attr_names, attr_values, s_preview_file)
1763 endif
1764 break
1765 case -1: // control being killed
1766 break
1767 endswitch
1768
1769 setdatafolder saveDF
1770 return 0
1771 End
load_mtrx_file
static dfr load_mtrx_file(string filename, string options=defaultValue)
load a matrix (STM) data file
Definition: pearl-data-explorer.ipf:1235
package_path
static const string package_path
Definition: pearl-data-explorer.ipf:38
adh5_load_preview
string adh5_load_preview(string ANickName, string APathName, string AFileName, variable load_data=defaultValue, variable load_attr=defaultValue)
load a single image from a HDF5 file created by the Area Detector software.
Definition: pearl-area-import.ipf:387
update_datasets
static variable update_datasets()
Definition: pearl-data-explorer.ipf:214
psh5_load_reduced
string psh5_load_reduced(string ANickName, string APathName, string AFileName, funcref reduction_func, string reduction_param, variable progress=defaultValue, variable nthreads=defaultValue)
load and reduce the ScientaImage dataset of the first scan of a PShell data file. ...
Definition: pearl-pshell-import.ipf:1911
bp_browse_filepath
static variable bp_browse_filepath(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1436
preview_file
static variable preview_file(string filename)
Definition: pearl-data-explorer.ipf:257
prompt_default_process
variable prompt_default_process(string *param)
prototype for prompting for processing function parameters.
Definition: pearl-data-explorer.ipf:1070
adh5_load_info
string adh5_load_info(string APathName, string AFileName)
load descriptive info from a HDF5 file created by the Area Detector software.
Definition: pearl-area-import.ipf:497
bp_dataset_prev
static variable bp_dataset_prev(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1688
display_preview_trace
static string display_preview_trace(wave xtrace, wave ytrace)
Definition: pearl-data-explorer.ipf:939
bp_file_prev
static variable bp_file_prev(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1534
ad_brick_slicer
variable ad_brick_slicer(wave data)
open a slicer panel for 3D data.
Definition: pearl-area-display.ipf:1256
PearlElog
interface for writing ELOG entries with Igor graphs as attachment.
lbp_datasets
static variable lbp_datasets(WMListboxAction *lba)
Definition: pearl-data-explorer.ipf:1715
bp_load_files_opt
static variable bp_load_files_opt(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1488
load_selected_files
static variable load_selected_files(string options=defaultValue)
Definition: pearl-data-explorer.ipf:972
PearlCleanupName
string PearlCleanupName(string name)
Definition: pearl-compat.ipf:47
bp_load_files
static variable bp_load_files(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1474
preview_datafolder
static variable preview_datafolder()
Definition: pearl-data-explorer.ipf:577
bp_file_next
static variable bp_file_next(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1502
lbp_filelist
static variable lbp_filelist(WMListboxAction *lba)
Definition: pearl-data-explorer.ipf:1566
prompt_hdf_options
static variable prompt_hdf_options(string *options)
Definition: pearl-data-explorer.ipf:1031
bp_update_datasets
static variable bp_update_datasets(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1601
ks_filematch_pshell
static const string ks_filematch_pshell
Definition: pearl-data-explorer.ipf:41
ks_filematch_adh5
static const string ks_filematch_adh5
Definition: pearl-data-explorer.ipf:40
preview_mtrx_file
static wave preview_mtrx_file(string filename)
load the preview of a Matrix STM file.
Definition: pearl-data-explorer.ipf:452
init_package
static variable init_package()
initialize the global variables of the data explorer.
Definition: pearl-data-explorer.ipf:56
preview_pshell_file
static wave preview_pshell_file(string filename)
load the preview of a PShell HDF5 file.
Definition: pearl-data-explorer.ipf:309
bp_dataset_folder
static variable bp_dataset_folder(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1615
preview_dataset
static variable preview_dataset(string datasetname)
Definition: pearl-data-explorer.ipf:534
package_name
static const string package_name
Definition: pearl-data-explorer.ipf:37
update_filelist
static variable update_filelist()
read a list of PEARL files from the file system
Definition: pearl-data-explorer.ipf:186
load_itx_file
static dfr load_itx_file(string filename, string options=defaultValue)
Definition: pearl-data-explorer.ipf:1192
psh5_load_preview
string psh5_load_preview(string APathName, string AFileName, variable load_data=defaultValue, variable load_attr=defaultValue, string pref_scans=defaultValue, string pref_datasets=defaultValue)
load a preview image from a PShell data file.
Definition: pearl-pshell-import.ipf:251
bp_attr_notebook
static variable bp_attr_notebook(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1750
load_file
static variable load_file(string filename, string options=defaultValue)
Definition: pearl-data-explorer.ipf:996
PearlDataExplorer
preview and import panel for PEARL data
bp_load_prefs
static variable bp_load_prefs(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1408
preview_setscale_x
static variable preview_setscale_x(wave data, wave preview)
Definition: pearl-data-explorer.ipf:618
bp_save_prefs
static variable bp_save_prefs(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1422
load_hdf_file
static dfr load_hdf_file(string filename, string options=defaultValue)
Definition: pearl-data-explorer.ipf:1142
ad_suggest_foldername
string ad_suggest_foldername(string filename, variable ignoredate=defaultValue, string sourcename=defaultValue, variable unique=defaultValue)
generate the name of a data folder based on a file name.
Definition: pearl-area-import.ipf:106
preview_hdf_file
static wave preview_hdf_file(string filename)
load the preview of a PEARL HDF5 file.
Definition: pearl-data-explorer.ipf:365
pearl_file_type
static variable pearl_file_type(string filename)
check whether a file can be imported by this module.
Definition: pearl-data-explorer.ipf:163
bp_dataset_display
static variable bp_dataset_display(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1641
ks_filematch_itx
static const string ks_filematch_itx
Definition: pearl-data-explorer.ipf:42
adh5_load_complete
string adh5_load_complete(string ANickName, string APathName, string AFileName, variable load_data=defaultValue, variable load_attr=defaultValue)
import everything from a HDF5 file created by the Area Detector software.
Definition: pearl-area-import.ipf:207
bp_dataset_next
static variable bp_dataset_next(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1661
extract_preview_image
static variable extract_preview_image(wave data, wave preview)
Definition: pearl-data-explorer.ipf:495
psh5_load_info
string psh5_load_info(string APathName, string AFileName)
load descriptive info from a PShell data file.
Definition: pearl-pshell-import.ipf:2367
adh5_load_reduced
string adh5_load_reduced(string ANickName, string APathName, string AFileName, funcref reduction_func, string reduction_param, variable load_data=defaultValue, variable load_attr=defaultValue, variable progress=defaultValue)
load and reduce a dataset from a HDF5 file created by the Area Detector software. ...
Definition: pearl-area-import.ipf:302
ad_display_profiles
string ad_display_profiles(wave image, string filter=defaultValue)
open a new profiles graph window.
Definition: pearl-area-display.ipf:166
bp_update_filelist
static variable bp_update_filelist(WMButtonAction *ba)
Definition: pearl-data-explorer.ipf:1460
pearl_data_explorer
variable pearl_data_explorer()
Definition: pearl-data-explorer.ipf:45
itx_suggest_foldername
string itx_suggest_foldername(string filename, variable ignoredate=defaultValue, string sourcename=defaultValue, variable unique=defaultValue)
Definition: pearl-data-explorer.ipf:1258
psh5_load_complete
string psh5_load_complete(string ANickName, string APathName, string AFileName, variable load_data=defaultValue, variable load_attr=defaultValue)
load everything from a PShell data file.
Definition: pearl-pshell-import.ipf:170
load_prefs
static variable load_prefs()
Definition: pearl-data-explorer.ipf:118
prompt_func_params
variable prompt_func_params(string func_name, string *func_param)
Definition: pearl-data-explorer.ipf:1076
preview_itx_file
static wave preview_itx_file(string filename)
load the preview of a general ITX file.
Definition: pearl-data-explorer.ipf:416
display_dataset
static variable display_dataset(string datasetname)
Definition: pearl-data-explorer.ipf:782
load_pshell_file
static dfr load_pshell_file(string filename, string options=defaultValue)
Definition: pearl-data-explorer.ipf:1090
save_prefs
static variable save_prefs()
save persistent package data to the preferences file.
Definition: pearl-data-explorer.ipf:102
test_attributes_notebook
variable test_attributes_notebook()
Definition: pearl-data-explorer.ipf:815
show_preview_graph
static string show_preview_graph(wave data, wave xdata=defaultValue)
Definition: pearl-data-explorer.ipf:888
mtrx_load_preview
string mtrx_load_preview(string destName, string pathName, string fileName, string traces=defaultValue)
load a preview image from a Matrix data file.
Definition: pearl-matrix-import.ipf:682
ad_display_slice
string ad_display_slice(wave data)
display three-dimensional data by 2D slice.
Definition: pearl-area-display.ipf:1404
ks_filematch_mtrx
static const string ks_filematch_mtrx
Definition: pearl-data-explorer.ipf:43
attributes_notebook
static variable attributes_notebook(wave attr_names, wave attr_values, string title)
Definition: pearl-data-explorer.ipf:822
mtrx_load_file
string mtrx_load_file(string pathName, string fileName, string traces=defaultValue)
load all data from a Matrix data file.
Definition: pearl-matrix-import.ipf:767
preview_attributes
static variable preview_attributes(dfref attr_folder, dfref dest_folder=defaultValue, wave attr_filter=defaultValue, variable include_datawaves=defaultValue, variable include_infowaves=defaultValue)
Definition: pearl-data-explorer.ipf:648
adh5_list_reduction_funcs
string adh5_list_reduction_funcs()
get a list of functions which can be used as reduction functions.
Definition: pearl-area-import.ipf:1041
notebook_add_attributes
static variable notebook_add_attributes(string notebook_name, wave attr_filter, wave attr_names, wave attr_values)
Definition: pearl-data-explorer.ipf:861
ad_extract_slab
threadsafe wave ad_extract_slab(wave dataset, variable x1, variable x2, variable y1, variable y2, variable z1, variable z2, string destname, variable noavg=defaultValue, variable pscale=defaultValue)
2D cut through 3D dataset, integrate in normal dimension
Definition: pearl-area-profiles.ipf:313