Skip to content
Snippets Groups Projects
Commit 9a94e525 authored by Raphael Sturgis's avatar Raphael Sturgis
Browse files

reorganised file

parent d29c2006
No related branches found
No related tags found
1 merge request!6Develop
...@@ -50,18 +50,20 @@ class AISPoints: ...@@ -50,18 +50,20 @@ class AISPoints:
self.df = df self.df = df
@staticmethod # cleaning functions
def load_from_csv(file_name):
df = pd.read_csv(file_name)
ais_points = AISPoints(df)
return ais_points
def remove_outliers(self, features, rank=4): def remove_outliers(self, features, rank=4):
if rank <= 0: if rank <= 0:
raise ValueError(f"Rank is equal to {rank}, must be positive and superior to 0") raise ValueError(f"Rank is equal to {rank}, must be positive and superior to 0")
for feature in features: for feature in features:
self.df = self.df.drop(self.df[(np.abs(stats.zscore(self.df[feature])) > rank)].index) self.df = self.df.drop(self.df[(np.abs(stats.zscore(self.df[feature])) > rank)].index)
def clean_angles(self):
self.df = self.df[self.df["cog"] <= 360]
self.df = self.df[self.df["cog"] >= 0]
self.df = self.df[self.df["heading"] <= 360]
self.df = self.df[self.df["heading"] >= 0]
def normalize(self, features, normalization_type="min-max"): def normalize(self, features, normalization_type="min-max"):
normalization_dict = {} normalization_dict = {}
if normalization_type == "min-max": if normalization_type == "min-max":
...@@ -93,20 +95,12 @@ class AISPoints: ...@@ -93,20 +95,12 @@ class AISPoints:
f"standardization]") f"standardization]")
return normalization_type, normalization_dict return normalization_type, normalization_dict
# New features
# TODO: rename # TODO: rename
def compute_diff_heading_cog(self): def compute_diff_heading_cog(self):
self.df["diff"] = self.df.apply(lambda x: 180 - abs(abs(x['heading'] - x['cog']) - 180), self.df["diff"] = self.df.apply(lambda x: 180 - abs(abs(x['heading'] - x['cog']) - 180),
axis=1) axis=1)
def clean_angles(self):
self.df = self.df[self.df["cog"] <= 360]
self.df = self.df[self.df["cog"] >= 0]
self.df = self.df[self.df["heading"] <= 360]
self.df = self.df[self.df["heading"] >= 0]
# TODO: redo # TODO: redo
def get_trajectories(self, time_gap=30, min_size=50, interpolation_time=None): def get_trajectories(self, time_gap=30, min_size=50, interpolation_time=None):
...@@ -139,6 +133,7 @@ class AISPoints: ...@@ -139,6 +133,7 @@ class AISPoints:
return stats return stats
# Static methods
@staticmethod @staticmethod
def fuse(*args): def fuse(*args):
if len(args) == 1: if len(args) == 1:
...@@ -153,3 +148,9 @@ class AISPoints: ...@@ -153,3 +148,9 @@ class AISPoints:
dfs.append(aisPosition.df) dfs.append(aisPosition.df)
return AISPoints(pd.concat(dfs).reindex()) return AISPoints(pd.concat(dfs).reindex())
@staticmethod
def load_from_csv(file_name):
df = pd.read_csv(file_name)
ais_points = AISPoints(df)
return ais_points
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment