1 package nom.tam.fits.test;
5 import nom.tam.image.ImageTiler;
10 import static org.junit.Assert.assertEquals;
11 import junit.framework.JUnit4TestAdapter;
13 /** This class tests the ImageTiler. It
14 * first creates a FITS file and then reads
15 * it back and allows the user to select
16 * tiles. The values of the corner and center
17 * pixels for the selected tile are displayed.
18 * Both file and memory tiles are checked.
20 public class TilerTest {
22 void doTile(String test,
25 int x, int y, int nx, int ny)
28 float[] tile = new float[nx * ny];
29 t.getTile(tile, new int[]{y, x}, new int[]{ny, nx});
35 for (int i = 0; i < nx; i += 1) {
36 for (int j = 0; j < ny; j += 1) {
37 sum0 += tile[i + j * nx];
38 sum1 += data[j + y][i + x];
42 assertEquals("Tiler" + test, sum0, sum1, 0);
46 public void test() throws Exception {
48 float[][] data = new float[300][300];
50 for (int i = 0; i < 300; i += 1) {
51 for (int j = 0; j < 300; j += 1) {
52 data[i][j] = 1000 * i + j;
58 BufferedFile bf = new BufferedFile("tiler1.fits", "rw");
59 f.addHDU(Fits.makeHDU(data));
64 f = new Fits("tiler1.fits");
66 ImageHDU h = (ImageHDU) f.readHDU();
68 ImageTiler t = h.getTiler();
69 doTile("t1", data, t, 200, 200, 50, 50);
70 doTile("t2", data, t, 133, 133, 72, 26);
72 Object o = h.getData().getKernel();
73 doTile("t3", data, t, 200, 200, 50, 50);
74 doTile("t4", data, t, 133, 133, 72, 26);