コード例 #1
0
ファイル: BaseFitsTest.java プロジェクト: LCOGT/nom-tam-fits
  @Test
  public void testFitsDeleteHdu() throws Exception {
    try (Fits fits1 = makeAsciiTable()) {
      fits1.read();
      Exception actual = null;
      try {
        fits1.deleteHDU(-2);
      } catch (FitsException ex) {
        actual = ex;
      }
      Assert.assertNotNull(actual);

      Assert.assertNull(fits1.getHDU(99));
      // will be ignored
      fits1.insertHDU(null, 99);
      fits1.deleteHDU(2);
      fits1.deleteHDU(2);
      writeFile(fits1, TARGET_BASIC_FITS_TEST_FITS);
    }

    Fits fits1 = new Fits(new File(TARGET_BASIC_FITS_TEST_FITS));
    fits1.readHDU();
    AsciiTableHDU hdu2 = (AsciiTableHDU) fits1.readHDU();
    AsciiTableHDU hdu3 = (AsciiTableHDU) fits1.readHDU();
    Assert.assertArrayEquals(new int[] {11}, (int[]) hdu2.getData().getElement(1, 1));
    Assert.assertArrayEquals(new int[] {41}, (int[]) hdu3.getData().getElement(1, 1));
    hdu3.getData();
  }
コード例 #2
0
ファイル: BaseFitsTest.java プロジェクト: LCOGT/nom-tam-fits
  @Test
  public void testFitsDeleteHduNewPrimary() throws Exception {
    Fits fits1 = makeAsciiTable();
    fits1.read();
    fits1.deleteHDU(0);
    for (int index = 0; index < 4; index++) {
      fits1.deleteHDU(1);
    }
    BasicHDU<?> dummyHDU = BasicHDU.getDummyHDU();
    dummyHDU.addValue("TEST", "XYZ", null);
    fits1.addHDU(dummyHDU);
    fits1.deleteHDU(0);
    writeFile(fits1, TARGET_BASIC_FITS_TEST_FITS);

    fits1 = new Fits(new File(TARGET_BASIC_FITS_TEST_FITS));
    Assert.assertEquals(1, fits1.read().length);
    Assert.assertEquals("XYZ", fits1.getHDU(0).getTrimmedString("TEST"));
  }