示例#1
0
    def test_longitude(self):
        """
        Test that the latitude variable can be successfully returned,
        irrespective of any other dimensions on top of it. Checks that
        the values of the latitude variable can be successfully read.
        """
        # Test on a dataset with only a single datapoint.
        reader1 = NetCDFReader(TIME_DATASET1)
        lon1 = reader1.longitude()
        reader1.close()
        self.assertEqual(1, len(lon1))
        self.assertEqual(0, lon1[0])

        # Test on a dataset with only a time dimension, and only one unit of
        # longitude in length.
        reader5 = NetCDFReader(TIME_DATASET5)
        lon5 = reader5.longitude()
        reader5.close()
        self.assertEqual(1, len(lon5))
        self.assertEqual(0, lon5[0])

        # Test on a dataset with two dimensions plus a time dimension, with
        # multiple units of longitude length.
        reader12 = NetCDFReader(TIME_DATASET12)
        lon12 = reader12.longitude()
        reader12.close()
        self.assertEqual(2, len(lon12))
        self.assertEqual(0, lon12[0])
        self.assertEqual(1, lon12[1])

        # Test on a dataset with more dimensions that just latitude,
        # longitude, and time.
        reader48 = NetCDFReader(TIME_DATASET48)
        lon48 = reader48.longitude()
        reader48.close()
        self.assertEqual(2, len(lon48))
        self.assertEqual(0, lon48[0])
        self.assertEqual(1, lon48[1])
示例#2
0
    def test_longitude(self):
        """
        Test that longitude data is stored correctly, and its data is
        retrieved by the longitude method without interference by any other
        dimensions.
        """
        # Test with a single point in longitude and latitude.
        reader1 = NetCDFReader(DATASET1)
        lon1 = reader1.longitude()
        reader1.close()
        self.assertEqual(1, len(lon1))
        self.assertEqual(0, lon1[0])

        # Test with a single point in longitude, but more in latitude.
        reader5 = NetCDFReader(DATASET5)
        lon5 = reader5.longitude()
        reader5.close()
        self.assertEqual(1, len(lon5))
        self.assertEqual(0, lon5[0])

        # Test with multiple points in both longitude and latitude.
        reader6 = NetCDFReader(DATASET6)
        lon6 = reader6.longitude()
        reader6.close()
        self.assertEqual(2, len(lon6))
        self.assertEqual(0, lon6[0])
        self.assertEqual(1, lon6[1])

        # Test with three dimensions, including multiple points in longitude
        # and latitude.
        reader12 = NetCDFReader(DATASET12)
        lon12 = reader12.longitude()
        reader12.close()
        self.assertEqual(2, len(lon12))
        self.assertEqual(0, lon12[0])
        self.assertEqual(1, lon12[1])