-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot.py
More file actions
78 lines (66 loc) · 2.6 KB
/
Copy pathplot.py
File metadata and controls
78 lines (66 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import pandas as pd
import seaborn as sns
import matplotlib.dates as mdates
import matplotlib.pyplot as plt
Cargo = pd.read_csv('/Users/caseywong/Documents/GitHub/analyze_ais/Cargo_stats.out', delimiter = ",")
Tanker = pd.read_csv('/Users/caseywong/Documents/GitHub/analyze_ais/Tanker_stats.out', delimiter = ",")
Fishing = pd.read_csv('/Users/caseywong/Documents/GitHub/analyze_ais/Fishing_stats.out', delimiter = ",")
Passenger = pd.read_csv('/Users/caseywong/Documents/GitHub/analyze_ais/Passenger2.out', delimiter = ",")
Cargo['date'] = pd.to_datetime(Cargo['date'], format='%Y%m%d')
Tanker['date'] = pd.to_datetime(Tanker['date'], format='%Y%m%d')
Fishing['date'] = pd.to_datetime(Fishing['date'], format='%Y%m%d')
Passenger['date'] = pd.to_datetime(Passenger['date'], format='%Y%m%d')
#######
# date vs types
#######
#1
sns.set_palette("husl")
concatenated = pd.concat([Cargo.assign(dataset='Cargo'), Tanker.assign(dataset='Tanker'), Fishing.assign(dataset="Fishing"), Passenger.assign(dataset="Passenger")])
g=sns.relplot(x='date', y='Zone_true', data=concatenated ,kind='line', hue= 'dataset' , style='dataset')
g.fig.autofmt_xdate()
plt.ylabel("percentage")
plt.title("Zone entry for 4 ship types in July 2020")
plt.savefig('zone202007.png')
#2
g=sns.relplot(x='date', y='Gap_true', data=concatenated ,kind='line', hue= 'dataset' , style='dataset')
g.fig.autofmt_xdate()
plt.ylabel("percentage")
plt.title("AIS Gaps for 4 ship types in July 2020")
plt.savefig('gap202007.png')
#3
g=sns.relplot(x='date', y='Speed_true', data=concatenated ,kind='line', hue= 'dataset' , style='dataset')
g.fig.autofmt_xdate()
plt.ylabel("percentage")
plt.title("Speed change for 4 ship types in July 2020")
plt.savefig('sc202007.png')
#####
# date vs anomalies
#####
Cargo2=Cargo[["date","Gap_true","Speed_true","Zone_true"]]
Fishing2=Fishing[["date","Gap_true","Speed_true","Zone_true"]]
Tanker2=Tanker[["date","Gap_true","Speed_true","Zone_true"]]
Passenger2=Passenger[["date","Gap_true","Speed_true","Zone_true"]]
#1
sns.relplot(data=Cargo2,kind="line")
plt.xlabel("date")
plt.ylabel("percentage")
plt.title("Anomalies for Cargo ships in July 2020")
plt.savefig('cargo202007.png')
#2
sns.lineplot(data=Tanker2)
plt.xlabel("date")
plt.ylabel("percentage")
plt.title("Anomalies for Tankers in July 2020")
plt.savefig('tankers202007.png')
#3
sns.lineplot(data=Fishing2)
plt.xlabel("date")
plt.ylabel("percentage")
plt.title("Anomalies for fishing vessels in July 2020")
plt.savefig('fish202007.png')
#4
sns.lineplot(data=Passenger2)
plt.xlabel("date")
plt.ylabel("percentage")
plt.title("Anomalies for passenger ships in July 2020")
plt.savefig('pass202007.png')