PEARL Procedures rev-distro-1.6.0-0-gcf1399e-dirty Igor procedures for the analysis of PEARL data

- Main Page
- Related Pages
- Packages
- Namespaces
- Files

- File List
- Globals

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