コード例 #1
0
ファイル: BaseFitsTest.java プロジェクト: LCOGT/nom-tam-fits
  @Test
  public void testFitsUndefinedHdu4() throws Exception {
    Fits fits1 = makeAsciiTable();
    fits1.read();
    byte[] undefinedData = new byte[1000];
    for (int index = 0; index < undefinedData.length; index++) {
      undefinedData[index] = (byte) index;
    }
    Data data = UndefinedHDU.encapsulate(undefinedData);
    Header header = new Header();
    header.pointToData(data);

    fits1.addHDU(FitsFactory.hduFactory(header, data));
    BufferedDataOutputStream os =
        new BufferedDataOutputStream(new FileOutputStream("target/UndefindedHDU4.fits"));
    fits1.write(os);
    os.close();

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

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

    ByteArrayOutputStream out = new ByteArrayOutputStream();
    hdus[hdus.length - 1].info(new PrintStream(out));
    String undefinedInfo = new String(out.toByteArray());

    Assert.assertTrue(undefinedInfo.indexOf("Apparent size:1000") >= 0);
  }
コード例 #2
0
ファイル: BaseFitsTest.java プロジェクト: LCOGT/nom-tam-fits
  @Test
  public void testFitsUndefinedHdu3() throws Exception {
    Fits fits1 = makeAsciiTable();
    fits1.read();
    byte[] undefinedData = new byte[1000];
    for (int index = 0; index < undefinedData.length; index++) {
      undefinedData[index] = (byte) index;
    }
    Data data = UndefinedHDU.encapsulate(undefinedData);
    Header header = new Header(data);

    Cursor<String, HeaderCard> iter = header.iterator();

    String[] headers = new String[header.getNumberOfCards() - 1];
    int index = 0;
    while (iter.hasNext()) {
      HeaderCard headerCard = iter.next();
      // the EXTEND key will be deleted later on because the header is no
      // primary header so don't use it
      if (!headerCard.getKey().equals("EXTEND")) {
        headers[index++] = headerCard.toString();
      }
    }
    Header newHeader = new Header(headers);
    for (index = 0; index < headers.length; index++) {
      Assert.assertEquals(header.getCard(index), newHeader.getCard(index));
    }

    fits1.addHDU(FitsFactory.hduFactory(newHeader, data));
    BufferedDataOutputStream os =
        new BufferedDataOutputStream(new FileOutputStream("target/UndefindedHDU3.fits"));
    fits1.write(os);
    os.close();

    Fits fits2 = new Fits("target/UndefindedHDU3.fits");
    BasicHDU[] hdus = fits2.read();

    for (index = 0; index < headers.length; index++) {
      Assert.assertEquals(header.getCard(index), hdus[5].getHeader().getCard(index));
    }
  }
コード例 #3
0
ファイル: BaseFitsTest.java プロジェクト: LCOGT/nom-tam-fits
  @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);
  }
コード例 #4
0
ファイル: BaseFitsTest.java プロジェクト: LCOGT/nom-tam-fits
  @Test
  public void testFitsUndefinedHdu2() throws Exception {
    Fits fits1 = makeAsciiTable();
    fits1.read();
    byte[] undefinedData = new byte[1000];
    for (int index = 0; index < undefinedData.length; index++) {
      undefinedData[index] = (byte) index;
    }
    Data data = UndefinedHDU.encapsulate(undefinedData);
    Header header = UndefinedHDU.manufactureHeader(data);

    fits1.addHDU(FitsFactory.HDUFactory(header, data));
    BufferedDataOutputStream os =
        new BufferedDataOutputStream(new FileOutputStream("target/UndefindedHDU2.fits"));
    fits1.write(os);
    os.close();

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

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