Package: aisUtils
aisUtilsA tool package for MITS AIS users.Installpip install aisUtilsDevelopgit clone https://github.com/aisUtils.gitUsageThe package can satisfy fundamental demand for the use of AIS, which is  what I usually do.PreprocessingSuppose we start with AIS messages. We need to decode, crawl static information and perform filtering operations.decoderThe decoder process requires the package—libais.Parameters include source file path, destination file path and original timestamp, no return value. If you want to decode multiple files, it is easy to use a loop outside the call.fromaisUtilsimportPreprocessingasppsourcePath=r'D:/data/2021-08-28_CST.txt'# source file pathdesPath=r'D:/data/2021-08-28_output.csv'# destination file pathtimestr='2021-08-28:00:00:00;'# AIS initial timestamppp.decode(sourcePath,desPath,timestr)crawlIf you need some static data such as length, ship type, crawl them from a mmsi list. Then you will get a static data table.fromaisUtilsimportPreprocessingasppsourcePath=r'D:/python/data'# a directory stored all ais filesmmsiPath=r'D:/python/mmsiall.csv'# store mmsiliststaticDataPath=r'D:/python/staticData.csv'# store ais static data# get the mmsilistmmsiList=pp.getMmsiList(sourcePath)# write the mmsilistpp.writeMmsiList(mmsiPath,mmsiList)# crawlpp.crawl(mmsiPath,staticDataPath)matchingMatch the static data — length and ship type with the ais files.fromaisUtilsimportPreprocessingasppstaticDataPath=r'D:/python/staticData.csv'aisPath=r'D:/data/2021-08-28_output.csv'desPath=r'D:/data/2021-08-28_matching.csv'pp.match(staticDataPath,aisPath,desPath)othersThis part includes area, speed and ship type filtering.fromaisUtilsimportPreprocessingasppsourcePath=r'D:/data/2021-08-28_matching.csv'desPath=r'D:/data/2021-08-28_prep.csv'max_Lon=122.757min_Lon=122.145max_Lat=30.749min_Lat=30.409speed=[2,20]shiptype_list=[6,7,8]pp.filtering(sourcePath,desPath,max_Lon,min_Lon,max_Lat,min_Lat,speed,shiptype_list)if you want to read the file, you can use the code block, which returns a array type.importpandasaspddata=pd.read_csv(r'D:/data/2021-08-28_prep.csv')data_p=data.values#print(type(data_p)) #numpy.ndarrayInterpolationPackage scipy has powerful statistical tools.CSDN linkfromscipyimportinterpolateasinterfromscipy.interpolateimportlagrangimportnumpyasnp# sort the data according the index# data = data[np.lexsort((data[:,1], data[:,0]))]xli=np.arange(0,constants.pi*2,0.1)#   Interval pointsyli=inter.interp1d(x,y,kind="linear")(xli)# Linear interpolationycub=inter.interp1d(x,y,kind="cubic")(xli)# Cubic spline interpolationyquadratic=inter.interp1d(x,y,kind="quadratic")(xli)#  Quadratic spline interpolationynear=inter.interp1d(x,y,kind="nearest")(xli)# Nearest neighbor interpolation# Lagrange interpolationdeflagrangePoly(poly,x,length):result=[]foriinrange(len(x)):subresult=0forjinrange(length):subresult+=poly[j]*(x[i]**j)result.append(subresult)returnresultx=np.linspace(0,constants.pi*2,4)y=np.cos(x**2/3+4)poly=lagrange(x,y)length=len(x)ylagrange=lagrangePoly(poly,xli,length)CalculationHaversinefromhaversineimporthaversinelyon=(45.7597,4.8422)# (lat, lon)paris=(48.8567,2.3508)haversine(lyon,paris)scipy spatialfromscipy.spatial.distanceimportcdistcdist(x1,x2,metric=' euclidean')# Euclidean distancecdist(x1,x2,metric='minkowski')cdist(x1,x2,metric=' jaccard')ProjectSome codes for project, including section flow statistics, ship types statistics and track point drawing.DescriptionAlthough I have created  many functions in the package according my own ideas, there are still many possible requirements that can be improved later. I am tired. Thanks to senior fellow apprentice Chunshen for supporting the development of the crawl function.