Wolfram Language

Time Series Processing

Data from Internet Sources

Download daily mean temperatures for the past year for the Great Lakes.

In[1]:=
Click for copyable input
rawdata = Import["http://coastwatch.glerl.noaa.gov/ftp/glsea/avgtemps/glsea-\ temps_1024.dat", "Data"];

The observations begin from row 11.

In[2]:=
Click for copyable input
rawdata[[;; 11]]
Out[2]=
In[3]:=
Click for copyable input
obs = rawdata[[11 ;;]];

The number of observations.

In[4]:=
Click for copyable input
Length[obs]
Out[4]=

Define the list of lakes.

In[5]:=
Click for copyable input
lakes = {"Superior", "Michigan", "Huron", "Erie", "Ontario", "St. Clair"};
show complete Wolfram Language input
In[6]:=
Click for copyable input
en = {Entity["Lake", "LakeSuperior::52tvr"], Entity["Lake", "LakeMichigan::y3357"], Entity["Lake", "LakeHuron::5t8vh"], Entity["Lake", "LakeErie::6tm6r"], Entity["Lake", "LakeOntario::35gt7"], Entity["Lake", "LakeSaintClair::3r368"]}; markers = Map[Text[Style[ StringReplace[StringTrim[#["Name"], "Lake"], "Saint" -> "St."], Bold, 12, Black, FontFamily -> "Arial"], #["Position"], Right] &, en]; GeoGraphics[{EntityClass["Lake", "GreatLakes"], markers}, GeoCenter -> GeoPosition[{46, -84}], GeoRange -> {{40, 50}, {-93, -74}}, GeoBackground -> GeoStyling["ReliefMap", ColorFunction -> (ColorData["RedBlueTones"][1 - #] &)], ImageSize -> Medium]
Out[6]=

Create dates to serve as time stamps in the TimeSeries.

In[7]:=
Click for copyable input
dates = Table[ DatePlus[{obs[[k, 1]], 1, 1}, Quantity[obs[[k, 2]], "Days"]], {k, 1, Length[obs]}];

Use QuantityArray to store the temperatures and the unit.

In[8]:=
Click for copyable input
values = QuantityArray[obs[[All, 3 ;;]], "DegreesCelsius"]
Out[8]=

Store the list of the lakes as MetaInformation that can be retrieved later, for example, to create plot legends.

In[9]:=
Click for copyable input
ts = TimeSeries[values, {dates}, MetaInformation -> {"Lakes" -> lakes}]
Out[9]=
In[10]:=
Click for copyable input
DateListPlot[ts, PlotLegends -> ts["Lakes"], PlotTheme -> "Detailed", FrameLabel -> Automatic]
Out[10]=

Study descriptive statistics for each lake.

In[11]:=
Click for copyable input
stats = {Min, Max, Mean, Median, StandardDeviation}; summary[lake_] := Map[#[lake] &, stats]
In[12]:=
Click for copyable input
TableForm[ Table[summary[ts["PathComponent", k]], {k, 1, Length[lakes]}], TableHeadings -> {lakes, stats}]
Out[12]//TableForm=

Related Examples

de es fr ja ko pt-br ru zh