Wolfram言語

Knowledgebaseへの幅広いアクセス

火球の実体ストアの作成

Wolfram Knowledgebaseには,幅広い分野をカバーする大量の情報が含まれている.また,この知識を表したりこれにアクセスして計算したりするのに適した強力な機能も有している.ユーザが自分の実体特性集合を作り,あたかも組込みデータであるようにそれを使うことも,可能(かつ簡単)になった.以下で,既存のデータソースに基づいた 火球(爆発流星)についての実体ストアの作成と使用のプロセスを説明する.

Jet Propulsion Laboratoryで管理されている爆発流星のデータ集合をImportを使ってダウンロードする.

In[1]:=
Click for copyable input
(rawdata = Import["http://neo.jpl.nasa.gov/fireballs/", "FullData"])[[3, 9, 2, 12, 1, ;; 5]]
Out[1]=

生のデータに単位を付ける効用関数を定義する.

In[2]:=
Click for copyable input
AddUnits[x_, u_: "Kilometers"/"Seconds"] := If[NumberQ[x], Quantity[Interpreter["Number"][x], u], Missing["NotAvailable"]]

データの関係する部分を抽出し,適切なQuantityタグを付け,実体ストアを作る.

完全なWolfram言語入力を表示する
In[3]:=
Click for copyable input
bolidedata = DeleteCases[{ DateObject[#1], With[{i = Interpreter["GeoCoordinates"][#2 <> " " <> #3]}, If[Head[i] === Missing, i, GeoPosition[Join[i[[1]], If[NumberQ[#4], {#4 10^3}, {}]]]]], AddUnits[#5], AddUnits[#6], AddUnits[#7], AddUnits[#8], AddUnits[#9, "Joules"], AddUnits[#10, "MetricKilotons"] } & @@@ rawdata[[3, 9, 2, 12, 1, 2 ;;]], {_, _Missing, __}];
In[4]:=
Click for copyable input
entities = Association @@ MapIndexed[ "Bolide" <> ToString[First[#2]] -> <| "Date" -> #[[1]], "Position" -> #[[2]], "Velocity" -> #[[3]], "VelocityX" -> #[[4]], "VelocityY" -> #[[5]], "VelocityZ" -> #[[6]], "TotalRadiatedEnergy" -> #[[7]], "CalculatedTotalImpactEnergy" -> #[[8]], "Label" -> "bolide on " <> DateString[#[[1]]] <> " GMT" |> &, bolidedata];
In[5]:=
Click for copyable input
properties = <| "Date" -> <|"Label" -> "date"|>, "Position" -> <|"Label" -> "position"|>, "Velocity" -> <|"Label" -> "velocity"|>, "VelocityX" -> <|"Label" -> "velocity x\[Hyphen]component"|>, "VelocityY" -> <|"Label" -> "velocity y\[Hyphen]component"|>, "VelocityZ" -> <|"Label" -> "velocity z\[Hyphen]component"|>, "TotalRadiatedEnergy" -> <|"Label" -> "total radiated energy"|>, "CalculatedTotalImpactEnergy" -> <|"Label" -> "calculated total impact energy"|> |>;
In[6]:=
Click for copyable input
store = EntityStore["Bolide" -> <| "Label" -> "bolide", "LabelPlural" -> "bolides", "Entities" -> entities, "Properties" -> properties |>]
Out[6]=

このセッション用にストアを登録する.

In[7]:=
Click for copyable input
PrependTo[$EntityStores, store];

爆発流星の位置とエネルギーについての「EntityAssociation」を作る.

In[8]:=
Click for copyable input
ea = EntityValue["Bolide", {"Position", "TotalRadiatedEnergy"}, "EntityAssociation"];

爆発流星の可視性の地理的プロットを,その高さと天空における位置に基づいて作る.

In[9]:=
Click for copyable input
GeoGraphics[{GeoVisibleRegion[#] & @@@ Values[ea]}]
Out[9]=

爆発流星のエネルギーをQuantityArray中に抽出する.

In[10]:=
Click for copyable input
energies = QuantityArray[Values[ea][[All, -1]]]
Out[10]=

爆発流星のエネルギーをヒストグラムを使って可視化する.

In[11]:=
Click for copyable input
Histogram[energies, "Log", AxesLabel -> {"energy (J)", "count"}]
Out[11]=

スケーリング関数を適用して火球の明るさの定性的に表す.

完全なWolfram言語入力を表示する
In[12]:=
Click for copyable input
scale[e_] := Quantity[1.*10^4 Sqrt[e/Max[energies]], "Kilometers"]
In[13]:=
Click for copyable input
GeoGraphics[{Red, GeoDisk[#1, scale[#2]] & @@@ Values[ea]}]
Out[13]=

関連する例

en es fr ko pt-br ru zh