Skip to content

Commit

Permalink
WIP: air traffic control example
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Oct 4, 2024
1 parent 7d262bf commit 4b0ee7b
Showing 1 changed file with 306 additions and 0 deletions.
306 changes: 306 additions & 0 deletions examples/air-traffic-control.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,306 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"from io import BytesIO\n",
"\n",
"import pyarrow as pa\n",
"import pyarrow.parquet as pq\n",
"import requests\n",
"\n",
"import lonboard\n",
"from lonboard.experimental import TripsLayer\n",
"from lonboard import Map\n",
"import arro3.core"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'0.5.0-beta.2'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"arro3.core.__version__"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"url = \"https://github.com/kylebarron/adsb-extract/releases/download/v0.1/2024-10-03_traces.parquet\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"r = requests.get(url)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"table = pq.read_table(BytesIO(r.content))"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"timestamps = table[\"timestamp\"]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/Users/kyle/github/developmentseed/lonboard/lonboard/_geoarrow/ops/reproject.py:33: UserWarning: No CRS exists on data. If no data is shown on the map, double check that your CRS is WGS84.\n",
" warn(\n",
"/Users/kyle/github/developmentseed/lonboard/lonboard/experimental/traits.py:146: UserWarning: Reducing precision of input timestamp data to 's' to fit into available GPU precision.\n",
" warnings.warn(\n"
]
}
],
"source": [
"layer = TripsLayer(table=table, get_timestamps=table[\"timestamp\"])"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"m = Map(layer)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "a1794393a04d49ec84606b857dc3e6da",
"version_major": 2,
"version_minor": 1
},
"text/plain": [
"Map(custom_attribution='', layers=(TripsLayer(get_timestamps=arro3.core.ChunkedArray<List(Field { name: \"\", da…"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"m"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"from datetime import timedelta"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6ee7b44ce46543d48e343af6fcdb3243",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Play(value=-16777216, interval=16, max=-16690817, min=-16777216, repeat=True, step=120)"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"layer.animate(step=timedelta(minutes=2), interval=1000/60)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
"layer.stop_animation()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [],
"source": [
"layer.width_min_pixels = 3"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [],
"source": [
"layer.get_color = [30, 30, 200, 200]"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [],
"source": [
"layer.trail_length = 1000"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"-16748736.0"
]
},
"execution_count": 29,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"layer.current_time"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [],
"source": [
"m._height = 800"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"arro3.core.Table\n",
"-----------\n",
"geometry: List(Field { name: \"element\", data_type: FixedSizeList(Field { name: \"element\", data_type: Float64, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} }, 3), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })\n",
"timestamp: List(Field { name: \"element\", data_type: Timestamp(Millisecond, Some(\"UTC\")), nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })\n",
"ground_speed: List(Field { name: \"element\", data_type: Float32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })\n",
"heading: List(Field { name: \"element\", data_type: Float32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })\n",
"vertical_speed: List(Field { name: \"element\", data_type: Float32, nullable: true, dict_id: 0, dict_is_ordered: false, metadata: {} })\n",
"icao_id: Utf8"
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"layer.table"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"arro3.core.ChunkedArray<List(Field { name: \"\", data_type: Timestamp(Second, Some(\"UTC\")), nullable: false, dict_id: 0, dict_is_ordered: false, metadata: {} })>"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"layer.get_timestamps"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "lonboard",
"language": "python",
"name": "lonboard"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.8"
}
},
"nbformat": 4,
"nbformat_minor": 4
}

0 comments on commit 4b0ee7b

Please sign in to comment.