Wolfram Language

Time Series Processing

Filter Time Series with Dates

Get the temperature for given dates using WeatherData. Create a new time series with specified MissingDataMethod to fill in missing data.

In[1]:=
Click for copyable input
data = TimeSeries[ WeatherData["Chicago", "Temperature", {{2015, 1, 1}, {2015, 12, 31}}], MissingDataMethod -> "Interpolation"]
Out[1]=
In[2]:=
Click for copyable input
DateListPlot[data, FrameLabel -> Automatic]
Out[2]=

Use MinFilter with one-month range to analyze when the last and first freeze occurred that year.

In[3]:=
Click for copyable input
minF = MinFilter[data, Quantity[1, "Month"]];
show complete Wolfram Language input
In[4]:=
Click for copyable input
freezeline = {{minF["FirstDate"], 0}, {minF["LastDate"], 0}};
In[5]:=
Click for copyable input
DateListPlot[{data, minF, freezeline}, FrameLabel -> Automatic]
Out[5]=

First day after last spring freeze.

In[6]:=
Click for copyable input
spring = TimeSeriesWindow[minF, {"15 April 2015", "15 May 2015"}];
In[7]:=
Click for copyable input
DateObject[ First@FirstCase[ spring["Path"], _?(#[[2]] > Quantity[0, "DegreesCelsius"] &)]]
Out[7]=

First fall freeze.

In[8]:=
Click for copyable input
fall = TimeSeriesWindow[minF, {"1 Oct 2015", "31 Oct 2015"}];
In[9]:=
Click for copyable input
DateObject[ First@FirstCase[ fall["Path"], _?(#[[2]] <= Quantity[0, "DegreesCelsius"] &)]]
Out[9]=

Related Examples

de es fr ja ko pt-br ru zh