コード例 #1
0
ファイル: ais_names.py プロジェクト: dieforfree/noaadata
def getNameMMSI(logfile,outfile):
    for line in logfile: 
	fields = line.split(',')[:6]
	if '1'!=fields[2]: # Must be the start of a sequence
	    continue
	if len(fields[5])<39: continue
	bv = binary.ais6tobitvec(fields[5][:39]) # Hacked for speed

	mmsi = ais_msg_5.decodeUserID(bv)
	name = aisstring.unpad(ais_msg_5.decodename(bv))
	outfile.write(str(mmsi)+' '+str(name)+'\n')
コード例 #2
0
ファイル: ais_names.py プロジェクト: mdeogune/noaadata
def getNameMMSI(logfile,outfile):
    for line in logfile:
        fields = line.split(',')[:6]
        if '1'!=fields[2]: # Must be the start of a sequence
            continue
        if len(fields[5])<39: continue
        bv = binary.ais6tobitvec(fields[5][:39]) # Hacked for speed

        mmsi = ais_msg_5.decodeUserID(bv)
        name = aisstring.unpad(ais_msg_5.decodename(bv))
        outfile.write(str(mmsi)+' '+str(name)+'\n')
コード例 #3
0
ファイル: ais_5report.py プロジェクト: mdeogune/noaadata
    ws_report.write(ws_report_row,col,'first reported (UTCsec)'); col += 1

    ws_report_row += 1

    msgsByShip={}
    # FIX: error checking?
    for filename in args:
        linenum=0
        for line in file(filename):
            line=line.strip()
            linenum +=1
            if linenum%1000==0:
                print linenum
            fields = line.split(',')
            bv = binary.ais6tobitvec(fields[5][:38])
            mmsi = m5.decodeUserID(bv)
            timestamp=fields[-1]

            if mmsi in msgsByShip:
                #if line not in msgsByShip:
                msgsByShip[mmsi].append(line)
            #if line in timeByMsgs
            else:
                msgsByShip[mmsi]=[line]

    print 'Finished scan.  Now processing ships.\n'

    ships = msgsByShip.keys()
    ships.sort()

    # FIX: use this to make sure that only these fields have changed