updates: scaling of pshell data, matrix preview, elog panel

- elog panel supports multiple attachments
- matrix (omicron STM) data file preview in data explorer
- various improvements for the scaling of pshell data
This commit is contained in:
2017-02-02 15:31:13 +01:00
parent c8a69460bc
commit 9a65d26984
5 changed files with 1680 additions and 171 deletions

View File

@ -1,11 +1,14 @@
#pragma rtGlobals=3 // Use modern global access method and strict wave access.
#pragma IgorVersion = 6.1
#pragma ModuleName = PearlDataExplorer
#pragma version = 1.43
#pragma version = 1.50
#include "pearl-area-import"
#include "pearl-area-profiles"
#include "pearl-area-display"
#include "pearl-pshell-import"
#if exists("MFR_OpenResultFile")
#include "pearl-matrix-import"
#endif
// copyright (c) 2013-16 Paul Scherrer Institut
//
@ -20,7 +23,10 @@
///
///
/// preview and import panel for PEARL data:
/// scienta analyser, prosilica cameras, s-scans, otf-scans
/// @arg area detector (HDF5) files from scienta analyser and prosilica cameras (if HDF5.xop is installed).
/// @arg igor text files from s-scans and otf-scans.
/// @arg pshell (HDF5) data files (if HDF5.xop is installed).
/// @arg matrix STM files (if MatrixFileReader.xop is installed).
/// @namespace PearlDataExplorer
/// @brief preview and import panel for PEARL data
@ -33,6 +39,7 @@ static strconstant package_path = "root:packages:pearl_explorer:"
static strconstant ks_filematch_adh5 = "*.h5"
static strconstant ks_filematch_pshell = "psh*.h5"
static strconstant ks_filematch_itx = "*.itx"
static strconstant ks_filematch_mtrx = "*_mtrx"
function pearl_data_explorer()
init_package()
@ -140,31 +147,64 @@ static function load_prefs()
return result
end
/// check whether a file can be imported by this module.
///
/// the file type is determined by the extension of the file name.
///
/// @return file type
/// @arg 0 not a recognized file type
/// @arg 1 PShell file (HDF5, name starts with psh_)
/// @arg 2 area detector HDF5 file
/// @arg 3 Igor text (itx) file
/// @arg 4 Matrix STM file (*_mtrx)
///
static function pearl_file_type(filename)
string filename
if (StringMatch(filename, ks_filematch_pshell))
return 1
elseif (StringMatch(filename, ks_filematch_adh5))
return 2
elseif (StringMatch(filename, ks_filematch_itx))
return 3
#if exists("MFR_OpenResultFile")
elseif (StringMatch(filename, ks_filematch_mtrx))
return 4
#endif
else
return 0
endif
end
/// read a list of PEARL files from the file system
///
/// wtFiles and wSelectedFiles in the package data folder are updated.
/// only files for which pearl_file_type() returns non-zero are listed.
///
static function update_filelist()
dfref saveDF = GetDataFolderDFR()
string hdf_files, itx_files, all_files
string all_files
wave /t wtFiles = $(package_path + "wtFiles")
wave wSelectedFiles = $(package_path + "wSelectedFiles")
variable nn
PathInfo pearl_explorer_filepath
if (v_flag == 1)
hdf_files = IndexedFile(pearl_explorer_filepath, -1, ".h5")
itx_files = IndexedFile(pearl_explorer_filepath, -1, ".itx")
all_files = hdf_files + itx_files
all_files = SortList(hdf_files + itx_files, ";", 4)
all_files = IndexedFile(pearl_explorer_filepath, -1, "????")
nn = ItemsInList(all_files)
else
all_files = ""
nn = 0
endif
redimension /n=(nn) wtFiles, wSelectedFiles
if (nn > 0)
wtFiles = StringFromList(p, all_files)
wSelectedFiles = 0
endif
make /n=(nn) /t /free wtAllFiles
wtAllFiles = StringFromList(p, all_files)
Extract /o /t wtAllFiles, wtFiles, pearl_file_type(wtAllFiles[p])
Sort /A /R wtFiles, wtFiles
redimension /n=(numpnts(wtFiles)) wSelectedFiles
wSelectedFiles = 0
setdatafolder saveDF
end
@ -216,14 +256,24 @@ static function preview_file(filename)
string filename
dfref saveDF = GetDataFolderDFR()
if (StringMatch(filename, ks_filematch_pshell))
wave /z image = preview_pshell_file(filename)
elseif (StringMatch(filename, ks_filematch_adh5))
wave /z image = preview_hdf_file(filename)
elseif (StringMatch(filename, ks_filematch_itx))
wave /z image = preview_itx_file(filename)
endif
variable ft = pearl_file_type(filename)
switch(ft)
case 1:
wave /z image = preview_pshell_file(filename)
break
case 2:
wave /z image = preview_hdf_file(filename)
break
case 3:
wave /z image = preview_itx_file(filename)
break
case 4:
wave /z image = preview_mtrx_file(filename)
break
default:
wave /z image = $""
endswitch
if (WaveExists(image))
string graphname = show_preview_graph(image)
@ -240,9 +290,10 @@ static function preview_file(filename)
endif
setdatafolder saveDF
return 0
end
/// load the preview of a PShell HDF5 file (not implemented).
/// load the preview of a PShell HDF5 file.
///
/// the preview is an arbitrary detector image extracted from the file, see adh5_load_preview().
/// the preview is loaded to the preview_image wave in the pear_explorer data folder.
@ -354,6 +405,63 @@ static function /wave preview_itx_file(filename)
return preview_image
end
/// load the preview of a Matrix STM file.
///
/// the preview is loaded to the preview_image wave in the pearl_explorer data folder.
///
/// the s_file_info string is updated with information about the scan dimensions.
///
/// this function requires the MatrixFileReader.xop and pearl-matrix-import.ipf to be loaded.
/// otherwise it will return an empty wave reference.
///
/// @param filename name of a file in the directory specified by the pearl_explorer_filepath path object.
///
/// @return wave reference of the preview image.
/// empty wave reference if the function failed.
///
static function /wave preview_mtrx_file(filename)
string filename
#if exists("MFR_OpenResultFile")
dfref saveDF = GetDataFolderDFR()
setdatafolder $package_path
variable /g V_MatrixFileReaderOverwrite = 1
variable /g V_MatrixFileReaderFolder = 0
variable /g V_MatrixFileReaderDouble = 0
svar s_preview_file
svar s_preview_source
string datanames
string dataname
datanames = mtrx_load_preview("preview", "pearl_explorer_filepath", filename)
if (strlen(datanames) > 0)
s_preview_file = filename
dataname = StringFromList(0, datanames)
wave data = $dataname
duplicate /o $dataname, preview_image
s_preview_source = StringByKey("Dataset", note(data), "=", "\r")
svar /z s_file_info
if (svar_exists(s_file_info))
s_file_info = ""
endif
variable i
variable n = ItemsInList(datanames)
string s
for (i = 0; i < n; i += 1)
s = StringFromList(i, datanames)
killwaves /z $s
endfor
endif
wave /z preview_image
setdatafolder saveDF
#else
wave /z preview_image = $""
#endif
return preview_image
end
static function extract_preview_image(data, preview)
// extracts a preview image from a wave of arbitrary dimension
wave data
@ -862,22 +970,32 @@ static function load_file(filename, [options])
dfref saveDF = GetDataFolderDFR()
if (StringMatch(filename, ks_filematch_pshell))
if (ParamIsDefault(options))
load_pshell_file(filename)
else
load_pshell_file(filename, options=options)
endif
elseif (StringMatch(filename, ks_filematch_adh5))
if (ParamIsDefault(options))
load_hdf_file(filename)
else
load_hdf_file(filename, options=options)
endif
elseif (StringMatch(filename, ks_filematch_itx))
load_itx_file(filename)
endif
variable ft = pearl_file_type(filename)
switch(ft)
case 1:
if (ParamIsDefault(options))
load_pshell_file(filename)
else
load_pshell_file(filename, options=options)
endif
break
case 2:
if (ParamIsDefault(options))
load_hdf_file(filename)
else
load_hdf_file(filename, options=options)
endif
break
case 3:
load_itx_file(filename)
break
case 4:
load_mtrx_file(filename)
break
default:
break
endswitch
setdatafolder saveDF
end
@ -1080,6 +1198,32 @@ static function /df load_itx_file(filename, [options])
return actDF
end
/// load a matrix (STM) data file
///
///
static function /df load_mtrx_file(filename, [options])
string filename
string options
dfref saveDF = GetDataFolderDFR()
dfref dataDF = $""
#if exists("MFR_OpenResultFile")
setdatafolder root:
string datasets = ""
datasets = mtrx_load_file("pearl_explorer_filepath", filename)
if (strlen(datasets) > 0)
string /g pearl_explorer_import = "load_mtrx_file"
string s1 = StringFromList(0, datasets)
wave w1 = $s1
dataDF = GetWavesDataFolderDFR(w1)
endif
#endif
setdatafolder saveDF
return dataDF
end
function /s itx_suggest_foldername(filename, [ignoredate,sourcename,unique])
// suggests the name of a data folder based on a file name
// if the file name follows the naming convention source-date-index.extension,