1
$\begingroup$

I am currently trying to interpret my FTIR data. But due to a lot of background noise, my spectrum is quite spiky and fluctuating at some points. I want to try to smoothen my function to make the peaks in the spectrum more apparent.

My code looks like this:

ListLinePlot[{q2, q1}, ScalingFunctions -> {"Reverse", Identity},
PlotRange -> {{3100, 2700}, Automatic}, 
PlotLegends -> {"UV1", "PURE1"}, ImageSize -> Full, 
GridLines -> {{2870, 2960, 2925, 2850}, {}}, Black, 
Bold, FontSize -> 16], Style["Absorbance", Black, Bold, FontSize -> 16]}, 
TicksStyle -> Directive[FontSize -> 14]]

Giving the following plot:

enter image description here

So I would like to make it more smooth. Any ideas on how to do this? I've tried to find something, but I only came across Interpolating, but that did not really work because my data set is not just a list of numbers.

$\endgroup$
4
  • 2
    $\begingroup$ Interpolation accepts input data in various forms (input does not have to be just a list of numbers). If your q1 and q2 are lists of pairs you can use this form of Interpolation. If you post a small portion of your actual data (for example, q1[[;;10]] and q2[[;;10]]), it will make it easier for people to help you. $\endgroup$
    – kglr
    Commented Jul 4, 2017 at 17:29
  • 2
    $\begingroup$ Perhaps convolving your data with a suitable kernel (Gaussian perhaps) could help. $\endgroup$
    – Tucker
    Commented Jul 4, 2017 at 17:32
  • 1
    $\begingroup$ Note that smoothing can make some peaks less apparent. Do you have a definition for what constitutes a peak over and above the noise? Maybe something as simple as using the functions MovingAverage or MovingMedian or FindPeaks will suit your needs. $\endgroup$
    – JimB
    Commented Jul 4, 2017 at 17:45
  • $\begingroup$ Related: mathematica.stackexchange.com/questions/115444/… $\endgroup$
    – Michael E2
    Commented Jul 4, 2017 at 23:58

1 Answer 1

1
$\begingroup$

I think LowpassFilter should do what you want. (I can't comment yet)

Edit: An example of how you could use it:

data = Table[{x, Sin[x] + RandomReal[{-0.1, 0.1}]}, {x, 0, 2 \[Pi], 0.01}];
data2 = Transpose[{data[[All, 1]], LowpassFilter[data[[All, 2]], 0.2]}];
ListPlot[{data, data2}, Joined -> True]
$\endgroup$
2
  • $\begingroup$ Perhaps you can add some Mathematica code to show how this works on a some "test data"? $\endgroup$
    – Dunlop
    Commented Oct 17, 2017 at 18:25
  • $\begingroup$ sure, but note that there are also good examples in the documentation $\endgroup$
    – M. Stern
    Commented Oct 17, 2017 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.