def _data_array_to_dictionary(data_array, include_data=True):
    """ Convert DataArray to a dictionary.

    Args:
        data_array (DataArray): The data to convert.
        include_data (bool): If True then include the ndarray field.

    Returns:
        dict: A dictionary containing the serialized data.
    """
    keys = ['label', 'name', 'unit', 'is_setpoint', 'full_name', 'array_id', 'shape']
    if include_data:
        keys.append('ndarray')

    data_dictionary = {key: getattr(data_array, key) for key in keys}
    data_dictionary['set_arrays'] = tuple(array.array_id for array in data_array.set_arrays)

    return data_dictionary