updates: igor 7, map projections, hemi cuts, longitudinal section

- pearl procedures compile under igor 7.
  some features may not work, e.g. 3D graphics with gizmo.
- add orthographic map projection to angle scans.
- add functions for azimuthal and polar cuts through hemispherical scan.
- add function to load longitudinal section from pshell data file.
This commit is contained in:
2016-10-14 16:56:20 +02:00
parent 600061f684
commit c8a69460bc
4 changed files with 459 additions and 88 deletions

View File

@ -676,6 +676,56 @@ function /s psh5_load_dataset(fileID, scanpath, datasetname, [set_scale])
return dataname
end
/// select the preferred dataset from a list of available datasets.
///
/// @param file_datasets semicolon-separated list of datasets that are available in the file.
///
/// @param pref_datasets semicolon-separated list of preferred datasets.
/// the items of the list are match strings for the Igor StringMatch function.
/// the first matching dataset is loaded from the file.
/// if no match is found, the first file dataset is selected.
///
/// @return name of selected dataset.
///
static function /s select_dataset(file_datasets, pref_datasets)
string file_datasets
string pref_datasets
variable index
variable nds = ItemsInList(file_datasets)
variable ids
string sds = ""
variable np = ItemsInList(pref_datasets)
variable ip
string sp
variable found = 0
if (nds > 0)
for (ip = 0; ip < np; ip += 1)
for (ids = 0; ids < nds; ids += 1)
sds = StringFromList(ids, file_datasets)
index = ItemsInList(sds, "/") - 1
sds = StringFromList(index, sds, "/")
sp = StringFromList(ip, pref_datasets)
if (StringMatch(sds, sp))
found = 1
break
endif
endfor
if (found)
break
endif
endfor
if (!found)
ids = 0
sds = StringFromList(ids, file_datasets)
index = ItemsInList(sds, "/") - 1
sds = StringFromList(index, sds, "/")
endif
endif
return sds
end
/// load a preview dataset from an open PShell HDF5 file.
///
/// if the dataset has a maximum of two dimensions, the function loads it at once.
@ -686,9 +736,6 @@ end
///
/// @param scanpath path to the scan group in the HDF5 file, e.g. "/scan 1".
///
/// @param dataset name of the dataset.
/// the name of the loaded wave is a cleaned up version of the dataset name.
///
/// @param set_scale by default, the function tries to set the wave scaling if the attributes have been loaded.
/// if multiple datasets are loaded from a file,
/// it is more efficient to set the scaling of all loaded datasets at the end by calling ps_scale_datasets().
@ -720,45 +767,11 @@ function /s psh5_load_scan_preview(fileID, scanpath, [set_scale, pref_datasets])
dfref dataDF = saveDF
string datasets = psh5_list_scan_datasets(fileID, scanpath)
variable index
variable nds = ItemsInList(datasets)
variable ids
string sds
variable np = ItemsInList(pref_datasets)
variable ip
string sp
variable found = 0
if (nds > 0)
for (ip = 0; ip < np; ip += 1)
for (ids = 0; ids < nds; ids += 1)
sds = StringFromList(ids, datasets)
index = ItemsInList(sds, "/") - 1
sds = StringFromList(index, sds, "/")
sp = StringFromList(ip, pref_datasets)
if (StringMatch(sds, sp))
found = 1
break
endif
endfor
if (found)
break
endif
endfor
if (!found)
ids = 0
sds = StringFromList(ids, datasets)
index = ItemsInList(sds, "/") - 1
sds = StringFromList(index, sds, "/")
endif
else
return ""
endif
string datasetname = select_dataset(datasets, pref_datasets)
string datasetpath
string datasetname = sds
datasetpath = scanpath + "/" + datasetname
datasetpath = ReplaceString("//", datasetpath, "/")
STRUCT HDF5DataInfo di // Defined in HDF5 Browser.ipf.
InitHDF5DataInfo(di)
variable err = HDF5DatasetInfo(fileID, datasetpath, 0, di)
@ -824,6 +837,153 @@ function /s psh5_load_scan_preview(fileID, scanpath, [set_scale, pref_datasets])
return dataname
end
/// load a longitudinal section of a scan from an open PShell HDF5 file.
///
/// the dataset must have three dimensions.
///
///
/// @param fileID ID of open HDF5 file from psh5_open_file().
///
/// @param scanpath path to the scan group in the HDF5 file, e.g. "/scan 1".
///
/// @param dim reserved, must be 0.
///
/// @param set_scale by default, the function tries to set the wave scaling if the attributes have been loaded.
/// if multiple datasets are loaded from a file,
/// it is more efficient to set the scaling of all loaded datasets at the end by calling ps_scale_datasets().
/// @arg 1 (default) set the wave scaling.
/// @arg 0 do not set the wave scaling.
///
/// @param pref_datasets semicolon-separated list of preferred datasets.
/// the items of the list are match strings for the Igor StringMatch function.
/// the first matching dataset is loaded from the file.
/// if no match is found, the first dataset listed in the file is loaded.
/// if empty, a hard-coded default preference list is used.
///
/// @return name of loaded wave if successful. empty string otherwise.
///
/// @warning EXPERIMENTAL: this function is under development.
///
function /s psh5_load_scan_section(fileID, scanpath, dim, [set_scale, pref_datasets])
variable fileID
string scanpath
variable dim
variable set_scale
string pref_datasets
// select first dimension (future argument)
// 0 = first dimension is x axis (energy of scienta image)
dim = 0
if (ParamIsDefault(set_scale))
set_scale = 1
endif
if (ParamIsDefault(pref_datasets) || (strlen(pref_datasets) == 0))
pref_datasets = kPreviewDatasets
endif
dfref saveDF = GetDataFolderDFR()
dfref dataDF = saveDF
string datasets = psh5_list_scan_datasets(fileID, scanpath)
string datasetname = select_dataset(datasets, pref_datasets)
string datasetpath
datasetpath = scanpath + "/" + datasetname
datasetpath = ReplaceString("//", datasetpath, "/")
string dataname = StringFromList(ItemsInList(datasetpath, "/") - 1, datasetpath, "/")
string destname = dataname[0,29] + num2str(dim)
STRUCT HDF5DataInfo di // Defined in HDF5 Browser.ipf.
InitHDF5DataInfo(di)
variable err = HDF5DatasetInfo(fileID, datasetpath, 0, di)
if (err != 0)
print "error accessing detector/data"
return ""
elseif (di.ndims != 3)
print "error: rank of dataset != 3"
return ""
endif
variable idx, idy, idz, idt
variable transpose = WhichListItem(dataname, kTransposedDatasets) >= 0
if (transpose)
idx = 1
idy = 0
else
idx = 0
idy = 1
endif
idz = 2
idt = 3
variable nx, ny, nz
nx = di.dims[idx]
ny = di.dims[idy]
nz = di.dims[idz]
HDF5MakeHyperslabWave(GetDataFolder(1) + "slab", max(di.ndims, 4))
wave slab
slab[][%Start] = 0
slab[][%Stride] = 1
slab[][%Count] = 1
slab[][%Block] = 1
if (dim == 0)
slab[idy][%Start] = floor(ny / 2)
slab[idx][%Block] = nx
make /n=(nx,nz) /o $destname
else
slab[idx][%Start] = floor(nx / 2)
slab[idy][%Block] = ny
make /n=(ny,nz) /o $destname
endif
slab[idz][%Block] = nz
wave data = $destname
data = 0
HDF5LoadData /O /Q /Z /SLAB=slab /N=slabdata fileID, datasetpath
if (!v_flag)
wave slabdata
if (transpose)
data += slabdata[0][p][q][0]
else
data += slabdata[p][0][q][0]
endif
endif
killwaves /z slab, slabdata
if (set_scale)
make /n=(1,1,1) /free dummy
ps_set_dimlabels2(dummy, dataname)
setdimlabel 0, -1, $GetDimLabel(dummy, dim, -1), data
setdimlabel 1, -1, $kScanDimLabel, data
setdatafolder dataDF
string positioners
string positioner
string positionerpath
positioners = psh5_load_scan_meta(fileID, scanpath)
wave /t /z ScanWritables
if (waveexists(ScanWritables) && (numpnts(ScanWritables) >= 1))
positioner = ScanWritables[0]
if (strlen(positioner) > 0)
positionerpath = scanpath + "/" + positioner
positionerpath = ReplaceString("//", positionerpath, "/")
HDF5LoadData /O /Q /Z fileID, positionerpath
endif
endif
setdatafolder dataDF
newdatafolder /o/s attr
killwaves /a/z
psh5_load_scan_attrs(fileID, scanpath, attr_sets=2)
setdatafolder dataDF
ps_scale_dataset(data)
endif
return destname
end
/// load metadata of a PShell dataset.
///
/// "metadata" are the HDF5 attributes attached to the scan dataset.
@ -1136,9 +1296,27 @@ end
function ps_set_dimlabels(data)
wave data
string name = NameOfWave(data)
variable dummy
ps_set_dimlabels2(data, NameOfWave(data))
end
/// set dimension labels according to the axis type
///
/// same as ps_set_dimlabels() except that the dimension labels are set
/// according to a separate name argument instead of the wave name.
///
/// @param data data wave as loaded from PShell file.
///
/// @param name original name of the dataset in the PShell file.
///
/// @return @arg 0 all labels set successfully.
/// @arg 1 unidentified data source.
/// @arg 2 wave does not contain data.
///
function ps_set_dimlabels2(data, name)
wave data
string name
variable dummy
try
// intrinsic dimensions
strswitch(name)