# Map an Arbitrary Function over a Time Series

TimeSeriesMap and TimeSeriesMapThread can be used to transform values of time series.

Time series of wind speeds in Champaign, IL in May 2014.

 In[1]:= Xwd = WeatherData[{"Champaign", "Illinois"}, "WindSpeed", {2014, 5}]
 Out[1]=

Use TimeSeriesMap to build the time series for the power output of a GE 1.5 MW wind turbine.

 In[3]:= Xpts = TimeSeriesMap[power, wd];

Visualize the daily moving average of the energy output.

 In[4]:= Xma = MovingMap[Mean, TimeSeries[pts, MissingDataMethod -> "PathMean"], {1, "Day"}]
 Out[4]=
 Out[5]=

 In[6]:= Xts = TemporalData[TimeSeries, {CompressedData[" 1:eJwNlH081Accxy/KXhM6yZqHSqWcah6GWMo3iR4u5bklRbo8XImarJZUpvbg Ul3EiMg0lJlu3E7LN5SFm9zR8uy4O/dzz+dp5Nj88f7v88fn9X69Pp+1kfEB p3RIJNKiBZoWSK0M+viJxTt4tXZoYKc9DywKRi7JN/GhZt0kd+PAMNhuWQu+ mwcg8MgD4sQSAbw6f9DAmzwCe05nFQYckICo2DhV4jIAwYnWWYWKIWDPm1aF e8khtHLGlQiUwPcvtdnT0TJYWV4uZvwgBa3VEdP1bUIwmSHNMM0V4PDjZ6Lm PgJutUs4w0kKWJnDmNsepgZ5qq/bXvUo7FuUsWl6uQY2qBY/NbihBquDPQLG SgVkNJSkpzsoYa7T5KL+rBxubaDV2IYroc6n0Nu2Ug21/Mvnw2tUUPdJjyUv RQFwnUt/w1ODZZrZOSJDCYO1mal6mSPw8HntPV9XAv52vesb66kA7+DmwHon GSQwLl7bnSGEvpqSwIStBMy8t8w9QhPCgf4VuvRkIWRFP6V+umcI4khBoW6z AvD2m6qVJglgnZWxk5FFPwQvsxv3It5DsDa58MO9Lij99V1a2pcN4ED7OipZ 2wTUC/6sYzptoFMsXZpuxYL/zI05XzkglMamVxhdiAfr8XsmeY6l2BPlO1+W 34GUqhfRc16v0aeSYrQjh4u08aiZLUNtmOh2+5hjER/PpUboth8aRKOQ433i EQGaJ7Dv7nA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gUck5e0gfk/N4DZcHcI1p3Qdz2UOoJfir3+XuAzjJLNoYPgCgTU2V368 Ua7ExWGNJu2rJfiy3y+cMSPCxXbNmHKVwBdjVZGKM1JsPBZvOUWT4aENxaKA FhmS+Z6NE44avJbkHOdBUuCEG628/6QUbXeqLQtM5UjtmnicIlMhxSDtdnb1 OA63hjlHJMiwOoo/4KmvxlCH1qX5dkoc8hLve1amwjcVLsbSLCn21RbQzq6T Y49uxGiexShWvtXrGo2XYWJy6J0rbAI/dLC/JU/L8BdKzCOutQLd2RMyxl0x UlyfVeQu9PofPeFayA== "], {{0., 9.850000000000001, 0.05000000000000001}}, 1, {"Continuous", 1}, {"Discrete", 1}, 1, { ValueDimensions -> 1, ResamplingMethod -> {"Interpolation", InterpolationOrder -> 1}}}, False, 10.];
 In[7]:= Xmodel = NonlinearModelFit[ts, a Sin[b t + \[Phi]], {a, b, \[Phi]}, t]
 Out[7]=

Find the model residuals.

 In[8]:= Xresiduals = TimeSeriesMapThread[Function[{t, v}, v - model[t]], ts]
 Out[8]=
 In[9]:= XListPlot[residuals, Filling -> Axis, ImageSize -> 300]
 Out[9]=

## Mathematica

Questions? Comments? Contact a Wolfram expert »