vax Module
PDS Ring-Moon Systems Node, SETI Institute
Functions to convert between VAX single- and double-precision floats and IEEE floats. Conversions to/from VAX single precision are supported. However, only conversion from VAX doubles to IEEE doubles is supported, not the reverse.
This module continues to support Python 2 in addition to Python 3.
Conversions to/from VAX single precision is supported. However, only conversions from VAX doubles to IEEE doubles are supported, not the reverse.
- vax.from_vax32(data)[source]
Return equivalent single-precision IEEE value for VAX representation.
Given a byte string, array, or array-like (something that can be converted to a numpy array), interpet it as VAX float32 or complex64 values and return the equivalent single-precision IEEE value(s).
- Parameters:
data (bytes or bytearray or memoryview or str or numpy array-like) –
The input data.
If the input is an array, the shape of that array is preserved except for the last axis, which may be modified to account for the new itemsize.
- Returns:
The interpreted IEEE value. If the input array is complex, the returned array will have dtype “<c8”; otherwise, it will have dtype “<f4”.
- Return type:
np.array or np.float32 or np.complex64
- vax.to_vax32_bytes(array)[source]
Return equivalent VAX representation for value(s) as bytes.
Convert this number, array, or array-like into a byte string containing the binary representation of the equivalent VAX float32 or complex64 value(s).
- Parameters:
array (numpy array-like) – The input data.
- Returns:
The VAX representation for the value(s).
- Return type:
bytes
- vax.to_vax32(array)[source]
Return equivalent VAX representation for value(s) as numpy array.
Convert this number, array, or array-like into an array of VAX float32 or complex64 values with the same shape.
- Parameters:
array (numpy array-like) – The input data
- Returns:
The VAX representation of the value(s) stored in a numpy array.
If the input is a scalar, the returned object is an array of shape ().
If the input is complex, the returned array will be of dtype “<c8”; otherwise, it will be of dtype “<f4”.
Note that this object will not be usable for arithmetic operations in its returned form.
- Return type:
np.array
- vax.from_vax64(data)[source]
Return equivalent double-precision IEEE value for VAX representation.
Given a byte string, array, or array-like (something that can be converted to a numpy array), interpet it as VAX float64 or complex128 values and return the equivalent double-precision IEEE value(s).
- Parameters:
data (bytes or bytearray or memoryview or str or numpy array-like) –
The input data.
If the input is an array, the shape of that array is preserved except for the last axis, which may be modified to account for the new itemsize.
- Returns:
The interpreted IEEE value. If the input array is complex, the returned array will have dtype “<c16”; otherwise, it will have dtype “<f8”.
- Return type:
np.array or np.float64 or np.complex128