3
3
This is a C implementation of the XDI specification. While the XDI
4
4
specification is not difficult to implement correctly, we encourage
5
5
people implementing XDI readers in other languages to base their
6
- implementation on ` libxdifile ` . That way, the behaviour of XDI
6
+ implementation on ` libxdifile ` . That way, the behavior of XDI
7
7
readers in different languages is guaranteed to be identical (or at
8
8
least very similar).
9
9
10
10
See ` xdi_reader.c ` for an example of a C program using ` libxdifile ` to
11
11
import and interpret XDI-formatted data.
12
12
13
+ ` libxdifile ` was written by Matt Newville and Bruce Ravel.
14
+
15
+ ## XDIFile struct
16
+
17
+ This is the content of the XDIFile struct. It will contain the entire
18
+ contents of the XDI file along with a few particularly important items
19
+ (d-spaing, element, and edge).
20
+
21
+ | attribute | type | explanation |
22
+ | --------------- | ------------------ | ----------- |
23
+ | nmetadata | long | number of metadata fields |
24
+ | narrays | long | number of arrays in data table |
25
+ | npts | long | number of rows in data table |
26
+ | narray\_ labels | long | number of array labels |
27
+ | error\_ lineno | long | the line number of a line returning an error |
28
+ | dspacing | double | the Mono.d-spacing value |
29
+ | xdi\_ libversion | char* | the ` libxdifile ` version number |
30
+ | xdi\_ version | char* | the XDI file specification version number from the file |
31
+ | extra\_ version | char* | versioning information for extension fields |
32
+ | filename | char* | the name of the XDI file |
33
+ | element | char* | the 1, 2, or 3 letter symbol of the element |
34
+ | edge | char* | the 1 or 2 letter symbol of the edge |
35
+ | comments | char* | the user supplied comments from the XDI file |
36
+ | error\_ line | char* | the line returning an error |
37
+ | error\_ message | char* | the error message |
38
+ | array\_ labels | array of char* | array of labels for arrays in the data table |
39
+ | array\_ units | array of char* | array of units for arrays in the data table |
40
+ | meta\_ families | array of char* | array of family names found among the metadata, indexed to nmetadata |
41
+ | meta\_ keywords | array of char* | array of keyword names found among the metadata, indexed to nmetadata |
42
+ | meta\_ values | array of char* | array of values found among the metadata, indexed to nmetadata |
43
+ | array | of array of double | the data table |
44
+ | nouter | long | |
45
+ | outer\_ label | array char* | |
46
+ | outer\_ array | array of double | |
47
+ | outer\_ breakpts | array of long | |
48
+
49
+
13
50
## API
14
51
15
52
### Read an XDI file
@@ -65,7 +102,7 @@ If `XDI_required_metadata` returns a non-zero value, the file is
65
102
}
66
103
```
67
104
68
- Run ` xdi_reader ` agains ` baddata/bad_30.xdi ` for an example of a
105
+ Run ` xdi_reader ` against ` baddata/bad_30.xdi ` for an example of a
69
106
file which is non-compliant because of missing ** required** metadata.
70
107
71
108
### Test for recommended metadata
@@ -83,7 +120,7 @@ highly useful to the interchange of the data contained in the file.
83
120
}
84
121
```
85
122
86
- Run `xdi_reader` agains `baddata/bad_32.xdi` for an example of a
123
+ Run `xdi_reader` against `baddata/bad_32.xdi` for an example of a
87
124
file which is missing **recommended** metadata.
88
125
89
126
@@ -125,6 +162,20 @@ table. The return value is -1 if the array cannot be retrieved.
125
162
126
163
The array names are held in the ` Column.N ` metadata fields.
127
164
165
+ ### Destroy and deallocate the XDIFile struct
166
+
167
+ To deallocate the memory from the XDIFile struct, do this:
168
+
169
+ ``` C
170
+ XDI_cleanup (xdifile, ret);
171
+ ```
172
+
173
+ Here, the second argument is the return code from the call to
174
+ XDI_readfile. That is needed so that the cleanup method knows how
175
+ much stuff needs to be freed.
176
+
177
+
178
+
128
179
## Error codes
129
180
130
181
Here is a list of all error codes and their English explanation. An
@@ -134,20 +185,20 @@ translation of a table of error messages into another language.
134
185
### XDI_readfile error codes
135
186
136
187
| code | message |
137
- | ---- | ------------------------------------------------------------ |
188
+ | ---: | ------------------------------------------------------------ |
138
189
| -1 | not an XDI file, no XDI versioning information in first line |
139
- | -2 | ` <word> ` -- invalid family name in metadata |
140
- | -4 | ` <word> ` -- invalid keyword name in metadata |
141
- | -8 | ` <word> ` -- not formatted as Family.Key: Value |
190
+ | -2 | `<word>` -- invalid family name in metadata |
191
+ | -4 | `<word>` -- invalid keyword name in metadata |
192
+ | -8 | `<word>` -- not formatted as Family.Key: Value |
142
193
| -16 | number of columns changes in data table |
143
- | -32 | non-numeric value in data table: ` <word> ` |
194
+ | -32 | non-numeric value in data table: `<word>` |
144
195
145
196
Here `<word>` will be the the text that triggered the error.
146
197
147
198
### XDI_readfile warning codes
148
199
149
200
| code | message |
150
- | ----- | ------------------------------------------------------------ |
201
+ | ----: | ------------------------------------------------------------ |
151
202
| 1 | no mono.d_spacing given with angle array |
152
203
| 2 | no line of minus signs '#-----' separating header from data |
153
204
| 4 | contains unrecognized header lines |
@@ -158,7 +209,7 @@ Here `<word>` will be the the text that triggered the error.
158
209
| 128 | extension field used without versioning information |
159
210
| 256 | Column.1 is not "energy" or "angle" |
160
211
| 512 | invalid timestamp: format should be ISO 8601 (YYYY-MM-DD HH:MM:SS) |
161
- | 1024 | invalid timestamp: date out of valuid range |
212
+ | 1024 | invalid timestamp: date out of valid range |
162
213
163
214
164
215
### XDI_required_metadata return codes
@@ -168,7 +219,7 @@ bitwise. That is, a return code of 7 means that all three required
168
219
metadata fields were missing.
169
220
170
221
| code | message |
171
- | ---- | ----------------------------------- |
222
+ | ---: | ----------------------------------- |
172
223
| 1 | Element.symbol missing or not valid |
173
224
| 2 | Element.edge missing or not valid |
174
225
| 4 | Mono.d\_spacing missing |
@@ -181,7 +232,7 @@ bitwise. That is, a return code of 7 means that the first three
181
232
recommendation metadata fields were missing.
182
233
183
234
| code | message |
184
- | ---- | --------------------------------------------------- |
235
+ | ---: | --------------------------------------------------- |
185
236
| 1 | Missing recommended metadata field: Facility.name |
186
237
| 2 | Missing recommended metadata field: Facility.source |
187
238
| 4 | Missing recommended metadata field: Beamline.name |
0 commit comments