示例#1
0
def test_to_protobuf():
    value = 1.25
    int_dtype = 2
    log = io_controlnetwork.MeasureLog(int_dtype, value)
    proto = log.to_protobuf()
    assert proto.doubleDataType == int_dtype
    assert proto.doubleDataValue == value
示例#2
0
def test_MeasureLog(messagetype, value):
    l = io_controlnetwork.MeasureLog(messagetype, value)
    if isinstance(messagetype, int):
        assert l.messagetype == io_controlnetwork.MeasureMessageType(
            messagetype)
    elif isinstance(messagetype, str):
        assert l.messagetype == io_controlnetwork.MeasureMessageType[
            messagetype]

    assert l.value == value
    assert isinstance(l.to_protobuf, object)
def cnet_dataframe(tmpdir):
    npts = 5
    serial_times = {
        295: '1971-07-31T01:24:11.754',
        296: '1971-07-31T01:24:36.970'
    }
    serials = {
        i: 'APOLLO15/METRIC/{}'.format(j)
        for i, j in enumerate(serial_times.values())
    }
    columns = [
        'id', 'pointType', 'serialnumber', 'measureType', 'sample', 'line',
        'image_index', 'pointLog', 'measureLog', 'aprioriCovar',
        'referenceIndex'
    ]

    data = []
    for i in range(npts):
        aprioriCovar = None
        if i == npts - 1:
            aprioriCovar = np.ones((2, 3))
        reference_idx = i % 2
        data.append((i, 2, serials[0], 2, 0, 0, 0, [], [], aprioriCovar,
                     reference_idx))
        data.append(
            (i, 2, serials[1], 2, 0, 0, 1, [],
             [io_controlnetwork.MeasureLog(2,
                                           0.5)], aprioriCovar, reference_idx))

    df = pd.DataFrame(data, columns=columns)

    df.creation_date = strftime("%Y-%m-%d %H:%M:%S", gmtime())
    df.modified_date = strftime("%Y-%m-%d %H:%M:%S", gmtime())
    io_controlnetwork.to_isis(df,
                              tmpdir.join('test.net'),
                              mode='wb',
                              targetname='Moon')

    df.header_message_size = 78
    df.point_start_byte = 65614  # 66949
    df.npts = npts
    df.measure_size = [149, 149, 149, 149,
                       200]  # Size of each measure in bytes
    df.serials = serials
    return df
示例#4
0
def test_log_error():
    with pytest.raises(TypeError) as err:
        io_controlnetwork.MeasureLog(2, 'foo')