(datatype)
return output_info
Parses a datatype string conforming to the SigMF spec and returns a dict
    of values describing the format.

    Keyword arguments:
    datatype -- a SigMF-compliant datatype string
Parses a datatype string conforming to the SigMF spec and returns a dict
    of values describing the format.
Parses a datatype string conforming to the SigMF spec and returns a dict of values describing the format .
def dtype_info(datatype):
    """
    Parses a datatype string conforming to the SigMF spec and returns a dict
    of values describing the format.

    Keyword arguments:
    datatype -- a SigMF-compliant datatype string
    """
    if datatype is None:
        raise SigMFFileError("Invalid datatype 'None'.")
    output_info = {}
    dtype = datatype.lower()

    is_unsigned_data = "u" in datatype
    is_complex_data = "c" in datatype
    is_fixedpoint_data = "f" not in datatype

    dtype = datatype.lower().split("_")

    byte_order = ""
    if len(dtype) == 2:
        if dtype[1][0] == "l":
            byte_order = "<"
        elif dtype[1][0] == "b":
            byte_order = ">"
        else:
            raise SigMFFileError("Unrecognized endianness specifier: '{}'".format(dtype[1]))
    dtype = dtype[0]
    if "32" in dtype:
        sample_size = 4
    elif "16" in dtype:
        sample_size = 2
    elif "8" in dtype:
        sample_size = 1
    else:
        raise SigMFFileError("Unrecognized datatype: '{}'".format(dtype))
    component_size = sample_size
    if is_complex_data:
        sample_size *= 2
    sample_size = int(sample_size)

    data_type_str = byte_order
    data_type_str += "f" if not is_fixedpoint_data else "u" if is_unsigned_data else "i"
    data_type_str += str(component_size)

    if is_complex_data:
        data_type_str = ','.join((data_type_str, data_type_str))

    data_type_in = np.dtype(data_type_str)
    output_info['sample_dtype'] = data_type_in
    output_info['component_dtype'] = data_type_in['f0'] if is_complex_data else data_type_in
    output_info['sample_size'] = sample_size
    output_info['component_size'] = component_size
    output_info['is_complex'] = is_complex_data
    output_info['is_unsigned'] = is_unsigned_data
    output_info['is_fixedpoint'] = is_fixedpoint_data
    return output_info
def dtype_info ( datatype ) : if datatype is None : raise SigMFFileError ( "Invalid datatype 'None'." ) output_info = { } dtype = datatype . lower ( ) is_unsigned_data = "u" in datatype is_complex_data = "c" in datatype is_fixedpoint_data = "f" not in datatype dtype = datatype . lower ( ) . split ( "_" ) byte_order = "" if len ( dtype ) == 2 : if dtype [ 1 ] [ 0 ] == "l" : byte_order = "<" elif dtype [ 1 ] [ 0 ] == "b" : byte_order = ">" else : raise SigMFFileError ( "Unrecognized endianness specifier: '{}'" . format ( dtype [ 1 ] ) ) dtype = dtype [ 0 ] if "32" in dtype : sample_size = 4 elif "16" in dtype : sample_size = 2 elif "8" in dtype : sample_size = 1 else : raise SigMFFileError ( "Unrecognized datatype: '{}'" . format ( dtype ) ) component_size = sample_size if is_complex_data : sample_size *= 2 sample_size = int ( sample_size ) data_type_str = byte_order data_type_str += "f" if not is_fixedpoint_data else "u" if is_unsigned_data else "i" data_type_str += str ( component_size ) if is_complex_data : data_type_str = ',' . join ( ( data_type_str , data_type_str ) ) data_type_in = np . dtype ( data_type_str ) output_info [ 'sample_dtype' ] = data_type_in output_info [ 'component_dtype' ] = data_type_in [ 'f0' ] if is_complex_data else data_type_in output_info [ 'sample_size' ] = sample_size output_info [ 'component_size' ] = component_size output_info [ 'is_complex' ] = is_complex_data output_info [ 'is_unsigned' ] = is_unsigned_data output_info [ 'is_fixedpoint' ] = is_fixedpoint_data return output_info