예제 #1
0
def test_deltaTime_times():
    '''
    make sure deltaTime is dealing with times correctly
    '''

    # same day, same time:
    early = (2004, 2, 28, 0)
    late = (2004, 2, 28, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 0., 'incorrect time difference for identical dates and times'

    # same day, different time:
    early = (2004, 2, 28, 0)
    late = (2004, 2, 28, 1.5)

    diff = geo.deltaTime(early, late)
    assert diff == 5400., 'incorrect time difference for identical dates and different times'

    # earlier time on later day
    early = (2005, 2, 27, 2)
    late = (2005, 2, 28, 1)

    diff = geo.deltaTime(early, late)
    assert diff == 82800., 'incorrect time difference for earlier times but later days'
예제 #2
0
def test_deltaTime_dateAware():
    '''
    make sure deltaTime is coping with real dates correctly
    '''

    # 2 days on a leap year:
    early = (2004, 2, 28, 0)
    late = (2004, 3, 1, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 172800., 'incorrect date difference on leap year'

    # 1 day on not a leap year:
    early = (2005, 2, 28, 0)
    late = (2005, 3, 1, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 86400., 'incorrect date difference on non-leap year'

    # 30 days in June:
    early = (2004, 6, 30, 0)
    late = (2004, 7, 1, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 86400., 'should only be 1 day between June 30 and July 1'

    # 31 days in July:
    early = (2004, 7, 30, 0)
    late = (2004, 8, 1, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 172800., 'should be 2 days between July 30 and August 1'
예제 #3
0
def test_deltaTime_dateAware():
    '''
    make sure deltaTime is coping with real dates correctly
    '''

    # 2 days on a leap year:
    early = (2004, 2, 28, 0)
    late  = (2004, 3, 1, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 172800., 'incorrect date difference on leap year'

    # 1 day on not a leap year:
    early = (2005, 2, 28, 0)
    late  = (2005, 3, 1, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 86400., 'incorrect date difference on non-leap year'

    # 30 days in June:
    early = (2004, 6, 30, 0)
    late  = (2004, 7, 1, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 86400., 'should only be 1 day between June 30 and July 1'

    # 31 days in July:
    early = (2004, 7, 30, 0)
    late  = (2004, 8, 1, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 172800., 'should be 2 days between July 30 and August 1'
예제 #4
0
파일: geo_tests.py 프로젝트: yf1412/AutoQC
def test_deltaTime_times():
    '''
    make sure deltaTime is dealing with times correctly
    '''  

    # same day, same time:
    early = util.testingProfile.fakeProfile([0], [0], date=[2004, 2, 28, 0])
    late  = util.testingProfile.fakeProfile([0], [0], date=[2004, 2, 28, 0])

    diff = geo.deltaTime(early, late)
    assert diff == 0., 'incorrect time difference for identical dates and times'

    # same day, different time:
    early = util.testingProfile.fakeProfile([0], [0], date=[2004, 2, 28, 0])
    late  = util.testingProfile.fakeProfile([0], [0], date=[2004, 2, 28, 1.5])

    diff = geo.deltaTime(early, late)
    assert diff == 5400., 'incorrect time difference for identical dates and different times'


    # earlier time on later day
    early = util.testingProfile.fakeProfile([0], [0], date=[2005, 2, 27, 2])
    late  = util.testingProfile.fakeProfile([0], [0], date=[2005, 2, 28, 1])

    diff = geo.deltaTime(early, late)
    assert diff == 82800., 'incorrect time difference for earlier times but later days'
예제 #5
0
def test_deltaTime_times():
    '''
    make sure deltaTime is dealing with times correctly
    '''  

    # same day, same time:
    early = (2004, 2, 28, 0)
    late  = (2004, 2, 28, 0)

    diff = geo.deltaTime(early, late)
    assert diff == 0., 'incorrect time difference for identical dates and times'

    # same day, different time:
    early = (2004, 2, 28, 0)
    late  = (2004, 2, 28, 1.5)

    diff = geo.deltaTime(early, late)
    assert diff == 5400., 'incorrect time difference for identical dates and different times'


    # earlier time on later day
    early = (2005, 2, 27, 2)
    late  = (2005, 2, 28, 1)

    diff = geo.deltaTime(early, late)
    assert diff == 82800., 'incorrect time difference for earlier times but later days'
예제 #6
0
def condition_h(rows, speeds, angles, index, maxSpeed):
    '''
    assess condition (h) from the text
    '''

    if index > 1 and index < len(rows) - 1:

        dist1 = geo.haversineDistance(
            rows[index][5], rows[index][6], rows[index - 2][5],
            rows[index - 2][6]) + geo.haversineDistance(
                rows[index + 1][5], rows[index + 1][6], rows[index][5],
                rows[index][6])
        dist2 = geo.haversineDistance(
            rows[index - 1][5], rows[index - 1][6], rows[index - 2][5],
            rows[index - 2][6]) + geo.haversineDistance(
                rows[index + 1][5], rows[index + 1][6], rows[index - 1][5],
                rows[index - 1][6])

        PD1 = geo.haversineDistance(rows[index - 1][5], rows[index - 1][6],
                                    rows[index - 2][5],
                                    rows[index - 2][6]) / dist2
        PD2 = geo.haversineDistance(rows[index][5], rows[index][6],
                                    rows[index - 2][5],
                                    rows[index - 2][6]) / dist1

        PT1 = geo.deltaTime(
            (rows[index - 2][1], rows[index - 2][2], rows[index - 2][3],
             rows[index - 2][4]),
            (rows[index - 1][1], rows[index - 1][2], rows[index - 1][3],
             rows[index - 1][4])) / geo.deltaTime(
                 (rows[index - 2][1], rows[index - 2][2], rows[index - 2][3],
                  rows[index - 2][4]),
                 (rows[index + 1][1], rows[index + 1][2], rows[index + 1][3],
                  rows[index + 1][4]))
        PT2 = geo.deltaTime((rows[index - 2][1], rows[index - 2][2],
                             rows[index - 2][3], rows[index - 2][4]),
                            (rows[index][1], rows[index][2], rows[index][3],
                             rows[index][4])) / geo.deltaTime(
                                 (rows[index - 2][1], rows[index - 2][2],
                                  rows[index - 2][3], rows[index - 2][4]),
                                 (rows[index + 1][1], rows[index + 1][2],
                                  rows[index + 1][3], rows[index + 1][4]))

        if abs(PD1 - PT1) > 0.1 + abs(PD2 - PT2):
            return index - 1, 'h'
        if abs(PD2 - PT2) > 0.1 + abs(PD1 - PT1):
            return index, 'h'

    return -1, 'i'
예제 #7
0
def meanSpeed(speeds, headers, maxSpeed):
    '''
    determine mean speed, neglecting missing data, intervals less than 1h, and speeds over maxspeed, for use in condition (f)
    '''

    meanSpeed = 0
    speedCount = 0
    for iSpeed, speed in enumerate(speeds):
        if speed == None or iSpeed == 0:
            #missing values
            continue
        elif iSpeed > 0 and geo.deltaTime(headers[iSpeed-1], headers[iSpeed]) < 3600.:
            #too close together in time
            continue
        elif speed > maxSpeed:
            #too fast
            continue
        else:
            meanSpeed += speed
            speedCount += 1

    if speedCount > 0:
        meanSpeed = meanSpeed / speedCount

    return meanSpeed
예제 #8
0
def meanSpeed(speeds, rows, maxSpeed):
    '''
    determine mean speed, neglecting missing data, intervals less than 1h, and speeds over maxspeed, for use in condition (f)
    '''

    meanSpeed = 0
    speedCount = 0
    for iSpeed, speed in enumerate(speeds):
        if speed == None or iSpeed == 0:
            #missing values
            continue
        elif iSpeed > 0 and geo.deltaTime((rows[iSpeed-1][1], rows[iSpeed-1][2], rows[iSpeed-1][3], rows[iSpeed-1][4]), (rows[iSpeed][1], rows[iSpeed][2], rows[iSpeed][3], rows[iSpeed][4])):
            #too close together in time
            continue
        elif speed > maxSpeed:
            #too fast
            continue
        else:
            meanSpeed += speed
            speedCount += 1

    if speedCount > 0:
        meanSpeed = meanSpeed / speedCount

    return meanSpeed
예제 #9
0
def condition_h(rows, speeds, angles, index, maxSpeed):
    '''
    assess condition (h) from the text
    '''
    
    if index > 1 and index < len(rows) - 1:

        dist1 = geo.haversineDistance(rows[index][5], rows[index][6], rows[index-2][5], rows[index-2][6]) + geo.haversineDistance(rows[index+1][5], rows[index+1][6], rows[index][5], rows[index][6])
        dist2 = geo.haversineDistance(rows[index-1][5], rows[index-1][6], rows[index-2][5], rows[index-2][6]) + geo.haversineDistance(rows[index+1][5], rows[index+1][6], rows[index-1][5], rows[index-1][6])

        PD1 = geo.haversineDistance(rows[index-1][5], rows[index-1][6], rows[index-2][5], rows[index-2][6]) / dist2
        PD2 = geo.haversineDistance(rows[index][5], rows[index][6], rows[index-2][5], rows[index-2][6]) / dist1

        PT1 = geo.deltaTime((rows[index-2][1], rows[index-2][2], rows[index-2][3], rows[index-2][4]), (rows[index-1][1], rows[index-1][2], rows[index-1][3], rows[index-1][4])) / geo.deltaTime((rows[index-2][1], rows[index-2][2], rows[index-2][3], rows[index-2][4]), (rows[index+1][1], rows[index+1][2], rows[index+1][3], rows[index+1][4]))
        PT2 = geo.deltaTime((rows[index-2][1], rows[index-2][2], rows[index-2][3], rows[index-2][4]), (rows[index][1], rows[index][2], rows[index][3], rows[index][4])) / geo.deltaTime((rows[index-2][1], rows[index-2][2], rows[index-2][3], rows[index-2][4]), (rows[index+1][1], rows[index+1][2], rows[index+1][3], rows[index+1][4]))

        if abs(PD1-PT1) > 0.1 + abs(PD2-PT2):
            return index-1, 'h'
        if abs(PD2 - PT2) > 0.1 + abs(PD1 - PT1):
            return index, 'h'

    return -1, 'i'
예제 #10
0
def condition_h(headers, speeds, angles, index, maxSpeed):
    '''
    assess condition (h) from the text
    typeo in text, implementation incomplete
    '''
    
    if index > 1 and index < len(headers) - 1:

        dist1 = geo.haversineDistance(headers[index], headers[index-2]) + geo.haversineDistance(headers[index + 1], headers[index])
        dist2 = geo.haversineDistance(headers[index-1], headers[index-2]) + geo.haversineDistance(headers[index + 1], headers[index-1])

        PD1 = geo.haversineDistance(headers[index-1], headers[index-2]) / dist2
        PD2 = geo.haversineDistance(headers[index], headers[index-2]) / dist1

        PT1 = geo.deltaTime(headers[index-2], headers[index-1]) / geo.deltaTime(headers[index-2], headers[index+1])
        PT2 = geo.deltaTime(headers[index-2], headers[index]) / geo.deltaTime(headers[index-2], headers[index+1])

        if abs(PD1-PT1) > 0.1 + abs(PD2-PT2):
            return index-1, 'h'
        if abs(PD2 - PT2) > 0.1 + abs(PD1 - PT1):
            return index, 'h'

    return -1, 'i'
예제 #11
0
def trackSpeed(prevHeader, header):
    '''
    computes the speed, including rounding tolerance from the reference,
    for the track at <header>.
    return None if some necessary data is missing
    '''

    # check that all required data is present:
    if None in [header.latitude(), header.longitude(), prevHeader.latitude(), prevHeader.longitude()]:
        return None
    if None in [header.year(), header.month(), header.day(), header.time(), prevHeader.year(), prevHeader.month(), prevHeader.day(), prevHeader.time()]:
        return None

    dist = geo.haversineDistance(prevHeader, header)
    DTime = geo.deltaTime(prevHeader, header)
    speed = (dist - DistRes) / max(DTime, TimeRes)

    return speed
예제 #12
0
def trackSpeed(prev_row, row):
    '''
    computes the speed, including rounding tolerance from the reference,
    for the track at <row>.
    return None if some necessary data is missing
    '''

    # check that all required data (full timestamp + lat + long) is present:
    if None in [row[1], row[2], row[3], row[4], row[5], row[6]]:
        return None
    if None in [prev_row[1], prev_row[2], prev_row[3], prev_row[4], prev_row[5], prev_row[6] ]:
        return None

    dist = geo.haversineDistance(prev_row[5], prev_row[6], row[5], row[6])
    DTime = geo.deltaTime((prev_row[1], prev_row[2], prev_row[3], prev_row[4]), (row[1], row[2], row[3], row[4]))
    speed = (dist - DistRes) / max(DTime, TimeRes)

    return speed
예제 #13
0
def trackSpeed(prev_row, row):
    '''
    computes the speed, including rounding tolerance from the reference,
    for the track at <row>.
    return None if some necessary data is missing
    '''

    # check that all required data (full timestamp + lat + long) is present:
    if None in [row[1], row[2], row[3], row[4], row[5], row[6]]:
        return None
    if None in [prev_row[1], prev_row[2], prev_row[3], prev_row[4], prev_row[5], prev_row[6] ]:
        return None

    dist = geo.haversineDistance(prev_row[5], prev_row[6], row[5], row[6])
    DTime = geo.deltaTime((prev_row[1], prev_row[2], prev_row[3], prev_row[4]), (row[1], row[2], row[3], row[4]))
    speed = (dist - DistRes) / max(DTime, TimeRes)

    return speed