given a mixture of two signals, how to separate it to its base components?
I would suggest you take a look at 'independent component analysis', and 'blind source separation' tasks. In general, given a signal of mixtures of components to be separated to its contents well addressed by optimization in complicated cases. Here you show one example, but probably in each experiment you have something very different. I will also take a look at my files to see if still I have relevant codes to solve it or not.