Skip to content

Commit

Permalink
Refactor: Visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
kcwongaz committed Jul 30, 2022
1 parent a18424d commit 51f0e08
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 139 deletions.
Empty file added air_traffic/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions air_traffic/visual.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
import cartopy.feature as cfeature


def draw_map(boundary=[111, 117.5, 19, 25.5]):
"""
Create plt ax obtject with cartopy map on the given boundary box.
"""

ax = plt.axes(projection=ccrs.PlateCarree())
ax.set_extend(boundary, ccrs.PlateCarree())

# Add map features
ax.add_feature(cfeature.LAND)
ax.add_feature(cfeature.OCEAN)

# Draw gridlines
gridlines = ax.gridlines(draw_labels=True, zorder=0,
linestyle="dashed", linewidth=0.5, color="dimgrey")
gridlines.top_labels = False
gridlines.right_labels = False

return ax
131 changes: 131 additions & 0 deletions notebooks/1_trajectory_visualization.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import cartopy.crs as ccrs\n",
"import cartopy.feature as cfeature\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from air_traffic.visual import draw_map\n",
"from air_traffic.io import read_trajectories, read_trajectories_range"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"plt.rcParams.update({\n",
" \"text.usetex\": True,\n",
" \"font.family\": \"serif\",\n",
" \"font.serif\": [\"Palatino\"]\n",
" }\n",
")\n",
"\n",
"ncolor = 25\n",
"cmap = plt.cm.get_cmap(\"rainbow\", ncolor)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"datadir = \"\"\n",
"savedir = \"\""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 1 - Distribution of Trajectories\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"data = read_trajectories(datadir, \"2017-01-01\")\n",
"ax = draw_map()\n",
"\n",
"for i, df in enumerate(data):\n",
"\n",
" lat = df[\"latitude\"].to_numpy()\n",
" lon = df[\"longitude\"].to_numpy()\n",
" c = cmap(i % ncolor)\n",
"\n",
" ax.plot(lon, lat, transform=ccrs.Geodetic(),\n",
" marker=\".\", ms=1.5, linewidth=0.5, alpha=0.8, color=c)\n",
"\n",
"plt.cla()\n",
"plt.clf()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 2 - Trajectories Entry and End Points"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 3 - Clustering of Entry Direction"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.8.10 64-bit",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3.8.10"
},
"orig_nbformat": 4,
"vscode": {
"interpreter": {
"hash": "916dbcbb3f70747c44a77c7bcd40155683ae19c65e1c03b4aa3499c5328201f1"
}
}
},
"nbformat": 4,
"nbformat_minor": 2
}
46 changes: 0 additions & 46 deletions visual/draw_trajectory_csv_plotly.py

This file was deleted.

93 changes: 0 additions & 93 deletions visual/draw_trajectory_csv_range.py

This file was deleted.

0 comments on commit 51f0e08

Please sign in to comment.