The environment of power system is complex, and the field to line coupling and coupling between lines are important factors lead to electromagnetic disturbance, so the electromagnetic compatibility problem in the system is serious. Electromagnetic compatibility on-site testing can distinguish disturbance sources and diagnose the failure of equipment. When testing the disturbance of secondary equipment in on-site environment, received signal contains not only the disturbance of secondary equipment, but also ambient noise, which influence the accuracy of testing. In this paper, spectral difference method based on threshold calculation is used. With wavelet theory and correlation analysis, ambient noise is eliminated effectively, and the accuracy of on-site testing is improved. Through the actual test, the validity of the method is verified.