def remove_nan(arr, val=0.0, ncore=None):
    """
    Replace NaN values in array with a given value.

    Parameters