def f_read_raw_mat_length(filename, data_format='f4'):
    """len = f_read_raw_mat_length(filename, data_format='f4')
    Read length of data, i.e., number of elements in the data file.
    If data is in shape (N, M), then len = N * M
    
    input
    -----
      filename: str, path to the binary data on the file system
      format:   str, please use the Python protocal to write format
                 default: 'f4', float32
    output
    ------
      len: int, number of data elements in the data file
    """
    f = open(filename,'rb')
    tmp = f.seek(0, 2)
    bytes_num = f.tell()
    f.close()
    if data_format == 'f4':
        return int(bytes_num / 4)
    else:
        return bytes_num