PEARL Procedures rev-distro-3.1.0-0-gea838b3-dirty
Igor procedures for the analysis of PEARL data
Loading...
Searching...
No Matches
pearl-data-explorer.ipf
Go to the documentation of this file.
1#pragma TextEncoding = "UTF-8"
2#pragma rtGlobals=3 // Use modern global access method and strict wave access.
3#pragma IgorVersion = 6.36
4#pragma ModuleName = PearlDataExplorer
5#pragma version = 2.2
6#include <HierarchicalListWidget>, version >= 1.14
7#include "pearl-area-import"
8#include "pearl-area-profiles"
9#include "pearl-area-display"
10#include "pearl-compat"
11#include "pearl-pshell-import"
12
13// copyright (c) 2013-25 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
29
34
35static strconstant package_name = "pearl_explorer"
36static strconstant package_path = "root:packages:pearl_explorer:"
37
38static strconstant ks_filematch_adh5 = "*.h5"
39static strconstant ks_filematch_pshell = "psh*.h5"
40static strconstant ks_filematch_itx = "*.itx"
41
48 DoWindow /HIDE=0 /F PearlDataExplorer
49 if (v_flag == 0)
52 execute /q/z "PearlDataExplorer()"
53 MakeListIntoHierarchicalList("PearlDataExplorer", "lb_contents", "PearlDataExplorer#hlp_contents_open", selectionMode=WMHL_SelectionNonContinguous, pathSeparator="/")
54 WMHL_AddColumns("PearlDataExplorer", "lb_contents", 1)
55 WMHL_SetNotificationProc("PearlDataExplorer", "lb_contents", "PearlDataExplorer#hlp_contents_selection", WMHL_SetSelectNotificationProc)
56 ListBox lb_contents win=PearlDataExplorer, widths={6,60,20}
57 update_controls()
58 endif
59end
60
61static function init_package()
62 dfref save_df = GetDataFolderDFR()
63 SetDataFolder root:
64 newdatafolder /o/s packages
65 newdatafolder /o/s $package_name
66 if (exists("v_InitPanelDone") == 2)
67 SetDataFolder save_df
68 return 0
69 endif
70
71 make /o/n=0/t wtFiles
72 make /o/n=0/i wSelectedFiles,wSelectedDatasets
73 make /o/n=0/t wtDatasets
74 make /o/n=0/t wtPositioners,wtDetectors
75 make /o/n=0/i wSelectedPositioners,wSelectedDetectors
76
77 make /o/n=(1,1) preview_image // preview 2D data
78 make /o/n=0 preview_trace // preview 1D data
79 make /o/n=0/t attr_names, attr_values, attr_filter, attr_filter_summary
80
81 // persistent strings and variables. persistent = saved in preferences
82 string /g s_filepath = "" // directory path to be listed
83 string /g s_hdf_options = "" // recently used HDF5 load options
84 string /g s_reduction_params = "" // recently used reduction parameters
85 string /g s_preview_pvs = "" // semicolon-separated list of EPICS PVs to display in preview.
86 // the list items can contain wildcards for StringMatch
87 s_preview_pvs = "*OP:CURRENT*;*Stats*Total*;*KEITHLEY*READOUT;*CADC*"
88
89 redimension /n=26 attr_filter_summary
90 attr_filter_summary[0] = "MonoEnergy"
91 attr_filter_summary[1] = "MonoGrating"
92 attr_filter_summary[2] = "ExitSlit"
93 attr_filter_summary[3] = "FrontendHSize"
94 attr_filter_summary[4] = "FrontendVSize"
95 attr_filter_summary[5] = "ManipulatorPhi"
96 attr_filter_summary[6] = "ManipulatorTheta"
97 attr_filter_summary[7] = "ManipulatorTilt"
98 attr_filter_summary[8] = "ManipulatorX"
99 attr_filter_summary[9] = "ManipulatorY"
100 attr_filter_summary[10] = "ManipulatorZ"
101 attr_filter_summary[11] = "PassEnergy"
102 attr_filter_summary[12] = "LensMode"
103 attr_filter_summary[13] = "ScientaDwellTime"
104 attr_filter_summary[14] = "ScientaCenterEnergy"
105 attr_filter_summary[15] = "ScientaChannelBegin"
106 attr_filter_summary[16] = "ScientaChannelEnd"
107 attr_filter_summary[17] = "ScientaSliceBegin"
108 attr_filter_summary[18] = "ScientaSliceEnd"
109 attr_filter_summary[19] = "ScientaNumChannels"
110 attr_filter_summary[20] = "StepSize"
111 attr_filter_summary[21] = "ScientaNumSlices"
112 attr_filter_summary[22] = "ManipulatorTempA"
113 attr_filter_summary[23] = "ManipulatorTempB"
114 attr_filter_summary[24] = "RefCurrent"
115 attr_filter_summary[25] = "SampleCurrent"
116
117 // non-persistent strings and variables
118 string /g s_short_filepath = "" // abbreviated directory path
119 string /g s_selected_file = ""
120 string /g s_selected_dataset = ""
121 string /g s_preview_file = "" // file or folder name of the current preview
122 string /g s_preview_source = "" // data source, e.g. EPICS channel name, of the current preview
123 string /g s_profiles_graph = "" // window name of the current preview if the data is two-dimensional
124 string /g s_preview_trace_graph = "" // window name of the current preview if the data is one-dimensional
125 string /g s_preview_graph = "" // window name of the most recent preview graph
126 string /g s_file_info = "" // description of selected file
127 string /g s_result = "" // result of last operation
128
129 variable/g v_InitPanelDone = 1
130
131 SetDataFolder save_df
132end
133
139static function save_prefs()
140 dfref save_df = GetDataFolderDFR()
141 dfref df = $package_path
142 if (DataFolderRefStatus(df) == 1)
143 string fullPath = SpecialDirPath("Packages", 0, 0, 0)
144 fullPath += package_name
145 NewPath/O/C/Q tempPackagePrefsPath, fullPath
146 fullPath += ":preferences.pxp"
147 SetDataFolder df
148 string objects = "attr_filter;attr_filter_summary;s_filepath;s_hdf_options;s_reduction_params;s_preview_pvs"
149 SaveData /O /Q /J=objects fullPath
150 KillPath/Z tempPackagePrefsPath
151 endif
152 SetDataFolder save_df
153end
154
155static function load_prefs()
156 // loads persistent package data from the preferences file
157 // the preferences file is an Igor packed experiment file in a special preferences folder
158 dfref save_df = GetDataFolderDFR()
159
160 variable result = -1
161 setdatafolder root:
162 NewDataFolder /O/S packages
163 NewDataFolder /O/S $package_name
164 dfref package_df = GetDataFolderDFR()
165 string fullPath = SpecialDirPath("Packages", 0, 0, 0)
166 fullPath += package_name
167
168 GetFileFolderInfo /Q /Z fullPath
169 if (V_Flag == 0) // Disk directory exists?
170 fullPath += ":preferences.pxp"
171 GetFileFolderInfo /Q /Z fullPath
172 if (V_Flag == 0) // Preference file exist?
173 LoadData /O /R /Q fullPath
174 result = 0
175 endif
176 endif
177
178 if (result == 0)
179 svar /sdfr=package_df filepath = s_filepath
180 NewPath /O/Z pearl_explorer_filepath, filepath
181 update_filepath()
182 update_filelist()
183 endif
184
185 SetDataFolder save_df
186 return result
187end
188
199static function pearl_file_type(filename)
200 string filename
201
202 if (StringMatch(filename, ks_filematch_pshell))
203 return 1
204 elseif (StringMatch(filename, ks_filematch_adh5))
205 return 2
206 elseif (StringMatch(filename, ks_filematch_itx))
207 return 3
208 else
209 return 0
210 endif
211end
212
218static function update_filepath()
219 PathInfo /S pearl_explorer_filepath
220 svar filepath = $(package_path + "s_filepath")
221 svar shortpath = $(package_path + "s_short_filepath")
222 filepath = s_path
223 shortpath = shorten_filepath(filepath, 40)
224end
225
231static function update_filelist()
232 dfref save_df = GetDataFolderDFR()
233
234 string all_files
235 wave /t wtFiles = $(package_path + "wtFiles")
236 wave wSelectedFiles = $(package_path + "wSelectedFiles")
237 variable nn
238
239 PathInfo pearl_explorer_filepath
240 if (v_flag == 1)
241 all_files = IndexedFile(pearl_explorer_filepath, -1, "????")
242 nn = ItemsInList(all_files)
243 else
244 all_files = ""
245 nn = 0
246 endif
247
248 make /n=(nn) /t /free wtAllFiles
249 wtAllFiles = StringFromList(p, all_files)
250 Extract /o /t wtAllFiles, wtFiles, pearl_file_type(wtAllFiles[p])
251 Sort /A /R wtFiles, wtFiles
252
253 redimension /n=(numpnts(wtFiles)) wSelectedFiles
254 wSelectedFiles = 0
255
256 setdatafolder save_df
257end
258
259// ====== metadata ======
260
273static function get_file_info(filename)
274 string filename
275
276 dfref save_df = GetDataFolderDFR()
277 dfref package_df = $package_path
278
279 variable ft = pearl_file_type(filename)
280 variable result = 0
281
282 switch(ft)
283 case 1:
284 case 2:
285 dfref file_df = get_pshell_info("pearl_explorer_filepath", filename)
286 result = hl_contents_update(file_df)
287 result = result >= 3 ? 0 : -2
288 break
289 default:
290 hl_contents_clear()
291 dfref file_df = package_df:file_info
292 KillDataFolder /z file_df
293 result = -1
294 endswitch
295
296 setdatafolder save_df
297 return result
298end
299
301static function attributes_notebook(filename)
302 string filename
303
304 dfref save_df = GetDataFolderDFR()
305 dfref temp_df = NewFreeDataFolder()
306
307 load_file(filename, options="mode:load_diags", dest_df=temp_df, quiet=1)
308 svar /sdfr=temp_df /z s_loaded_datasets
309 string scan
310 dfref scan_df
311 if (SVAR_Exists(s_loaded_datasets) && (strlen(s_loaded_datasets) >= 4))
312 scan = StringFromList(0, psh5_extract_scan_paths(s_loaded_datasets), ";")
313 scan_df = psh5_dataset_to_folder(temp_df, scan)
314 else
315 scan_df = temp_df
316 endif
317
318 dfref attr_df = ps_find_attr_folder(scan_df)
319 if (DataFolderRefStatus(attr_df))
320 extract_attributes(attr_df, dest_df=temp_df)
321 wave /t /sdfr=temp_df /z attr_names
322 wave /t /sdfr=temp_df /z attr_values
323 if (WaveExists(attr_names) && WaveExists(attr_values))
324 create_attributes_notebook(attr_names, attr_values, filename)
325 endif
326 endif
327
328 setdatafolder save_df
329end
330
347static function extract_attributes(attr_df, [dest_df, attr_filter, include_datawaves, include_infowaves])
348 dfref attr_df
349 dfref dest_df
350 wave /t attr_filter
351 variable include_datawaves
352 variable include_infowaves
353
354 dfref save_df = GetDataFolderDFR()
355 dfref package_df = $package_path
356
357 if (ParamIsDefault(dest_df))
358 dest_df = GetDataFolderDFR()
359 endif
360 if (ParamIsDefault(attr_filter) || !WaveExists(attr_filter))
361 wave /t /sdfr=package_df /z attr_filter
362 endif
363 if (ParamIsDefault(include_datawaves))
364 include_datawaves = 1
365 endif
366 if (ParamIsDefault(include_infowaves))
367 include_infowaves = 1
368 endif
369
370 setdatafolder dest_df
371 wave /t /z attr_names, attr_values
372 if (!WaveExists(attr_names) || !WaveExists(attr_values))
373 make /n=(1) /o /t attr_names, attr_values
374 endif
375 attr_names = ""
376 attr_values = ""
377
378 setdatafolder attr_df
379 wave /t /z IN
380 wave /t /z ID
381 wave /t /z IV
382 wave /t /z IU
383
384 // compile list of attributes
385 variable nattr // destination attributes
386 variable iattr
387 variable ninfo // info wave elements
388 variable iinfo
389 variable nw // attribute waves
390 variable iw
391 string sw
392 string ss
393
394 if (WaveExists(IN) && include_infowaves)
395 ninfo = numpnts(IN)
396 else
397 ninfo = 0
398 endif
399 if (include_datawaves)
400 string waves = WaveList("*", ";", "")
401 string exceptions = "ID;IN;IU;IV"
402 waves = RemoveFromList(exceptions, waves)
403 nw = ItemsInList(waves, ";")
404 else
405 nw = 0
406 endif
407
408 if (WaveExists(attr_filter) && (numpnts(attr_filter) >= 1))
409 nattr = numpnts(attr_filter)
410 redimension /n=(nattr) attr_names
411 attr_names = attr_filter
412 else
413 if(ninfo > 0)
414 redimension /n=(ninfo) attr_names
415 attr_names = SelectString(strlen(ID[p]) >= 0, IN[p], ID[p]) // use ID unless empty
416 endif
417
418 nattr = ninfo + nw
419 iattr = ninfo
420 redimension /n=(nattr) attr_names
421 for (iw = 0; iw < nw; iw +=1 )
422 sw = StringFromList(iw, waves, ";")
423 ss = StringByKey("PV", note($sw), "=", "\r")
424 FindValue /text=sw attr_names
425 if ((v_value < 0) && (strlen(ss) >= 0))
426 attr_names[iattr] = sw
427 iattr += 1
428 endif
429 endfor
430 nattr = iattr
431 endif
432 redimension /n=(nattr) attr_names, attr_values
433 sort attr_names, attr_names
434
435 // look up attribute values
436 for (iattr = 0; iattr < nattr; iattr += 1)
437 sw = attr_names[iattr]
438 // try info waves
439 if (ninfo > 0)
440 FindValue /text=sw ID
441 if (v_value >= 0)
442 attr_values[iattr] = IV[v_value]
443 endif
444 FindValue /text=sw IN
445 if (v_value >= 0)
446 attr_values[iattr] = IV[v_value]
447 endif
448 endif
449
450 // override from attribute wave if existent
451 if (nw > 0)
452 switch (WaveType($sw, 1))
453 case 1: // numeric
454 wave /z w = $sw
455 if (WaveExists(w) && (numpnts(w) >= 1))
456 sprintf ss, "%g", w[0]
457 attr_values[iattr] = ss
458 endif
459 break
460 case 2: // text
461 wave /t/z wt = $sw
462 if (WaveExists(wt) && (numpnts(wt) >= 1))
463 attr_values[iattr] = wt[0]
464 endif
465 break
466 endswitch
467 endif
468 endfor
469
470 setdatafolder save_df
471end
472
473function test_attributes_notebook()
474 dfref df = GetDataFolderDFR()
475 wave /t /sdfr=df attr_names
476 wave /t /sdfr=df attr_values
477 create_attributes_notebook(attr_names, attr_values, GetDataFolder(0))
478end
479
480static function create_attributes_notebook(attr_names, attr_values, title)
481 wave /t attr_names
482 wave /t attr_values
483 string title
484
485 dfref save_df = GetDataFolderDFR()
486 setdatafolder $package_path
487 wave /t/z attr_filter, attr_filter_summary
488
489 string name = PearlCleanupName("nb_" + title[0,27])
490 if (WinType(name) == 5)
491 Notebook $name selection={startOfFile, endOfFile}
492 Notebook $name text=""
493 else
494 NewNotebook /F=1 /K=1 /N=$name as title
495 GetWindow $name wsize
496 v_right = v_left + 260
497 v_bottom = v_top + 360
498 MoveWindow /W=$name v_left, v_top, v_right, v_bottom
499 Notebook $name tabs={2*72}
500 endif
501
502 // summary
503 if (WaveExists(attr_filter_summary) && (numpnts(attr_filter_summary) >= 1))
504 notebook $name fStyle=1, text="Summary\r\r"
505 notebook $name fStyle=0
506 notebook_add_attributes(name, attr_filter_summary, attr_names, attr_values)
507 notebook $name text="\r"
508 endif
509
510 // all attributes
511 notebook $name fStyle=1, text="All Attributes\r\r"
512 notebook $name fStyle=0
513 notebook_add_attributes(name, $"", attr_names, attr_values)
514 notebook $name selection={startOfFile,startOfFile}, findText={"",1}
515
516 setdatafolder save_df
517end
518
519static function notebook_add_attributes(notebook_name, attr_filter, attr_names, attr_values)
520 string notebook_name
521 wave /t /z attr_filter
522 wave /t attr_names
523 wave /t attr_values
524
525 variable nw = numpnts(attr_names)
526 variable iw
527 string sw
528 string ss
529
530 variable do_filter = WaveExists(attr_filter)
531
532 for (iw = 0; iw < nw; iw += 1)
533 if (do_filter)
534 sw = attr_names[iw]
535 FindValue /text=sw attr_filter
536 else
537 v_value = 0
538 endif
539 if (v_value >= 0)
540 sprintf ss, "%s\t%s\r", attr_names[iw], attr_values[iw]
541 notebook $notebook_name text=ss
542 endif
543 endfor
544end
545
546// ====== preview ======
547
548static function preview_file(filename)
549 string filename
550
551 dfref save_df = GetDataFolderDFR()
552 dfref preview_df = $package_path
553
554 killStrings /z authors, pgroup, proposal, proposer, sample
555
556 variable ft = pearl_file_type(filename)
557 switch(ft)
558 case 1:
559 wave /z image = preview_pshell_file(filename)
560 break
561 case 2:
562 wave /z image = preview_hdf_file(filename)
563 break
564 case 3:
565 wave /z image = preview_itx_file(filename)
566 break
567 default:
568 wave /z image = $""
569 endswitch
570
571 if (WaveExists(image))
572 show_preview_graph(image)
573 endif
574
575 setdatafolder save_df
576 return 0
577end
578
590static function /wave preview_pshell_file(filename)
591 string filename
592
593 dfref save_df = GetDataFolderDFR()
594
595 setdatafolder $package_path
596 dfref preview_df = GetDataFolderDFR()
597 svar s_preview_file
598 svar s_preview_source
599 svar /z s_file_info
600 if (! svar_exists(s_file_info))
601 string /g s_file_info
602 endif
603
604 dfref temp_df = NewFreeDataFolder()
605 dfref file_df = psh5_preview("pearl_explorer_filepath", filename, dest_df=temp_df)
606 svar /z /sdfr=temp_df dataname=s_preview_wave
607
608 s_preview_file = filename
609 s_preview_source = ""
610
611 wave /z /sdfr=temp_df data = $dataname
612 if (waveexists(data))
613 duplicate /o data, preview_df:preview_image
614 else
615 print "no data found in file " + filename
616 endif
617
618 s_file_info = ""
619
620 setdatafolder save_df
621 wave /z /sdfr=preview_df preview_image
622 return preview_image
623end
624
636static function /wave preview_hdf_file(filename)
637 string filename
638
639 dfref save_df = GetDataFolderDFR()
640 setdatafolder $package_path
641 svar s_preview_file
642 svar s_preview_source
643 adh5_load_preview("preview_image", "pearl_explorer_filepath", filename)
644 s_preview_file = filename
645 s_preview_source = ""
646 wave /z preview_image
647
648 svar /z s_file_info
649 if (! svar_exists(s_file_info))
650 string /g s_file_info
651 endif
652 if (strlen(s_preview_file) > 0)
653 s_file_info = adh5_load_info("pearl_explorer_filepath", filename)
654 else
655 s_file_info = ""
656 endif
657
658 setdatafolder save_df
659 return preview_image
660end
661
681static function /wave preview_itx_file(filename)
682 string filename
683
684 dfref save_df = GetDataFolderDFR()
685 setdatafolder $package_path
686 svar s_preview_file
687 svar s_preview_source
688 wave preview_image
689
690 dfref data_df = newfreedatafolder()
691 setdatafolder data_df
692 LoadWave /t/p=pearl_explorer_filepath/q filename
693 s_preview_file = s_filename
694 s_preview_source = ""
695
696 preview_datafolder()
697
698 setdatafolder save_df
699 return preview_image
700end
701
703static function extract_preview_image(data, preview)
704 wave data
705 wave preview
706
707 variable z1, z2
708
709 // extract image
710 switch (WaveDims(data))
711 case 1:
712 redimension /n=(numpnts(data)) preview
713 preview = data[p]
714 break
715 case 2:
716 redimension /n=(dimsize(data, 0), dimsize(data, 1)) preview
717 preview = data
718 break
719 case 3:
720 redimension /n=(dimsize(data, 0), dimsize(data, 1)) preview
721 z1 = floor(DimSize(data, 2) / 2)
722 z2 = z1
723 wave slab = ad_extract_slab(data, nan, nan, nan, nan, z1, z2, "", pscale=1)
724 preview = slab
725 break
726 case 4:
727 // not implemented
728 endswitch
729
730 switch (WaveDims(data))
731 case 4:
732 case 3:
733 case 2:
734 setscale /p y dimoffset(data, 1), dimdelta(data, 1), waveunits(data, 1), preview
735 case 1:
736 setscale /p x dimoffset(data, 0), dimdelta(data, 0), waveunits(data, 0), preview
737 setscale d 0, 0, waveunits(data, -1), preview
738 endswitch
739end
740
745static function preview_datafolder()
746 dfref save_df = GetDataFolderDFR()
747
748 setdatafolder $package_path
749 svar s_preview_file
750 svar s_preview_source
751 svar s_preview_pvs
752 wave preview_image
753
754 setdatafolder save_df
755
756 // select a wave to display
757 // consider only double-precision waves, i.e. ignore text and other special waves
758 // filter by matching PV name to s_preview_pvs
759 string d_names = WaveList("*", ";", "DP:1")
760 variable nw = ItemsInList(d_names, ";")
761 variable npv = ItemsInList(s_preview_pvs, ";")
762 variable iw, ipv
763 string wname, wnote, pv_name, pv_match
764 for (iw = 0; iw < nw; iw += 1)
765 wname = StringFromList(iw, d_names, ";")
766 wnote = note($wname)
767 pv_name = StringByKey("PV", wnote, "=", "\r")
768 // find matching data wave by PV name
769 for (ipv = 0; ipv < npv; ipv += 1)
770 pv_match = StringFromList(ipv, s_preview_pvs)
771 if (StringMatch(pv_name, pv_match))
772 wave data = $wname
773 s_preview_source = pv_name
774 extract_preview_image(data, preview_image)
775 preview_setscale_x(data, preview_image)
776 npv = 0
777 nw = 0
778 endif
779 endfor
780 endfor
781
782 setdatafolder save_df
783end
784
785static function preview_setscale_x(data, preview)
786 // sets the approximate x scale of OTF data.
787 // requires an Axis1 tag with name of x wave in the wave note.
788 // if any of these conditions is true, the function does not change the scaling:
789 // 1) Axis1 tag or referenced wave is missing.
790 // 2) preview wave is not set to point scaling.
791 // 3) x wave is not monotonic (90% of the steps in the same direction).
792 wave data
793 wave preview
794
795 if ((DimOffset(preview, 0) == 0) && (DimDelta(preview, 0) == 1))
796 string xname = StringByKey("Axis1", note(data), "=", "\r")
797 wave /z xwave = $xname
798 if (WaveExists(xwave))
799 // check for monotonicity
800 variable monotonic = 0
801 duplicate /free xwave, xdiff
802 differentiate /p xwave /D=xdiff
803 duplicate /free xdiff, xflag
804 xflag = xdiff > 0
805 monotonic = sum(xflag) > numpnts(xwave) * 0.9
806 xflag = xdiff < 0
807 monotonic = monotonic || (sum(xflag) > numpnts(xwave) * 0.9)
808 if (monotonic)
809 setscale /i x xwave[0], xwave[numpnts(xwave)-1], waveunits(xwave, -1), preview
810 endif
811 endif
812 endif
813end
814
816static function display_dataset(file_df, dataset)
817 dfref file_df // top data folder of file
818 string dataset // dataset path inside data folder
819
820 dfref save_df = GetDataFolderDFR()
821
822 dfref data_df = psh5_dataset_to_folder(file_df, dataset)
823 SetDataFolder data_df
824 string data_name = StringFromList(ItemsInList(dataset, "/") - 1, dataset, "/")
825 wave /z data=$data_name
826
827 if (WaveExists(data))
828 switch(WaveDims(data))
829 case 1:
830 case 2:
831 show_preview_graph(data)
832 break
833 case 3:
834 ad_display_slice(data)
835 ad_brick_slicer(data)
836 break
837 endswitch
838 endif
839
840 setdatafolder save_df
841 return 0
842end
843
844static function /s show_preview_graph(data, [xdata])
845 // displays a preview of one- or two-dimensional data
846 wave data // data to be displayed. must either one-dimensional or two-dimensional
847 wave xdata // positions on x axis
848
849 dfref save_df = GetDataFolderDFR()
850 setdatafolder $package_path
851
852 svar s_profiles_graph
853 svar s_preview_file
854 svar s_preview_source
855 svar s_preview_trace_graph
856 svar s_preview_graph
857
858 if ((strlen(s_profiles_graph) > 0) && (WinType(s_profiles_graph) == 1))
859 KillWindow $s_profiles_graph
860 endif
861 if ((strlen(s_preview_trace_graph) > 0) && (WinType(s_preview_trace_graph) == 1))
862 KillWindow $s_preview_trace_graph
863 endif
864
865 string graphname
866 if (wavedims(data) == 2)
867 s_profiles_graph = ad_display_profiles(data)
868 ModifyGraph /w=$s_profiles_graph /z wbRGB=(48640,56832,60160)
869 graphname = s_profiles_graph
870 elseif (wavedims(data) == 1)
871 duplicate /o data, preview_trace
872 if (!ParamIsDefault(xdata))
873 duplicate /o xdata, preview_trace_x
874 else
875 duplicate /o data, preview_trace_x
876 preview_trace_x = x
877 setscale d 0, 0, WaveUnits(data, 0), preview_trace_x
878 endif
879 s_preview_trace_graph = display_preview_trace(preview_trace_x, preview_trace)
880 ModifyGraph /w=$s_preview_trace_graph wbRGB=(48640,56832,60160)
881 graphname = s_preview_trace_graph
882 else
883 return ""
884 endif
885
886 string title = "Preview " + s_preview_file
887 if (strlen(s_preview_source) > 0)
888 title = title + " (" + s_preview_source[0,31] + ")"
889 endif
890 dowindow /f/t $graphname, title
891 s_preview_graph = graphname
892
893 setdatafolder save_df
894 return graphname
895end
896
897static function /s display_preview_trace(xtrace, ytrace)
898 wave /z xtrace
899 wave ytrace
900
901 if (WaveExists(xtrace))
902 display /n=pearl_explorer_1d /k=1 ytrace vs xtrace as "Preview"
903 else
904 display /n=pearl_explorer_1d /k=1 ytrace as "Preview"
905 endif
906
907 string graphname = s_name
908 ModifyGraph /w=$graphname rgb[0]=(0,0,0)
909 ModifyGraph /w=$graphname grid=2
910 ModifyGraph /w=$graphname mirror=1
911 ModifyGraph /w=$graphname minor=1
912 ModifyGraph /w=$graphname axThick=0.5
913 ModifyGraph /w=$graphname gridRGB=(52224,52224,52224)
914 ModifyGraph /w=$graphname gridHair=0
915 ModifyGraph /w=$graphname tick=0
916 ModifyGraph /w=$graphname btLen=4
917
918 // axis labels
919 string labels = note(ytrace)
920 string lab
921 lab = StringByKey("AxisLabelX", labels, "=", "\r")
922 if (!strlen(lab))
923 lab = "X"
924 endif
925 Label /w=$graphname bottom lab + " (\\U)"
926 lab = StringByKey("Dataset", labels, "=", "\r")
927 if (!strlen(lab))
928 lab = "value"
929 endif
930 Label /w=$graphname left lab + " (\\U)"
931
932 return s_name
933end
934
935// ====== file loading ======
936
944static function load_selected_files([options])
945 string options
946
947 dfref save_df = GetDataFolderDFR()
948 setdatafolder $package_path
949
950 wave wSelectedFiles
951 wave/t wtFiles
952 variable nn = numpnts(wSelectedFiles)
953 variable ii
954 for (ii = 0; ii < nn; ii += 1)
955 if (wSelectedFiles[ii])
956 setdatafolder save_df
957 if (ParamIsDefault(options))
958 load_file(wtFiles[ii])
959 else
960 load_file(wtFiles[ii], options=options)
961 endif
962 endif
963 endfor
964end
965
983static function load_file(filename, [options, dest_df, quiet])
984 string filename
985 string options
986 dfref dest_df
987 variable quiet
988
989 if (ParamIsDefault(options))
990 options = ""
991 endif
992
993 variable ft = pearl_file_type(filename)
994 switch(ft)
995 case 1:
996 load_pshell_file(filename, options=options, dest_df=dest_df, quiet=quiet)
997 break
998 case 2:
999 load_hdf_file(filename, options=options, dest_df=dest_df, quiet=quiet)
1000 break
1001 case 3:
1002 load_itx_file(filename, dest_df=dest_df, quiet=quiet)
1003 break
1004 default:
1005 break
1006 endswitch
1007end
1008
1009static function prompt_hdf_options(options)
1010 string &options
1011
1012 string mode = StringByKey("mode", options, ":", ";")
1013 string reduction_func = StringByKey("reduction_func", options, ":", ";")
1014
1015 string modes = "load_scan;load_region;load_dataset;load_diags;load_complete;"
1016 string reduction_funcs = adh5_list_reduction_funcs()
1017 reduction_funcs = RemoveFromList("adh5_default_reduction", reduction_funcs, ";")
1018
1019 if (strlen(mode) == 0)
1020 mode = StringFromList(0, modes, ";")
1021 endif
1022 if (strlen(reduction_func) == 0)
1023 reduction_func = StringFromList(0, reduction_funcs, ";")
1024 endif
1025
1026 prompt mode, "Mode", popup, modes
1027 prompt reduction_func, "Reduction Function", popup, reduction_funcs
1028 doprompt "HDF5 Loading Options", mode, reduction_func
1029
1030 if (v_flag == 0)
1031 options = ReplaceStringByKey("mode", options, mode, ":", ";")
1032 options = ReplaceStringByKey("reduction_func", options, reduction_func, ":", ";")
1033 endif
1034 return v_flag // 0 = OK, 1 = cancel
1035end
1036
1049function prompt_default_process(param)
1050 string &param
1051
1052 return 0
1053end
1054
1055function prompt_func_params(func_name, func_param)
1056 string func_name
1057 string &func_param
1058
1059 string prompt_name = "prompt_" + func_name
1060 if (exists(prompt_name) == 6)
1061 funcref prompt_default_process prompt_func = $prompt_name
1062 return prompt_func(func_param)
1063 else
1064 // ignore missing prompt function
1065 return 0
1066 endif
1067end
1068
1107static function /df load_pshell_file(filename, [options, dest_df, quiet])
1108 string filename
1109 string options
1110 dfref dest_df
1111 variable quiet
1112
1113 dfref save_df = GetDataFolderDFR()
1114
1115 svar pref_options = $(package_path + "s_hdf_options")
1116 svar pref_params = $(package_path + "s_reduction_params")
1117 string path = "pearl_explorer_filepath"
1118
1119 if (ParamIsDefault(options))
1120 options = pref_options
1121 endif
1122
1123 if (strlen(options) == 0)
1124 if (prompt_hdf_options(options) == 0)
1125 pref_options = options
1126 else
1127 return $""
1128 endif
1129 endif
1130
1131 string reduction_func = StringByKey("reduction_func", options, ":", ";")
1132 string reduction_params = pref_params
1133 variable max_rank = 2
1134
1135 if (exists(reduction_func) == 6)
1136 max_rank = 3
1137 if (prompt_func_params(reduction_func, reduction_params) == 0)
1138 pref_params = reduction_params
1139 else
1140 return $""
1141 endif
1142 endif
1143
1144 string mode = StringByKey("mode", options, ":", ";")
1145 string selected_datasets = WMHL_SelectedObjectsList("PearlDataExplorer", "lb_contents")
1146 string selected_scans = psh5_extract_scan_paths(selected_datasets)
1147 string selected_regions = psh5_extract_region_paths(selected_datasets)
1148 variable dsc
1149
1150 if (!quiet)
1151 print mode, filename
1152 if (strlen(reduction_func))
1153 print reduction_func, reduction_params
1154 endif
1155 endif
1156
1157 strswitch(mode)
1158 case "load_complete":
1159 dsc = kDSCAll
1160 dfref file_df = psh5_load(path, filename, "", "", "*", classes=dsc, reduction_func=reduction_func, reduction_params=reduction_params, dest_df=dest_df)
1161 break
1162 case "load_diags":
1163 if (ItemsInList(selected_scans, ";") == 0)
1164 if (!quiet)
1165 print "no scan selected - defaulting to scan 1."
1166 endif
1167 selected_scans = "/scan1;"
1168 endif
1169 dsc = kDSCAttrs | kDSCDiags | kDSCSnaps | kDSCMeta | kDSCMonitors
1170 dfref file_df = psh5_load(path, filename, selected_scans, "", "", classes=dsc, dest_df=dest_df)
1171 break
1172 case "load_scan":
1173 if (ItemsInList(selected_scans, ";") == 0)
1174 if (!quiet)
1175 print "no scan selected - defaulting to scan 1."
1176 endif
1177 selected_scans = "/scan1;"
1178 endif
1179 dsc = kDSCPositioners | kDSCDetectors | kDSCScientaScaling | kDSCEssentialDiags
1180 dfref file_df = psh5_load(path, filename, selected_scans, "", "", classes=dsc, max_rank=max_rank, reduction_func=reduction_func, reduction_params=reduction_params, dest_df=dest_df)
1181 break
1182 case "load_region":
1183 if (ItemsInList(selected_regions, ";") == 0)
1184 if (!quiet)
1185 print "no region selected - defaulting to scan 1/region 1."
1186 endif
1187 selected_regions = "/scan1/region1;"
1188 endif
1189 dsc = kDSCPositioners | kDSCDetectors | kDSCScientaScaling | kDSCEssentialDiags
1190 dfref file_df = psh5_load(path, filename, "", selected_regions, "", classes=dsc, max_rank=max_rank, reduction_func=reduction_func, reduction_params=reduction_params, dest_df=dest_df)
1191 break
1192 case "load_dataset":
1193 if (ItemsInList(selected_datasets, ";") > 0)
1194 dsc = kDSCAll
1195 dfref file_df = psh5_load(path, filename, "", "", selected_datasets, classes=dsc, reduction_func=reduction_func, reduction_params=reduction_params, dest_df=dest_df)
1196 else
1197 if (!quiet)
1198 DoAlert /T="PShell Import" 0, "Please select the datasets to load."
1199 endif
1200 endif
1201 break
1202 endswitch
1203
1204 if (DataFolderRefStatus(file_df))
1205 setdatafolder file_df
1206 string /g pearl_explorer_import = "load_pshell_file"
1207 if (!quiet)
1208 print "data loaded to", GetDataFolder(1)
1209 endif
1210 else
1211 setdatafolder save_df
1212 endif
1213
1214 return file_df
1215end
1216
1217static function /df load_hdf_file(filename, [options, dest_df, quiet])
1218 string filename
1219 string options
1220 dfref dest_df
1221 variable quiet
1222
1223 dfref save_df = GetDataFolderDFR()
1224 string nickname = ad_suggest_foldername(filename)
1225 string loaded_filename = ""
1226
1227 if (ParamIsDefault(dest_df) || !DataFolderRefStatus(dest_df))
1228 //
1229 else
1230 DoAlert /T="load_hdf_file" 0, "optional argument dest_df not supported."
1231 return $""
1232 endif
1233
1234 if (ParamIsDefault(options))
1235 loaded_filename = adh5_load_complete(nickname, "pearl_explorer_filepath", filename)
1236 else
1237 if (strlen(options) == 0)
1238 svar pref_options = $(package_path + "s_hdf_options")
1239 options = pref_options
1240 if (prompt_hdf_options(options) == 0)
1241 // OK
1242 pref_options = options
1243 else
1244 // cancel
1245 options = ""
1246 endif
1247 endif
1248
1249 string mode = StringByKey("mode", options, ":", ";")
1250
1251 strswitch(mode)
1252 case "load_reduced":
1253 string reduction_func = StringByKey("reduction_func", options, ":", ";")
1254 svar pref_params = $(package_path + "s_reduction_params")
1255 string reduction_params = pref_params
1256 if (prompt_func_params(reduction_func, reduction_params) == 0)
1257 pref_params = reduction_params
1258 print reduction_func, reduction_params
1259 loaded_filename = adh5_load_reduced(nickname, "pearl_explorer_filepath", filename, $reduction_func, reduction_params)
1260 endif
1261 break
1262 endswitch
1263 endif
1264
1265 dfref data_df
1266 if (strlen(loaded_filename) > 0)
1267 setdatafolder $("root:" + nickname)
1268 data_df = GetDataFolderDFR()
1269 string /g pearl_explorer_import = "load_hdf_file"
1270 else
1271 setdatafolder save_df
1272 endif
1273
1274 return data_df
1275end
1276
1277static function /df load_itx_file(filename, [options, dest_df, quiet])
1278 string filename
1279 string options
1280 dfref dest_df
1281 variable quiet
1282
1283 dfref save_df = GetDataFolderDFR()
1284 string nickname = itx_suggest_foldername(filename)
1285
1286 if (ParamIsDefault(options))
1287 options = ""
1288 endif
1289
1290 variable own_data_df = 0
1291 if (ParamIsDefault(dest_df) || !DataFolderRefStatus(dest_df))
1292 setdatafolder root:
1293 newdatafolder /s/o $("root:" + nickname)
1294 own_data_df = 1
1295 else
1296 setdatafolder dest_df
1297 endif
1298 dfref data_df = GetDataFolderDFR()
1299
1300 // note: some versions of PEARL data files save data to a new data folder,
1301 // and leave the newly created folder as the current folder.
1302 // the free data folder is used by those files which don't create their own data folder.
1303 // this is the new recommended behaviour
1304
1305 LoadWave /t/p=pearl_explorer_filepath/q filename
1306 svar waves = s_wavenames
1307 dfref act_df = GetDataFolderDFR()
1308 if (v_flag > 0)
1309 string /g pearl_explorer_import = "load_itx_file"
1310 endif
1311
1312 if (!DataFolderRefsEqual(act_df, data_df) && own_data_df)
1313 // the file created its own data folder.
1314 // let's kill the pre-allocated folder
1315 setdatafolder data_df
1316 if (ItemsInList(WaveList("*", ";", ""), ";") == 0)
1317 killdatafolder /z data_df
1318 endif
1319 endif
1320
1321 setdatafolder save_df
1322 return act_df
1323end
1324
1346function /s itx_suggest_foldername(filename, [ignoredate,sourcename,unique])
1347 string filename
1348 variable ignoredate
1349 string sourcename
1350 variable unique
1351
1352 if (ParamIsDefault(ignoredate))
1353 ignoredate = 0
1354 endif
1355 if (ParamIsDefault(unique))
1356 unique = 0
1357 endif
1358
1359 string basename = ParseFilePath(3, filename, ":", 0, 0)
1360 string extension = ParseFilePath(4, filename, ":", 0, 0)
1361 string nickname
1362
1363 string autosource
1364 if (strsearch(basename, "X03DA_PC", 0, 2) >= 0)
1365 autosource = "sscan"
1366 basename = ReplaceString("_", basename, "-")
1367 ignoredate = 1
1368 elseif (strsearch(basename, "otf", 0, 2) >= 0)
1369 autosource = "otf"
1370 endif
1371 if (ParamIsDefault(sourcename))
1372 sourcename = autosource
1373 endif
1374
1375 variable nparts = ItemsInList(basename, "-")
1376 if (nparts >= 3)
1377 string datepart = StringFromList(nparts - 2, basename, "-")
1378 string indexpart = StringFromList(nparts - 1, basename, "-")
1379 if (ignoredate)
1380 sprintf nickname, "%s_%s", sourcename, indexpart
1381 else
1382 sprintf nickname, "%s_%s_%s", sourcename, datepart, indexpart
1383 endif
1384 else
1385 nickname = PearlCleanupName(basename)
1386 endif
1387
1388 if (unique && CheckName(nickname, 11))
1389 nickname = UniqueName(nickname + "_", 11, 0)
1390 endif
1391
1392 return nickname
1393end
1394
1395// ====== panel ======
1396
1403Window PearlDataExplorer() : Panel
1404 PauseUpdate; Silent 1 // building window...
1405 NewPanel /K=1 /W=(510,45,1190,539) as "PEARL Data Explorer"
1406 ModifyPanel cbRGB=(48640,56832,60160)
1407 GroupBox g_data_reduction,pos={355.00,370.00},size={306.00,49.00},title="data reduction"
1408 GroupBox g_data_reduction,help={"data reduction of 3D ScientaImage"}
1409 GroupBox gb_filepath,pos={8.00,4.00},size={328.00,48.00},title="file system folder"
1410 TitleBox tb_filepath,pos={20.00,28.00},size={279.00,21.00},frame=0
1411 TitleBox tb_filepath,variable= root:packages:pearl_explorer:s_short_filepath,fixedSize=1
1412 Button b_browse_filepath,pos={303.00,24.00},size={20.00,20.00},proc=PearlDataExplorer#bp_browse_filepath,title="..."
1413 Button b_browse_filepath,fColor=(65280,48896,32768)
1414 Button b_browse_filepath,help={"select the file system folder that contains the data files"}
1415 GroupBox gb_prefs,pos={8.00,351.00},size={65.00,131.00},title="prefs"
1416 GroupBox gb_prefs,help={"explorer package preferences"}
1417 Button b_save_prefs,pos={21.00,394.00},size={38.00,17.00},proc=PearlDataExplorer#bp_save_prefs,title="save"
1418 Button b_save_prefs,help={"save preferences of the data explorer package (data file path, attributes filter)"}
1419 Button b_save_prefs,fColor=(65280,48896,32768)
1420 Button b_load_prefs,pos={21.00,374.00},size={38.00,17.00},proc=PearlDataExplorer#bp_load_prefs,title="load"
1421 Button b_load_prefs,help={"load preferences of the data explorer package"}
1422 Button b_load_prefs,fColor=(65280,48896,32768)
1423 GroupBox gb_filelist,pos={8.00,55.00},size={328.00,293.00},title="data files"
1424 ListBox lb_files,pos={20.00,83.00},size={303.00,222.00},proc=PearlDataExplorer#lbp_filelist
1425 ListBox lb_files,listWave=root:packages:pearl_explorer:wtFiles
1426 ListBox lb_files,selWave=root:packages:pearl_explorer:wSelectedFiles,mode= 4
1427 Button b_update_filelist,pos={246.00,315.00},size={76.00,22.00},proc=PearlDataExplorer#bp_update_filelist,title="update list"
1428 Button b_update_filelist,fColor=(65280,48896,32768)
1429 Button b_update_filelist,help={"reload the file list"}
1430 CheckBox cb_file_preview,pos={94.00,375.00},size={59.00,14.00},title="preview"
1431 CheckBox cb_file_preview,help={"enable/disable automatic preview window when selecting a data file"}
1432 CheckBox cb_file_preview,value= 0
1433 CheckBox cb_file_elog,pos={94.00,395.00},size={82.00,14.00},title="ELOG"
1434 CheckBox cb_file_elog,help={"enable/disable sending metadata to ELOG panel when selecting a data file (does not submit to ELOG)"}
1435 CheckBox cb_file_elog,value= 0
1436 Button b_attr_notebook,pos={94.00,415.00},size={64.00,22.00},disable=2,proc=PearlDataExplorer#bp_attr_notebook,title="notebook"
1437 Button b_attr_notebook,help={"show a summary of attributes in a notebook window"}
1438 Button b_attr_notebook,fColor=(65280,48896,32768)
1439 Button b_file_prev,pos={20.00,314.00},size={22.00,22.00},proc=PearlDataExplorer#bp_file_prev,title="\\W646"
1440 Button b_file_prev,fColor=(65280,48896,32768)
1441 Button b_file_prev,help={"select previous file from list"}
1442 Button b_file_next,pos={44.00,314.00},size={22.00,22.00},proc=PearlDataExplorer#bp_file_next,title="\\W649"
1443 Button b_file_next,fColor=(65280,48896,32768)
1444 Button b_file_next,help={"select next file from list"}
1445 Button b_goto_dataset,pos={355.00,315.00},size={64.00,22.00},disable=2,proc=PearlDataExplorer#bp_goto_dataset,title="goto DF"
1446 Button b_goto_dataset,help={"change the current data folder to find the selected dataset (if loaded)"}
1447 Button b_goto_dataset,fColor=(65280,48896,32768)
1448 Button b_display_dataset,pos={423.00,315.00},size={64.00,22.00},disable=2,proc=PearlDataExplorer#bp_display_dataset,title="display"
1449 Button b_display_dataset,help={"display the selected dataset"}
1450 Button b_display_dataset,fColor=(65280,48896,32768)
1451 Button b_load_complete,pos={355.00,451.00},size={92.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="all data"
1452 Button b_load_complete,help={"load all datasets of the selected file."}
1453 Button b_load_complete,userdata= "mode:load_complete;"
1454 Button b_load_complete,fColor=(65280,48896,32768)
1455 TitleBox tb_selected_file,pos={360.00,28.00},size={309.00,22.00},frame=0
1456 TitleBox tb_selected_file,variable= root:packages:pearl_explorer:s_selected_file,fixedSize=1
1457 GroupBox gb_contents,pos={346.00,55.00},size={327.00,294.00},title="datasets"
1458 ListBox lb_contents,pos={355.00,84.00},size={305.00,222.00}
1459 ListBox lb_contents,keySelectCol= 1
1460 GroupBox gb_selected_file,pos={346.00,4.00},size={328.00,48.00},title="selected file"
1461 Button b_load_region,pos={355.00,426.00},size={92.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="region"
1462 Button b_load_region,help={"load significant datasets and metadata from the selected region"}
1463 Button b_load_region,userdata= "mode:load_region;",fColor=(65280,48896,32768)
1464 PopupMenu popup_reduction,pos={366.00,391.00},size={200.00,17.00},bodyWidth=200,proc=PearlDataExplorer#pmp_reduction_func
1465 PopupMenu popup_reduction,help={"data reduction function for 3d ScientaImage. note: the list may contain unsuitable functions. check the code or documentation!"}
1466 PopupMenu popup_reduction,mode=1,popvalue="None",value= #"PearlDataExplorer#pm_reduction_values()"
1467 GroupBox group_import,pos={346.00,351.00},size={326.00,131.00},title="import"
1468 Button b_load_scan,pos={450.00,426.00},size={94.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="scan"
1469 Button b_load_scan,help={"load significant datasets and metadata from the selected scan"},userdata= "mode:load_scan;"
1470 Button b_load_scan,fColor=(65280,48896,32768)
1471 Button b_load_diags,pos={450.00,451.00},size={94.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="diagnostics"
1472 Button b_load_diags,help={"load diagnostic datasets of the selected scans"}
1473 Button b_load_diags,userdata= "mode:load_diags;",fColor=(65280,48896,32768)
1474 Button b_load_dataset,pos={547.00,426.00},size={101.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="dataset"
1475 Button b_load_dataset,help={"load the selected dataset(s) and significant metadata"}
1476 Button b_load_dataset,userdata= "mode:load_dataset;",fColor=(65280,48896,32768)
1477 Button b_reduction_params,pos={571.00,390.00},size={71.00,19.00},disable=2,proc=PearlDataExplorer#bp_reduction_params,title="set params"
1478 Button b_reduction_params,help={"set data reduction parameters"}
1479 Button b_reduction_params,fColor=(65280,48896,32768)
1480 GroupBox g_fileinfo,pos={85.00,351.00},size={251.00,131.00},title="file info"
1481 ToolsGrid grid=(0,28.35,5)
1482EndMacro
1483
1486static function update_controls()
1487 dfref package_df = $package_path
1488 svar /z /sdfr=package_df hl_contents_datasets
1489 wave /z /sdfr=package_df wSelectedFiles
1490
1491 variable file_selected = 0
1492 if (WaveExists(wSelectedFiles))
1493 file_selected = sum(wSelectedFiles)
1494 endif
1495
1496 string selected_datasets = WMHL_SelectedObjectsList("PearlDataExplorer", "lb_contents")
1497 variable scan_selected = strsearch(selected_datasets, "scan", 0, 2) == 0
1498 variable region_selected = strsearch(selected_datasets, "region", 0, 2) >= 0
1499
1500 variable dataset_selected = 0
1501 variable nds = ItemsInList(selected_datasets, ";")
1502 variable ids
1503 string ds
1504 if (svar_exists(hl_contents_datasets))
1505 for (ids = 0; ids < nds; ids += 1)
1506 ds = "/" + StringFromList(ids, selected_datasets, ";")
1507 if (NumType(NumberByKey(ds, hl_contents_datasets, ":", ";")) == 0)
1508 dataset_selected = 1
1509 break
1510 endif
1511 endfor
1512 else
1513 nds = 0
1514 endif
1515
1516 variable dis
1517 dis = file_selected ? 0 : 2
1518 Button b_load_complete win=PearlDataExplorer,disable=dis
1519 Button b_load_diags win=PearlDataExplorer,disable=dis
1520 dis = file_selected && scan_selected ? 0 : 2
1521 Button b_attr_notebook win=PearlDataExplorer,disable=dis
1522
1523 dis = scan_selected ? 0 : 2
1524 Button b_load_scan win=PearlDataExplorer,disable=dis
1525 dis = region_selected ? 0 : 2
1526 Button b_load_region win=PearlDataExplorer,disable=dis
1527 dis = dataset_selected ? 0 : 2
1528 Button b_load_dataset win=PearlDataExplorer,disable=dis
1529 Button b_display_dataset win=PearlDataExplorer,disable=dis
1530 dis = file_selected && (nds > 0) ? 0 : 2
1531 Button b_goto_dataset win=PearlDataExplorer,disable=dis
1532
1533 ControlInfo /W=PearlDataExplorer popup_reduction
1534 if ((cmpstr(S_Value, "None") != 0) && (exists(S_Value) == 6))
1535 GroupBox g_data_reduction win=PearlDataExplorer,labelBack=(65535,49151,49151)
1536 Button b_reduction_params win=PearlDataExplorer,disable=0
1537 else
1538 GroupBox g_data_reduction win=PearlDataExplorer,labelBack=0
1539 Button b_reduction_params win=PearlDataExplorer,disable=2
1540 endif
1541
1542 return 0
1543end
1544
1545static function bp_load_prefs(ba) : ButtonControl
1546 STRUCT WMButtonAction &ba
1547
1548 switch( ba.eventCode )
1549 case 2: // mouse up
1550 load_prefs()
1551 update_controls()
1552 break
1553 case -1: // control being killed
1554 break
1555 endswitch
1556
1557 return 0
1558End
1559
1560static function bp_save_prefs(ba) : ButtonControl
1561 STRUCT WMButtonAction &ba
1562
1563 switch( ba.eventCode )
1564 case 2: // mouse up
1565 save_prefs()
1566 break
1567 case -1: // control being killed
1568 break
1569 endswitch
1570
1571 return 0
1572End
1573
1578static function /s shorten_filepath(long_path, max_len)
1579 string long_path
1580 variable max_len
1581
1582 string path = long_path
1583 variable ellipsis = 0
1584 do
1585 if (strlen(path) > max_len)
1586 path = RemoveListItem(1, path, ":")
1587 ellipsis += 1
1588 else
1589 break
1590 endif
1591 while (1)
1592
1593 if (ellipsis >= 1)
1594 path = AddListItem("
", path, ":", 1)
1595 endif
1596
1597 return path
1598end
1599
1600static function bp_browse_filepath(ba) : ButtonControl
1601 STRUCT WMButtonAction &ba
1602
1603 dfref save_df = GetDataFolderDFR()
1604
1605 switch( ba.eventCode )
1606 case 2: // mouse up
1607 PathInfo /S pearl_explorer_filepath
1608 NewPath /M="select data file folder" /O/Z pearl_explorer_filepath
1609 if (v_flag == 0)
1610 update_filepath()
1611 update_filelist()
1612 update_controls()
1613 endif
1614 break
1615 case -1: // control being killed
1616 break
1617 endswitch
1618
1619 setdatafolder save_df
1620 return 0
1621End
1622
1623static function bp_update_filelist(ba) : ButtonControl
1624 STRUCT WMButtonAction &ba
1625
1626 switch( ba.eventCode )
1627 case 2: // mouse up
1628 update_filelist()
1629 update_controls()
1630 break
1631 case -1: // control being killed
1632 break
1633 endswitch
1634
1635 return 0
1636End
1637
1639static function /s pm_reduction_values()
1640 string reduction_funcs = adh5_list_reduction_funcs()
1641 reduction_funcs = RemoveFromList("adh5_default_reduction", reduction_funcs, ";")
1642 reduction_funcs = AddListItem("None", reduction_funcs, ";", 0)
1643 return reduction_funcs
1644end
1645
1646static function pmp_reduction_func(pa) : PopupMenuControl
1647 STRUCT WMPopupAction &pa
1648
1649 switch( pa.eventCode )
1650 case 2: // mouse up
1651 Variable popNum = pa.popNum
1652 String popStr = pa.popStr
1653 update_controls()
1654 break
1655 case -1: // control being killed
1656 break
1657 endswitch
1658
1659 return 0
1660End
1661
1662static function bp_reduction_params(ba) : ButtonControl
1663 STRUCT WMButtonAction &ba
1664
1665 switch( ba.eventCode )
1666 case 2: // mouse up
1667 ControlInfo /W=PearlDataExplorer popup_reduction
1668 if ((cmpstr(S_Value, "None") != 0) && (exists(S_Value) == 6))
1669 svar pref_params = $(package_path + "s_reduction_params")
1670 string reduction_func = S_Value
1671 string reduction_params = pref_params
1672 if (prompt_func_params(reduction_func, reduction_params) == 0)
1673 pref_params = reduction_params
1674 endif
1675 endif
1676 break
1677 case -1: // control being killed
1678 break
1679 endswitch
1680
1681 return 0
1682End
1683
1684static function bp_load_options(ba) : ButtonControl
1685 STRUCT WMButtonAction &ba
1686
1687 switch( ba.eventCode )
1688 case 2: // mouse up
1689 // options must be in the button's unnamed user data in the form: "mode:load_complete".
1690 // see load_pshell_file for recognized values.
1691 string options=ba.userData
1692
1693 // data reduction popup
1694 ControlInfo /W=PearlDataExplorer popup_reduction
1695 if ((cmpstr(S_Value, "None") != 0) && (exists(S_Value) == 6))
1696 options = ReplaceStringByKey("reduction_func", options, S_Value, ":", ";")
1697 endif
1698
1699 load_selected_files(options=options)
1700 break
1701 case -1: // control being killed
1702 break
1703 endswitch
1704
1705 return 0
1706End
1707
1724static function selected_file(file, do_preview, do_elog)
1725 string file
1726 variable do_preview
1727 variable do_elog
1728
1729 dfref save_df = GetDataFolderDFR()
1730 setdatafolder $package_path
1731 svar s_selected_file
1732 s_selected_file = file
1733 variable fi = get_file_info(file)
1734 if (fi == 0 && do_preview != 0)
1735 preview_file(file)
1736 endif
1737 if (fi == 0 && do_elog != 0)
1738 send_to_elog()
1739 endif
1740 update_controls()
1741
1742 setdatafolder save_df
1743 return 0
1744end
1745
1746static function bp_file_next(ba) : ButtonControl
1747 STRUCT WMButtonAction &ba
1748
1749 dfref save_df = GetDataFolderDFR()
1750
1751 switch( ba.eventCode )
1752 case 2: // mouse up
1753 setdatafolder $package_path
1754 wave /t wtFiles
1755 wave wSelectedFiles
1756 FindValue /i=1 wSelectedFiles
1757 v_value += 1
1758 if (v_value >= numpnts(wtFiles))
1759 v_value = min(numpnts(wtFiles) - 1, 0)
1760 endif
1761 wSelectedFiles = p == v_value
1762 if (v_value >= 0)
1763 variable ifile = v_value
1764 ControlInfo /W=PearlDataExplorer cb_file_preview
1765 variable do_preview = v_value
1766 ControlInfo /W=PearlDataExplorer cb_file_elog
1767 variable do_elog = v_value
1768 selected_file(wtFiles[ifile], do_preview, do_elog)
1769 endif
1770 update_controls()
1771 break
1772 case -1: // control being killed
1773 break
1774 endswitch
1775
1776 setdatafolder save_df
1777 return 0
1778End
1779
1780static function bp_file_prev(ba) : ButtonControl
1781 STRUCT WMButtonAction &ba
1782
1783 dfref save_df = GetDataFolderDFR()
1784
1785 switch( ba.eventCode )
1786 case 2: // mouse up
1787 setdatafolder $package_path
1788 wave /t wtFiles
1789 wave wSelectedFiles
1790 FindValue /i=1 wSelectedFiles
1791 v_value -= 1
1792 if (v_value < 0)
1793 v_value = numpnts(wtFiles) - 1
1794 endif
1795 wSelectedFiles = p == v_value
1796 if (v_value >= 0)
1797 variable ifile = v_value
1798 ControlInfo /W=PearlDataExplorer cb_file_preview
1799 variable do_preview = v_value
1800 ControlInfo /W=PearlDataExplorer cb_file_elog
1801 variable do_elog = v_value
1802 selected_file(wtFiles[ifile], do_preview, do_elog)
1803 endif
1804 update_controls()
1805 break
1806 case -1: // control being killed
1807 break
1808 endswitch
1809
1810 setdatafolder save_df
1811 return 0
1812End
1813
1814static function lbp_filelist(lba) : ListBoxControl
1815 STRUCT WMListboxAction &lba
1816
1817 dfref save_df = GetDataFolderDFR()
1818
1819 Variable row = lba.row
1820 Variable col = lba.col
1821 WAVE/T/Z listWave = lba.listWave
1822 WAVE/Z selWave = lba.selWave
1823
1824 switch( lba.eventCode )
1825 case -1: // control being killed
1826 break
1827 case 1: // mouse down
1828 setdatafolder $package_path
1829 wave wSelectedFiles
1830 if (selWave[row])
1831 if (sum(wSelectedFiles) == 1)
1832 ControlInfo /W=PearlDataExplorer cb_file_preview
1833 variable do_preview = v_value
1834 ControlInfo /W=PearlDataExplorer cb_file_elog
1835 variable do_elog = v_value
1836 selected_file(listWave[row], do_preview, do_elog)
1837 else
1838 selected_file(listWave[row], 0, 0)
1839 endif
1840 endif
1841 update_controls()
1842 break
1843 case 3: // double click
1844 break
1845 case 4: // cell selection
1846 case 5: // cell selection plus shift key
1847 break
1848 case 6: // begin edit
1849 break
1850 case 7: // finish edit
1851 break
1852 case 13: // checkbox clicked (Igor 6.2 or later)
1853 break
1854 endswitch
1855
1856 setdatafolder save_df
1857 return 0
1858End
1859
1860static function bp_attr_notebook(ba) : ButtonControl
1861 STRUCT WMButtonAction &ba
1862
1863 dfref save_df = GetDataFolderDFR()
1864
1865 switch( ba.eventCode )
1866 case 2: // mouse up
1867 setdatafolder $package_path
1868 wave wSelectedFiles
1869 wave/t wtFiles
1870 variable nn = numpnts(wSelectedFiles)
1871 variable ii
1872 for (ii = 0; ii < nn; ii += 1)
1873 if (wSelectedFiles[ii])
1874 attributes_notebook(wtFiles[ii])
1875 break
1876 endif
1877 endfor
1878 break
1879 case -1: // control being killed
1880 break
1881 endswitch
1882
1883 setdatafolder save_df
1884 return 0
1885End
1886
1887
1888static function hlp_setup()
1889 dfref save_df = GetDataFolderDFR()
1890 setdatafolder $package_path
1891
1892 MakeListIntoHierarchicalList("PearlDataExplorer", "lb_contents", "hlp_contents_open", selectionMode=WMHL_SelectionSingle, pathSeparator="/")
1893
1894 setdatafolder save_df
1895 return 0
1896end
1897
1898static function hl_contents_clear()
1899 do
1900 if (cmpstr(WMHL_GetItemForRowNumber("PearlDataExplorer", "lb_contents", 0), "<uninitialized>") != 0)
1901 WMHL_DeleteRowAndChildren("PearlDataExplorer", "lb_contents", 0)
1902 else
1903 break
1904 endif
1905 while (1)
1906end
1907
1912static function hl_contents_update(file_df)
1913 dfref file_df
1914
1915 dfref save_df = GetDataFolderDFR()
1916 setdatafolder $package_path
1917 hl_contents_clear()
1918
1919 variable nds
1920 variable ids
1921 string ds
1922 string extra
1923 string /g hl_contents_datasets = ""
1924
1925 if (DataFolderRefStatus(file_df))
1926 svar /sdfr=file_df datasets = s_datasets
1927 svar /sdfr=file_df datatypes = s_datasets_datatypes
1928 svar /sdfr=file_df ranks = s_datasets_ranks
1929 svar /sdfr=file_df dimensions = s_datasets_dimensions
1930
1931 nds = ItemsInList(datasets, ";")
1932 for (ids = 0; ids < nds; ids += 1)
1933 ds = StringFromList(ids, datasets, ";")
1934 extra = StringFromList(ids, dimensions, ";")
1935 hl_contents_datasets = ReplaceStringByKey(ds, hl_contents_datasets, extra, ":", ";")
1936 endfor
1937 endif
1938
1939 variable nobj = hl_add_objects("", hl_contents_datasets)
1940 hl_expand_scans()
1941 hl_default_selection()
1942 setdatafolder save_df
1943
1944 return nobj
1945end
1946
1947static function /df get_pshell_info(path_name, file_name, [dest_df])
1948 string path_name
1949 string file_name
1950 dfref dest_df
1951
1952 dfref save_df = GetDataFolderDFR()
1953
1954 if (!ParamIsDefault(dest_df))
1955 setdatafolder dest_df
1956 else
1957 setdatafolder $package_path
1958 NewDataFolder /o /s file_info
1959 endif
1960
1961 dfref file_df = psh5_open_file(path_name, file_name, dest_df=GetDataFolderDFR())
1962 if (DataFolderRefStatus(file_df))
1963 psh5_load_general_group(file_df)
1964 psh5_close_file(file_df)
1965 endif
1966
1967 setdatafolder save_df
1968 return file_df
1969end
1970
1975static function hl_add_objects(parent_path, objects)
1976 string parent_path // e.g. "/a/b"
1977 string objects // all objects that might appear in the list. e.g. "/a/b/c:col0|col1;/a/b/d:col0|col1;/d/e/f:col0|col1;"
1978
1979 if (cmpstr(parent_path[0], "/") != 0)
1980 parent_path = "/" + parent_path
1981 endif
1982
1983 variable nobj = ItemsInList(objects, ";")
1984 variable iobj
1985 string obj
1986 string extra
1987 variable nel
1988
1989 string child_path = ""
1990 string child_name = ""
1991 string child_names = "" // e.g., "child1:1;child3:2;"
1992 string extra_data = "" // e.g., "child1:col0|col1;child2:col0|col1;"
1993
1994 // filter children of parent
1995 for (iobj = 0; iobj < nobj; iobj += 1)
1996 obj = StringFromList(iobj, objects, ";")
1997
1998 if (cmpstr(obj[0, strlen(parent_path)-1], parent_path) == 0)
1999 child_path = StringFromList(0, obj, ":")
2000 child_path = child_path[strlen(parent_path), strlen(child_path)-1]
2001 if (cmpstr(child_path[0], "/") == 0)
2002 child_path = child_path[1, strlen(child_path)-1]
2003 endif
2004 child_name = StringFromList(0, child_path, "/")
2005 nel = ItemsInList(child_path, "/")
2006 child_names = ReplaceNumberByKey(child_name, child_names, nel)
2007 if (nel == 1)
2008 extra = RemoveListItem(0, obj, ":")
2009 extra_data = ReplaceStringByKey(child_name, extra_data, extra)
2010 endif
2011 endif
2012 endfor
2013
2014 // add rows
2015 variable row
2016 variable children
2017 nobj = ItemsInList(child_names)
2018 for (iobj = 0; iobj < nobj; iobj += 1)
2019 obj = StringFromList(iobj, child_names)
2020 child_name = StringFromList(0, obj, ":")
2021 nel = NumberByKey(child_name, child_names)
2022 WMHL_AddObject("PearlDataExplorer", "lb_contents", parent_path[1, strlen(parent_path)], child_name, nel > 1)
2023 if (nel == 1)
2024 extra = StringByKey(child_name, extra_data)
2025 row = WMHL_GetRowNumberForItem("PearlDataExplorer", "lb_contents", parent_path[1, strlen(parent_path)] + "/" + child_name)
2026 if (row >= 0)
2027 WMHL_ExtraColumnData("PearlDataExplorer", "lb_contents", 0, row, StringFromList(0, extra, "|"), 0)
2028 endif
2029 endif
2030 endfor
2031
2032 return nobj
2033end
2034
2035static function hl_expand_scans()
2036 dfref save_df = GetDataFolderDFR()
2037 setdatafolder $package_path
2038
2039 svar hl_contents_datasets
2040 variable nds = ItemsInList(hl_contents_datasets, ";")
2041 variable ids
2042 string sds
2043 string scan
2044 string scans = ""
2045 for (ids = 0; ids < nds; ids += 1)
2046 sds = StringFromList(ids, hl_contents_datasets, ";")
2047 if (cmpstr(sds[0,4], "/scan", 0) == 0)
2048 scan = StringFromList(1, sds, "/")
2049 scans = ReplaceNumberByKey(scan, scans, 1)
2050 endif
2051 endfor
2052
2053 variable nscans = ItemsInList(scans)
2054 variable iscan
2055 for (iscan = 0; iscan < nscans; iscan += 1)
2056 scan = StringFromList(iscan, scans)
2057 scan = StringFromList(0, scan, ":")
2058 WMHL_OpenAContainer("PearlDataExplorer", "lb_contents", scan)
2059 endfor
2060
2061 setdatafolder save_df
2062end
2063
2064static function hl_default_selection()
2065 variable row
2066 row = WMHL_GetRowNumberForItem("PearlDataExplorer", "lb_contents", "scan 1")
2067 if (row < 0)
2068 row = WMHL_GetRowNumberForItem("PearlDataExplorer", "lb_contents", "scan1")
2069 endif
2070 if (row >= 0)
2071 WMHL_SelectARow("PearlDataExplorer", "lb_contents", row, 1)
2072 endif
2073end
2074
2075static function hlp_contents_open(HostWindow, ListControlName, ContainerPath)
2076 String HostWindow, ListControlName, ContainerPath
2077
2078 dfref save_df = GetDataFolderDFR()
2079 setdatafolder $package_path
2080 svar hl_contents_datasets
2081 hl_add_objects(ContainerPath, hl_contents_datasets)
2082 setdatafolder save_df
2083end
2084
2085static function hlp_contents_selection(HostWindow, ListControlName, SelectedItem, EventCode)
2086 String HostWindow, ListControlName
2087 String SelectedItem
2088 Variable EventCode
2089
2090 dfref save_df = GetDataFolderDFR()
2091 setdatafolder $package_path
2092
2093 switch (eventCode)
2094 case 3: // double click
2095 // todo: load dataset?
2096 break
2097 case 4: // cell selection
2098 case 5: // cell selection plus shift key
2099 update_controls()
2100 break
2101 endswitch
2102
2103 setdatafolder save_df
2104 return 0
2105end
2106
2121static function goto_dataset_folder(filename, datapath)
2122 string filename
2123 string datapath
2124
2125 dfref save_df = GetDataFolderDFR()
2126 setdatafolder $package_path
2127
2128 variable ft = pearl_file_type(filename)
2129 string parent_folder
2130 string folder
2131 string path
2132
2133 switch(ft)
2134 case 1:
2135 case 2:
2136 parent_folder = ad_suggest_foldername(filename)
2137 path = "root:" + parent_folder
2138 if (DataFolderExists(path))
2139 setdatafolder $path
2140 else
2141 return -2
2142 endif
2143
2144 variable nparts = ItemsInList(datapath, "/")
2145 variable ipart
2146 for (ipart = 0; ipart < nparts; ipart += 1)
2147 folder = StringFromList(ipart, datapath, "/")
2148 path = ":" + ps_fix_folder_name(folder)
2149 if (DataFolderExists(path))
2150 setdatafolder $path
2151 endif
2152 endfor
2153 break
2154
2155 case 3:
2156 parent_folder = "root:" + itx_suggest_foldername(filename)
2157 if (DataFolderExists(parent_folder))
2158 setdatafolder $parent_folder
2159 else
2160 return -2
2161 endif
2162 break
2163
2164 default:
2165 // unsupported file type
2166 return -1
2167 endswitch
2168
2169 return 0
2170end
2171
2177static function bp_goto_dataset(ba) : ButtonControl
2178 STRUCT WMButtonAction &ba
2179
2180 switch( ba.eventCode )
2181 case 2: // mouse up
2182 dfref save_df = GetDataFolderDFR()
2183 setdatafolder $package_path
2184 svar s_selected_file
2185 svar hl_contents_datasets
2186 string datapath = StringFromList(0, WMHL_SelectedObjectsList("PearlDataExplorer", "lb_contents"))
2187 if (strsearch(hl_contents_datasets, datapath, 0) != 0)
2188 datapath = datapath + "/"
2189 endif
2190 variable result = goto_dataset_folder(s_selected_file, datapath)
2191 if (result != 0)
2192 setdatafolder save_df
2193 string msg
2194 msg = "Can't find data folder. Has the file been loaded?"
2195 DoAlert /T="Goto DF" 0, msg
2196 endif
2197
2198 break
2199 case -1: // control being killed
2200 break
2201 endswitch
2202
2203 return 0
2204End
2205
2209static function bp_display_dataset(ba) : ButtonControl
2210 STRUCT WMButtonAction &ba
2211
2212 switch( ba.eventCode )
2213 case 2: // mouse up
2214 dfref save_df = GetDataFolderDFR()
2215 setdatafolder $package_path
2216 svar s_selected_file
2217 svar hl_contents_datasets
2218 string datapath = StringFromList(0, WMHL_SelectedObjectsList("PearlDataExplorer", "lb_contents"))
2219 if (strsearch(hl_contents_datasets, datapath, 0) < 0)
2220 // path leads to folder
2221 return 0
2222 endif
2223 goto_dataset_folder(s_selected_file, "")
2224 display_dataset(GetDataFolderDFR(), datapath)
2225 setdatafolder save_df
2226 break
2227 case -1: // control being killed
2228 break
2229 endswitch
2230
2231 return 0
2232End
2233
2234
2236static function /s get_default_elog_module()
2237 string modules = "PearlSciLog;PearlElog"
2238
2239 variable imod
2240 variable nmod = ItemsInList(modules, ";")
2241 string smod
2242 for (imod = 0; imod < nmod; imod += 1)
2243 smod = StringFromList(imod, modules, ";")
2244 if (exists(smod + "#set_panel_attributes") == 6)
2245 return smod
2246 endif
2247 endfor
2248 return ""
2249end
2250
2251
2262static function send_to_elog()
2263 dfref save_df = GetDataFolderDFR()
2264
2265 dfref preview_df = $package_path
2266 svar /z /sdfr=preview_df s_selected_file
2267 svar /z /sdfr=preview_df s_preview_file
2268 svar /z /sdfr=preview_df s_preview_graph
2269
2270 if (!SVAR_Exists(s_selected_file) || (strlen(s_selected_file) < 1))
2271 return 0
2272 endif
2273
2274 // check data folder
2275 variable result = -1
2276 result = goto_dataset_folder(s_selected_file, "")
2277 if (result == 0)
2278 dfref data_df = GetDataFolderDFR()
2279 svar /sdfr=data_df /z authors
2280 if (!svar_Exists(authors))
2281 result = -1
2282 endif
2283 endif
2284
2285 // file info folder
2286 dfref infoDF = preview_df:file_info
2287 if ((result != 0) && (DataFolderRefStatus(infoDF)))
2288 svar /z /sdfr=infoDF s_filepath
2289 if (SVAR_Exists(s_filepath) && (strsearch(s_filepath, s_selected_file, inf, 1) >= 0))
2290 dfref data_df = infoDF
2291 result = 0
2292 endif
2293 endif
2294
2295 // check preview (package) folder
2296 if ((result != 0) && (SVAR_Exists(s_preview_file) && (cmpstr(s_preview_file, s_selected_file) == 0)))
2297 dfref data_df = preview_df
2298 result = 0
2299 endif
2300
2301 string graphname
2302 if (SVAR_Exists(s_preview_graph) && (WinType(s_preview_graph) == 1))
2303 graphname = s_preview_graph
2304 else
2305 graphname = ""
2306 endif
2307
2308 string module = get_default_elog_module()
2309 funcref PearlDataExplorer_proto_get_panel_name f_get_panel_name = $(module + "#get_default_panel_name")
2310 string panel = f_get_panel_name()
2311
2312 if (result == 0)
2313 set_elog_attributes(module, panel, data_df, filename=s_selected_file, graphname=graphname)
2314 endif
2315
2316 setdatafolder save_df
2317end
2318
2319function /s PearlDataExplorer_proto_get_panel_name()
2320 return ""
2321end
2322
2323function /s PearlDataExplorer_proto_set_panel_attributes(windowname, attributes, [clear])
2324 string windowname
2325 string attributes
2326 variable clear
2327 return ""
2328end
2329
2330function /s PearlDataExplorer_proto_set_panel_graphs(windowname, graphs)
2331 string windowname
2332 string graphs
2333 return ""
2334end
2335
2365static function set_elog_attributes(elog_module, panel_name, file_df, [filename, graphname])
2366 string elog_module
2367 string panel_name
2368 dfref file_df
2369 string filename
2370 string graphname
2371
2372 if (ParamIsDefault(filename))
2373 svar /sdfr=file_df /z loaded_file=s_filepath
2374 if (svar_Exists(loaded_file))
2375 filename = loaded_file
2376 else
2377 filename = ""
2378 endif
2379 endif
2380
2381 if (ParamIsDefault(graphname))
2382 graphname = ""
2383 endif
2384
2385 string cmd
2386 string attrib = ""
2387
2388 if (exists(elog_module + "#set_panel_attributes") == 6)
2389 funcref PearlDataExplorer_proto_set_panel_attributes f_set_attributes = $(elog_module + "#set_panel_attributes")
2390 funcref PearlDataExplorer_proto_set_panel_graphs f_set_graphs = $(elog_module + "#set_panel_graphs")
2391
2392 attrib = ReplaceStringByKey("file", attrib, ParseFilePath(0, filename, ":", 1, 0), ":", ";")
2393 svar /sdfr=file_df /z authors
2394 if (svar_Exists(authors))
2395 if (strlen(authors)>=1)
2396 attrib = ReplaceStringByKey("author", attrib, authors, ":", ";")
2397 endif
2398 endif
2399 svar /sdfr=file_df /z pgroup
2400 if (svar_Exists(pgroup))
2401 if (strlen(pgroup)>=1)
2402 attrib = ReplaceStringByKey("p-group", attrib, pgroup, ":", ";")
2403 endif
2404 endif
2405 svar /sdfr=file_df /z proposal
2406 if (svar_Exists(proposal))
2407 if (strlen(proposal)>=1)
2408 attrib = ReplaceStringByKey("project", attrib, proposal, ":", ";")
2409 endif
2410 endif
2411 svar /sdfr=file_df /z proposer
2412 svar /sdfr=file_df /z sample
2413 if (svar_Exists(sample))
2414 if (strlen(sample)>=1)
2415 attrib = ReplaceStringByKey("sample", attrib, sample, ":", ";")
2416 endif
2417 endif
2418
2419 if (strlen(attrib)>=3)
2420 f_set_attributes(panel_name, attrib)
2421 endif
2422
2423 if ((strlen(graphname) > 0) && (WinType(graphname) == 1))
2424 f_set_graphs(panel_name, graphname)
2425 endif
2426 endif
2427end
static const string package_name
package name is used as data folder name
static const string ks_filematch_pshell
static const string ks_filematch_adh5
static variable init_package()
static const string ks_filematch_itx
void PearlDataExplorer()
macro to create the data explorer panel
static const string package_path
static variable load_prefs()
variable pearl_data_explorer()
show the pearl data explorer window