def find_max(lbda, flux, lrange):
    """Look for lbda of maximum flux within wavelength range lrange."""

    lmin,lmax = lrange
    g = (lmin<=lbda) & (lbda<=lmax)

    if not lbda[g].any():
        raise ValueError("Reasearch range %.2f-%.2f incompatible with "
                         "wavelength domaine %.2f-%.2f" %
                         (lmin,lmax,lbda[0],lbda[-1]))

    return lbda[g][flux[g].argmax()]