347static function extract_attributes(attr_df, [dest_df, attr_filter, include_datawaves, include_infowaves])
351 variable include_datawaves
352 variable include_infowaves
354 dfref save_df = GetDataFolderDFR()
355 dfref package_df = $package_path
357 if (ParamIsDefault(dest_df))
358 dest_df = GetDataFolderDFR()
360 if (ParamIsDefault(attr_filter) || !WaveExists(attr_filter))
361 wave /t /sdfr=package_df /z attr_filter
363 if (ParamIsDefault(include_datawaves))
364 include_datawaves = 1
366 if (ParamIsDefault(include_infowaves))
367 include_infowaves = 1
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
378 setdatafolder attr_df
384 // compile list of attributes
385 variable nattr // destination attributes
387 variable ninfo // info wave elements
389 variable nw // attribute waves
394 if (WaveExists(IN) && include_infowaves)
399 if (include_datawaves)
400 string waves = WaveList("*", ";", "")
401 string exceptions = "ID;IN;IU;IV"
402 waves = RemoveFromList(exceptions, waves)
403 nw = ItemsInList(waves, ";")
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
414 redimension /n=(ninfo) attr_names
415 attr_names = SelectString(strlen(ID[p]) >= 0, IN[p], ID[p]) // use ID unless empty
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
432 redimension /n=(nattr) attr_names, attr_values
433 sort attr_names, attr_names
435 // look up attribute values
436 for (iattr = 0; iattr < nattr; iattr += 1)
437 sw = attr_names[iattr]
440 FindValue /text=sw ID
442 attr_values[iattr] = IV[v_value]
444 FindValue /text=sw IN
446 attr_values[iattr] = IV[v_value]
450 // override from attribute wave if existent
452 switch (WaveType($sw, 1))
455 if (WaveExists(w) && (numpnts(w) >= 1))
456 sprintf ss, "%g", w[0]
457 attr_values[iattr] = ss
462 if (WaveExists(wt) && (numpnts(wt) >= 1))
463 attr_values[iattr] = wt[0]
470 setdatafolder save_df
1107static function /df load_pshell_file(filename, [options, dest_df, quiet])
1113 dfref save_df = GetDataFolderDFR()
1115 svar pref_options = $(package_path + "s_hdf_options")
1116 svar pref_params = $(package_path + "s_reduction_params")
1117 string path = "pearl_explorer_filepath"
1119 if (ParamIsDefault(options))
1120 options = pref_options
1123 if (strlen(options) == 0)
1124 if (prompt_hdf_options(options) == 0)
1125 pref_options = options
1131 string reduction_func = StringByKey("reduction_func", options, ":", ";")
1132 string reduction_params = pref_params
1133 variable max_rank = 2
1135 if (exists(reduction_func) == 6)
1137 if (prompt_func_params(reduction_func, reduction_params) == 0)
1138 pref_params = reduction_params
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)
1151 print mode, filename
1152 if (strlen(reduction_func))
1153 print reduction_func, reduction_params
1158 case "load_complete":
1160 dfref file_df = psh5_load(path, filename, "", "", "*", classes=dsc, reduction_func=reduction_func, reduction_params=reduction_params, dest_df=dest_df)
1163 if (ItemsInList(selected_scans, ";") == 0)
1165 print "no scan selected - defaulting to scan 1."
1167 selected_scans = "/scan1;"
1169 dsc = kDSCAttrs | kDSCDiags | kDSCSnaps | kDSCMeta | kDSCMonitors
1170 dfref file_df = psh5_load(path, filename, selected_scans, "", "", classes=dsc, dest_df=dest_df)
1173 if (ItemsInList(selected_scans, ";") == 0)
1175 print "no scan selected - defaulting to scan 1."
1177 selected_scans = "/scan1;"
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)
1183 if (ItemsInList(selected_regions, ";") == 0)
1185 print "no region selected - defaulting to scan 1/region 1."
1187 selected_regions = "/scan1/region1;"
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)
1192 case "load_dataset":
1193 if (ItemsInList(selected_datasets, ";") > 0)
1195 dfref file_df = psh5_load(path, filename, "", "", selected_datasets, classes=dsc, reduction_func=reduction_func, reduction_params=reduction_params, dest_df=dest_df)
1198 DoAlert /T="PShell Import" 0, "Please select the datasets to load."
1204 if (DataFolderRefStatus(file_df))
1205 setdatafolder file_df
1206 string /g pearl_explorer_import = "load_pshell_file"
1208 print "data loaded to", GetDataFolder(1)
1211 setdatafolder save_df
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)
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
1491 variable file_selected = 0
1492 if (WaveExists(wSelectedFiles))
1493 file_selected = sum(wSelectedFiles)
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
1500 variable dataset_selected = 0
1501 variable nds = ItemsInList(selected_datasets, ";")
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
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
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
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
1538 GroupBox g_data_reduction win=PearlDataExplorer,labelBack=0
1539 Button b_reduction_params win=PearlDataExplorer,disable=2
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;"
1979 if (cmpstr(parent_path[0], "/") != 0)
1980 parent_path = "/" + parent_path
1983 variable nobj = ItemsInList(objects, ";")
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;"
1994 // filter children of parent
1995 for (iobj = 0; iobj < nobj; iobj += 1)
1996 obj = StringFromList(iobj, objects, ";")
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]
2004 child_name = StringFromList(0, child_path, "/")
2005 nel = ItemsInList(child_path, "/")
2006 child_names = ReplaceNumberByKey(child_name, child_names, nel)
2008 extra = RemoveListItem(0, obj, ":")
2009 extra_data = ReplaceStringByKey(child_name, extra_data, extra)
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)
2024 extra = StringByKey(child_name, extra_data)
2025 row = WMHL_GetRowNumberForItem("PearlDataExplorer", "lb_contents", parent_path[1, strlen(parent_path)] + "/" + child_name)
2027 WMHL_ExtraColumnData("PearlDataExplorer", "lb_contents", 0, row, StringFromList(0, extra, "|"), 0)