Wolfram 语言

更丰富的知识库访问

创建火球流星雨实体库

Wolfram Knowledgebase 包含了覆盖广泛领域的大量信息,而且还拥有表现、访问和计算这些信息的强大功能. 现在,用户还可以(并更直接的)创建自定义的实体-属性集合,并用与内置数据相同方法进行使用. 在此,根据火球流星雨(即,火星流)现有数据来源,展示了创建并使用火球流星雨实体库的过程.

Import 来下载喷气推进实验室(JPL)维护的火星流数据集.

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 ja ko pt-br ru