code changes for release 3.1.0: SciLog, DA30-PShell data files

This commit is contained in:
2025-12-22 17:04:08 +01:00
parent 43689ef162
commit ea838b395f
12 changed files with 2437 additions and 169 deletions
+187 -124
View File
@@ -2,7 +2,7 @@
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
#pragma IgorVersion = 6.36
#pragma ModuleName = PearlDataExplorer
#pragma version = 2.1
#pragma version = 2.2
#include <HierarchicalListWidget>, version >= 1.14
#include "pearl-area-import"
#include "pearl-area-profiles"
@@ -10,7 +10,7 @@
#include "pearl-compat"
#include "pearl-pshell-import"
// copyright (c) 2013-22 Paul Scherrer Institut
// copyright (c) 2013-25 Paul Scherrer Institut
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
@@ -543,87 +543,6 @@ static function notebook_add_attributes(notebook_name, attr_filter, attr_names,
endfor
end
/// send general metadata to ELOG panel - if available
///
/// the following metatdata are sent.
/// they must be present as strings in the specified data folder:
///
/// | ELOG parameter | global string | function argument |
/// | --- | --- | --- |
/// | file | s_filepath | filename |
/// | graph attachment | | graphname |
/// | author | authors | |
/// | p-group | pgroup | |
/// | project | proposal | |
/// | sample | sample | |
///
/// @param file_df data folder that contains the metadata.
///
/// @param filename override file path read from s_filepath global string variable.
/// if neither is declared, the file name is reset to empty field.
///
/// @param graphname select this graph window for attaching.
/// default: do not change the selection.
///
static function set_elog_attributes(file_df, [filename, graphname])
dfref file_df
string filename
string graphname
if (ParamIsDefault(filename))
svar /sdfr=file_df /z loaded_file=s_filepath
if (svar_Exists(loaded_file))
filename = loaded_file
else
filename = ""
endif
endif
if (ParamIsDefault(graphname))
graphname = ""
endif
string cmd
if (exists("PearlElog#set_panel_attributes") == 6)
sprintf cmd, "PearlElog#set_panel_attributes(\"\", \"File=%s\")", ParseFilePath(0, filename, ":", 1, 0)
execute /Q/Z cmd
if ((strlen(graphname) > 0) && (WinType(graphname) == 1))
sprintf cmd, "PearlElog#set_panel_graphs(\"\", \"%s\")", graphname
execute /Q/Z cmd
endif
svar /sdfr=file_df /z authors
if (svar_Exists(authors))
if (strlen(authors)>=1)
sprintf cmd, "PearlElog#set_panel_attributes(\"\", \"author=%s\")", authors
execute /Q/Z cmd
endif
endif
svar /sdfr=file_df /z pgroup
if (svar_Exists(pgroup))
if (strlen(pgroup)>=1)
sprintf cmd, "PearlElog#set_panel_attributes(\"\", \"p-group=%s\")", pgroup
execute /Q/Z cmd
endif
endif
svar /sdfr=file_df /z proposal
if (svar_Exists(proposal))
if (strlen(proposal)>=1)
sprintf cmd, "PearlElog#set_panel_attributes(\"\", \"project=%s\")", proposal
execute /Q/Z cmd
endif
endif
svar /sdfr=file_df /z proposer
svar /sdfr=file_df /z sample
if (svar_Exists(sample))
if (strlen(sample)>=1)
sprintf cmd, "PearlElog#set_panel_attributes(\"\", \"sample=%s\")", sample
execute /Q/Z cmd
endif
endif
endif
end
// ====== preview ======
static function preview_file(filename)
@@ -1475,6 +1394,12 @@ end
// ====== panel ======
/// macro to create the data explorer panel
///
/// note: after editing the panel using the graphical editor,
/// remove all automatically generated assignments from the lb_contents listbox.
/// only the pos, size and keySelectCol properties should remain.
///
Window PearlDataExplorer() : Panel
PauseUpdate; Silent 1 // building window...
NewPanel /K=1 /W=(510,45,1190,539) as "PEARL Data Explorer"
@@ -1486,6 +1411,7 @@ Window PearlDataExplorer() : Panel
TitleBox tb_filepath,variable= root:packages:pearl_explorer:s_short_filepath,fixedSize=1
Button b_browse_filepath,pos={303.00,24.00},size={20.00,20.00},proc=PearlDataExplorer#bp_browse_filepath,title="..."
Button b_browse_filepath,fColor=(65280,48896,32768)
Button b_browse_filepath,help={"select the file system folder that contains the data files"}
GroupBox gb_prefs,pos={8.00,351.00},size={65.00,131.00},title="prefs"
GroupBox gb_prefs,help={"explorer package preferences"}
Button b_save_prefs,pos={21.00,394.00},size={38.00,17.00},proc=PearlDataExplorer#bp_save_prefs,title="save"
@@ -1500,18 +1426,27 @@ Window PearlDataExplorer() : Panel
ListBox lb_files,selWave=root:packages:pearl_explorer:wSelectedFiles,mode= 4
Button b_update_filelist,pos={246.00,315.00},size={76.00,22.00},proc=PearlDataExplorer#bp_update_filelist,title="update list"
Button b_update_filelist,fColor=(65280,48896,32768)
CheckBox cb_file_preview,pos={78.00,318.00},size={59.00,14.00},title="preview"
Button b_update_filelist,help={"reload the file list"}
CheckBox cb_file_preview,pos={94.00,375.00},size={59.00,14.00},title="preview"
CheckBox cb_file_preview,help={"enable/disable automatic preview window when selecting a data file"}
CheckBox cb_file_preview,value= 0
CheckBox cb_file_elog,pos={94.00,395.00},size={82.00,14.00},title="ELOG"
CheckBox cb_file_elog,help={"enable/disable sending metadata to ELOG panel when selecting a data file (does not submit to ELOG)"}
CheckBox cb_file_elog,value= 0
Button b_attr_notebook,pos={94.00,415.00},size={64.00,22.00},disable=2,proc=PearlDataExplorer#bp_attr_notebook,title="notebook"
Button b_attr_notebook,help={"show a summary of attributes in a notebook window"}
Button b_attr_notebook,fColor=(65280,48896,32768)
Button b_file_prev,pos={20.00,314.00},size={22.00,22.00},proc=PearlDataExplorer#bp_file_prev,title="\\W646"
Button b_file_prev,help={"previous file"},fColor=(65280,48896,32768)
Button b_file_prev,fColor=(65280,48896,32768)
Button b_file_prev,help={"select previous file from list"}
Button b_file_next,pos={44.00,314.00},size={22.00,22.00},proc=PearlDataExplorer#bp_file_next,title="\\W649"
Button b_file_next,help={"next file"},fColor=(65280,48896,32768)
Button b_file_next,fColor=(65280,48896,32768)
Button b_file_next,help={"select next file from list"}
Button b_goto_dataset,pos={355.00,315.00},size={64.00,22.00},disable=2,proc=PearlDataExplorer#bp_goto_dataset,title="goto DF"
Button b_goto_dataset,help={"change the current data folder ot where the selected dataset could be located"}
Button b_goto_dataset,help={"change the current data folder to find the selected dataset (if loaded)"}
Button b_goto_dataset,fColor=(65280,48896,32768)
Button b_display_dataset,pos={423.00,315.00},size={64.00,22.00},disable=2,proc=PearlDataExplorer#bp_display_dataset,title="display"
Button b_display_dataset,help={"display the selected dataset in its own window"}
Button b_display_dataset,help={"display the selected dataset"}
Button b_display_dataset,fColor=(65280,48896,32768)
Button b_load_complete,pos={355.00,451.00},size={92.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="all data"
Button b_load_complete,help={"load all datasets of the selected file."}
@@ -1520,35 +1455,29 @@ Window PearlDataExplorer() : Panel
TitleBox tb_selected_file,pos={360.00,28.00},size={309.00,22.00},frame=0
TitleBox tb_selected_file,variable= root:packages:pearl_explorer:s_selected_file,fixedSize=1
GroupBox gb_contents,pos={346.00,55.00},size={327.00,294.00},title="datasets"
Button b_attr_notebook,pos={97.00,375.00},size={64.00,22.00},disable=2,proc=PearlDataExplorer#bp_attr_notebook,title="notebook"
Button b_attr_notebook,help={"show a summary of attributes in a notebook window"}
Button b_attr_notebook,fColor=(65280,48896,32768)
ListBox lb_contents,pos={355.00,84.00},size={305.00,222.00}
ListBox lb_contents,keySelectCol= 1
GroupBox gb_selected_file,pos={346.00,4.00},size={328.00,48.00},title="selected file"
Button b_load_region,pos={355.00,426.00},size={92.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="region"
Button b_load_region,help={"load the selected region"}
Button b_load_region,help={"load significant datasets and metadata from the selected region"}
Button b_load_region,userdata= "mode:load_region;",fColor=(65280,48896,32768)
PopupMenu popup_reduction,pos={366.00,391.00},size={200.00,17.00},bodyWidth=200,proc=PearlDataExplorer#pmp_reduction_func
PopupMenu popup_reduction,help={"data reduction of 3d ScientaImage. note: the list may contain unsuitable functions. check the code or documentation!"}
PopupMenu popup_reduction,help={"data reduction function for 3d ScientaImage. note: the list may contain unsuitable functions. check the code or documentation!"}
PopupMenu popup_reduction,mode=1,popvalue="None",value= #"PearlDataExplorer#pm_reduction_values()"
GroupBox group_import,pos={346.00,351.00},size={326.00,131.00},title="import"
Button b_load_scan,pos={450.00,426.00},size={94.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="scan"
Button b_load_scan,help={"load the selected scan"},userdata= "mode:load_scan;"
Button b_load_scan,help={"load significant datasets and metadata from the selected scan"},userdata= "mode:load_scan;"
Button b_load_scan,fColor=(65280,48896,32768)
Button b_load_diags,pos={450.00,451.00},size={94.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="diagnostics"
Button b_load_diags,help={"load diagnostics of selected scans"},userdata= "mode:load_diags;"
Button b_load_diags,fColor=(65280,48896,32768)
Button b_load_diags,help={"load diagnostic datasets of the selected scans"}
Button b_load_diags,userdata= "mode:load_diags;",fColor=(65280,48896,32768)
Button b_load_dataset,pos={547.00,426.00},size={101.00,22.00},disable=2,proc=PearlDataExplorer#bp_load_options,title="dataset"
Button b_load_dataset,help={"load the selected datasets"}
Button b_load_dataset,help={"load the selected dataset(s) and significant metadata"}
Button b_load_dataset,userdata= "mode:load_dataset;",fColor=(65280,48896,32768)
Button b_reduction_params,pos={571.00,390.00},size={71.00,19.00},disable=2,proc=PearlDataExplorer#bp_reduction_params,title="set params"
Button b_reduction_params,help={"set data reduction parameters"}
Button b_reduction_params,fColor=(65280,48896,32768)
GroupBox g_fileinfo,pos={85.00,351.00},size={251.00,131.00},title="file info"
Button b_elog,pos={97.00,401.00},size={64.00,22.00},disable=2,proc=PearlDataExplorer#bp_elog,title="ELOG"
Button b_elog,help={"send file metadata to ELOG panel (does not submit to ELOG)"}
Button b_elog,fColor=(65280,48896,32768)
ToolsGrid grid=(0,28.35,5)
EndMacro
@@ -1591,8 +1520,6 @@ static function update_controls()
dis = file_selected && scan_selected ? 0 : 2
Button b_attr_notebook win=PearlDataExplorer,disable=dis
dis = file_selected && (strlen(WinList("*ElogPanel*", ";", "WIN:64")) > 1) ? 0 : 2
Button b_elog win=PearlDataExplorer,disable=dis
dis = scan_selected ? 0 : 2
Button b_load_scan win=PearlDataExplorer,disable=dis
dis = region_selected ? 0 : 2
@@ -1782,24 +1709,34 @@ End
///
/// - load metadata
/// - load preview if requested
/// - send to elog panel if requested
///
/// @param file name of selected file
///
/// @param do_preview enable/disable loading of preview data
/// non-zero: load preview,
/// zero: don't load preview
///
static function selected_file(file, do_preview)
/// @param do_elog enable/disable sending metadata to elog panel
/// non-zero: send,
/// zero: don't send
///
static function selected_file(file, do_preview, do_elog)
string file
variable do_preview
variable do_elog
dfref save_df = GetDataFolderDFR()
setdatafolder $package_path
svar s_selected_file
s_selected_file = file
get_file_info(file)
if (do_preview)
variable fi = get_file_info(file)
if (fi == 0 && do_preview != 0)
preview_file(file)
endif
if (fi == 0 && do_elog != 0)
send_to_elog()
endif
update_controls()
setdatafolder save_df
@@ -1825,7 +1762,10 @@ static function bp_file_next(ba) : ButtonControl
if (v_value >= 0)
variable ifile = v_value
ControlInfo /W=PearlDataExplorer cb_file_preview
selected_file(wtFiles[ifile], v_value)
variable do_preview = v_value
ControlInfo /W=PearlDataExplorer cb_file_elog
variable do_elog = v_value
selected_file(wtFiles[ifile], do_preview, do_elog)
endif
update_controls()
break
@@ -1856,7 +1796,10 @@ static function bp_file_prev(ba) : ButtonControl
if (v_value >= 0)
variable ifile = v_value
ControlInfo /W=PearlDataExplorer cb_file_preview
selected_file(wtFiles[ifile], v_value)
variable do_preview = v_value
ControlInfo /W=PearlDataExplorer cb_file_elog
variable do_elog = v_value
selected_file(wtFiles[ifile], do_preview, do_elog)
endif
update_controls()
break
@@ -1887,9 +1830,12 @@ static function lbp_filelist(lba) : ListBoxControl
if (selWave[row])
if (sum(wSelectedFiles) == 1)
ControlInfo /W=PearlDataExplorer cb_file_preview
selected_file(listWave[row], v_value)
variable do_preview = v_value
ControlInfo /W=PearlDataExplorer cb_file_elog
variable do_elog = v_value
selected_file(listWave[row], do_preview, do_elog)
else
selected_file(listWave[row], 0)
selected_file(listWave[row], 0, 0)
endif
endif
update_controls()
@@ -2285,6 +2231,24 @@ static function bp_display_dataset(ba) : ButtonControl
return 0
End
/// *******
static function /s get_default_elog_module()
string modules = "PearlSciLog;PearlElog"
variable imod
variable nmod = ItemsInList(modules, ";")
string smod
for (imod = 0; imod < nmod; imod += 1)
smod = StringFromList(imod, modules, ";")
if (exists(smod + "#set_panel_attributes") == 6)
return smod
endif
endfor
return ""
end
/// send file metadata to the ELOG panel
///
/// metadate is looked up in the following locations:
@@ -2292,6 +2256,9 @@ End
/// 2. file info folder inside package folder
/// 3. package folder if it contains preview data from the selected file (???)
///
/// the data is sent to the first ElogPanel in the window list.
/// call open_pearl_elog() to ensure a new default panel.
///
static function send_to_elog()
dfref save_df = GetDataFolderDFR()
@@ -2338,27 +2305,123 @@ static function send_to_elog()
graphname = ""
endif
string module = get_default_elog_module()
funcref PearlDataExplorer_proto_get_panel_name f_get_panel_name = $(module + "#get_default_panel_name")
string panel = f_get_panel_name()
if (result == 0)
set_elog_attributes(data_df, filename=s_selected_file, graphname=graphname)
string windowname
windowname = StringFromList(0, WinList("*ElogPanel*", ";", "WIN:64"), ";")
DoWindow /F $windowname
set_elog_attributes(module, panel, data_df, filename=s_selected_file, graphname=graphname)
endif
setdatafolder save_df
end
static function bp_elog(ba) : ButtonControl
STRUCT WMButtonAction &ba
function /s PearlDataExplorer_proto_get_panel_name()
return ""
end
switch( ba.eventCode )
case 2: // mouse up
send_to_elog()
break
case -1: // control being killed
break
endswitch
function /s PearlDataExplorer_proto_set_panel_attributes(windowname, attributes, [clear])
string windowname
string attributes
variable clear
return ""
end
return 0
End
function /s PearlDataExplorer_proto_set_panel_graphs(windowname, graphs)
string windowname
string graphs
return ""
end
/// send general metadata to ELOG panel - if available
///
/// the function works with any electronic logbook that has the same interfaces as pearl-elog.ipf.
/// the set_panel_attributes and set_panel_graphs functions are required.
///
/// the following metatdata are sent.
/// they must be present as strings in the specified data folder:
///
/// | ELOG parameter | global string | function argument |
/// | --- | --- | --- |
/// | file | s_filepath | filename |
/// | graph attachment | | graphname |
/// | author | authors | |
/// | p-group | pgroup | |
/// | project | proposal | |
/// | sample | sample | |
///
/// @param elog_module Igor module name of the electronic logbook, PearlElog or PearlSciLog.
///
/// @param panel_name Window name of the logbook panel
///
/// @param file_df data folder that contains the metadata.
///
/// @param filename override file path read from s_filepath global string variable.
/// if neither is declared, the file name is reset to empty field.
///
/// @param graphname select this graph window for attaching.
/// default: do not change the selection.
///
static function set_elog_attributes(elog_module, panel_name, file_df, [filename, graphname])
string elog_module
string panel_name
dfref file_df
string filename
string graphname
if (ParamIsDefault(filename))
svar /sdfr=file_df /z loaded_file=s_filepath
if (svar_Exists(loaded_file))
filename = loaded_file
else
filename = ""
endif
endif
if (ParamIsDefault(graphname))
graphname = ""
endif
string cmd
string attrib = ""
if (exists(elog_module + "#set_panel_attributes") == 6)
funcref PearlDataExplorer_proto_set_panel_attributes f_set_attributes = $(elog_module + "#set_panel_attributes")
funcref PearlDataExplorer_proto_set_panel_graphs f_set_graphs = $(elog_module + "#set_panel_graphs")
attrib = ReplaceStringByKey("file", attrib, ParseFilePath(0, filename, ":", 1, 0), ":", ";")
svar /sdfr=file_df /z authors
if (svar_Exists(authors))
if (strlen(authors)>=1)
attrib = ReplaceStringByKey("author", attrib, authors, ":", ";")
endif
endif
svar /sdfr=file_df /z pgroup
if (svar_Exists(pgroup))
if (strlen(pgroup)>=1)
attrib = ReplaceStringByKey("p-group", attrib, pgroup, ":", ";")
endif
endif
svar /sdfr=file_df /z proposal
if (svar_Exists(proposal))
if (strlen(proposal)>=1)
attrib = ReplaceStringByKey("project", attrib, proposal, ":", ";")
endif
endif
svar /sdfr=file_df /z proposer
svar /sdfr=file_df /z sample
if (svar_Exists(sample))
if (strlen(sample)>=1)
attrib = ReplaceStringByKey("sample", attrib, sample, ":", ";")
endif
endif
if (strlen(attrib)>=3)
f_set_attributes(panel_name, attrib)
endif
if ((strlen(graphname) > 0) && (WinType(graphname) == 1))
f_set_graphs(panel_name, graphname)
endif
endif
end