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]:=
data = TimeSeries[
WeatherData["Chicago",
"Temperature", {{2015, 1, 1}, {2015, 12, 31}}],
MissingDataMethod -> "Interpolation"]
Out[1]=
In[2]:=
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]:=
minF = MinFilter[data, Quantity[1, "Month"]];
show complete Wolfram Language input
Out[5]=
First day after last spring freeze.
In[6]:=
spring = TimeSeriesWindow[minF, {"15 April 2015", "15 May 2015"}];
In[7]:=
DateObject[
First@FirstCase[
spring["Path"], _?(#[[2]] > Quantity[0, "DegreesCelsius"] &)]]
Out[7]=
First fall freeze.
In[8]:=
fall = TimeSeriesWindow[minF, {"1 Oct 2015", "31 Oct 2015"}];
In[9]:=
DateObject[
First@FirstCase[
fall["Path"], _?(#[[2]] <= Quantity[0, "DegreesCelsius"] &)]]
Out[9]=