def test_xcreateRaster3(self):
        """Test can create img files"""
        file_is = 'test.img'

        f_img = tempfile.NamedTemporaryFile(suffix='.tif',
                                        prefix='test_proMult',
                                        delete=False)
        f_img.close()

        gust = np.asarray([[1., -1., 10, -10.],
                         [100., -100., 1000, -1000.]])
        lon = np.asarray([136, 138, 140, 142]) # 136 is used
        lat = np.array([-22, -20]) # -22 is used

        result = pM.createRaster(gust, lon, lat,
                                 2, -2,
                                 filename=f_img.name)
        minx, miny, maxx, maxy, data = pM.loadRasterFileBandLonLat(f_img.name)

        self.assertEqual(minx, 136)
        self.assertEqual(maxx, 144)
        self.assertEqual(miny, -24)
        self.assertEqual(maxy, -20)

        # This isn't working in this test
        # but works in
        # test_xprocessMult_A
        # assert_almost_equal(np.flipud(gust), data)

        del result
        os.remove(f_img.name)
    def test_xprocessMult_A(self):
        dir_path = tempfile.mkdtemp(prefix='test_processMult')
        
        tmp_m4_file = tempfile.NamedTemporaryFile(suffix='.img', 
                                            prefix="test_processMult",
                                            delete=False)
        tmp_m4_file.close()
        
        pM.generate_syn_mult_img(136, -20, 2, dir_path, shape=(2, 4))

        # Top to bottom format.
        # Which is the wrong format
        uu = np.asarray([[0., -1., -1., -1.],
                         [0., 1., 1., 1.]])
        vv = np.asarray([[-1., -1., 0, 1.],
                         [1., 1., 0, -1.]])
        gust = np.asarray([[1., -1., 10, -10.],
                         [100., -100., 1000, -1000.]])

        # Bottom to top
        # This is the format required by the interface
        uu = np.asarray([[0., 1., 1., 1.],
                         [0., -1., -1., -1.]])
        vv = np.asarray([[1., 1., 0, -1.],
                         [-1., -1., 0, 1.]])
        gust = np.asarray([[100., -100., 1000, -1000.],
                         [1., -1., 10, -10.]])


        lon = np.asarray([136, 138, 140, 142])
        lat = np.array([-22, -20])
        windfield_path = os.path.dirname(tmp_m4_file.name) #dir_path # write the output to the multiplier dir
        multiplier_path = os.path.basename(tmp_m4_file.name)#dir_path

        output_file = pM.processMult(gust, uu, vv, lon, lat, windfield_path,
                       multiplier_path)

        minx, miny, maxx, maxy, data = pM.loadRasterFileBandLonLat(output_file)

        actual = np.asarray([[0., -1., 20, -30.],
                         [400., -500., 6000, -7000.]])

        # print 'dir_path', dir_path

        assert_almost_equal(data, actual)
        self.assertEqual(minx, 136)
        self.assertEqual(maxx, 144)
        self.assertEqual(miny, -24)
        self.assertEqual(maxy, -20)

        shutil.rmtree(dir_path)