A new approach to determine surface-wave attenuation from seismic ambient noise: numerical validation and application