bugfixes in pshell import and preview
changes: - fix null string exception in preview - fix transposition of two-dimensional datasets
This commit is contained in:
parent
0dc6ca820b
commit
600061f684
@ -66,6 +66,15 @@ strconstant kScanDimLabel = "scan"
|
||||
/// This label may be used to store the parameters for the `setscale d` operation.
|
||||
strconstant kDataDimLabel = "data"
|
||||
|
||||
/// List of preferred datasets to load for preview
|
||||
strconstant kPreviewDatasets = "ScientaImage;ScientaSpectrum;ImageAngleDistribution;ImageEnergyDistribution;Counts;SampleCurrent;"
|
||||
|
||||
/// List of datasets that must be loaded to determine the axis scaling of a Scienta image
|
||||
strconstant kScientaScalingDatasets = "LensMode;ScientaChannelBegin;ScientaChannelEnd;ScientaSliceBegin;ScientaSliceEnd;"
|
||||
|
||||
/// List of datasets that should be transposed upon loading
|
||||
strconstant kTransposedDatasets = "ScientaImage;"
|
||||
|
||||
/// open a HDF5 file created by the PShell data acquisition program and prepare the data folder.
|
||||
///
|
||||
/// the function opens a specified or interactively selected HDF5 file,
|
||||
@ -301,21 +310,25 @@ function /s psh5_load_preview(ANickName, APathName, AFileName, [load_data, load_
|
||||
endif
|
||||
sg = StringFromList(ig, scanpaths)
|
||||
dataname = psh5_load_scan_preview(fileID, sg, set_scale=load_attr, pref_datasets=pref_datasets)
|
||||
endif
|
||||
|
||||
wave /z data = $dataname
|
||||
string destpath = GetDataFolder(1, saveDF) + ANickName
|
||||
if (waveexists(data))
|
||||
duplicate /o data, $destpath
|
||||
wave /z data = $destpath
|
||||
endif
|
||||
|
||||
if (load_attr)
|
||||
setdatafolder saveDF
|
||||
newdatafolder /o/s attr
|
||||
killwaves /a/z
|
||||
psh5_load_scan_attrs(fileID, sg)
|
||||
setdatafolder ::
|
||||
wave /z data = $dataname
|
||||
string destpath = GetDataFolder(1, saveDF) + ANickName
|
||||
if (waveexists(data))
|
||||
duplicate /o data, $destpath
|
||||
wave /z data = $destpath
|
||||
else
|
||||
print "no data found in file " + AFileName
|
||||
endif
|
||||
|
||||
if (load_attr)
|
||||
setdatafolder saveDF
|
||||
newdatafolder /o/s attr
|
||||
killwaves /a/z
|
||||
psh5_load_scan_attrs(fileID, sg)
|
||||
setdatafolder ::
|
||||
endif
|
||||
else
|
||||
print "no scans found in file " + AFileName
|
||||
endif
|
||||
|
||||
HDF5CloseFile fileID
|
||||
@ -510,17 +523,21 @@ function /s psh5_load_scan_attrs(fileID, scanpath, [attr_sets])
|
||||
endif
|
||||
endif
|
||||
|
||||
variable ids
|
||||
variable nds
|
||||
string sds
|
||||
|
||||
if (attr_sets & 2)
|
||||
attr_list = AddListItem("LensMode", attr_list, ";", inf)
|
||||
attr_list = AddListItem("ScientaChannelBegin", attr_list, ";", inf)
|
||||
attr_list = AddListItem("ScientaChannelEnd", attr_list, ";", inf)
|
||||
attr_list = AddListItem("ScientaSliceBegin", attr_list, ";", inf)
|
||||
attr_list = AddListItem("ScientaSliceEnd", attr_list, ";", inf)
|
||||
nds = ItemsInList(kScientaScalingDatasets, ";")
|
||||
for (ids = 0; ids < nds; ids += 1)
|
||||
sds = StringFromList(ids, kScientaScalingDatasets)
|
||||
if (WhichListItem(sds, attr_list) < 0)
|
||||
attr_list = AddListItem(sds, attr_list, ";", inf)
|
||||
endif
|
||||
endfor
|
||||
endif
|
||||
|
||||
variable ids
|
||||
variable nds = ItemsInList(attr_list, ";")
|
||||
string sds
|
||||
nds = ItemsInList(attr_list, ";")
|
||||
string wavenames = ""
|
||||
for (ids = 0; ids < nds; ids += 1)
|
||||
sds = StringFromList(ids, attr_list, ";")
|
||||
@ -529,6 +546,7 @@ function /s psh5_load_scan_attrs(fileID, scanpath, [attr_sets])
|
||||
wavenames = AddListItem(s_wavenames, wavenames, ";", inf)
|
||||
endif
|
||||
endfor
|
||||
wavenames = ReplaceString(";;", wavenames, ";")
|
||||
|
||||
return wavenames
|
||||
end
|
||||
@ -695,7 +713,7 @@ function /s psh5_load_scan_preview(fileID, scanpath, [set_scale, pref_datasets])
|
||||
set_scale = 1
|
||||
endif
|
||||
if (ParamIsDefault(pref_datasets) || (strlen(pref_datasets) == 0))
|
||||
pref_datasets = "ScientaImage;ScientaSpectrum;ImageAngleDistribution;ImageEnergyDistribution;Counts;SampleCurrent"
|
||||
pref_datasets = kPreviewDatasets
|
||||
endif
|
||||
|
||||
dfref saveDF = GetDataFolderDFR()
|
||||
@ -880,9 +898,6 @@ end
|
||||
///
|
||||
/// @return name of loaded wave if successful. empty string otherwise.
|
||||
///
|
||||
/// @todo images are transposed in the first two dimensions.
|
||||
/// this is useful for Scienta images but may not be appropriate for other sources.
|
||||
///
|
||||
function /s psh5_load_dataset_slabs(fileID, datapath, datasetname, [progress])
|
||||
variable fileID
|
||||
string datapath
|
||||
@ -910,11 +925,19 @@ function /s psh5_load_dataset_slabs(fileID, datapath, datasetname, [progress])
|
||||
if (di.ndims < 2)
|
||||
print "error: rank of dataset < 2"
|
||||
return ""
|
||||
elseif (di.ndims < 3)
|
||||
progress = 0
|
||||
endif
|
||||
|
||||
variable idx, idy, idz, idt, izt
|
||||
idx = 1
|
||||
idy = 0
|
||||
variable transpose = WhichListItem(datawavename, kTransposedDatasets) >= 0
|
||||
if (transpose)
|
||||
idx = 1
|
||||
idy = 0
|
||||
else
|
||||
idx = 0
|
||||
idy = 1
|
||||
endif
|
||||
idz = 2
|
||||
idt = 3
|
||||
|
||||
@ -951,7 +974,11 @@ function /s psh5_load_dataset_slabs(fileID, datapath, datasetname, [progress])
|
||||
slab[idt][%Start] = it
|
||||
HDF5LoadData /O /Q /Z /SLAB=slab /N=slabdata fileID, datasetpath
|
||||
wave slabdata // 2D, 3D, or 4D with singletons
|
||||
data[][][iz][it] = slabdata[q][p][0][0]
|
||||
if (transpose)
|
||||
data[][][iz][it] = slabdata[q][p][0][0]
|
||||
else
|
||||
data[][][iz][it] = slabdata[p][q][0][0]
|
||||
endif
|
||||
|
||||
// progress window
|
||||
izt += 1
|
||||
@ -1007,9 +1034,6 @@ end
|
||||
///
|
||||
/// @return name of loaded wave if successful. empty string otherwise.
|
||||
///
|
||||
/// @todo images are transposed in the first two dimensions.
|
||||
/// this is useful for Scienta images but may not be appropriate for other data sources.
|
||||
///
|
||||
function /s psh5_load_dataset_slab(fileID, datapath, datasetname, dim2start, dim2count, dim3start, dim3count)
|
||||
variable fileID
|
||||
string datapath
|
||||
@ -1038,8 +1062,14 @@ function /s psh5_load_dataset_slab(fileID, datapath, datasetname, dim2start, dim
|
||||
endif
|
||||
|
||||
variable idx, idy, idz, idt
|
||||
idx = 1
|
||||
idy = 0
|
||||
variable transpose = WhichListItem(datawavename, kTransposedDatasets) >= 0
|
||||
if (transpose)
|
||||
idx = 1
|
||||
idy = 0
|
||||
else
|
||||
idx = 0
|
||||
idy = 1
|
||||
endif
|
||||
idz = 2
|
||||
idt = 3
|
||||
|
||||
@ -1070,7 +1100,11 @@ function /s psh5_load_dataset_slab(fileID, datapath, datasetname, dim2start, dim
|
||||
HDF5LoadData /O /Q /Z /SLAB=slab /N=slabdata fileID, datasetpath
|
||||
if (!v_flag)
|
||||
wave slabdata
|
||||
data += slabdata[q][p][0][0]
|
||||
if (transpose)
|
||||
data += slabdata[q][p][0][0]
|
||||
else
|
||||
data += slabdata[p][q][0][0]
|
||||
endif
|
||||
navg += 1
|
||||
endif
|
||||
endfor
|
||||
@ -1570,11 +1604,19 @@ function /s psh5_load_dataset_reduced(fileID, scanpath, datasetname, reduction_f
|
||||
print "error: rank of dataset < 2"
|
||||
result = -2
|
||||
return wavenames
|
||||
elseif (di.ndims < 3)
|
||||
progress = 0
|
||||
endif
|
||||
|
||||
variable idx, idy, idz, idt
|
||||
idx = 1
|
||||
idy = 0
|
||||
variable transpose = WhichListItem(datawavename, kTransposedDatasets) >= 0
|
||||
if (transpose)
|
||||
idx = 1
|
||||
idy = 0
|
||||
else
|
||||
idx = 0
|
||||
idy = 1
|
||||
endif
|
||||
idz = 2
|
||||
idt = 3
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user