1 #pragma rtGlobals=3 // Use modern global access method and strict wave access. 2 #pragma IgorVersion = 6.2 3 #pragma ModuleName = PearlAreaImport 4 #include <HDF5 Browser> 5 #include "pearl-compat" 6 #include "pearl-gui-tools" 44 string fileName, path, type, creator
46 variable handledOpen = 0
51 string FileExt = LowerStr(ParseFilePath(4, FileName, ":", 0, 0))
55 svar /z cnn = gsCustomNickName
57 if (exists("gvNickNameIndex") != 2)
58 variable/g gvNickNameIndex = 1
60 nvar nni = gvNickNameIndex
61 NickName = cnn + num2str(nni)
65 if (stringmatch(FileExt, "h5") == 1)
69 string/g s_latest_datafile = result
70 string/g s_latest_nickname = nickname
72 handledOpen = strlen(result) > 0
112 if (ParamIsDefault(ignoredate))
115 if (ParamIsDefault(unique))
119 string basename = ParseFilePath(3, filename, ":", 0, 0)
120 string extension = ParseFilePath(4, filename, ":", 0, 0)
124 if (strsearch(basename, "scienta", 0, 2) >= 0)
126 elseif (strsearch(basename, "pshell", 0, 2) >= 0)
128 elseif (strsearch(basename, "OP-SL", 0, 2) >= 0)
130 elseif (strsearch(basename, "ES-PS", 0, 2) >= 0)
135 if (ParamIsDefault(sourcename))
136 sourcename = autosource
139 variable nparts = ItemsInList(basename, "-")
141 string datepart = StringFromList(1, basename, "-")
142 variable l_datepart = strlen(datepart)
144 datepart = datepart[l_datepart-6, l_datepart-1]
146 string indexpart = StringFromList(2, basename, "-")
148 sprintf nickname, "%s_%s", sourcename, indexpart
150 sprintf nickname, "%s_%s_%s", sourcename, datepart, indexpart
156 if (unique && CheckName(nickname, 11))
157 nickname = UniqueName(nickname + "_", 11, 0)
171 string message = "Select data files"
173 string filefilters = "Area Detector HDF5 Files (*.h5):.h5;"
174 filefilters += "All Files:.*;"
176 PathInfo /S $APathName
177 Open /D /R /F=filefilters /M=message /MULT=1 refNum
178 filepaths = S_fileName
180 dfref saveDF = GetDataFolderDFR()
183 if (strlen(filepaths) > 0)
184 variable nfiles = ItemsInList(filepaths, "\r")
186 for(ifile = 0; ifile < nfiles; ifile += 1)
187 String path = StringFromList(ifile, filepaths, "\r")
214 if (ParamIsDefault(load_data))
217 if (ParamIsDefault(load_attr))
221 dfref saveDF = GetDataFolderDFR()
223 newdatafolder /s/o $("root:" + ANickName)
227 string instrumentpath = "/entry/instrument/"
228 string detectorpath = instrumentpath + "detector/"
229 string attributespath = instrumentpath + "NDAttributes/"
235 variable /g adh5_perf_secs
236 timerRefNum = startMSTimer
239 #if Exists("HDF5OpenFile") 240 HDF5OpenFile /P=$APathName/R fileID as AFileName
242 AFileName = s_path + s_filename
243 print
"loading " + s_filename +
"\r" 249 newdatafolder /o/s attr
255 if (waveexists(data))
265 Abort
"HDF5 XOP not loaded." 268 if (timerRefNum >= 0)
269 adh5_perf_secs = stopMSTimer(timerRefNum) / 1e6
302 function /s
adh5_load_reduced(ANickName, APathName, AFileName, reduction_func, reduction_param, [load_data, load_attr, progress])
308 string reduction_param
314 if (ParamIsDefault(load_data))
317 if (ParamIsDefault(load_attr))
320 if (ParamIsDefault(progress))
324 dfref saveDF = GetDataFolderDFR()
326 newdatafolder /s/o $("root:" + ANickName)
330 string instrumentpath = "/entry/instrument/"
331 string detectorpath = instrumentpath + "detector/"
332 string attributespath = instrumentpath + "NDAttributes/"
338 variable /g adh5_perf_secs
339 timerRefNum = startMSTimer
342 #if Exists("HDF5OpenFile") 343 HDF5OpenFile /P=$APathName/R fileID as AFileName
345 AFileName = s_path + s_filename
346 print
"loading " + s_filename +
"\r" 349 newdatafolder /o/s attr
362 Abort
"HDF5 XOP not loaded." 365 if (timerRefNum >= 0)
366 adh5_perf_secs = stopMSTimer(timerRefNum) / 1e6
394 if (ParamIsDefault(load_data))
397 if (ParamIsDefault(load_attr))
401 dfref saveDF = GetDataFolderDFR()
403 newdatafolder /o/s pearl_area
404 newdatafolder /o/s preview
408 string instrumentpath = "/entry/instrument/"
409 string detectorpath = instrumentpath + "detector/"
410 string attributespath = instrumentpath + "NDAttributes/"
416 variable /g adh5_perf_secs
417 timerRefNum = startMSTimer
420 #if Exists("HDF5OpenFile") 421 HDF5OpenFile /P=$APathName/R/Z fileID as AFileName
423 AFileName = s_path + s_filename
426 datasetname = detectorpath +
"data" 427 STRUCT HDF5DataInfo di
429 variable err = HDF5DatasetInfo(fileID, datasetname, 0, di)
431 print
"error accessing detector/data" 435 print
"error: rank of dataset < 2" 439 variable dim2start = 0, dim2count = 1, dim3start = 0, dim3count = 1
441 dim2start = floor(di.dims[di.ndims - 3] / 2)
445 dim3start = floor(di.dims[di.ndims - 4] / 2)
452 string destpath = GetDataFolder(1, saveDF) + ANickName
453 if (waveexists(data))
454 duplicate /o data, $destpath
455 wave /z data = $destpath
461 newdatafolder /o/s attr
465 if (waveexists(data))
472 print "error opening file " + AFileName
476 Abort
"HDF5 XOP not loaded." 479 if (timerRefNum >= 0)
480 adh5_perf_secs = stopMSTimer(timerRefNum) / 1e6
501 dfref saveDF = GetDataFolderDFR()
505 string instrumentpath = "/entry/instrument/"
506 string detectorpath = instrumentpath + "detector/"
507 string attributespath = instrumentpath + "NDAttributes/"
517 #if Exists("HDF5OpenFile") 518 HDF5OpenFile /P=$APathName/R/Z fileID as AFileName
520 AFileName = s_path + s_filename
523 datasetname = detectorpath +
"data" 524 STRUCT HDF5DataInfo di
526 variable err = HDF5DatasetInfo(fileID, datasetname, 0, di)
528 print
"error accessing detector/data" 532 for (idim = 0; idim < di.ndims; idim += 1)
533 sprintf s,
"dim %u: %u points", idim, di.dims[idim]
534 if (strlen(s_info) > 0)
535 s_info = s_info +
"\r" + s
541 dfref df = NewFreeDataFolder()
545 for (idim = 1; idim < 5; idim += 1)
546 sprintf s, "Scan%uActive", idim
548 if (waveexists(w) && (numpnts(w) > 0) && (w[0] > 0))
549 sprintf s, "Scan%uPositioner1", idim
551 sprintf s, "scan %u: %s", idim, wt[0]
552 if (strlen(s_info) > 0)
553 s_info = s_info + "\r" + s
562 print "error opening file " + AFileName
566 Abort
"HDF5 XOP not loaded." 586 #if Exists("HDF5LoadData") 591 datasetname = detectorpath +
"data" 592 STRUCT HDF5DataInfo di
594 variable err = HDF5DatasetInfo(fileID, datasetname, 0, di)
596 print
"error accessing detector/data" 600 print
"error: rank of dataset < 2" 604 HDF5LoadData /O /Q /Z fileID, datasetname
608 Abort
"HDF5 XOP not loaded." 629 duplicate /free data, tempdata
630 variable nd = wavedims(tempdata)
631 variable nx = dimsize(tempdata, nd - 1)
632 variable ny = dimsize(tempdata, nd - 2)
633 variable nz = dimsize(tempdata, nd - 3)
634 variable nt = dimsize(tempdata, nd - 4)
639 redimension /n=(ny) data
640 setdimlabel 0, -1, AD_Dim1, data
641 data = tempdata[p][0]
643 redimension /n=(nx) data
644 setdimlabel 0, -1, AD_Dim0, data
645 data = tempdata[0][p]
647 redimension /n=(nx,ny) data
648 setdimlabel 0, -1, AD_Dim0, data
649 setdimlabel 1, -1, AD_Dim1, data
650 data = tempdata[q][p]
655 redimension /n=(ny,nz) data
656 setdimlabel 0, -1, AD_Dim1, data
657 setdimlabel 1, -1, AD_DimN, data
658 multithread data = tempdata[q][p][0]
660 redimension /n=(nx,nz) data
661 setdimlabel 0, -1, AD_Dim0, data
662 setdimlabel 1, -1, AD_DimN, data
663 multithread data = tempdata[q][0][p]
665 redimension /n=(nx,ny) data
666 setdimlabel 0, -1, AD_Dim0, data
667 setdimlabel 1, -1, AD_Dim1, data
668 multithread data = tempdata[0][q][p]
670 redimension /n=(nx,ny,nz) data
671 setdimlabel 0, -1, AD_Dim0, data
672 setdimlabel 1, -1, AD_Dim1, data
673 setdimlabel 2, -1, AD_DimN, data
674 multithread data = tempdata[r][q][p]
680 redimension /n=(nx,ny,nt) data
681 setdimlabel 0, -1, AD_Dim0, data
682 setdimlabel 1, -1, AD_Dim1, data
683 setdimlabel 2, -1, AD_DimX, data
684 multithread data = tempdata[r][0][q][p]
686 redimension /n=(nx,ny,nz,nt) data
687 setdimlabel 0, -1, AD_Dim0, data
688 setdimlabel 1, -1, AD_Dim1, data
689 setdimlabel 2, -1, AD_DimN, data
690 setdimlabel 3, -1, AD_DimX, data
691 multithread data = tempdata[s][r][q][p]
710 dfref dataDF = GetWavesDataFolderDFR(data)
711 dfref attrDF = dataDF:attr
712 if (DataFolderRefStatus(attrDF) == 0)
730 dfref saveDF = GetDataFolderDFR()
731 dfref dataDF = GetWavesDataFolderDFR(data)
734 if (ParamIsDefault(source))
736 wave /SDFR=attrDF /Z AcquisitionMode
737 wave /SDFR=attrDF /T /Z Manufacturer
739 if (waveexists(Manufacturer) && (numpnts(Manufacturer) >= 1))
740 strswitch(Manufacturer[0])
748 elseif (waveexists(AcquisitionMode) && (numpnts(AcquisitionMode) >= 1))
749 if (stringmatch(note(AcquisitionMode), "*SCIENTA*"))
785 if (ParamIsDefault(progress))
791 #if Exists("HDF5LoadData") 796 datasetname = detectorpath +
"data" 797 STRUCT HDF5DataInfo di
799 variable err = HDF5DatasetInfo(fileID, datasetname, 0, di)
801 print
"error accessing detector/data" 805 print
"error: rank of dataset < 2" 810 variable idx, idy, idz, idt, izt
816 variable nx, ny, nz, nt, nzt
822 make /n=(nx,ny,nz,nt) /o data
823 string dim_labels =
"AD_Dim0;AD_Dim1;AD_DimN;AD_DimX;AD_DimY" 825 dim_label = StringFromList(0, dim_labels,
";")
826 setdimlabel 0, -1, $dim_label, data
827 dim_labels = RemoveFromList(dim_label, dim_labels,
";")
828 dim_label = StringFromList(0, dim_labels, ";")
829 setdimlabel 1, -1, $dim_label, data
830 dim_labels = RemoveFromList(dim_label, dim_labels, ";")
834 for (
id = idy - 1; (
id >= 0) && (nz == 1);
id -= 1)
838 dim_label = StringFromList(0, dim_labels, ";")
839 setdimlabel 2, -1, $dim_label, data
841 dim_labels = RemoveListItem(0, dim_labels, ";")
843 for (
id = idz - 1; (
id >= 0) && (nt == 1);
id -= 1)
847 dim_label = StringFromList(0, dim_labels, ";")
848 setdimlabel 3, -1, $dim_label, data
850 dim_labels = RemoveListItem(0, dim_labels, ";")
852 redimension /n=(nx,ny,nz,nt) data
869 HDF5MakeHyperslabWave(GetDataFolder(1) + "slab", max(di.ndims, 4))
875 slab[idx][%Block] = nx
876 slab[idy][%Block] = ny
879 for (iz = 0; iz < nz; iz += 1)
880 for (it = 0; it < nt; it += 1)
881 slab[idz][%Start] = iz
882 slab[idt][%Start] = it
883 HDF5LoadData /O /Q /Z /SLAB=slab /N=slabdata fileID, datasetname
885 switch (WaveDims(slabdata))
887 data[][][iz][it] = slabdata[q][p]
890 data[][][iz][it] = slabdata[0][q][p]
893 data[][][iz][it] = slabdata[0][0][q][p]
911 redimension /n=(nx,ny) data
913 redimension /n=(nx,ny,nz) data
920 Abort
"HDF5 XOP not loaded." 954 #if Exists("HDF5LoadData") 959 datasetname = detectorpath +
"data" 960 STRUCT HDF5DataInfo di
962 variable err = HDF5DatasetInfo(fileID, datasetname, 0, di)
964 print
"error accessing detector/data" 968 print
"error: rank of dataset < 1" 973 variable idx, idy, idz, idt
975 idy = di.ndims >= 2 ? di.ndims - 2 : 1
976 idz = di.ndims >= 3 ? di.ndims - 3 : 2
977 idt = di.ndims >= 4 ? di.ndims - 4 : 3
981 ny = di.ndims >= 2 ? di.dims[idy] : 1
983 variable dim2end = dim2start + dim2count - 1
984 variable dim3end = dim3start + dim3count - 1
988 HDF5MakeHyperslabWave(GetDataFolder(1) +
"slab", max(di.ndims, 4))
994 slab[idx][%Block] = nx
995 slab[idy][%Block] = ny
997 make /n=(nx,ny)/o/d data
1001 for (iz = dim2start; iz <= dim2end; iz += 1)
1002 for (it = dim3start; it <= dim3end; it += 1)
1003 slab[idz][%Start] = iz
1004 slab[idt][%Start] = it
1005 HDF5LoadData /O /Q /Z /SLAB=slab /N=slabdata fileID, datasetname
1007 switch (WaveDims(slabdata))
1013 data += slabdata[q][p]
1017 data += slabdata[0][q][p]
1021 data += slabdata[0][0][q][p]
1028 setdimlabel 0, -1, AD_Dim0, data
1029 setdimlabel 1, -1, AD_Dim1, data
1032 Abort
"HDF5 XOP not loaded." 1042 string all_funcs = FunctionList("*", ";", "KIND:6,NPARAMS:2,VALTYPE:8")
1046 variable nn = ItemsInList(all_funcs, ";")
1053 for (ii = 0; ii < nn; ii += 1)
1054 funcname = StringFromList(ii, all_funcs, ";")
1055 info = FunctionInfo(funcname)
1056 accept = (NumberByKey("RETURNTYPE", info, ":", ";") == 0x4000)
1057 accept = accept && (cmpstr(StringByKey("THREADSAFE", info, ":", ";"), "yes") == 0)
1058 accept = accept && (NumberByKey("N_PARAMS", info, ":", ";") == 2)
1059 accept = accept && (NumberByKey("N_OPT_PARAMS", info, ":", ";") == 0)
1062 accept = accept && (NumberByKey("PARAM_0_TYPE", info, ":", ";") == 0x4002)
1063 accept = accept && (NumberByKey("PARAM_1_TYPE", info, ":", ";") == 0x3000)
1066 result = AddListItem(funcname, result, ";")
1070 result = SortList(result, ";", 4)
1117 make /n=0 /free dest1, dest2
1123 make /n=2 /free /wave results
1139 redimension /n=(dimsize(image, dim)) profile
1140 setscale /p x dimoffset(image, dim), dimdelta(image, dim), waveunits(image, dim), profile
1141 setscale d 0, 0, waveunits(image, -1), profile
1142 setdimlabel 0, -1, $getdimlabel(image, dim, -1), profile
1170 string reduction_param
1171 string result_prefix
1173 wave /wave results = reduction_func(source, reduction_param)
1176 return reduction_param
1198 function
adh5_reduce_brick(source, reduction_func, reduction_param, result_prefix, [progress, nthreads])
1201 string reduction_param
1202 string result_prefix
1207 if (ParamIsDefault(progress))
1210 if (ParamIsDefault(nthreads))
1216 variable nx, ny, nz, nt
1217 nx = dimsize(source, 0)
1218 ny = dimsize(source, 1)
1219 nz = dimsize(source, 2)
1223 variable nzt = max(nz, 1) * max(nt, 1)
1228 nthreads = ThreadProcessorCount
1231 variable threadGroupID = ThreadGroupCreate(nthreads)
1233 for (ithread = 0; ithread < nthreads; ithread += 1)
1237 make /n=(nzt) /df /free processing_folders
1248 make /n=0 /free /wave result_waves
1251 for (iz = 0; iz < max(nz, 1); iz += 1)
1252 for (it = 0; it < max(nt, 1); it += 1)
1253 dfname = "processing_" + num2str(izt)
1254 newdatafolder /s $dfname
1255 ad_extract_slab(source, nan, nan, nan, nan, iz, iz, "image", pscale=1)
1259 variable /g r_index = iz
1260 variable /g s_index = it
1261 string /g func_param = reduction_param
1265 ThreadGroupPutDF threadGroupID, :
1267 processing_folders[izt] = GetDataFolderDFR()
1268 string param = reduction_param
1269 wave /wave reduced_waves = reduction_func(image, param)
1270 variable /g func_result = numpnts(reduced_waves)
1272 WaveClear image, reduced_waves
1292 for (izt = 0; (izt < nzt) && (result == 0); izt += 1)
1295 dfr = ThreadGroupGetDFR(threadGroupID, 1000)
1296 if (DatafolderRefStatus(dfr) != 0)
1300 if (update_progress_panel(izt))
1307 dfr = processing_folders[izt]
1309 if (update_progress_panel(izt))
1320 nvar rr = dfr:r_index
1321 nvar ss = dfr:s_index
1322 nvar func_result = dfr:func_result
1324 if (func_result < 1)
1329 if (numpnts(result_waves) == 0)
1330 redimension /n=(func_result) result_waves
1331 for (iw = 0; iw < func_result; iw += 1)
1332 sw = "redw_" + num2str(iw)
1333 wave profile = dfr:$sw
1334 sw = "ReducedData" + num2str(iw+1)
1335 make /n=(dimsize(profile, 0), nz, nt) /d /o $sw
1337 setdimlabel 0, -1, $getdimlabel(profile, 0, -1), data
1338 setscale /p x dimoffset(profile, 0), dimdelta(profile, 0), waveunits(profile, 0), data
1339 setscale /p y dimoffset(source, 2), dimdelta(source, 2), waveunits(source, 2), data
1340 setscale /p z dimoffset(source, 3), dimdelta(source, 3), waveunits(source, 3), data
1341 setscale d 0, 0, waveunits(profile, -1), data
1342 result_waves[iw] = data
1345 for (iw = 0; iw < func_result; iw += 1)
1346 sw = "redw_" + num2str(iw)
1347 wave profile = dfr:$sw
1348 wave data = result_waves[iw]
1349 data[][rr][ss] = profile[p]
1354 variable tstatus = ThreadGroupRelease(threadGroupID)
1359 for (izt = 0; izt < nzt; izt += 1)
1360 KillDataFolder /Z processing_folders[izt]
1382 dfref dfr = ThreadGroupGetDFR(0, 1000)
1383 if (DataFolderRefStatus(dfr) == 0)
1393 wave image = dfr:image
1394 svar func_param = dfr:func_param
1395 nvar rr = dfr:r_index
1396 nvar ss = dfr:s_index
1399 newdatafolder /s outDF
1400 variable /g r_index = rr
1401 variable /g s_index = ss
1402 string param = func_param
1403 wave /wave reduced_waves = reduction_func(image, param)
1404 variable /g func_result = numpnts(reduced_waves)
1408 WaveClear image, reduced_waves
1409 ThreadGroupPutDF 0, :
1432 string result_prefix
1433 variable start_index
1435 variable nw = numpnts(results)
1438 for (iw = 0; iw < nw; iw += 1)
1439 sw = result_prefix + num2str(iw + start_index)
1440 duplicate /o results[iw], $sw
1470 string reduction_param
1474 if (ParamIsDefault(progress))
1477 if (ParamIsDefault(nthreads))
1483 #if Exists("HDF5LoadData") 1488 datasetname = detectorpath +
"data" 1489 STRUCT HDF5DataInfo di
1490 InitHDF5DataInfo(di)
1491 variable err = HDF5DatasetInfo(fileID, datasetname, 0, di)
1493 print
"error accessing detector/data" 1497 print
"error: rank of dataset < 2" 1502 variable idx, idy, idz, idt
1508 variable nx, ny, nz, nt
1516 for (
id = idy - 1; (
id >= 0) && (nz == 1);
id -= 1)
1517 if (di.dims[
id] > 1)
1522 for (
id = idz - 1; (
id >= 0) && (nt == 1);
id -= 1)
1523 if (di.dims[
id] > 1)
1535 variable nzt = nz * nt
1539 HDF5MakeHyperslabWave(GetDataFolder(1) + "slab", max(di.ndims, 4))
1545 slab[idx][%Block] = nx
1546 slab[idy][%Block] = ny
1550 nthreads = ThreadProcessorCount
1553 variable threadGroupID = ThreadGroupCreate(nthreads)
1555 for (ithread = 0; ithread < nthreads; ithread += 1)
1559 make /n=(nzt) /df /free processing_folders
1566 make /n=(nx,ny)/d image_template
1567 setdimlabel 0, -1, AD_Dim0, image_template
1568 setdimlabel 1, -1, AD_Dim1, image_template
1575 make /n=0 /free /wave result_waves
1578 for (iz = 0; iz < nz; iz += 1)
1579 for (it = 0; it < nt; it += 1)
1581 slab[idz][%Start] = iz
1582 slab[idt][%Start] = it
1583 dfname = "processing_" + num2str(izt)
1584 newdatafolder /s $dfname
1585 HDF5LoadData /O /Q /Z /SLAB=slab /N=slabdata fileID, datasetname
1588 duplicate image_template, image
1589 variable /g r_index = iz
1590 variable /g s_index = it
1591 string /g func_param = reduction_param
1595 ThreadGroupPutDF threadGroupID, :
1597 processing_folders[izt] = GetDataFolderDFR()
1599 wave /wave reduced_waves =
reduce_slab_image(slabdata, image, reduction_func, func_param)
1600 variable /g func_result = numpnts(reduced_waves)
1602 WaveClear slabdata, image, reduced_waves
1609 if (update_progress_panel(izt))
1617 killwaves /z slab, image_template
1619 update_progress_panel(0, message="Processing data (step 2 of 2)...")
1623 for (izt = 0; (izt < nzt) && (result == 0); izt += 1)
1626 dfr = ThreadGroupGetDFR(threadGroupID, 1000)
1627 if (DatafolderRefStatus(dfr) != 0)
1631 if (update_progress_panel(izt))
1638 dfr = processing_folders[izt]
1640 if (update_progress_panel(izt))
1651 nvar rr = dfr:r_index
1652 nvar ss = dfr:s_index
1653 nvar func_result = dfr:func_result
1655 if (func_result < 1)
1660 if (numpnts(result_waves) == 0)
1661 redimension /n=(func_result) result_waves
1662 for (iw = 0; iw < func_result; iw += 1)
1663 sw = "redw_" + num2str(iw)
1664 wave profile = dfr:$sw
1665 sw = "ReducedData" + num2str(iw+1)
1666 make /n=(dimsize(profile, 0), nz, nt) /d /o $sw
1668 setdimlabel 0, -1, $getdimlabel(profile, 0, -1), data
1669 setscale /p x dimoffset(profile, 0), dimdelta(profile, 0), waveunits(profile, 0), data
1670 setscale d 0, 0, waveunits(profile, -1), data
1671 result_waves[iw] = data
1674 for (iw = 0; iw < func_result; iw += 1)
1675 sw = "redw_" + num2str(iw)
1676 wave profile = dfr:$sw
1677 wave data = result_waves[iw]
1678 data[][rr][ss] = profile[p]
1683 variable tstatus = ThreadGroupRelease(threadGroupID)
1688 for (izt = 0; izt < nzt; izt += 1)
1689 KillDataFolder /Z processing_folders[izt]
1694 nw = numpnts(result_waves)
1695 for (iw = 0; iw < nw; iw += 1)
1696 wave data = result_waves[iw]
1698 redimension /n=(dimsize(data, 0)) data
1700 redimension /n=(dimsize(data, 0),nz) data
1701 setdimlabel 1, -1, AD_DimN, data
1703 setdimlabel 1, -1, AD_DimN, data
1704 setdimlabel 2, -1, AD_DimX, data
1713 Abort
"HDF5 XOP not loaded." 1723 dfref dfr = ThreadGroupGetDFR(0, 1000)
1724 if (DataFolderRefStatus(dfr) == 0)
1734 wave slabdata = dfr:slabdata
1735 wave image = dfr:image
1736 svar func_param = dfr:func_param
1737 nvar rr = dfr:r_index
1738 nvar ss = dfr:s_index
1741 newdatafolder /s outDF
1742 variable /g r_index = rr
1743 variable /g s_index = ss
1744 wave /wave reduced_waves =
reduce_slab_image(slabdata, image, reduction_func, func_param)
1745 variable /g func_result = numpnts(reduced_waves)
1749 WaveClear slabdata, image, reduced_waves
1750 ThreadGroupPutDF 0, :
1757 threadsafe static function /wave
reduce_slab_image(slabdata, image, reduction_func, reduction_param)
1761 string reduction_param
1763 switch (WaveDims(slabdata))
1765 image = slabdata[q][p]
1768 image = slabdata[0][q][p]
1771 image = slabdata[0][0][q][p]
1775 return reduction_func(image, reduction_param)
1792 string attributespath
1798 #if Exists("HDF5LoadData") 1801 HDF5ListGroup /F /TYPE=2 fileID, attributespath
1802 string h5datasets = S_HDF5ListGroup
1803 HDF5ListAttributes /TYPE=1 /Z fileID, attributespath
1804 string h5attributes = S_HDF5ListAttributes
1806 variable nds = ItemsInList(h5datasets,
";")
1807 variable na = ItemsInList(h5attributes, ";")
1814 make /n=(nds+na) /t /o IN, ID, IV, IU
1816 for (ids = 0; ids < nds; ids += 1)
1817 datasetname = StringFromList(ids, h5datasets, ";")
1818 HDF5LoadData /O/Q fileID, datasetname
1820 datawavename = StringFromList(0, s_wavenames)
1824 HDF5LoadData /A="source"/O/Q/TYPE=2 fileID, datasetname
1827 s_source = source[0]
1836 nds = ItemsInList(h5attributes, ";")
1840 for (ids = 0; ids < nds; ids += 1)
1841 datasetname = StringFromList(ids, h5attributes, ";")
1842 HDF5LoadData /A=datasetname/O/Q/TYPE=1 fileID, attributespath
1844 datawavename = StringFromList(0, s_wavenames)
1849 redimension /n=(idest) IN, ID, IV, IU
1850 sort {IN, ID}, IN, ID, IV, IU
1854 Abort
"HDF5 XOP not loaded." 1890 if (exists(datawavename) == 1)
1891 if (strlen(source) > 0)
1892 Note $datawavename,
"PV=" + source
1894 switch(WaveType($datawavename, 1))
1896 wave w_attr = $datawavename
1897 n_attr = numpnts(w_attr)
1898 sprintf s_attr,
"%.12g", w_attr[0]
1901 wave /t wt_attr = $datawavename
1902 n_attr = numpnts(wt_attr)
1910 ID[idest] = datawavename
1928 dfref saveDF = GetDataFolderDFR()
1930 dfref dataDF = GetWavesDataFolderDFR(data)
1933 wave /SDFR=attrDF LensMode
1934 wave /SDFR=attrDF /Z ChannelBegin, ChannelEnd
1935 wave /SDFR=attrDF /Z SliceBegin, SliceEnd
1938 variable ELow, EHigh, ALow, AHigh
1942 strswitch(GetDimLabel(data, 0, -1))
1952 strswitch(GetDimLabel(data, 1, -1))
1965 ELow = dimoffset(data, EDim)
1966 EHigh = dimoffset(data, EDim) + dimdelta(data, EDim) * (dimsize(data, EDim) - 1)
1970 ALow = dimoffset(data, ADim)
1971 AHigh = dimoffset(data, ADim) + dimdelta(data, ADim) * (dimsize(data, ADim) - 1)
1976 if (waveexists(LensMode) && (numpnts(LensMode) >= 1))
1992 if (waveexists(ChannelBegin) && waveexists(ChannelEnd) && (numpnts(ChannelBegin) >= 1) && (numpnts(ChannelEnd) >= 1))
1993 ELow = ChannelBegin[0]
1994 EHigh = ChannelEnd[0]
1996 if (waveexists(SliceBegin) && waveexists(SliceEnd) && (numpnts(SliceBegin) >= 1) && (numpnts(SliceEnd) >= 1))
1997 ALow = SliceBegin[0]
2004 setscale /i x ELow, EHigh, EUnit, data
2007 setscale /i y ELow, EHigh, EUnit, data
2012 setscale /i x ALow, AHigh, AUnit, data
2015 setscale /i y ALow, AHigh, AUnit, data
2019 setscale d 0, 0, "arb.", data
2021 setdatafolder saveDF
2033 dfref saveDF = GetDataFolderDFR()
2035 dfref dataDF = GetWavesDataFolderDFR(data)
2036 wave /SDFR=dataDF AcquisitionMode, DetectorMode, EnergyMode
2038 wave /SDFR=dataDF /z Scan1Active, Scan2Active
2039 wave /SDFR=dataDF /t /z Scan1Positioner1, Scan1Readback1
2040 wave /SDFR=dataDF /t /z Scan1Positioner2, Scan1Readback2
2041 wave /SDFR=dataDF /t /z Scan2Positioner1, Scan2Readback1
2042 wave /SDFR=dataDF /t /z Scan2Positioner2, Scan2Readback2
2048 strswitch(GetDimLabel(data, 0, -1))
2050 setscale /i x zscale[0], zscale[numpnts(zscale)-1], "", data
2053 strswitch(GetDimLabel(data, 1, -1))
2055 setscale /i y zscale[0], zscale[numpnts(zscale)-1], "", data
2058 strswitch(GetDimLabel(data, 2, -1))
2060 setscale /i z zscale[0], zscale[numpnts(zscale)-1], "", data
2064 setdatafolder saveDF
string adh5_load_preview(string ANickName, string APathName, string AFileName, variable load_data=defaultValue, variable load_attr=defaultValue)
load a single image from a HDF5 file created by the Area Detector software.
string adh5_load_info(string APathName, string AFileName)
load descriptive info from a HDF5 file created by the Area Detector software.
variable ad_load_dialog(string APathName)
load area detector data files selected in a file dialog window
threadsafe wave ad_profile_x_w(wave dataset, variable q1, variable q2, wave destwave, variable noavg=defaultValue)
1D cut through 2D dataset along X dimension, existing destination wave.
static variable read_attribute_info(string datawavename, string source, variable *idest)
sub-function of adh5_loadattr_all.
string PearlCleanupName(string name)
static dfr GetAttrDataFolderDFR(wave data)
find the attributes data folder of an area detector dataset.
threadsafe variable adh5_setup_profile(wave image, wave profile, variable dim)
set up a one-dimensional wave for a line profile based on a 2D original wave.
threadsafe variable adh5_get_result_waves(wave results, string result_prefix, variable start_index)
copy waves from wave reference wave into current data folder
variable adh5_scale_scienta(wave data)
set the energy and angle scales of an area detector dataset from the Scienta analyser.
string adh5_test_reduction_func(wave source, funcref reduction_func, string reduction_param, string result_prefix)
wrapper function for testing reduction functions from the command line.
variable adh5_loadattr_all(variable fileID, string attributespath)
load an NDAttributes group from an open HDF5 file into the current data folder.
variable adh5_scale_scan(wave data)
scales the extra dimensions of an area detector dataset according to the EPICS scan ...
static threadsafe variable reduce_brick_worker(funcref reduction_func)
thread worker for adh5_reduce_brick
variable adh5_reduce_brick(wave source, funcref reduction_func, string reduction_param, string result_prefix, variable progress=defaultValue, variable nthreads=defaultValue)
reduce a three-dimensional intensity distribution
string ad_suggest_foldername(string filename, variable ignoredate=defaultValue, string sourcename=defaultValue, variable unique=defaultValue)
generate the name of a data folder based on a file name.
threadsafe wave ad_profile_y_w(wave dataset, variable p1, variable p2, wave destwave, variable noavg=defaultValue)
1D cut through 2D dataset along X dimension, existing destination wave.
string adh5_load_complete(string ANickName, string APathName, string AFileName, variable load_data=defaultValue, variable load_attr=defaultValue)
import everything from a HDF5 file created by the Area Detector software.
variable adh5_load_reduced_detector(variable fileID, string detectorpath, funcref reduction_func, string reduction_param, variable progress=defaultValue, variable nthreads=defaultValue)
load a reduced detector dataset from the open HDF5 file.
string adh5_load_reduced(string ANickName, string APathName, string AFileName, funcref reduction_func, string reduction_param, variable load_data=defaultValue, variable load_attr=defaultValue, variable progress=defaultValue)
load and reduce a dataset from a HDF5 file created by the Area Detector software. ...
variable adh5_redim(wave data)
redimension a multi-dimensional area detector array loaded from HDF5.
threadsafe wave adh5_default_reduction(wave source, string *param)
function prototype for adh5_load_reduced_detector
variable adh5_load_detector_slabs(variable fileID, string detectorpath, variable progress=defaultValue)
load the detector dataset from the open HDF5 file.
variable adh5_scale(wave data, string source=defaultValue)
set the dimension scales of an area detector dataset.
variable adh5_load_detector(variable fileID, string detectorpath)
load the detector dataset from the open HDF5 file.
static threadsafe wave reduce_slab_image(wave slabdata, wave image, funcref reduction_func, string reduction_param)
static variable BeforeFileOpenHook(variable refNum, string fileName, string path, string type, string creator, variable kind)
callback function for drag&drop of HDF5 files into Igor.
string adh5_list_reduction_funcs()
get a list of functions which can be used as reduction functions.
variable adh5_load_detector_image(variable fileID, string detectorpath, variable dim2start, variable dim2count, variable dim3start, variable dim3count)
load a single image from the detector dataset of the open HDF5 file
threadsafe wave ad_extract_slab(wave dataset, variable x1, variable x2, variable y1, variable y2, variable z1, variable z2, string destname, variable noavg=defaultValue, variable pscale=defaultValue)
2D cut through 3D dataset, integrate in normal dimension
static threadsafe variable reduce_slab_worker(funcref reduction_func)