Package net.ivoa.fits.hdu

Examples of net.ivoa.fits.hdu.BinaryTableHDU


  public void testTable1() throws Exception {
    Fits f = new Fits();
    f.addHDU(Fits.makeHDU(new Object[]{bytes, bits, bools, shorts, ints,
        floats, doubles, longs, strings}));

    BinaryTableHDU bhdu = (BinaryTableHDU) f.getHDU(1);
    bhdu.setColumnName(0, "bytes", null);
    bhdu.setColumnName(1, "bits", "bits later on");
    bhdu.setColumnName(6, "doubles", null);
    bhdu.setColumnName(5, "floats", "4 x 4 array");

    BufferedFile bf = new BufferedFile("bt1.fits", "rw");

    f.write(bf);
    bf.flush();
    bf.close();

    // read file
    f = new Fits("bt1.fits");
    BasicHDU hdu;

    f.read();
    for (int i = 0; i < f.getNumberOfHDUs(); i += 1) {
      hdu = f.getHDU(i);
    }

    BinaryTableHDU thdu = (BinaryTableHDU) f.getHDU(1);
    byte[] tb = (byte[]) thdu.getColumn(0);
    byte[][] tbits = (byte[][]) thdu.getColumn(1);
    boolean[] tbools = (boolean[]) thdu.getColumn(2);
    short[][] tsh = (short[][]) thdu.getColumn(3);
    int[] tints = (int[]) thdu.getColumn(4);
    float[][][] tflt = (float[][][]) thdu.getColumn(5);
    double[] tdoub = (double[]) thdu.getColumn(6);
    long[] tlong = (long[]) thdu.getColumn(7);
    String[] tstr = (String[]) thdu.getColumn(8);

    for (int i = 0; i < tb.length; i += 1) {
      assertEquals(bytes[i], tb[i]);
      for (int j = 0; j < 2; j += 1) {
        assertEquals(bits[i][j], tbits[i][j]);
View Full Code Here


    f.read();
    for (int i = 0; i < f.getNumberOfHDUs(); i += 1) {
      f.getHDU(i).toString();
    }

    BinaryTableHDU bhdu = (BinaryTableHDU) f.getHDU(1);

    float[][] tvf = (float[][]) bhdu.getColumn(1);
    short[][] tvs = (short[][]) bhdu.getColumn(2);
    double[][] tvd = (double[][]) bhdu.getColumn(3);
    boolean[][] tvbool = (boolean[][]) bhdu.getColumn(5);

    for (int i = 0; i < 50; i += 10) {
      assertEquals(vf[i].length, tvf[i].length);
      assertEquals(vs[i].length, tvs[i].length);
      assertEquals(vd[i].length, tvd[i].length);
View Full Code Here

    BufferedDataOutputStream bdos = new BufferedDataOutputStream(
        new FileOutputStream("bt3.fits"));
    f.write(bdos);

    f = new Fits("bt3.fits");
    BinaryTableHDU bhdu = (BinaryTableHDU) f.getHDU(1);
    btab = (BinaryTable) bhdu.getData();

    float[] flatfloat = (float[]) btab.getFlattenedColumn(0);
    float[][] tvf = (float[][]) btab.getColumn(1);
    String[] xstr = (String[]) btab.getColumn(2);
    boolean[][] tvbool = (boolean[][]) btab.getColumn(3);
View Full Code Here

    } 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);
    }

    return null;
View Full Code Here

TOP

Related Classes of net.ivoa.fits.hdu.BinaryTableHDU

Copyright © 2018 www.massapicom. 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.