memmap.getfield(dtype,offset=0)¶Returns a field of the given array as a certain type.
A field is a view of the array data with a given data-type. The values inthe view are determined by the given type and the offset into the currentarray in bytes. The offset needs to be such that the view dtype fits in thearray dtype; for example an array of dtype complex128 has 16-byte elements.If taking a view with a 32-bit integer (4 bytes), the offset needs to bebetween 0 and 12 bytes.
| Parameters: |
|
|---|
Examples
>>>x=np.diag([1.+1.j]*2)>>>x[1,1]=2+4.j>>>xarray([[ 1.+1.j, 0.+0.j], [ 0.+0.j, 2.+4.j]])>>>x.getfield(np.float64)array([[ 1., 0.], [ 0., 2.]])
By choosing an offset of 8 bytes we can select the complex part of thearray for our view:
>>>x.getfield(np.float64,offset=8)array([[ 1., 0.], [ 0., 4.]])