예제 #1
0
    def test_read_binary_subset_Data_int(self):
        # binary data from subset in Data object

        # write binary test data
        fname = tempfile.mktemp()
        f = open(fname, 'w')

        tmp = (np.random.random(self.x.shape) * 100.).astype('int16')
        f.write(tmp)
        f.close()

        D = Data(None, None)
        D.filename = fname
        ny, nx = self.x.shape

        latmin = self.lat[self.ymin]
        latmax = self.lat[self.ymax]
        lonmin = self.lon[self.xmin]
        lonmax = self.lon[self.xmax]

        D._read_binary_file(nt=1,
                            dtype='int16',
                            latmin=latmin,
                            latmax=latmax,
                            lonmin=lonmin,
                            lonmax=lonmax,
                            lat=self.lat,
                            lon=self.lon)
        self.assertTrue(
            np.all(
                D.data -
                tmp[self.ymin:self.ymax + 1, self.xmin:self.xmax + 1] == 0.))
예제 #2
0
    def test_read_full_binary_file_double(self):
        # write binary test data
        fname = tempfile.mktemp()
        f = open(fname, 'w')
        f.write(self.x)
        f.close()

        D = Data(None, None)
        D.filename = fname
        ny, nx = self.x.shape
        D._read_binary_file(ny=ny, nx=nx, nt=1, dtype='double')
        self.assertTrue(np.all(D.data - self.x == 0.))
예제 #3
0
    def test_read_full_binary_file_double(self):
        # write binary test data
        fname = tempfile.mktemp()
        f = open(fname, 'w')
        f.write(self.x)
        f.close()

        D = Data(None, None)
        D.filename = fname
        ny, nx = self.x.shape
        D._read_binary_file(ny=ny, nx=nx, nt=1, dtype='double')
        self.assertTrue(np.all(D.data-self.x == 0.))
예제 #4
0
    def test_read_binary_subset_Data_int(self):
        # binary data from subset in Data object

        # write binary test data
        fname = tempfile.mktemp()
        f = open(fname, 'w')

        tmp = (np.random.random(self.x.shape)*100.).astype('int16')
        f.write(tmp)
        f.close()

        D = Data(None, None)
        D.filename = fname
        ny, nx = self.x.shape

        latmin = self.lat[self.ymin]
        latmax = self.lat[self.ymax]
        lonmin = self.lon[self.xmin]
        lonmax = self.lon[self.xmax]

        D._read_binary_file(nt=1, dtype='int16', latmin=latmin, latmax=latmax, lonmin=lonmin, lonmax=lonmax, lat=self.lat, lon=self.lon)
        self.assertTrue(np.all(D.data-tmp[self.ymin:self.ymax+1,self.xmin:self.xmax+1] == 0.))