예제 #1
0
    def test_open_dods_das(self):
        """Open a file downloaded from the test server with the DAS."""
        dataset = open_file(DODS, DAS)

        # test data
        self.assertEqual(dataset.data, [
            0,
            1,
            0,
            0,
            0,
            0.0,
            1000.0,
            'This is a data test string (pass 0).',
            'http://www.dods.org',
        ])

        # test attributes
        self.assertEqual(dataset.i32.units, 'unknown')
        self.assertEqual(dataset.i32.Description, 'A 32 bit test server int')
        self.assertEqual(dataset.b.units, 'unknown')
        self.assertEqual(dataset.b.Description, 'A test byte')
        self.assertEqual(dataset.Facility['DataCenter'],
                         "COAS Environmental Computer Facility")
        self.assertEqual(dataset.Facility['PrincipleInvestigator'],
                         ['Mark Abbott', 'Ph.D'])
        self.assertEqual(dataset.Facility['DrifterType'], "MetOcean WOCE/OCM")
예제 #2
0
def test_open_dods_das():
    """Open a file downloaded from the test server with the DAS."""
    dataset = open_file(DODS, DAS)

    # test data
    assert dataset.data == [
        0, 1, 0, 0, 0, 0.0, 1000.0,
        'This is a data test string (pass 0).',
        'http://www.dods.org',
    ]

    # test attributes
    assert (dataset.i32.units == 'unknown')
    assert (dataset.i32.Description == 'A 32 bit test server int')
    assert (dataset.b.units == 'unknown')
    assert (dataset.b.Description == 'A test byte')
    assert (
        dataset.Facility['DataCenter'] ==
        "COAS Environmental Computer Facility")
    assert (
        dataset.Facility['PrincipleInvestigator'] ==
        ['Mark Abbott', 'Ph.D'])
    assert (
        dataset.Facility['DrifterType'] ==
        "MetOcean WOCE/OCM")
예제 #3
0
def test_open_dods():
    """Open a file downloaded from the test server with the DAS."""
    dataset = open_file(DODS)

    # test data
    assert dataset.data == [
        0, 1, 0, 0, 0, 0.0, 1000.0,
        'This is a data test string (pass 0).',
        'http://www.dods.org',
    ]

    # test attributes
    assert dataset.attributes == {}
    assert dataset.i32.attributes == {}
    assert dataset.b.attributes == {}
예제 #4
0
    def test_open_dods(self):
        """Open a file downloaded from the test server with the DAS."""
        dataset = open_file(DODS)

        # test data
        self.assertEqual(dataset.data, [
            0, 1, 0, 0, 0, 0.0, 1000.0,
            'This is a data test string (pass 0).',
            'http://www.dods.org',
        ])

        # test attributes
        self.assertEqual(dataset.attributes, {})
        self.assertEqual(dataset.i32.attributes, {})
        self.assertEqual(dataset.b.attributes, {})
예제 #5
0
    def test_open_file(self):
        dataset = open_file(DODS, DAS)
        self.assertEqual(dataset.data, [
            0, 1, 0, 0, 0, 0.0, 1000.0,
            'This is a data test string (pass 0).',
            'http://www.dods.org',
        ])

        self.assertEqual(dataset.i32.units, 'unknown')
        self.assertEqual(dataset.i32.Description, 'A 32 bit test server int')
        self.assertEqual(dataset.b.units, 'unknown')
        self.assertEqual(dataset.b.Description, 'A test byte')
        self.assertEqual(dataset.Facility['DataCenter'],
            "COAS Environmental Computer Facility")
        self.assertEqual(dataset.Facility['PrincipleInvestigator'],
            ['Mark Abbott', 'Ph.D'])
        self.assertEqual(dataset.Facility['DrifterType'],
            "MetOcean WOCE/OCM")
예제 #6
0
    def test_open_dods(self):
        """Open a file downloaded from the test server with the DAS."""
        dataset = open_file(DODS)

        # test data
        self.assertEqual(dataset.data, [
            0,
            1,
            0,
            0,
            0,
            0.0,
            1000.0,
            'This is a data test string (pass 0).',
            'http://www.dods.org',
        ])

        # test attributes
        self.assertEqual(dataset.attributes, {})
        self.assertEqual(dataset.i32.attributes, {})
        self.assertEqual(dataset.b.attributes, {})
예제 #7
0
    (2, 4, 4, [(15, 16, 17)]),
    (3, 6, 9, []),
    (4, 8, 16, [(31, 32, 33), (41, 42, 43), (51, 52, 53), (61, 62, 63)]),
], NestedSequence.location)

# A simple array with bytes, strings and shorts. These types require special
# encoding for the DODS response.
SimpleArray = DatasetType("SimpleArray")
SimpleArray["byte"] = BaseType("byte", np.arange(5, dtype="b"))
SimpleArray["string"] = BaseType("string", np.array(["one", "two"]))
SimpleArray["short"] = BaseType("short", np.array(1, dtype="h"))

DODS = os.path.join(os.path.dirname(__file__),
                    'rainfall_time_malaysia.cdp.dods')
DAS = os.path.join(os.path.dirname(__file__), 'rainfall_time_malaysia.cdp.das')
dapper = open_file(DODS, DAS)

# dataset from http://test.opendap.org:8080/dods/dts/D1.asc
D1 = DatasetType('EOSDB.DBO', type='Drifters')
D1['Drifters'] = SequenceType('Drifters')
D1['Drifters']['instrument_id'] = BaseType('instrument_id')
D1['Drifters']['location'] = BaseType('location')
D1['Drifters']['latitude'] = BaseType('latitude')
D1['Drifters']['longitude'] = BaseType('longitude')
D1.Drifters.data = np.array(
    np.rec.fromrecords(list(
        zip([
            u"This is a data test string (pass {0}).".format(1 + i * 2)
            for i in range(5)
        ], [
            u"This is a data test string (pass {0}).".format(i * 2)
예제 #8
0
    (4, 8, 16, [(31, 32, 33), (41, 42, 43), (51, 52, 53), (61, 62, 63)]),
    ], NestedSequence.location)


# A simple array with bytes, strings and shorts. These types require special
# encoding for the DODS response.
SimpleArray = DatasetType("SimpleArray")
SimpleArray["byte"] = BaseType("byte", np.arange(5, dtype="b"))
SimpleArray["string"] = BaseType("string", np.array(["one", "two"]))
SimpleArray["short"] = BaseType("short", np.array(1, dtype="h"))


DODS = os.path.join(
    os.path.dirname(__file__), 'rainfall_time_malaysia.cdp.dods')
DAS = os.path.join(os.path.dirname(__file__), 'rainfall_time_malaysia.cdp.das')
dapper = open_file(DODS, DAS)


# dataset from http://test.opendap.org:8080/dods/dts/D1.asc
D1 = DatasetType('EOSDB.DBO', type='Drifters')
D1['Drifters'] = SequenceType('Drifters')
D1['Drifters']['instrument_id'] = BaseType('instrument_id')
D1['Drifters']['location'] = BaseType('location')
D1['Drifters']['latitude'] = BaseType('latitude')
D1['Drifters']['longitude'] = BaseType('longitude')
D1.Drifters.data = np.array(np.rec.fromrecords(list(zip(
    [u"This is a data test string (pass {0}).".format(1+i*2)
     for i in range(5)],
    [u"This is a data test string (pass {0}).".format(i*2) for i in range(5)],
    [1000.0, 999.95, 999.80, 999.55, 999.20],
    [999.95, 999.55, 998.75, 997.55, 995.95])),