Import upstream version 2.24.1
Debian Janitor
1 year, 4 months ago
0 | *.o | |
1 | *.lo | |
2 | *.la | |
3 | *.class | |
4 | .deps | |
5 | .dirstamp | |
6 | .libs | |
7 | stamp-* | |
8 | /.indent.pro | |
9 | /Makefile | |
10 | /Makefile.in | |
11 | /aclocal.m4 | |
12 | /ar-lib | |
13 | /autom4te.cache/ | |
14 | /classnoinst.stamp | |
15 | /coda.h | |
16 | /codacheck | |
17 | /codacmp | |
18 | /codadd | |
19 | /codadump | |
20 | /codaeval | |
21 | /codafind | |
22 | /compile | |
23 | /config.guess | |
24 | /config.h | |
25 | /config.h.in | |
26 | /config.log | |
27 | /config.status | |
28 | /config.sub | |
29 | /configure | |
30 | /depcomp | |
31 | /findtypedef | |
32 | /findtypedef.c | |
33 | /fortran/Makefile | |
34 | /idl/coda_idl.dlm | |
35 | /install-sh | |
36 | /java/build.xml | |
37 | /java/coda.jar | |
38 | /java/doc/Doxyfile | |
39 | /libcoda/coda-expr-parser.c | |
40 | /libcoda/coda-expr-parser.h | |
41 | /libcoda/coda-expr-tokenizer.c | |
42 | /libcoda/doc/Doxyfile | |
43 | /libtool | |
44 | /ltmain.sh | |
45 | /m4/depend.am | |
46 | /m4/libtool.m4 | |
47 | /m4/ltoptions.m4 | |
48 | /m4/ltsugar.m4 | |
49 | /m4/ltversion.m4 | |
50 | /m4/lt~obsolete.m4 | |
51 | /missing | |
52 | /py-compile | |
53 | /ylwrap |
0 | 2.24.1 2022-12-07 | |
1 | ~~~~~~~~~~~~~~~~~ | |
2 | ||
3 | * Fixed printing of coda.Record objects in Python interface (missing | |
4 | end-of-line and support for 0-dimensional arrays). | |
5 | ||
6 | 2.24 2022-05-18 | |
7 | ~~~~~~~~~~~~~~~ | |
8 | ||
9 | * Added significant speed improvements for recursive reads in Python interface. | |
10 | ||
0 | 11 | 2.23.1 2022-02-18 |
1 | 12 | ~~~~~~~~~~~~~~~~~ |
2 | 13 | |
3 | 14 | * Improved performance in Python interface for some use cases. |
4 | 15 | |
5 | * Fixed backward compatibility issu with new Python interface (coda.CodaError | |
16 | * Fixed backward compatibility issue with new Python interface (coda.CodaError | |
6 | 17 | has been reintroduced as an alias for the new coda.Error exception class). |
7 | 18 | |
8 | 19 | 2.23 2021-12-17 |
4 | 4 | |
5 | 5 | project(CODA) |
6 | 6 | |
7 | set(VERSION 2.23.1) | |
7 | set(VERSION 2.24.1) | |
8 | 8 | set(CODA_VERSION \"${VERSION}\") |
9 | 9 | set(CPACK_PACKAGE_VERSION ${VERSION}) |
10 | 10 |
34 | 34 | and all documentation and examples. For the IDL and MATLAB interfaces, |
35 | 35 | pre-built versions are included for IDL 8.3 and higher for Windows, and |
36 | 36 | MATLAB R2019b (v9.7) and higher for Windows. For the Python interface, a |
37 | pre-built version for Python 3.7 is included. For the Java interface, a | |
38 | pre-built version for JDK 8 is included. All CODA interfaces have been | |
37 | pre-built version for Python 3.11 is included. For the Java interface, a | |
38 | pre-built version for JDK 11 is included. All CODA interfaces have been | |
39 | 39 | compiled with HDF4 and HDF5 support built in. |
40 | 40 | |
41 | 41 | If you do not have the CODA package you need, you can download it from the |
57 | 57 | - If you plan on using the Python interface you need Python version 2.7 or |
58 | 58 | higher and the Python 'numpy' and 'cffi' packages. |
59 | 59 | |
60 | - If you plan on using the Java interface you need JDK/JRE version 8. | |
60 | - If you plan on using the Java interface you need JDK/JRE version 8 or | |
61 | higher. | |
61 | 62 | |
62 | 63 | - If you use Windows you will need to have the Microsoft Visual C++ |
63 | 64 | Redistributable Packages for Visual Studio 2015 installed. |
0 | 0 | Copyright (C) 2007-2022 S[&]T, The Netherlands |
1 | 1 | |
2 | CODA 2.23.1 Release Notes | |
2 | CODA 2.24.1 Release Notes | |
3 | 3 | |
4 | 4 | |
5 | 5 | CODA is the Common Data Access framework that allows reading of scientific data |
0 | 0 | # autoconf file for CODA |
1 | AC_INIT([CODA],[2.23.1]) | |
1 | AC_INIT([CODA],[2.24.1]) | |
2 | 2 | AC_CONFIG_AUX_DIR([.]) |
3 | 3 | AM_INIT_AUTOMAKE(foreign subdir-objects 1.12 -Wall) |
4 | 4 |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">Class List</div></div> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">ArrayOrderingEnum Class Reference</div></div> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">FormatEnum Class Reference</div></div> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">NativeTypeEnum Class Reference</div></div> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">SpecialTypeEnum Class Reference</div></div> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">TypeClassEnum Class Reference</div></div> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">Class Index</div></div> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_coda.html">Coda</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_coda.html">Coda</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_coda_exception.html">CodaException</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_coda_exception.html">CodaException</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_cursor.html">Cursor</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_cursor.html">Cursor</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_expression.html">Expression</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_expression.html">Expression</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_product.html">Product</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_product.html">Product</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_type.html">Type</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | <div id="nav-path" class="navpath"> |
16 | 16 | <ul> |
17 | 17 | <li class="navelem"><b>nl</b></li><li class="navelem"><b>stcorp</b></li><li class="navelem"><b>coda</b></li><li class="navelem"><a class="el" href="classnl_1_1stcorp_1_1coda_1_1_type.html">Type</a></li> </ul> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="contents"> |
17 | 17 | <div class="textblock">Here is a list of all documented class members with links to the class documentation for each member:</div> |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="contents"> |
17 | 17 |   |
11 | 11 | <a class="qindex" href="annotated.html">Classes</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div><div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">CODA Java Interface </div></div> |
11 | 11 | <a class="qindex" href="modules.html">Modules</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="summary"> |
11 | 11 | <a class="qindex" href="modules.html">Modules</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="summary"> |
11 | 11 | <a class="qindex" href="modules.html">Modules</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="summary"> |
11 | 11 | <a class="qindex" href="modules.html">Modules</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="summary"> |
11 | 11 | <a class="qindex" href="modules.html">Modules</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="summary"> |
11 | 11 | <a class="qindex" href="modules.html">Modules</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="summary"> |
11 | 11 | <a class="qindex" href="modules.html">Modules</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="summary"> |
11 | 11 | <a class="qindex" href="modules.html">Modules</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div><div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">CODA C interface </div></div> |
11 | 11 | <a class="qindex" href="modules.html">Modules</a> |
12 | 12 | </center> |
13 | 13 | <hr> |
14 | <!-- Generated by Doxygen 1.9.2 --> | |
14 | <!-- Generated by Doxygen 1.9.3 --> | |
15 | 15 | </div><!-- top --> |
16 | 16 | <div class="header"> |
17 | 17 | <div class="headertitle"><div class="title">Modules</div></div> |
242 | 242 | |
243 | 243 | <div class="fragment"><pre> |
244 | 244 | import os |
245 | ||
246 | 245 | os.putenv('CODA_DEFINITION', '<your codadef search path>') |
247 | ||
248 | # ... | |
249 | ||
250 | 246 | import coda |
251 | 247 | </pre></div> |
252 | 248 |
97 | 97 | index[i] = (int)((int32_t *)data)[i]; |
98 | 98 | break; |
99 | 99 | default: |
100 | mexErrMsgTxt("index parameter not of type double or int32"); | |
100 | mexErrMsgTxt("Index parameter not of type double or int32"); | |
101 | 101 | break; |
102 | 102 | } |
103 | 103 | } |
138 | 138 | |
139 | 139 | if (type_class != coda_array_class) |
140 | 140 | { |
141 | mexErrMsgTxt("Error in paramater"); | |
141 | mexErrMsgTxt("Using numeric index for type that is not an array"); | |
142 | 142 | } |
143 | 143 | |
144 | 144 | for (i = 0; i < length; i++) |
192 | 192 | { |
193 | 193 | if (coda_errno == CODA_ERROR_ARRAY_NUM_DIMS_MISMATCH) |
194 | 194 | { |
195 | mexPrintf("ERROR: array dimensions mismatch\n"); | |
196 | mexErrMsgTxt("Error in parameter"); | |
195 | mexErrMsgTxt("Error in parameter (array dimensions mismatch)"); | |
197 | 196 | } |
198 | 197 | if (coda_errno == CODA_ERROR_ARRAY_OUT_OF_BOUNDS) |
199 | 198 | { |
200 | mexPrintf("ERROR: array index out of bounds\n"); | |
201 | mexErrMsgTxt("Error in parameter"); | |
199 | mexErrMsgTxt("Error in parameter (array index out of bounds)"); | |
202 | 200 | } |
203 | 201 | coda_matlab_coda_error(); |
204 | 202 | } |
213 | 211 | } |
214 | 212 | else |
215 | 213 | { |
216 | mexErrMsgTxt("Error in paramater"); | |
214 | mexErrMsgTxt("Error in parameter (not a string or integer)"); | |
217 | 215 | } |
218 | 216 | |
219 | 217 | if (name != NULL) |
811 | 811 | |
812 | 812 | elif isinstance(data, numpy.ndarray): |
813 | 813 | dim = data.shape |
814 | if len(dim) == 0: | |
815 | dim = [1] | |
814 | 816 | dimString = "" |
815 | 817 | for d in dim[:-1]: |
816 | 818 | dimString += "%ix" % (d,) |
817 | 819 | dimString += "%i" % (dim[-1],) |
818 | out.write("[%s %s]" % (dimString,self._typeToString[data.dtype.type])) | |
820 | out.write("[%s %s]" % (dimString, self._typeToString[data.dtype.type])) | |
819 | 821 | |
820 | 822 | elif _is_str(data): |
821 | 823 | out.write("\"%s\"" % (data,)) |
824 | 826 | # if type is none of the above, fall back |
825 | 827 | # on the type specific __str__() function. |
826 | 828 | out.write("%s" % (data,)) |
829 | ||
830 | out.write("\n") | |
827 | 831 | |
828 | 832 | return out.getvalue() |
829 | 833 | |
2381 | 2385 | # |
2382 | 2386 | # PATH TRAVERSAL |
2383 | 2387 | # |
2384 | def _traverse_path(cursor, path, start=0): | |
2388 | def _traverse_path(cursor, path, start=0, type_path=None): | |
2385 | 2389 | """ |
2386 | 2390 | _traverse_path() traverses the specified path until |
2387 | 2391 | an array with variable indices is encountered or the |
2390 | 2394 | thrown when a check fails. |
2391 | 2395 | """ |
2392 | 2396 | |
2397 | reldepth = 0 | |
2398 | ||
2393 | 2399 | for pathIndex in range(start, len(path)): |
2400 | if type_path is not None: | |
2401 | index = type_path[pathIndex] | |
2402 | if index is not None: | |
2403 | if _goto_index(cursor._x, index) != 0: # optimized to avoid lookup, boilerplate call | |
2404 | raise CodacError('coda_cursor_goto_record_field_by_index') | |
2405 | reldepth += 1 | |
2406 | continue | |
2407 | ||
2394 | 2408 | if isinstance(path[pathIndex], str): |
2395 | 2409 | cursor_goto(cursor, path[pathIndex]) |
2410 | reldepth += 1 | |
2396 | 2411 | else: |
2397 | 2412 | if isinstance(path[pathIndex], int): |
2398 | 2413 | arrayIndex = [path[pathIndex]] |
2428 | 2443 | raise ValueError("array index (%i) exceeds array range [0:%i)" % (arrayIndex[i], arrayShape[i])) |
2429 | 2444 | |
2430 | 2445 | if intermediateArray: |
2431 | return (True, pathIndex) | |
2446 | return (True, pathIndex, reldepth) | |
2432 | 2447 | else: |
2433 | 2448 | # if all indices are non-variable, just move the cursor |
2434 | 2449 | # to the indicated element. |
2436 | 2451 | cursor_goto_array_element(cursor, []) |
2437 | 2452 | else: |
2438 | 2453 | cursor_goto_array_element(cursor, arrayIndex) |
2454 | reldepth += 1 | |
2439 | 2455 | |
2440 | 2456 | # we've arrived at the end of the path. |
2441 | return (False, len(path) - 1) | |
2457 | return (False, len(path) - 1, reldepth) | |
2442 | 2458 | |
2443 | 2459 | |
2444 | 2460 | # |
2445 | 2461 | # HELPER FUNCTIONS FOR CODA.FETCH() |
2446 | 2462 | # |
2447 | def _fetch_intermediate_array(cursor, path, pathIndex=0): # TODO use type tree! | |
2463 | def _fetch_intermediate_array(cursor, path, pathIndex=0, type_path=None): | |
2448 | 2464 | """ |
2449 | 2465 | _fetch_intermediate_array calls _traverse_path() to traverse the path |
2450 | 2466 | until the end is reached or an intermediate array is encountered. |
2454 | 2470 | recursively fetches each element of the array. note that this will result |
2455 | 2471 | in calls to _fetch_data(). |
2456 | 2472 | """ |
2457 | ||
2458 | 2473 | arrayShape = cursor_get_array_dim(cursor) |
2459 | 2474 | |
2460 | 2475 | # handle a rank-0 array by converting it to |
2519 | 2534 | for i in range(0, elementCount): |
2520 | 2535 | # move the cursor to the next required array element. |
2521 | 2536 | while currentElementIndex < nextElementIndex: |
2522 | cursor_goto_next_array_element(cursor) | |
2537 | if _goto_next_elem(cursor._x) != 0: # optimized to avoid lookup, boilerplate call | |
2538 | raise CodacError('coda_cursor_goto_next_array_element') | |
2523 | 2539 | currentElementIndex += 1 |
2524 | 2540 | |
2525 | depth = cursor_get_depth(cursor) | |
2526 | ||
2527 | 2541 | # traverse the path. |
2528 | (intermediateNode, copiedPathIndex) = _traverse_path(cursor, path, pathIndex + 1) | |
2542 | (intermediateNode, copiedPathIndex, reldepth) = _traverse_path(cursor, path, pathIndex + 1, type_path) | |
2529 | 2543 | |
2530 | 2544 | # create the result array by examining the type of the first element. |
2531 | 2545 | # This is equivalent to i == 0 |
2567 | 2581 | array = numpy.empty(dtype=numpyType, shape=tmpShape) |
2568 | 2582 | else: |
2569 | 2583 | array = numpy.empty(dtype=object, shape=tmpShape) |
2584 | flat = array.flat # optimization | |
2585 | ||
2570 | 2586 | |
2571 | 2587 | # when this point is reached, a result array has been allocated |
2572 | 2588 | # and the flatArrayIter is set. |
2574 | 2590 | # result stored. |
2575 | 2591 | if intermediateNode: |
2576 | 2592 | # an intermediate array was encountered. |
2577 | array.flat[i] = _fetch_intermediate_array(cursor, path, copiedPathIndex) | |
2593 | flat[i] = _fetch_intermediate_array(cursor, path, copiedPathIndex, type_path) | |
2578 | 2594 | else: |
2579 | 2595 | # the end of the path was reached. from this point on, |
2580 | 2596 | # the entire subtree is fetched. |
2581 | 2597 | |
2582 | 2598 | if nodeReader is not None: |
2583 | array.flat[i] = nodeReader(cursor) # TODO optimize scalar leafs.. better yet, use type tree | |
2599 | flat[i] = nodeReader(cursor) | |
2584 | 2600 | else: |
2585 | array.flat[i] = _fetch_subtree(cursor) | |
2601 | flat[i] = _fetch_subtree(cursor) # TODO add type tree for leafs to type path | |
2586 | 2602 | |
2587 | 2603 | # update fetchIndex and nextElementIndex. |
2588 | 2604 | for j in range(0, len(fetchShape)): |
2595 | 2611 | fetchIndex[j] = 0 |
2596 | 2612 | nextElementIndex -= fetchStep[j + 1] |
2597 | 2613 | |
2598 | for j in range(cursor_get_depth(cursor) - depth): | |
2599 | cursor_goto_parent(cursor) | |
2614 | for j in range(reldepth): | |
2615 | if _goto_parent(cursor._x) != 0: # optimized to avoid lookup, boilerplate call | |
2616 | raise CodacError('coda_cursor_goto_parent') | |
2600 | 2617 | |
2601 | 2618 | cursor_goto_parent(cursor) |
2602 | 2619 | return array |
2725 | 2742 | |
2726 | 2743 | elif class_ == CLASS_SPECIAL: |
2727 | 2744 | return type_tree[1](cursor) |
2745 | ||
2746 | ||
2747 | # TODO we currently only cache field indices here, which helps a lot. | |
2748 | # TODO for small arrays, it would probably help to cache more information. | |
2749 | # TODO we probably also want to pre-determine the type tree for leafs. | |
2750 | ||
2751 | def _determine_type_path(nodeType, path): | |
2752 | type_path = [] | |
2753 | for segment in path: | |
2754 | if isinstance(segment, str): | |
2755 | i = type_get_record_field_index_from_name(nodeType, segment) | |
2756 | type_path.append(i) | |
2757 | nodeType = type_get_record_field_type(nodeType, i) | |
2758 | else: | |
2759 | type_path.append(None) | |
2760 | nodeType = type_get_array_base_type(nodeType) | |
2761 | return type_path | |
2728 | 2762 | |
2729 | 2763 | |
2730 | 2764 | def _determine_type_tree(nodeType): |
2829 | 2863 | |
2830 | 2864 | cursor = _get_cursor(start) |
2831 | 2865 | |
2832 | (intermediateNode, pathIndex) = _traverse_path(cursor, path) | |
2866 | (intermediateNode, _, _) = _traverse_path(cursor, path) | |
2833 | 2867 | if intermediateNode: |
2834 | 2868 | # we encountered an array with variable (-1) indices. |
2835 | 2869 | # this is only allowed when calling coda.fetch(). |
2860 | 2894 | |
2861 | 2895 | cursor = _get_cursor(start) |
2862 | 2896 | |
2863 | (intermediateNode, pathIndex) = _traverse_path(cursor, path) | |
2897 | (intermediateNode, _, _) = _traverse_path(cursor, path) | |
2864 | 2898 | if intermediateNode: |
2865 | 2899 | # we encountered an array with variable (-1) indices. |
2866 | 2900 | # this is only allowed when calling coda.fetch(). |
2907 | 2941 | if _is_str(start): |
2908 | 2942 | product = start = Product(start) |
2909 | 2943 | cursor = _get_cursor(start) |
2944 | nodeType = cursor_get_type(cursor) | |
2910 | 2945 | |
2911 | 2946 | # traverse the path |
2912 | (intermediateNode, pathIndex) = _traverse_path(cursor, path) | |
2947 | (intermediateNode, pathIndex, _) = _traverse_path(cursor, path) | |
2913 | 2948 | |
2914 | 2949 | try: |
2915 | 2950 | if (intermediateNode): |
2916 | result = _fetch_intermediate_array(cursor, path, pathIndex) | |
2951 | type_path = _determine_type_path(nodeType, path) | |
2952 | result = _fetch_intermediate_array(cursor, path, pathIndex, type_path) | |
2917 | 2953 | else: |
2918 | 2954 | result = _fetch_subtree(cursor) |
2919 | 2955 | finally: |
2948 | 2984 | cursor = _get_cursor(start) |
2949 | 2985 | |
2950 | 2986 | # traverse up until the last node of the path. |
2951 | (intermediateNode, pathIndex) = _traverse_path(cursor, path[:-1]) | |
2987 | (intermediateNode, _, _) = _traverse_path(cursor, path[:-1]) | |
2952 | 2988 | if intermediateNode: |
2953 | 2989 | # we encountered an array with variable (-1) indices. |
2954 | 2990 | # this is only allowed when calling coda.fetch(). |
2983 | 3019 | |
2984 | 3020 | cursor = _get_cursor(start) |
2985 | 3021 | |
2986 | (intermediateNode, pathIndex) = _traverse_path(cursor, path) | |
3022 | (intermediateNode, _, _) = _traverse_path(cursor, path) | |
2987 | 3023 | if intermediateNode: |
2988 | 3024 | # we encountered an array with variable (-1) indices. |
2989 | 3025 | # this is only allowed when calling coda.fetch(). |
3022 | 3058 | |
3023 | 3059 | cursor = _get_cursor(start) |
3024 | 3060 | |
3025 | (intermediateNode, pathIndex) = _traverse_path(cursor, path) | |
3061 | (intermediateNode, _, _) = _traverse_path(cursor, path) | |
3026 | 3062 | if intermediateNode: |
3027 | 3063 | # we encountered an array with variable (-1) indices. |
3028 | 3064 | # this is only allowed when calling coda.fetch(). |
3064 | 3100 | |
3065 | 3101 | cursor = _get_cursor(start) |
3066 | 3102 | |
3067 | (intermediateNode, pathIndex) = _traverse_path(cursor, path) | |
3103 | (intermediateNode, _, _) = _traverse_path(cursor, path) | |
3068 | 3104 | if intermediateNode: |
3069 | 3105 | # we encountered an array with variable (-1) indices. |
3070 | 3106 | # this is only allowed when calling coda.fetch(). |
3145 | 3181 | |
3146 | 3182 | cursor = _get_cursor(start) |
3147 | 3183 | |
3148 | (intermediateNode, pathIndex) = _traverse_path(cursor, path) | |
3184 | (intermediateNode, _, _) = _traverse_path(cursor, path) | |
3149 | 3185 | if intermediateNode: |
3150 | 3186 | # we encountered an array with variable (-1) indices. |
3151 | 3187 | # this is only allowed when calling coda.fetch(). |
3173 | 3209 | |
3174 | 3210 | def _init(): |
3175 | 3211 | """Initialize the CODA Python interface.""" |
3176 | global _lib, _encoding | |
3212 | global _lib, _encoding, _goto_index, _goto_parent, _goto_next_elem | |
3177 | 3213 | # Initialize the CODA C library |
3178 | 3214 | clib = _get_c_library_filename() |
3179 | 3215 | _lib = _ffi.dlopen(clib) |
3216 | _goto_index = _lib.coda_cursor_goto_record_field_by_index | |
3217 | _goto_parent = _lib.coda_cursor_goto_parent | |
3218 | _goto_next_elem = _lib.coda_cursor_goto_next_array_element | |
3180 | 3219 | |
3181 | 3220 | # Import constants |
3182 | 3221 | for attrname in dir(_lib): |