def genGridTransit_5minutes_from_1minute(mesh, gTrajFileName, transitFileName):
    GRIDNUMBER = (mesh.lonNum * mesh.latNum)
    print('genGridTransit Started : ', time.ctime())
    transitWriteFile = open(transitFileName, 'w')
    INDEX = getINDEX(mesh, gTrajFileName)
    GridImageIndex = getGridImageIndex(mesh)
    print('INDEX, Timestamps, GridImageIndex have been prepared.', time.ctime())
    (TT, SPAN) = ((24 * 12), 5)
    for i in range(TT):
        for j in range(GRIDNUMBER):
            cur_time = i
            cur_grid = j
            transitgrids = GridImageIndex[cur_grid]
            Transit = np.zeros(transitgrids.shape, dtype='int32')
            for ii in range(transitgrids.shape[0]):
                for jj in range(transitgrids.shape[1]):
                    next_grid = transitgrids[ii][jj]
                    if (next_grid != (- 1)):
                        cur_time_start = (cur_time * SPAN)
                        cur_time_end = (((cur_time + 1) * SPAN) + 1)
                        SS = set()
                        for pp in range(cur_time_start, cur_time_end):
                            trajfirst = INDEX[pp][cur_grid]
                            for qq in range(pp, cur_time_end):
                                trajsecond = INDEX[qq][next_grid]
                                SS.update((trajfirst & trajsecond))
                        transit_num = len(SS)
                        Transit[ii][jj] = transit_num
                    else:
                        pass
            FlattedTransit = Transit.reshape((- 1)).tolist()
            lineitem = [str(i), str(j)]
            lineitem.extend([str(t) for t in FlattedTransit])
            line = (','.join(lineitem) + '\n')
            transitWriteFile.write(line)
        print('genGridTransit timestamp: ', i)
    transitWriteFile.close()
    print('genGridTransit Ended: ', time.ctime())
def genGridTransit_5minutes_from_1minute(mesh, gTrajFileName, transitFileName):
    GRIDNUMBER = (mesh.lonNum * mesh.latNum)
    print('genGridTransit Started : ', time.ctime())
    transitWriteFile = open(transitFileName, 'w')
    INDEX = getINDEX(mesh, gTrajFileName)
    GridImageIndex = getGridImageIndex(mesh)
    print('INDEX, Timestamps, GridImageIndex have been prepared.', time.ctime())
    (TT, SPAN) = ((24 * 12), 5)
    for i in range(TT):
        for j in range(GRIDNUMBER):
            cur_time = i
            cur_grid = j
            transitgrids = GridImageIndex[cur_grid]
            Transit = np.zeros(transitgrids.shape, dtype='int32')
            for ii in range(transitgrids.shape[0]):
                for jj in range(transitgrids.shape[1]):
                    next_grid = transitgrids[ii][jj]
                    if (next_grid != (- 1)):
                        cur_time_start = (cur_time * SPAN)
                        cur_time_end = (((cur_time + 1) * SPAN) + 1)
                        SS = set()
                        for pp in range(cur_time_start, cur_time_end):
                            trajfirst = INDEX[pp][cur_grid]
                            for qq in range(pp, cur_time_end):
                                trajsecond = INDEX[qq][next_grid]
                                SS.update((trajfirst & trajsecond))
                        transit_num = len(SS)
                        Transit[ii][jj] = transit_num
                    else:
                        pass
            FlattedTransit = Transit.reshape((- 1)).tolist()
            lineitem = [str(i), str(j)]
            lineitem.extend([str(t) for t in FlattedTransit])
            line = (','.join(lineitem) + '\n')
            transitWriteFile.write(line)
        print('genGridTransit timestamp: ', i)
    transitWriteFile.close()
    print('genGridTransit Ended: ', time.ctime())