Keywords: gildas-python

Next: Python 3K Up: Programmer documentation Previous: The SicStructure class Contents Index

## Array elements types

As mentionned earlier (see subsection 2.1.2), `numpy.ndarray` elements can be of different kind, precision, and thus memory size. This is reflected through the `.dtype` attribute of any `numpy.ndarray`. By default, integer elements are created with the '`<i4`' datatype (standard integer), and floats with the '`<f8`' one (double precision float). Nevertheless, not all SIC elements follows these types. Attention have been paid to import SIC data into the correct type (see table 2).

Table 2: OBSOLETE TABLE. SEE NUMPY DOCUMENTATION. SIC to `Numeric` type conversion (for a 32-bit architecture)
SIC type | `Numeric` typecode | # of bytes
`INTEGER*4` | `'i'` | `sizeof(int) = 4`
`REAL*4` | `'f'` | `sizeof(float) = 4`
`REAL*8` | `'d'` | `sizeof(double) = 8`
`LOGICAL*4` | `'i'` | `sizeof(int) = 4`
`CHARACTER` | `'c'` | `sizeof(char) = 1`

Mixing arrays in Python formulas with element size different from the default Python behavior is not problematic. `NumPy` deals with all these types and applies coercion to the adequate type, and all is completely transparent for the user.

Next: Python 3K Up: Programmer documentation Previous: The SicStructure class Contents Index