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.
|
/// This label may be used to store the parameters for the `setscale d` operation.
|
||||||
strconstant kDataDimLabel = "data"
|
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.
|
/// 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,
|
/// 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
|
endif
|
||||||
sg = StringFromList(ig, scanpaths)
|
sg = StringFromList(ig, scanpaths)
|
||||||
dataname = psh5_load_scan_preview(fileID, sg, set_scale=load_attr, pref_datasets=pref_datasets)
|
dataname = psh5_load_scan_preview(fileID, sg, set_scale=load_attr, pref_datasets=pref_datasets)
|
||||||
endif
|
|
||||||
|
|
||||||
wave /z data = $dataname
|
wave /z data = $dataname
|
||||||
string destpath = GetDataFolder(1, saveDF) + ANickName
|
string destpath = GetDataFolder(1, saveDF) + ANickName
|
||||||
if (waveexists(data))
|
if (waveexists(data))
|
||||||
duplicate /o data, $destpath
|
duplicate /o data, $destpath
|
||||||
wave /z data = $destpath
|
wave /z data = $destpath
|
||||||
endif
|
else
|
||||||
|
print "no data found in file " + AFileName
|
||||||
if (load_attr)
|
endif
|
||||||
setdatafolder saveDF
|
|
||||||
newdatafolder /o/s attr
|
if (load_attr)
|
||||||
killwaves /a/z
|
setdatafolder saveDF
|
||||||
psh5_load_scan_attrs(fileID, sg)
|
newdatafolder /o/s attr
|
||||||
setdatafolder ::
|
killwaves /a/z
|
||||||
|
psh5_load_scan_attrs(fileID, sg)
|
||||||
|
setdatafolder ::
|
||||||
|
endif
|
||||||
|
else
|
||||||
|
print "no scans found in file " + AFileName
|
||||||
endif
|
endif
|
||||||
|
|
||||||
HDF5CloseFile fileID
|
HDF5CloseFile fileID
|
||||||
@ -510,17 +523,21 @@ function /s psh5_load_scan_attrs(fileID, scanpath, [attr_sets])
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
variable ids
|
||||||
|
variable nds
|
||||||
|
string sds
|
||||||
|
|
||||||
if (attr_sets & 2)
|
if (attr_sets & 2)
|
||||||
attr_list = AddListItem("LensMode", attr_list, ";", inf)
|
nds = ItemsInList(kScientaScalingDatasets, ";")
|
||||||
attr_list = AddListItem("ScientaChannelBegin", attr_list, ";", inf)
|
for (ids = 0; ids < nds; ids += 1)
|
||||||
attr_list = AddListItem("ScientaChannelEnd", attr_list, ";", inf)
|
sds = StringFromList(ids, kScientaScalingDatasets)
|
||||||
attr_list = AddListItem("ScientaSliceBegin", attr_list, ";", inf)
|
if (WhichListItem(sds, attr_list) < 0)
|
||||||
attr_list = AddListItem("ScientaSliceEnd", attr_list, ";", inf)
|
attr_list = AddListItem(sds, attr_list, ";", inf)
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
endif
|
endif
|
||||||
|
|
||||||
variable ids
|
nds = ItemsInList(attr_list, ";")
|
||||||
variable nds = ItemsInList(attr_list, ";")
|
|
||||||
string sds
|
|
||||||
string wavenames = ""
|
string wavenames = ""
|
||||||
for (ids = 0; ids < nds; ids += 1)
|
for (ids = 0; ids < nds; ids += 1)
|
||||||
sds = StringFromList(ids, attr_list, ";")
|
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)
|
wavenames = AddListItem(s_wavenames, wavenames, ";", inf)
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
|
wavenames = ReplaceString(";;", wavenames, ";")
|
||||||
|
|
||||||
return wavenames
|
return wavenames
|
||||||
end
|
end
|
||||||
@ -695,7 +713,7 @@ function /s psh5_load_scan_preview(fileID, scanpath, [set_scale, pref_datasets])
|
|||||||
set_scale = 1
|
set_scale = 1
|
||||||
endif
|
endif
|
||||||
if (ParamIsDefault(pref_datasets) || (strlen(pref_datasets) == 0))
|
if (ParamIsDefault(pref_datasets) || (strlen(pref_datasets) == 0))
|
||||||
pref_datasets = "ScientaImage;ScientaSpectrum;ImageAngleDistribution;ImageEnergyDistribution;Counts;SampleCurrent"
|
pref_datasets = kPreviewDatasets
|
||||||
endif
|
endif
|
||||||
|
|
||||||
dfref saveDF = GetDataFolderDFR()
|
dfref saveDF = GetDataFolderDFR()
|
||||||
@ -880,9 +898,6 @@ end
|
|||||||
///
|
///
|
||||||
/// @return name of loaded wave if successful. empty string otherwise.
|
/// @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])
|
function /s psh5_load_dataset_slabs(fileID, datapath, datasetname, [progress])
|
||||||
variable fileID
|
variable fileID
|
||||||
string datapath
|
string datapath
|
||||||
@ -910,11 +925,19 @@ function /s psh5_load_dataset_slabs(fileID, datapath, datasetname, [progress])
|
|||||||
if (di.ndims < 2)
|
if (di.ndims < 2)
|
||||||
print "error: rank of dataset < 2"
|
print "error: rank of dataset < 2"
|
||||||
return ""
|
return ""
|
||||||
|
elseif (di.ndims < 3)
|
||||||
|
progress = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
variable idx, idy, idz, idt, izt
|
variable idx, idy, idz, idt, izt
|
||||||
idx = 1
|
variable transpose = WhichListItem(datawavename, kTransposedDatasets) >= 0
|
||||||
idy = 0
|
if (transpose)
|
||||||
|
idx = 1
|
||||||
|
idy = 0
|
||||||
|
else
|
||||||
|
idx = 0
|
||||||
|
idy = 1
|
||||||
|
endif
|
||||||
idz = 2
|
idz = 2
|
||||||
idt = 3
|
idt = 3
|
||||||
|
|
||||||
@ -951,7 +974,11 @@ function /s psh5_load_dataset_slabs(fileID, datapath, datasetname, [progress])
|
|||||||
slab[idt][%Start] = it
|
slab[idt][%Start] = it
|
||||||
HDF5LoadData /O /Q /Z /SLAB=slab /N=slabdata fileID, datasetpath
|
HDF5LoadData /O /Q /Z /SLAB=slab /N=slabdata fileID, datasetpath
|
||||||
wave slabdata // 2D, 3D, or 4D with singletons
|
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
|
// progress window
|
||||||
izt += 1
|
izt += 1
|
||||||
@ -1007,9 +1034,6 @@ end
|
|||||||
///
|
///
|
||||||
/// @return name of loaded wave if successful. empty string otherwise.
|
/// @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)
|
function /s psh5_load_dataset_slab(fileID, datapath, datasetname, dim2start, dim2count, dim3start, dim3count)
|
||||||
variable fileID
|
variable fileID
|
||||||
string datapath
|
string datapath
|
||||||
@ -1038,8 +1062,14 @@ function /s psh5_load_dataset_slab(fileID, datapath, datasetname, dim2start, dim
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
variable idx, idy, idz, idt
|
variable idx, idy, idz, idt
|
||||||
idx = 1
|
variable transpose = WhichListItem(datawavename, kTransposedDatasets) >= 0
|
||||||
idy = 0
|
if (transpose)
|
||||||
|
idx = 1
|
||||||
|
idy = 0
|
||||||
|
else
|
||||||
|
idx = 0
|
||||||
|
idy = 1
|
||||||
|
endif
|
||||||
idz = 2
|
idz = 2
|
||||||
idt = 3
|
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
|
HDF5LoadData /O /Q /Z /SLAB=slab /N=slabdata fileID, datasetpath
|
||||||
if (!v_flag)
|
if (!v_flag)
|
||||||
wave slabdata
|
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
|
navg += 1
|
||||||
endif
|
endif
|
||||||
endfor
|
endfor
|
||||||
@ -1570,11 +1604,19 @@ function /s psh5_load_dataset_reduced(fileID, scanpath, datasetname, reduction_f
|
|||||||
print "error: rank of dataset < 2"
|
print "error: rank of dataset < 2"
|
||||||
result = -2
|
result = -2
|
||||||
return wavenames
|
return wavenames
|
||||||
|
elseif (di.ndims < 3)
|
||||||
|
progress = 0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
variable idx, idy, idz, idt
|
variable idx, idy, idz, idt
|
||||||
idx = 1
|
variable transpose = WhichListItem(datawavename, kTransposedDatasets) >= 0
|
||||||
idy = 0
|
if (transpose)
|
||||||
|
idx = 1
|
||||||
|
idy = 0
|
||||||
|
else
|
||||||
|
idx = 0
|
||||||
|
idy = 1
|
||||||
|
endif
|
||||||
idz = 2
|
idz = 2
|
||||||
idt = 3
|
idt = 3
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user