Examples of AsciiTableHDU


Examples of net.ivoa.fits.hdu.AsciiTableHDU

  }

  public void testAsciiTableRead() throws Exception {
    f = new Fits("at1.fits");

    AsciiTableHDU hdu = (AsciiTableHDU) f.getHDU(1);
    Object[] info = (Object[]) hdu.getKernel();
    float[] f1 = (float[]) info[0];
    String[] s1 = (String[]) info[4];

    for (int i = 0; i < f1.length; i += 1) {
      assertEquals(realCol[i], f1[i], 0.0f);
View Full Code Here

Examples of net.ivoa.fits.hdu.AsciiTableHDU

      assertEquals(strCol[i], s1[i].trim());
    }

    f = new Fits("at1.fits");

    AsciiTableHDU hdu = (AsciiTableHDU) f.getHDU(1);
    AsciiTable data = (AsciiTable) hdu.getData();

    for (int i = 0; i < 10; i += 1) {
      Object[] row = data.getRow(i);
      float[] f2 = (float[]) row[0];
      String[] s2 = (String[]) row[4];
      f1 = (float[]) data.getElement(i, 0);
      s1 = (String[]) data.getElement(i, 4);
      assertEquals(f1[0], f2[0], 0.0f);
      assertEquals(s1[0], s2[0]);
    }

    f1 = (float[]) data.getColumn(0);
    s1 = (String[]) data.getColumn(4);
    for (int i = 0; i < 10; i += 1) {
      assertEquals(realCol[i], f1[i], 0.0f);
      assertEquals(s1[i].trim(), strCol[i]);
    }

    for (int i = 0; i < 10; i += 1) {
      Object[] row = data.getRow(i);
      f1 = (float[]) row[0];
      s1 = (String[]) row[4];
      float[] f2 = (float[]) data.getElement(i, 0);
      String[] s2 = (String[]) data.getElement(i, 4);
      assertEquals(f1[0], f2[0], 0.0f);
      assertEquals(s1[0], s2[0]);
    }

    f1 = (float[]) data.getColumn(0);
    float[] f2 = (float[]) f1.clone();
    for (int i = 0; i < f2.length; i += 1) {
      f2[i] = 2 * f2[i];
    }

    data.setColumn(0, f2);
    f1 = new float[]{3.14159f};
    data.setElement(3, 0, f1);

    hdu.setNullString(0, "**INVALID**");
    data.setNull(5, 0, true);
    data.setNull(6, 0, true);

    Object[] row = new Object[5];
    row[0] = new float[]{6.28f};
    row[1] = new int[]{22};
    row[2] = new long[]{0};
    row[3] = new double[]{-3};
    row[4] = new String[]{"A string"};
    data.setRow(4, row);

    // Rewrite (for grins rewrite header second)
    hdu.getHeader().rewrite();

    BufferedFile bf = new BufferedFile("at1.fits", "rw");
    f.write(bf);

    bf.flush();
View Full Code Here

Examples of net.ivoa.fits.hdu.AsciiTableHDU

    if (d instanceof ImageData) {
      return new ImageHDU(hdr, d);
    } else if (d instanceof RandomGroupsData) {
      return new RandomGroupsHDU(hdr, d);
    } else if (d instanceof AsciiTable) {
      return new AsciiTableHDU(hdr, d);
    } else if (d instanceof BinaryTable) {
      return new BinaryTableHDU(hdr, d);
    } else if (d instanceof UndefinedData) {
      return new UndefinedHDU(hdr, d);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.