I'm trying to think of how to construct a filter based on the following scenario. I have some time trace with a certain known power spectral density (I can verify this with a periodogram of the time trace). The time trace then goes into a machine that realizes it, which does so with some level of imperfection. Treating the device as a black box, it is essentially a filter that is applied to the time trace, and produces a slightly adjusted power spectral density. This power spectral density I can then measure with a spectrum analyzer.
So I'm wondering, can I apply a preemptive filter to my time trace, before it goes into the black box, so that I get my desired power spectral density? I suppose I should have all the information I need as I know the power spectral density before and after the black box, which should somehow allow me to construct a type of inverse filter. How exactly I am not sure of however, and that is my main question.
I should also note that I tried a much less clean method. I took the power spectral density after the black box, and simply mirrored it, and used this as a preemptive filter. This actually seems to work quite well in the sense that the resulting PSD has the correct shape (it was sloping downwards before while it should be straight, which this method achieves), but the amplitudes are no longer correct and rescaling the data is problematic. So I figured a more analytic approach would be required.