def nanmean(x):
    """ Mean of array with NaN """
    import numpy as N
    sum = N.nansum(x)
    n = N.sum(~N.isnan(x))
    if n > 0:
        mean = sum / n
    else:
        mean = float('NaN')
    return mean
