Exemplo n.º 1
0
  private Fits makeAsciiTable() throws Exception {
    // Create the new ASCII table.
    Fits f = new Fits();
    f.addHDU(Fits.makeHDU(getSampleCols(10f)));
    f.addHDU(Fits.makeHDU(getSampleCols(20f)));
    f.addHDU(Fits.makeHDU(getSampleCols(30f)));
    f.addHDU(Fits.makeHDU(getSampleCols(40f)));

    writeFile(f, TARGET_BASIC_FITS_TEST_FITS);

    return new Fits(new File(TARGET_BASIC_FITS_TEST_FITS));
  }
Exemplo n.º 2
0
 @Test
 public void testHduFromHeader() throws Exception {
   Header header = new Header();
   header.addValue("SIMPLE", true, "");
   header.addValue("BITPIX", 8, "");
   header.addValue("NAXIS", 2, "");
   header.addValue("NAXIS1", 4, "");
   header.addValue("NAXIS3", 4, "");
   ImageHDU hdu = (ImageHDU) Fits.makeHDU(header);
   Assert.assertNotNull(hdu);
 }
Exemplo n.º 3
0
  @Test
  public void testFitsUndefinedHdu() throws Exception {
    Fits fits1 = makeAsciiTable();
    fits1.read();
    byte[] undefinedData = new byte[1000];
    for (int index = 0; index < undefinedData.length; index++) {
      undefinedData[index] = (byte) index;
    }
    fits1.addHDU(Fits.makeHDU(new UndefinedData(undefinedData)));
    BufferedDataOutputStream os =
        new BufferedDataOutputStream(new FileOutputStream("target/UndefindedHDU.fits"));
    fits1.write(os);
    os.close();

    Fits fits2 = new Fits("target/UndefindedHDU.fits");
    BasicHDU<?>[] hdus = fits2.read();

    byte[] rereadUndefinedData =
        (byte[]) ((UndefinedData) hdus[hdus.length - 1].getData()).getData();
    Assert.assertArrayEquals(undefinedData, rereadUndefinedData);
  }