Beispiel #1
0
  @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();
  }
Beispiel #2
0
  @Test
  public void testFitsSkipHdu() throws Exception {
    Fits fits1 = makeAsciiTable();

    BasicHDU<?> image = fits1.readHDU();
    AsciiTableHDU hdu2 = (AsciiTableHDU) fits1.readHDU();
    fits1.skipHDU(2);
    AsciiTableHDU hdu3 = (AsciiTableHDU) fits1.readHDU();

    hdu2.info(System.out);
    hdu3.info(System.out);
    Assert.assertArrayEquals(new int[] {11}, (int[]) hdu2.getData().getElement(1, 1));
    Assert.assertArrayEquals(new int[] {41}, (int[]) hdu3.getData().getElement(1, 1));
    hdu3.getData();
  }
Beispiel #3
0
  @Test
  public void convertAsciiToBinaryTable() throws Exception {
    FitsFactory.setUseAsciiTables(false);

    Fits fits1 = makeAsciiTable();

    fits1.readHDU();
    BinaryTableHDU hdu2 = (BinaryTableHDU) fits1.readHDU();
    fits1.skipHDU(2);
    BinaryTableHDU hdu3 = (BinaryTableHDU) fits1.readHDU();

    hdu2.info(System.out);
    hdu3.info(System.out);
    Assert.assertArrayEquals(new int[] {11}, (int[]) hdu2.getData().getElement(1, 1));
    Assert.assertArrayEquals(new int[] {41}, (int[]) hdu3.getData().getElement(1, 1));
    hdu3.getData();
  }
Beispiel #4
0
 @Test
 public void testDifferentTypes() throws Exception {
   FitsException actual = null;
   try {
     new Fits((String) null, false);
   } catch (FitsException ex) {
     actual = ex;
   }
   Assert.assertNotNull(actual);
   try (Fits fits = new Fits("nom/tam/fits/test/test.fits", false)) {
     Assert.assertNotNull(fits.readHDU());
     Assert.assertEquals(1, fits.currentSize());
   }
   try (Fits fits =
       new Fits(
           "file://"
               + new File("src/test/resources/nom/tam/fits/test/test.fits").getAbsolutePath(),
           false)) {
     Assert.assertNotNull(fits.readHDU());
   }
   actual = null;
   try {
     new Fits(
         "file://" + new File("src/test/resources/nom/tam/fits/test/test.fitsX").getAbsolutePath(),
         false);
   } catch (FitsException ex) {
     actual = ex;
   }
   Assert.assertNotNull(actual);
   actual = null;
   try {
     new Fits(
         new URL(
             "file://"
                 + new File("src/test/resources/nom/tam/fits/test/test.fitsX").getAbsolutePath()),
         false);
   } catch (FitsException ex) {
     actual = ex;
   }
   Assert.assertNotNull(actual);
   try (Fits fits = new Fits("src/test/resources/nom/tam/fits/test/test.fits", false)) {
     Assert.assertNotNull(fits.readHDU());
   }
 }