My situation is as follows. I have a whole bunch of data that I need to fit, which tends to look like this picture:
As can be seen, there's three dips (resonances) and a whole bunch of noise around amplitude 1. Now, in order to fit this, it will be much easier if I only fit the resonances themselves; this means a whole lot less points will have to be evaluated. So what I'm trying to do is cut away the parts that I don't care about.
The first thing to do of course is find the resonances. I think this should be doable with FindPeaks (although it does seem as if this literally only works for peaks, so I suppose I'd have to use 1 - the data points). The problem is here that I'm not sure how to go from there. What I do is the following:
I use FindPeaks for 1-Abs[s2]] (Abs[s2]] is the data), with gaussian blurring 0, minimum sharpness 0, and minimum peak height equal to X times the standard deviation of the dataset. (Or, well it's better to just take a piece from the beginning of the data and calculate the standard deviation here, but that's a detail). In the example here, if I use, say, X = 10, then it does find all three resonances.
However, it doesn't just find a single point, it finds a whole bunch of them around each actual resonance (they are all peaks to the function). So here's my first question; how do I adjust this to just pick out the actual lowest point for each of these resonances, instead of a whole bunch of points around each resonance? The function returns a list of x and y coordinates, so maybe I should somehow find some local minima's here again, but I don't see how really.
The next part of my question brings us closer to the title of the post, and that is cutting away the other data. So say that I've now found my three resonances; what I want to do is cut away all data around each one of them, leaving only N points to the left and right. What this N is I already know, but this depends on the specifics of the experiment from which I took the data, so that's not too important. Perhaps one could use the Table command? Say the first resonance is at x = 7.6, which is the 100th element of the vector. Then I could say that the new list is now Table[{f1[[n]],s2[[n]]},{n,100-N,100+N}]
. This would find it for the first resonance, and then maybe I can append this table with the lists from the other two resonances? But perhaps there is a much smarter way of doing this, in which case I'd be very happy to hear so.