1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087
|
/**********************************************************************
* cbf_hdf5.h -- read and write HDF5/NeXus files *
* *
* Version 0.9.3 21 December 2012 *
* *
* Paul Ellis and *
* Herbert J. Bernstein (yaya@bernstein-plus-sons.com) *
* *
* (C) Copyright 2009, 2012 Herbert J. Bernstein *
* *
**********************************************************************/
/**********************************************************************
* *
* YOU MAY REDISTRIBUTE THE CBFLIB PACKAGE UNDER THE TERMS OF THE GPL *
* *
* ALTERNATIVELY YOU MAY REDISTRIBUTE THE CBFLIB API UNDER THE TERMS *
* OF THE LGPL *
* *
**********************************************************************/
/*************************** GPL NOTICES ******************************
* *
* This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as *
* published by the Free Software Foundation; either version 2 of *
* (the License, or (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the Free Software *
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *
* 02111-1307 USA *
* *
**********************************************************************/
/************************* LGPL NOTICES *******************************
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Lesser General Public *
* License as published by the Free Software Foundation; either *
* version 2.1 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
* Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public *
* License along with this library; if not, write to the Free *
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, *
* MA 02110-1301 USA *
* *
**********************************************************************/
/**********************************************************************
* *
* Stanford University Notices *
* for the CBFlib software package that incorporates SLAC software *
* on which copyright is disclaimed *
* *
* This software *
* ------------- *
* The term ‘this software’, as used in these Notices, refers to *
* those portions of the software package CBFlib that were created by *
* employees of the Stanford Linear Accelerator Center, Stanford *
* University. *
* *
* Stanford disclaimer of copyright *
* -------------------------------- *
* Stanford University, owner of the copyright, hereby disclaims its *
* copyright and all other rights in this software. Hence, anyone *
* may freely use it for any purpose without restriction. *
* *
* Acknowledgement of sponsorship *
* ------------------------------ *
* This software was produced by the Stanford Linear Accelerator *
* Center, Stanford University, under Contract DE-AC03-76SFO0515 with *
* the Department of Energy. *
* *
* Government disclaimer of liability *
* ---------------------------------- *
* Neither the United States nor the United States Department of *
* Energy, nor any of their employees, makes any warranty, express or *
* implied, or assumes any legal liability or responsibility for the *
* accuracy, completeness, or usefulness of any data, apparatus, *
* product, or process disclosed, or represents that its use would *
* not infringe privately owned rights. *
* *
* Stanford disclaimer of liability *
* -------------------------------- *
* Stanford University makes no representations or warranties, *
* express or implied, nor assumes any liability for the use of this *
* software. *
* *
* Maintenance of notices *
* ---------------------- *
* In the interest of clarity regarding the origin and status of this *
* software, this and all the preceding Stanford University notices *
* are to remain affixed to any copy or derivative of this software *
* made or distributed by the recipient and are to be affixed to any *
* copy of software made or distributed by the recipient that *
* contains a copy or derivative of this software. *
* *
* Based on SLAC Software Notices, Set 4 *
* OTT.002a, 2004 FEB 03 *
**********************************************************************/
/**********************************************************************
* NOTICE *
* Creative endeavors depend on the lively exchange of ideas. There *
* are laws and customs which establish rights and responsibilities *
* for authors and the users of what authors create. This notice *
* is not intended to prevent you from using the software and *
* documents in this package, but to ensure that there are no *
* misunderstandings about terms and conditions of such use. *
* *
* Please read the following notice carefully. If you do not *
* understand any portion of this notice, please seek appropriate *
* professional legal advice before making use of the software and *
* documents included in this software package. In addition to *
* whatever other steps you may be obliged to take to respect the *
* intellectual property rights of the various parties involved, if *
* you do make use of the software and documents in this package, *
* please give credit where credit is due by citing this package, *
* its authors and the URL or other source from which you obtained *
* it, or equivalent primary references in the literature with the *
* same authors. *
* *
* Some of the software and documents included within this software *
* package are the intellectual property of various parties, and *
* placement in this package does not in any way imply that any *
* such rights have in any way been waived or diminished. *
* *
* With respect to any software or documents for which a copyright *
* exists, ALL RIGHTS ARE RESERVED TO THE OWNERS OF SUCH COPYRIGHT. *
* *
* Even though the authors of the various documents and software *
* found here have made a good faith effort to ensure that the *
* documents are correct and that the software performs according *
* to its documentation, and we would greatly appreciate hearing of *
* any problems you may encounter, the programs and documents any *
* files created by the programs are provided **AS IS** without any *
* warranty as to correctness, merchantability or fitness for any *
* particular or general use. *
* *
* THE RESPONSIBILITY FOR ANY ADVERSE CONSEQUENCES FROM THE USE OF *
* PROGRAMS OR DOCUMENTS OR ANY FILE OR FILES CREATED BY USE OF THE *
* PROGRAMS OR DOCUMENTS LIES SOLELY WITH THE USERS OF THE PROGRAMS *
* OR DOCUMENTS OR FILE OR FILES AND NOT WITH AUTHORS OF THE *
* PROGRAMS OR DOCUMENTS. *
**********************************************************************/
/**********************************************************************
* *
* The IUCr Policy *
* for the Protection and the Promotion of the STAR File and *
* CIF Standards for Exchanging and Archiving Electronic Data *
* *
* Overview *
* *
* The Crystallographic Information File (CIF)[1] is a standard for *
* information interchange promulgated by the International Union of *
* Crystallography (IUCr). CIF (Hall, Allen & Brown, 1991) is the *
* recommended method for submitting publications to Acta *
* Crystallographica Section C and reports of crystal structure *
* determinations to other sections of Acta Crystallographica *
* and many other journals. The syntax of a CIF is a subset of the *
* more general STAR File[2] format. The CIF and STAR File approaches *
* are used increasingly in the structural sciences for data exchange *
* and archiving, and are having a significant influence on these *
* activities in other fields. *
* *
* Statement of intent *
* *
* The IUCr's interest in the STAR File is as a general data *
* interchange standard for science, and its interest in the CIF, *
* a conformant derivative of the STAR File, is as a concise data *
* exchange and archival standard for crystallography and structural *
* science. *
* *
* Protection of the standards *
* *
* To protect the STAR File and the CIF as standards for *
* interchanging and archiving electronic data, the IUCr, on behalf *
* of the scientific community, *
* *
* * holds the copyrights on the standards themselves, *
* *
* * owns the associated trademarks and service marks, and *
* *
* * holds a patent on the STAR File. *
* *
* These intellectual property rights relate solely to the *
* interchange formats, not to the data contained therein, nor to *
* the software used in the generation, access or manipulation of *
* the data. *
* *
* Promotion of the standards *
* *
* The sole requirement that the IUCr, in its protective role, *
* imposes on software purporting to process STAR File or CIF data *
* is that the following conditions be met prior to sale or *
* distribution. *
* *
* * Software claiming to read files written to either the STAR *
* File or the CIF standard must be able to extract the pertinent *
* data from a file conformant to the STAR File syntax, or the CIF *
* syntax, respectively. *
* *
* * Software claiming to write files in either the STAR File, or *
* the CIF, standard must produce files that are conformant to the *
* STAR File syntax, or the CIF syntax, respectively. *
* *
* * Software claiming to read definitions from a specific data *
* dictionary approved by the IUCr must be able to extract any *
* pertinent definition which is conformant to the dictionary *
* definition language (DDL)[3] associated with that dictionary. *
* *
* The IUCr, through its Committee on CIF Standards, will assist *
* any developer to verify that software meets these conformance *
* conditions. *
* *
* Glossary of terms *
* *
* [1] CIF: is a data file conformant to the file syntax defined *
* at http://www.iucr.org/iucr-top/cif/spec/index.html *
* *
* [2] STAR File: is a data file conformant to the file syntax *
* defined at http://www.iucr.org/iucr-top/cif/spec/star/index.html *
* *
* [3] DDL: is a language used in a data dictionary to define data *
* items in terms of "attributes". Dictionaries currently approved *
* by the IUCr, and the DDL versions used to construct these *
* dictionaries, are listed at *
* http://www.iucr.org/iucr-top/cif/spec/ddl/index.html *
* *
* Last modified: 30 September 2000 *
* *
* IUCr Policy Copyright (C) 2000 International Union of *
* Crystallography *
**********************************************************************/
/** \file cbf_hdf5.h */
#ifndef CBF_HDF5_H
#define CBF_HDF5_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <hdf5.h>
#include "cbf.h"
#include "cbf_tree.h"
#include <string.h>
#ifdef CBF_USE_ULP
#include <stdint.h>
#ifndef UINT64_MAX
#define NO_UINT64_TYPE
#endif
#endif
#define CBF_H5_COLUMN_GROUP 0x00
#define CBF_H5_COLUMN_DATASET 0x01
#define CBF_H5_COLUMN_ATTRIBUTE 0x02
#define CBF_H5_COLUMN_MAP_AXES 0x04
#define CBF_H5_COLUMN_PATH 0x08
#define CBF_H5_TEXT 0x10
#define CBF_H5_FLOAT 0x20
#define CBF_H5_INTEGER 0x40
#define CBF_H5_PRIMARY 0x100
#define CBF_H5_TERMINATE 0x1000
#define CBF_H5_SPECIAL 0x2000
#define CBF_H5_ARRAY 0x4000
#define CBF_H5_LINK 0x8000 /* should appear both in the special
field of the target and the dsorat
field of the source */
#define CBF_H5_MORE 0x10000 /* more mappings of same column follow
field of the target and the dsorat
field of the source */
/** return the maximum of two numeric values */
#define cbf_max(a,b) ((a)>(b)?(a):(b))
typedef enum cbf_axisEquipment_e
{
/* actual physical equipment */
axisEquipment_detector,
axisEquipment_image,
axisEquipment_goniometer,
/* special values */
axisEquipment_gravity,
axisEquipment_source,
/* other/undefined */
axisEquipment_general
} cbf_axisEquipment_e;
typedef struct _cbf_axisData_t
{
const char * name; /* either from the last path component or
from the name attribute "long_name" */
hid_t axis;
cbf_axisEquipment_e equipment;
int flags;
struct _cbf_axisData_t * depends_on;
struct _cbf_axisData_t * rotation_axis;
struct _cbf_axisData_t * axis_hash_next_name;
struct _cbf_axisData_t * axis_hash_next_path;
struct _cbf_axisData_t * axis_hash_next_object;
ssize_t axisData_index; /* the index at which this entry appears */
const char * axis_path; /* A path to this axis */
const char * do_path;
const char * ra_path;
} cbf_axisData_t;
/* Note the number of hash bins must be a power of 2 */
#define CBF_NX2CBF_HASH_BINS 64
typedef struct cbf_nx2cbf_key_t
{
/*
keys - should not be modified once created.
*/
const char * array_id;
int binary_id;
const char * datablock_id;
const char * diffrn_id;
const char * diffrn_detector_id;
const char * diffrn_detector_element_id;
const char * diffrn_measurement_id;
const char * frame_id;
const char * scan_id;
const char * wavelength_id;
/*
tables - should be modified as data is added and
will be modified when the table is first created.
*/
cbf_node * array_data;
cbf_node * array_element_size;
cbf_node * array_intensities;
cbf_node * diffrn;
cbf_node * diffrn_data_frame;
cbf_node * diffrn_detector;
cbf_node * diffrn_detector_element;
cbf_node * diffrn_measurement;
cbf_node * diffrn_radiation;
cbf_node * diffrn_radiation_wavelength;
cbf_node * diffrn_scan;
cbf_node * diffrn_scan_frame;
cbf_node * diffrn_source;
/*
number of frames of data in the file - many array
data items must be scalar, have 1 element or be
this length.
*/
hsize_t frames; /* slowest index */
hsize_t xdim; /* fast index */
hsize_t ydim; /* mid index */
hsize_t zdim; /* slow index */
int rank; /* rank including the frame index */
/* axes */
cbf_axisData_t * * axisData;
cbf_axisData_t * axispathhash[CBF_NX2CBF_HASH_BINS]; /* path hash links */
cbf_axisData_t * axisnamehash[CBF_NX2CBF_HASH_BINS]; /* name hash links */
cbf_axisData_t * axisobjecthash[CBF_NX2CBF_HASH_BINS];/* object hash links */
size_t nAxes;
/* other data */
int has_scaling_factor;
int has_offset;
unsigned int indent;
} cbf_nx2cbf_key_t;
/****************************************************************
The following section of code is extracted from J. Sloan's
cbf_hdf5_common.h
****************************************************************/
#define CBF_H5FAIL ((hid_t)(-1))
/**
\defgroup section_HDF5_H5A
\defgroup section_HDF5_H5D
\defgroup section_HDF5_H5F
\defgroup section_HDF5_H5G
\defgroup section_HDF5_H5I
\defgroup section_HDF5_H5O
\defgroup section_HDF5_H5S
\defgroup section_HDF5_H5T
\defgroup section_H5Handle
\defgroup section_minicbf_config
*/
/**
Concatenate several null-terminated strings into a single string, with each component
separated by one 'sep' character. A leading or trailing empty string will cause a
leading or trailing 'sep' character to be written, the character may be repeated by
inserting an empty string into the 'parts' array at the appropriate place. The 'parts'
array must be terminated by a null pointer, not a pointer to an empty string.
Examples:
_cbf_str_join({0},c);
→ ""
_cbf_str_join({"string",0},c);
→ "string"
_cbf_str_join({"","",0},'#');
→ "#"
_cbf_str_join({"multi","part","string",0},'-');
→ "multi-part-string"
_cbf_str_join({"A","string","","with","more","separators",0},'_');
→ "A_string__with_more_separators"
_cbf_str_join({"","leading",0},'_');
→ "_leading"
_cbf_str_join({"trailing","",0},'_');
→ "trailing_"
Returns a string which must be free'd on success, NULL on failure.
Creating an empty string is not failure to create a string.
*/
char * _cbf_str_join(const char * const * const parts, const char sep);
/**
\brief Check the validity of an object identifier.
\ingroup section_HDF5_H5I
*/
int cbf_H5Ivalid(const hid_t ID);
/*
Find/create/free a HDF5 group if it's valid & possibly set the ID to an invalid identifier
can write requireGroup function as {if (!find(group)) create(group); return group;}
*/
/**
\brief Attempt to create a group.
\ingroup section_HDF5_H5G
*/
int cbf_H5Gcreate(const hid_t location, hid_t * const group, const char * const name);
/**
\brief Check if a group exists.
\ingroup section_HDF5_H5G
*/
int cbf_H5Gfind(const hid_t location, hid_t * const group, const char * const name);
/**
\brief Ensure a group exists.
\ingroup section_HDF5_H5G
*/
int cbf_H5Grequire(const hid_t location, hid_t * const group, const char * const name);
/**
\brief Close a HDF5 group.
\ingroup section_HDF5_H5G
*/
int cbf_H5Gfree(const hid_t ID);
/* Open/close a HDF5 file if it's valid & possibly set the ID to an invalid identifier */
/**
\brief Attempt to open an HDF5 file by file name
\ingroup section_HDF5_H5F
*/
int cbf_H5Fopen(hid_t * const file, const char * const name);
/**
\brief Close a HDF5 file
\ingroup section_HDF5_H5F
*/
int cbf_H5Fclose(const hid_t ID);
/* Attributes */
/**
\brief Create a new attribute
\ingroup section_HDF5_H5A
*/
int cbf_H5Acreate
(const hid_t location,
hid_t * const attr,
const char * const name,
const hid_t type,
const hid_t space);
/**
\brief Try to locate an existing attribute
\ingroup section_HDF5_H5A
*/
int cbf_H5Afind
(const hid_t location,
hid_t * const attr,
const char * const name,
const hid_t type,
const hid_t space);
/**
\brief Read an entire attribute from a file
\ingroup section_HDF5_H5A
*/
int cbf_H5Aread
(const hid_t attr,
const hid_t type,
void * const buf);
/**
\brief Read an entire string attribute from a file
\ingroup section_HDF5_H5A
*/
int cbf_H5Aread_string
(const hid_t attr,
const char * * const val);
/**
\brief Write an entire attribute to a file.
\ingroup section_HDF5_H5A
*/
int cbf_H5Awrite
(const hid_t attr,
const hid_t type,
void * const buf);
int cbf_H5Arequire_cmp
(const hid_t ID,
const char * const name,
const int rank,
const hsize_t * const dim,
const hid_t type,
const void * const value,
void * const buf,
int (*cmp)(const void *, const void *, size_t));
/* We provide a macro and 2 versions of each of the calls with _ULP
variants. */
#ifdef CBF_USE_ULP
#define CBFM_H5Arequire_cmp2(id,nm,rk,dm,ft,mt,vl,bf,cmp,prm) \
cbf_H5Arequire_cmp2_ULP(id,nm,rk,dm,ft,mt,vl,bf,cmp,prm)
#else
#define CBFM_H5Arequire_cmp2(id,nm,rk,dm,ft,mt,vl,bf,cmp,prm) \
cbf_H5Arequire_cmp2(id,nm,rk,dm,ft,mt,vl,bf,cmp)
#endif
/**
\brief Check for an attribute with the given space/type/value, or set one if it doesn't exist.
\ingroup section_HDF5_H5A
*/
int cbf_H5Arequire_cmp2
(const hid_t ID,
const char * const name,
const int rank,
const hsize_t * const dim,
const hid_t fileType,
const hid_t memType,
const void * const value,
void * const buf,
int (*cmp)(const void *, const void *, size_t));
/**
\brief Check for an attribute with the given space/type/value, or set one if it doesn't exist.
\ingroup section_HDF5_H5A
*/
int cbf_H5Arequire_cmp2_ULP
(const hid_t ID,
const char * const name,
const int rank,
const hsize_t * const dim,
const hid_t fileType,
const hid_t memType,
const void * const value,
void * const buf,
int (*cmp)(const void *, const void *, size_t, const void *),
const void * const cmp_params);
/**
\brief Check for a scalar string attribute with a given value, or set one if it doesn't exist.
\ingroup section_HDF5_H5A
*/
int cbf_H5Arequire_string
(const hid_t location,
const char * const name,
const char * const value);
/**
\brief Close a HDF5 attribute.
\ingroup section_HDF5_H5A
*/
int cbf_H5Afree(const hid_t ID);
/* find/create/free hdf5 datasets without directly using hdf5 API */
/**
\brief Creates a new dataset in the given location.
\ingroup section_HDF5_H5D
*/
int cbf_H5Dcreate
(const hid_t location,
hid_t * const dataset,
const char * const name,
const int rank,
const hsize_t * const dim,
const hsize_t * const max,
const hsize_t * const chunk,
const hid_t type);
/* Look for a dataset with the given properties. */
int cbf_H5Dfind
(const hid_t location,
hid_t * const dataset,
const char * const name,
const int rank,
const hsize_t * const dim,
const hsize_t * const max,
const hsize_t * const chunk,
const hid_t type);
/**
\brief Look for a dataset with the given properties.
\ingroup section_HDF5_H5D
*/
int cbf_H5Dfind2
(const hid_t location,
hid_t * const dataset,
const char * const name,
const int rank,
const hsize_t * const max,
hsize_t * const buf,
const hid_t type);
/**
\brief Ensure that a dataset exists, returning a handle to an existing dataset or creating a new dataset if needed.
\ingroup section_HDF5_H5D
*/
int cbf_H5Drequire
(const hid_t location,
hid_t * const dataset,
const char * const name,
const int rank,
const hsize_t * const max,
const hsize_t * const chunk,
hsize_t * const buf,
const hid_t type);
/**
\brief Add some data to a datset, expanding the dataset to the appropriate size if needed.
\ingroup section_HDF5_H5D
*/
int cbf_H5Dinsert
(const hid_t dataset,
const hsize_t * const offset,
const hsize_t * const stride,
const hsize_t * const count,
hsize_t * const buf,
const void * const value,
const hid_t type);
/**
\brief Change the extent of a chunked dataset to the values in <code>dim</code>.
\ingroup section_HDF5_H5D
*/
int cbf_H5Dset_extent(const hid_t dataset, const hsize_t * const dim);
int cbf_H5Dwrite
(const hid_t dataset,
const hsize_t * const offset,
const hsize_t * const stride,
const hsize_t * const count,
const void * const value);
/**
\brief Add some data to the specified position in the dataset, without checking what (if anything) was there before.
\ingroup section_HDF5_H5D
*/
int cbf_H5Dwrite2
(const hid_t dataset,
const hsize_t * const offset,
const hsize_t * const stride,
const hsize_t * const count,
const void * const value,
const hid_t type);
int cbf_H5Dread
(const hid_t dataset,
const hsize_t * const offset,
const hsize_t * const stride,
const hsize_t * const count,
void * const value);
/**
\brief Extract some existing data from a dataset at a known position.
\ingroup section_HDF5_H5D
*/
int cbf_H5Dread_element_as_string
(const hid_t dataset,
const hsize_t * const offsets,
const size_t noffsets,
char * * value);
/**
\brief Extract some existing data from a dataset at a known position with memtype.
\ingroup section_HDF5_H5D
*/
int cbf_H5Dread2
(const hid_t dataset,
const hsize_t * const offset,
const hsize_t * const stride,
const hsize_t * const count,
void * const value,
const hid_t type);
int cbf_H5Drequire_scalar_F64LE
(const hid_t location,
hid_t * const dataset,
const char * const name,
const double value);
/* We provide a macro and 2 versions of each of the calls with _ULP
variants. */
#ifdef CBF_USE_ULP
#define CBFM_H5Drequire_scalar_F64LE2(loc,ds,nm,val,cmp,prm) \
cbf_H5Drequire_scalar_F64LE2_ULP(loc,ds,nm,val,cmp,prm)
#else
#define CBFM_H5Drequire_scalar_F64LE2(loc,ds,nm,val,cmp,prm) \
cbf_H5Drequire_scalar_F64LE2(loc,ds,nm,val,cmp)
#endif
/**
\brief Write a scalar 64-bit floating point number as a dataset with comparison.
\ingroup section_HDF5_H5D
*/
int cbf_H5Drequire_scalar_F64LE2
(const hid_t location,
hid_t * const dataset,
const char * const name,
const double value,
int (*cmp)(const void *, const void *, size_t)
);
/**
\brief Write a scalar 64-bit floating point number as a dataset with a user-defined comparison.
\ingroup section_HDF5_H5D
*/
int cbf_H5Drequire_scalar_F64LE2_ULP
(const hid_t location,
hid_t * const dataset,
const char * const name,
const double value,
int (*cmp)(const void *, const void *, size_t, const void *),
const void * const cmp_params);
/**
\brief Write a single fixed-length string as a dataset.
\ingroup section_HDF5_H5D
*/
int cbf_H5Drequire_flstring
(const hid_t location,
hid_t * const dataset,
const char * const name,
const char * const value);
/**
\brief Close a HDF5 dataset.
\ingroup section_HDF5_H5D
*/
int cbf_H5Dfree(const hid_t ID);
/* Custom HDF5 types - to get the correct string type for datasets in a consistent way */
/**
\brief Get a HDF5 string datatype to describe a string of the specified length.
\ingroup section_HDF5_H5T
*/
int cbf_H5Tcreate_string(hid_t * const type, const size_t len);
/**
\brief Close a HDF5 datatype identifier.
\ingroup section_HDF5_H5T
*/
int cbf_H5Tfree(const hid_t ID);
/* HDF5 dataspace functions: I need a uniform method of creating data spaces to ensure correct operation of comparison functions */
/**
\brief Create a dataspace with some given values.
\ingroup section_HDF5_H5S
*/
int cbf_H5Screate
(hid_t * const ID,
const int rank,
const hsize_t * const dim,
const hsize_t * const max);
/**
\brief Close a HDF5 dataspace identifier.
\ingroup section_HDF5_H5S
*/
int cbf_H5Sfree(const hid_t ID);
/**
\brief A missing HDF5 function.
\ingroup section_HDF5_H5O
*/
htri_t cbf_H5Ocmp
(const hid_t id0,
const hid_t id1);
/**
\brief Close a HDF5 object identifier.
\ingroup section_HDF5_H5O
*/
int cbf_H5Ofree(const hid_t ID);
/****************************************************************
End of section of code extracted from J. Sloan's
cbf_hdf5_common.h
****************************************************************/
/****************************************************************
The following section of code is extracted from J. Sloan's
config.h
****************************************************************/
extern const int cbf_configError_success;
/* Opaque type for a collection of configuration items */
struct cbf_config_t;
typedef struct cbf_config_t cbf_config_t;
/**
\brief Obtain a new handle for some configuration settings.
\ingroup section_minicbf_config
*/
cbf_config_t * cbf_config_create( void );
/**
\brief Read a minicbf configuration file into the given handle, writing errors to <code>logfile</code>.
\ingroup section_minicbf_config
*/
int cbf_config_parse(FILE * const configFile, FILE * const logFile, cbf_config_t * const vec);
/**
\brief Free any heap memory associated with the given cbf_hdf5_configItemVectorhandle object.
\ingroup section_minicbf_config
*/
void cbf_config_free(const cbf_config_t * const vector);
/**
\brief Convert a parse error to a descriptive string.
\ingroup section_minicbf_config
*/
const char * cbf_config_strerror(const int error);
/****************************************************************
End of section of code extracted from J. Sloan's
config.h
****************************************************************/
/* Attribute type definition, agrees with CBFlib data convensions */
typedef struct cbf_name_value_pair_def
{
const char * name;
const void * value;
} cbf_name_value_pair;
#define cbf_h5failneg(x,code) {int err; err = (x); if (err < 0) {return (code);}}
#define cbf_h5onfailneg(x,code,y) {int err; err = (x); if (err < 0) {{y;} return (code);}}
#define cbf_h5reportneg(x,code,cerr) \
{int err; if (!(cerr)) {err = (x); if (err < 0) {(cerr)|=code;}}}
#define reportFail(f, errorCode, errorVar) \
do { \
if (CBF_SUCCESS == errorVar && !(f)) { \
errorVar |= (errorCode); \
fprintf(stderr, "%s:%d: '" #f "' failed.\n", __FILE__, __LINE__); \
} \
} while (0)
#define cbf_reportFail(f, errorVar) \
do { \
if (CBF_SUCCESS == errorVar) { \
const int errorCode = (f); \
if (CBF_SUCCESS != errorCode) \
errorVar |= errorCode; \
} \
} while (0)
#ifndef H5_VERS_MAJOR
#define H5_VERS_MAJOR 0
#endif
#ifndef H5_VERS_MINOR
#define H5_VERS_MINOR 0
#endif
#if (H5_VERS_MAJOR>1)||((H5_VERS_MAJOR==1)&&(H5_VERS_MINOR>=8))
#define H5Acreatex(loc_id,name,type_id,space_id,acpl_id) \
H5Acreate2(loc_id,name,type_id,space_id,acpl_id,H5P_DEFAULT)
#define H5Dcreatex(loc_id,name,type_id,space_id,dcpl_id) \
H5Dcreate2(loc_id,name,type_id,space_id,H5P_DEFAULT,dcpl_id,H5P_DEFAULT)
#define H5Gcreatex(loc_id,name) \
H5Gcreate2(loc_id,name,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT)
#define H5Gopenx(loc_id,name) H5Gopen2(loc_id,name,H5P_DEFAULT)
#else
#error HDF5 Version >= 1.8 Required
#endif
/* CBF Bookmark */
typedef struct {
const char * datablock;
const char * saveframe;
const char * category;
const char * column;
unsigned int row;
int haverow;
} cbf_bookmark;
/* CBF Fast Bookmark */
typedef struct {
cbf_node *node;
int row;
} cbf_fast_bookmark;
/* H5File structure */
typedef struct
{
int rwmode; /* 0 for read-only, 1 for read-write */
unsigned int slice; /* The slice within the HDF5 data arrays where data will be added */
unsigned int block; /* The block of data arrays, or zero if no blocking */
unsigned int blocksize; /* The number of arrays in a block */
unsigned int num_detectors; /* The number of NXdetector groups */
unsigned int cap_detectors; /* The capacity in terms of NXdetector groups */
unsigned int cur_detector; /* The currently active detector, numbered from 1 */
hid_t hfile; /* The HDF5 file */
hid_t nxid; /* /entry@NXentry */
hid_t nxdata; /* /entry/data@NXdata */
hid_t nxsample; /* /entry/sample@NXsample group */
hid_t nxbeam; /* /entry/beam@NXbeam group */
hid_t nxinst; /* /entry/instrument@NXinstrument */
hid_t nxdetector_group; /* /entry/instrument/detector_group@NXdetector_group */
hid_t * nxdetectors; /* /entry/instrument/detector@NXdetector */
hid_t nxmonochromator; /* /entry/instrument/monochromator@NXmonochromator */
hid_t nxgoniometer; /* /entry/instrument/goniometer@NXgoniometer */
hid_t nxsource; /* /entry/instrument/source@NXsource */
hid_t rootid; /* The root CBF database group */
hid_t dbid; /* The current datablock in the CBF */
hid_t sfid; /* The current saveframe in the current datablock or -1 */
hid_t catid; /* The current category */
hid_t colid; /* The current column */
hid_t curnxid; /* The current NeXus group */
hid_t dataid; /* The NeXus NXdata group */
/* Names of various groups, used to construct paths to the axes */
const char * nxid_name;
const char * nxdetector_group_name;
const char * * nxdetector_names;
const char * scan_id; /* a unique identifier for the scan */
const char * sample_id; /* a unique identifier for the sample */
const char * nxsample_name;
const char * nxbeam_name;
const char * nxinstrument_name;
const char * nxgoniometer_name;
const char * nxmonochromator_name;
const char * nxsource_name;
const char * nxdata_name;
const char * nxfilename;
const char * dbid_name;
const char * sfid_name;
const char * catid_name;
const char * colid_name;
/* Names of corresponding CBF datablock, saveframe, category, column
each case these must have already been created in the cbf and should
not be freed or modified
*/
const char * cbf_datablock;
const char * cbf_saveframe;
const char * cbf_category;
const char * cbf_column;
/* Flags for various options */
unsigned long int flags;
#ifdef CBF_USE_ULP
/* Parameters controlling floating point comparisons */
int cmp_double_as_float;
unsigned int float_ulp;
#ifndef NO_UINT64_TYPE
uint64_t double_ulp;
#endif
#endif
cbf_bookmark
bookmark;/* Read bookmark to save names for paths */
cbf_handle scratch_tables;
FILE * logfile;
}
cbf_h5handle_struct;
typedef cbf_h5handle_struct *cbf_h5handle;
typedef struct
{
cbf_handle handle;
cbf_h5handle h5handle;
hid_t parent_id;
haddr_t parent_addr;
const char * great_grand_parent_name;
const char * grand_parent_name;
const char * parent_name;
/* when at column, parent is category,
grand-parent is data-block (or save frame if there is a grand parent)
and great_grand_parent is data-block for a save_fame */
size_t capacity;
size_t path_size;
hid_t *hid_path;
haddr_t *haddr_path;
cbf_bookmark bookmark; /* bookmark in the CBF */
int incbf; /* set to 1 when we have descended
into a NeXus NXcbf */
int incbfdb; /* set to 1 when we have descended
into a NeXus NXcbfdb */
int incbfsf; /* set to 1 when we have descended
into a NeXus NXcbfsf */
int incbfcat; /* set to 1 when we have descended
into a NeXus NXcbfcat */
int incbfcol; /* set to 1 when we have descended
into a NeXus NXcbfcol */
int innexus; /* set to 1 when we have descended
into a NeXus NXexntry */
int innxpdb; /* set to 1 when we have descended
into a NeXus NXpdb, updated by 1
for each subgroup level */
}
cbf_h5Ovisit_struct;
typedef cbf_h5Ovisit_struct *cbf_h5Ovisithandle;
/**
\brief Get the current id of the file within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_file
(const cbf_h5handle nx,
hid_t * const file);
/**
\brief Set the id of the file within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_file
(const cbf_h5handle nx,
const hid_t file);
/**
\brief Get the current id and name of the data group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_data
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Get the current id and name of the entry group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_entry
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the entry group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_entry
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Ensure I have an entry in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_entry
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/**
\brief Ensure I have an entry in the hdf5 handle with definition
\ingroup section_H5Handle
*/
int cbf_h5handle_require_entry_definition
(const cbf_h5handle nx,
hid_t * const group,
const char * name,
const char * definition,
const char * version,
const char * URL);
/**
\brief Get the current id and name of the sample group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_sample
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the sample group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_sample
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Ensure I have a sample in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_sample
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/**
\brief Get the current id and name of the cbfdb group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_cbfdb
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the cbfdb group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_cbfdb
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Ensure I have a cfbdb in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_cbfdb
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/**
\brief Get the current id and name of the beam group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_beam
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the beam group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_beam
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Ensure I have a beam in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_beam
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/**
\brief Get the current id and name of the instrument group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_instrument
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the instrument group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_instrument
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Find an existing instrument group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_find_instrument
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Ensure I have an instrument in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_instrument
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/**
\brief Get the current id and name of the detector_group group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_detector_group
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the detector_group group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_detector_group
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Ensure I have a detector_group in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_detector_group
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/**
\brief Get the current id and name of the detector group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_detector
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the detector group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_detector
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Ensure I have a detector in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_detector
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/**
\brief Get the current id and name of the goniometer group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_goniometer
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the goniometer group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_goniometer
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Ensure I have a goniometer in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_goniometer
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/**
\brief Get the current id and name of the monochromator group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_monochromator
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the monochromator group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_monochromator
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Ensure I have a monochromator in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_monochromator
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/**
\brief Get the current id and name of the source group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_get_source
(const cbf_h5handle nx,
hid_t * const group,
const char * * const name);
/**
\brief Set the id and name of the source group within the given handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_set_source
(const cbf_h5handle nx,
const hid_t group,
const char * const name);
/**
\brief Ensure I have a source in the hdf5 handle.
\ingroup section_H5Handle
*/
int cbf_h5handle_require_source
(const cbf_h5handle nx,
hid_t * const group,
const char * name);
/* Create a dotted CBF location string
returns a newly allocated string that
must be freed */
int cbf_location_string(const char* datablock,
const char* category,
const char* column,
unsigned int row,
char * * stringout);
/* Conatenate two strings, returning a newly allocated string */
int cbf_strcat(const char * string1, const char * string2,
char * * stringout);
/* Either open or create a NeXus group*/
int cbf_require_nxgroup(cbf_h5handle h5handle,
const char * nxgroup,
const char * nxclass,
hid_t parent_id,
hid_t * groupid);
/* get an axis vector and offset */
int cbf_get_axis_vector_and_offset(cbf_handle handle,
const char *axis_id,
double vector[3],
double offset[3]);
/* Compute the cross-product of 2 3-vectors */
int cbf_cross_product(double vecin1[3],
double vecin2[3],
double vecout[3] );
/* compute the L2 norm of a 3-vector */
double cbf_norm(double vector[3]);
/* compute the product of a scalar and a vector */
int cbf_scalar_product(double scalar, double vecin[3], double vecout[3]);
/* Apply a matrix to a vector */
int cbf_apply_matrix(double matrix[3][3], double vecin[3], double vecout[3]);
/* compute the transform from CBF vectors to NeXus vectors
Use the transpose to transfrom from NeXus vectors to CBF*/
int cbf_get_NX_axis_transform(cbf_handle handle,
double matrix [3][3]);
/* Get a nexus detector name */
int cbf_get_NX_detector_name(cbf_h5handle h5handle,
unsigned int row,
const char * * detector_element);
/* Set a nexus detector name */
int cbf_set_NX_detector_name(cbf_h5handle h5handle, const char * detector_element);
/* Count the nexus detector names */
int cbf_count_NX_detector_names(cbf_h5handle h5handle, unsigned int * count);
/* get the Nexus axis path if previously established.
If not, try to create both the path and the intervening groups
*/
int cbf_require_NX_axis_path(cbf_handle handle,
cbf_h5handle h5handle,
const char * axis_id,
const char * * nexus_path);
/* Get the nexus path of an axis, if previously set */
int cbf_get_NX_axis_path(cbf_h5handle h5handle, const char * axis_id, const char * * nexus_path);
/* Get the nexus poise path of an axis, if previously set. */
int cbf_get_NX_axis_poise_path(cbf_h5handle h5handle, const char * axis_id, const char * * poise_path);
/* Set the parent path of an axis */
int cbf_set_NX_parent_path(cbf_h5handle h5handle, const char * axis_id, const char * parent_path);
/* Get the flag that this is an array_axis to the value given */
int cbf_get_NX_axis_array_axis(cbf_h5handle h5handle,
const char * axis_id, int *flag);
/* Set the flag that this is an array_axis to the value given */
int cbf_set_NX_axis_array_axis(cbf_h5handle h5handle,
const char * axis_id, const int flag);
/* increment the count of axes dependent on this axis */
int cbf_increment_NX_axis_depcount(cbf_h5handle h5handle, const char * axis_id);
/* Set the nexus path of an axis */
int cbf_set_NX_axis_path(cbf_h5handle h5handle, const char * axis_id, const char * nexus_path);
/* Set the parent path of an axis */
int cbf_set_NX_parent_path(cbf_h5handle h5handle, const char * axis_id, const char * parent_path);
/* Write the HDF5 version of the NeXus axis definitions, if
the original CBF had axis definitions */
int cbf_write_h5nxaxes(cbf_handle handle, cbf_h5handle h5handle);
/* apply a double vector attribute to a group or dataset */
int cbf_apply_h5vector_attribute(hid_t hid,
const char* attribname,
const double* attribvec,
const size_t dimension,
int errorcode);
/* apply a long attribute to a group or dataset */
int cbf_apply_h5longasstr_attribute(hid_t hid,
const char* attribname,
const long attriblong,
int errorcode);
/* apply an integer attribute to a group or dataset as a string */
int cbf_apply_h5intasstr_attribute(hid_t hid,
const char* attribname,
const int attribint,
int errorcode);
/* apply a integer attribute to a group or dataset */
int cbf_apply_h5integer_attribute(hid_t hid,
const char* attribname,
const int attribint,
int errorcode);
/* apply a text attribute to a group or dataset */
int cbf_apply_h5text_attribute(hid_t hid,
const char* attribname,
const char* attribtext,
int errorcode);
/* apply a text attribute slab to a dataset
Actually works with a text data set and makes
the attribute be an object reference to that
dataset. The name of the dataset is the
name of the attribute with the optional
prefix and suffix
*/
int cbf_add_h5text_attribute_slab(hid_t datasetid,
hid_t groupid,
const char* attributename,
const char* attributetext,
const char* datasetnameprefix,
const char* datasetnamesuffix,
const hsize_t slab,
int errorcode);
/* find a text dataset slab in a dataset in a group, with slab location
places the specified datasettext in some slab of the
specified datasetname for group hid. The slab where the text is
found or placed is reported in textslab.
If the new text is the same as the existing text in any slab, nothing changes.
A case-insensitive compare is used.
The slabs are indexed from 0
*/
int cbf_find_h5text_dataset_slab(hid_t hid,
const char* datasetname,
const char* datasettext,
hsize_t * textslab,
int errorcode);
/* require a text dataset slab in a dataset in a group
places the specified datasettext in some slab of the
specified datasetname for group hid. The dataset is created
if it does not already exist.
If the new text is the same as the existing text in any slab, nothing changes.
A case-insensitive patch is used.
The first slab goes in rank = 0. Additional slabs go in rank 1.
If the new text is different, a new slab is appended.
The slabs are indexed from 0
*/
int cbf_require_h5text_dataset_slab(hid_t hid,
const char* datasetname,
const char* datasettext,
int errorcode);
/* apply a text dataset slab to a group
places the specified datasettext in the specified slab of the
specified datasetname for group hid. The dataset is created
if it does not already exist.
The slabs are indexed from 0
*/
int cbf_add_h5text_dataset_slab(hid_t hid,
const char* datasetname,
const char* datasettext,
const hsize_t slab,
int errorcode);
/* get the length of text list attribute from a group or dataset
this uses variable length strings*/
int cbf_get_h5text_list_attribute_length(hid_t hid,
const char* attribname,
size_t *length,
int errorcode);
/* apply a text list attribute to a group or dataset
this uses variable length strings*/
int cbf_apply_h5text_list_attribute(hid_t hid,
const char* attribname,
const size_t length,
const char** attribtext,
int errorcode);
/* read a text list attribute from a group or dataset
this uses variable length strings. To use this code,
The calling routine should first call
cbf_get_h5text_list_attribute_length and allocate
attribtext as an array of char * of that length.
The call to the cbf_get_h5text_list_attribute will allocate
the individual text strings, or return NULL for each
string.
*/
int cbf_get_h5text_list_attribute(hid_t hid,
const char* attribname,
const size_t length,
const char** attribtext,
int errorcode);
/* add a text list attribute slab to a text list attribute of a group or dataset
this uses variable length strings*/
int cbf_add_h5text_list_attribute_slab(hid_t hid,
const char* attribname,
const char* attribtext,
const hsize_t slab,
int errorcode);
/* add a double dataset to a group */
int cbf_add_h5double_dataset(hid_t hid,
const char* datasetname,
const double datasetvalue,
int errorcode);
/* add a double dataset array slab to a double dataset array dataset */
int cbf_add_h5double_dataset_slab(hid_t hid,
const char* datasetname,
const double datasetvalue,
const hsize_t slab,
int errorcode);
/* add a double vector dataset slab to a group
places the specified dataset vector in the specified slab of the
specified datasetname for group hid. The dataset is created
if it does not already exist.
The slabs are indexed from 0 in the slowest dimension
*/
int cbf_add_h5double_vector_dataset_slab(hid_t hid,
const char* datasetname,
const double* datasetvalue,
const size_t dimension,
const hsize_t slab,
int errorcode);
/* Count the number of links in an HDF5 group */
int cbf_count_h5group_links (const hid_t parent,
const char * group,
hsize_t * numlinks);
/* Count the number of attributes of an HDF5 object */
int cbf_count_h5object_attributes (const hid_t parent,
const char * object,
hsize_t * numattribs);
/* Find an hdf5 group link by name pattern */
int cbf_find_h5group_link(const hid_t parent,
const char * group,
const char * name_pattern,
hsize_t search_index,
hsize_t *found_index,
char ** name);
/* Find an hdf5 attribute by name pattern */
int cbf_find_h5attribute(const hid_t parent,
const char * object_name,
const char * name_pattern,
hsize_t search_index,
hsize_t *found_index,
char ** name );
/* Get the rank of a dataset */
int cbf_get_h5dataset_rank(hid_t hid, const char * datasetname, size_t * rank);
/* Get the dimensions of a dataset */
int cbf_get_h5dataset_dims(hid_t hid, const char * datasetname, size_t rank,
size_t * dims,
size_t * maxdims);
/* apply a text dataset to a group */
int cbf_add_h5text_dataset(hid_t hid,
const char* datasetname,
const char* datasettext,
int errorcode);
/* add a long dataset slab to a group
places the specified datasetvalue in the specified slab of the
specified datasetname for group hid. The dataset is created
if it does not already exist.
The slabs are indexed from 0
*/
int cbf_add_h5long_dataset_slab(hid_t hid,
const char* datasetname,
const long datasetvalue,
const hsize_t slab,
int errorcode);
/* add a long dataset to a group */
int cbf_add_h5long_dataset(hid_t hid,
const char* datasetname,
const long datasetvalue,
int errorcode);
/* add an unsigned long dataset slab to a group
places the specified datasetvalue in the specified slab of the
specified datasetname for group hid. The dataset is created
if it does not already exist.
The slabs are indexed from 0
*/
int cbf_add_h5ulong_dataset_slab(hid_t hid,
const char* datasetname,
const unsigned long datasetvalue,
const hsize_t slab,
int errorcode);
/* add an unsigned long dataset to a group */
int cbf_add_h5ulong_dataset(hid_t hid,
const char* datasetname,
const long datasetvalue,
int errorcode);
/* Write a binary value to an HDF5 file */
int cbf_write_h5binary (cbf_handle handle,
cbf_node *column,
unsigned int row,
cbf_h5handle h5handle);
/* Write an ascii value to an HDF5 file */
int cbf_write_h5ascii (cbf_handle handle,
unsigned int row,
const char *string,
cbf_h5handle h5handle);
/* Write a value to an HDF5 file */
int cbf_write_h5value (cbf_handle handle, cbf_node *column, unsigned int row,
cbf_h5handle h5handle);
/* Write a category to an HDF5 file */
int cbf_write_h5category (cbf_handle handle,
const cbf_node *category,
cbf_h5handle h5handle);
/* create top-level NXentry */
int cbf_create_NXentry(cbf_h5handle h5handle);
/* Create an HDF5 Group below NX entry or below curnxid */
int cbf_H5Gcreate_in_handle(cbf_h5handle h5handle,
const char * groupname,
hid_t * newgroup);
/* Create an HDF5 NeXus Group below NX entry or below curnxid */
int cbf_H5NXGcreate(cbf_h5handle h5handle,
const char * groupname,
const char * nxclass,
hid_t * newgroup);
/* Require a group below NXentry or below curnxid
groupname -- the final path to be used
group_id -- optional pointer to the newly opened group
if NULL, no return and the group will be
closed
oldgroupname -- an optional existing path name or NULL
to be renamed to new_name if old_name exists
and if groupname does not yet exist
returns 0 for success
*/
int cbf_H5Grequire_in_handle(const cbf_h5handle h5handle,
const char * groupname,
hid_t * group_id,
const char * oldgroupname);
/* Require NeXus group below NXentry or below curnxid
groupname -- the final path to be used
group_id -- optional pointer to the newly opened group
if NULL, no return and the group will be
closed
oldgroupname -- an optional existing path name or NULL
to be renamed to new_name if old_name exists
and if groupname does not yet exist
returns 0 for success
*/
int cbf_H5NXGrequire_in_handle(const cbf_h5handle h5handle,
const char * groupname,
const char * nxclass,
hid_t * group_id,
const char * oldgroupname);
/* Free an H5File handle */
/**
\brief Free a handle for an HDF5 file.
\ingroup section_H5Handle
*/
int cbf_free_h5handle(cbf_h5handle h5handle);
/* Make an (empty) H5File handle */
int cbf_make_h5handle(cbf_h5handle *h5handle);
/* Close the current saveframe in an HDF5 file */
int cbf_close_h5saveframe (cbf_h5handle h5handle);
/* Write a saveframe name to an HDF5 file
Make a new group of NeXus class NXcifsf in the NXcif current datablock
*/
int cbf_write_h5saveframename (const cbf_node *saveframename,
cbf_h5handle h5handle);
/* Write a datablock name to an HDF5 file
Make a new group of NeXus class NXcifdb in the NXcif class root
*/
int cbf_write_h5datablockname (const cbf_node *datablock, cbf_h5handle h5handle);
/* Write a node to an HDF5 file */
int cbf_write_h5node (cbf_handle handle, const cbf_node *node,
const cbf_h5handle h5handle);
/* Create an H5File handle */
int cbf_create_h5handle(cbf_h5handle *h5handle, const char * h5filename);
/* Create an H5File handle for NXpdb */
int cbf_create_h5handle_nxpdb(cbf_h5handle *h5handle, const char * h5filename);
/* Require the filename in the H5 file handle */
int cbf_require_h5handle_filename(cbf_h5handle h5handle);
/* Create an HDF5 File handle without adding an NXcbf group to it */
int cbf_create_h5handle2(cbf_h5handle *h5handle,const char * h5filename);
/* Create an HDF5 File handle without adding a CBF_cbf group to it
in update mode*/
int cbf_create_h5handle2u(cbf_h5handle *h5handle,const char * h5filename);
/**
\brief Allocates space for a HDF5 file handle and associates it with the given file.
\ingroup section_H5Handle
*/
int cbf_create_h5handle3(cbf_h5handle * handle, hid_t file);
/* Write cbf to HDF5 file hfile */
int cbf_write_h5file (cbf_handle handle, cbf_h5handle h5handle, unsigned long int flags);
/**
\brief Extract the data from a CBF file & put it into a NeXus file.
\ingroup section_H5Handle
*/
int cbf_write_cbf_h5file
(cbf_handle handle,
cbf_h5handle h5handle);
/**
\brief Extract the data from a CBF file & put it into a NeXus file.
\ingroup section_H5Handle
*/
int cbf_write_cbf2nx
(cbf_handle handle,
cbf_h5handle h5handle,
const char * const datablock,
const char * const scan,
const int list);
/**
\brief Extract the data from a CBF file & put it into a NeXus metadata file data file.
\ingroup section_H5Handle
*/
int cbf_write_cbf2nx2
(cbf_handle handle,
cbf_h5handle h5handle,
cbf_h5handle h5datahandle,
const char * const datablock,
const char * const scan,
const int list);
/**
\brief Extract the data from a miniCBF file & put it into a NeXus file.
\ingroup section_H5Handle
*/
int cbf_write_minicbf_h5file (cbf_handle handle, cbf_h5handle h5handle, const cbf_config_t * const axisConfig);
/**
\brief Extract data from a nexus file and store it in a CBF file
\ingroup section_H5Handle
*/
int cbf_write_nx2cbf
(cbf_h5handle nx,
cbf_handle cbf);
/* Open an HDF5 File handle */
int cbf_open_h5handle(cbf_h5handle *h5handle,
const char * h5filename);
/* Convert an HDF5 typeclass to a string
and flag for atomic or not
copies up to n-1 characters of the
type string to buffer*/
int cbf_h5type_class_string(H5T_class_t type_class,
char * buffer,
int * atomic, size_t n );
/* Store an HDF5 Dataset in CBF handle as a column, using
category categoryname, ...
If target_row is -1, the new column is appended to any
existing column
If target row is >= 0, overwrites any existing rows starting
at target_row
*/
int cbf_h5ds_store_as_column(cbf_handle handle,
int target_row,
const char * columnname,
const char * categoryname,
hid_t obj_id,
hid_t space,
hid_t type,
void ** value);
/* Store an HDF5 Dataset in CBF handle, using
category categoryname, ...*/
int cbf_h5ds_store(cbf_handle handle, haddr_t parent,
const char * parent_name,
const int target_row,
const char * categoryname, hid_t obj_id,
hid_t space, hid_t type,
const char * name,
const int readattrib,
void ** value);
/* Callback routine for objects in a group */
herr_t cbf_object_visit(hid_t loc_id, const char *name,
const H5L_info_t *info,
void *op_data);
/* Read an HDF5 file */
int cbf_read_h5file(const cbf_handle handle,
const cbf_h5handle h5handle,
const unsigned long int flags);
/* get a fast bookmark from the current information in a cbf handle */
int cbf_get_fast_bookmark(const cbf_handle handle, cbf_fast_bookmark * bookmark);
/* go to a fast bookmark in a cbf handle */
int cbf_goto_fast_bookmark(const cbf_handle handle, const cbf_fast_bookmark bookmark);
/* go to a bookmark in the cbf handle */
int cbf_goto_bookmark(const cbf_handle handle, const cbf_bookmark bookmark);
/* get a bookmark from the current information in a cbf handle */
int cbf_get_bookmark(const cbf_handle handle, cbf_bookmark * bookmark);
int cbf_map_h5value(
const char * const name, const char * const value,
const char * const group, const char * const groupNXclass,
const char * const subGroup, const char * const subGroupNXclass,
const size_t attrc, const cbf_name_value_pair * const attrv,
cbf_h5handle h5handle);
int cbf_cimatch(const char * name, const char * pattern);
#ifdef __cplusplus
}
#endif
#endif /* CBF_HDF5_H */
|