Wolfram Language

Processamento de séries temporais

Dados de fontes da internet

Faça download diariamente da temperatura média de um ano atrás dos Grandes Lagos.

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

As observações começam da linha 11.

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

O número de observações.

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

Defina a lista dos lagos.

In[5]:=
Click for copyable input
lakes = {"Superior", "Michigan", "Huron", "Erie", "Ontario", "St. Clair"};
mostre o input completo da Wolfram Language
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]=

Crie dados que sirvam de marcas de tempo em uma 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 para armazenar as temperaturas e a unidade.

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

Armazene a lista dos lagos como MetaInformation que poser extraído depois, por exemplo, para criar legendas de gráfico.

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]=

Estude as estatísticas descritivas para cada lago.

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=

Exemplos Relacionados

de en es fr ja ko ru zh