Exemple #1
0
 // TODO handle uncaught exceptions
 public FitsImage(Fits fitsFile, ImageController controller) throws FitsException, IOException {
   this.controller = controller;
   this.fitsFile = fitsFile;
   this.hdu = (ImageHDU) fitsFile.getHDU(0);
   ;
   width = hdu.getAxes()[1];
   height = hdu.getAxes()[0];
   this.tiler = hdu.getTiler();
   setNanColour(controller.getNanColour());
   prepareData();
   createHistogram();
   minValue = histogram.getMinValue();
   maxValue = histogram.getMaxValue();
   writeImage();
 }
Exemple #2
0
  private void prepareData() {

    double[] img = null;
    try {
      Object dataArray = tiler.getTile(new int[] {0, 0}, hdu.getAxes());
      img = (double[]) ArrayFuncs.convertArray(dataArray, double.class);
      data = (float[]) ArrayFuncs.convertArray(img, float.class);
      processingFriendlyData = (double[][]) ArrayFuncs.convertArray(hdu.getKernel(), double.class);
      imageFriendlyData = new double[width * height];
      for (int h = height - 1; h >= 0; h--) {
        for (int w = 0; w < width; w++) {
          imageFriendlyData[h * width + w] = (img[(height - 1 - h) * width + w]);
        }
      }
    } catch (IOException | FitsException e) {
      e.printStackTrace();
    }

    System.out.println(processingFriendlyData.length + ", " + processingFriendlyData[0].length);
  }
Exemple #3
0
 /**
  * this test is only for manual usage with enough memory allocated.
  *
  * @throws Exception
  */
 @Test
 @Ignore
 public void testVeryBigDataFiles() throws Exception {
   Fits f = new Fits();
   ImageData data = new ImageData(new float[50000][50000]);
   Header manufactureHeader = ImageHDU.manufactureHeader(data);
   f.addHDU(FitsFactory.hduFactory(manufactureHeader, data));
   BufferedFile bf = new BufferedFile("target/big.fits", "rw");
   f.write(bf);
   System.out.println(Arrays.toString(ArrayFuncs.getDimensions(f.getHDU(0).getData().getData())));
   f = new Fits("target/big.fits");
   System.out.println(Arrays.toString(ArrayFuncs.getDimensions(f.getHDU(0).getData().getData())));
 }
Exemple #4
0
  @Test
  public void testBigDataSegments() throws Exception {
    ImageData data = new ImageData(new float[4][4]);

    Header manufactureHeader = ImageHDU.manufactureHeader(data);
    manufactureHeader.card(Standard.END).comment("");
    manufactureHeader.findCard(Standard.NAXIS1).setValue(25000);
    manufactureHeader.findCard(Standard.NAXIS2).setValue(25000);

    long value = manufactureHeader.getDataSize();
    int intValue = (int) manufactureHeader.getDataSize();
    assertEquals(2500001280L, value);
    Assert.assertTrue(intValue != value);
  }
Exemple #5
0
  public String getHeaderString() {
    Header hdr = hdu.getHeader();
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    hdr.dumpHeader(ps);
    String hdrString = baos.toString();
    try {
      baos.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
    ps.close();

    return hdrString;
  }
Exemple #6
0
  public String getWcsHeaderCardsString() {
    Header header = hdu.getHeader();
    Header filteredHeader = new Header();

    // now adjust WCS values:
    ArrayList<HeaderCard> cards = new ArrayList<HeaderCard>();
    cards.add(header.findCard("CTYPE1"));
    cards.add(header.findCard("CTYPE2"));
    cards.add(header.findCard("RADESYS"));
    cards.add(header.findCard("RADECSYS"));
    cards.add(header.findCard("CRVAL1"));
    cards.add(header.findCard("CRVAL2"));
    cards.add(header.findCard("CDELT1"));
    cards.add(header.findCard("CDELT2"));
    cards.add(header.findCard("EQUINOX"));
    cards.add(header.findCard("BUNIT"));
    cards.add(header.findCard("EPOCH"));
    cards.add(header.findCard("CD1_1"));
    cards.add(header.findCard("CD1_2"));
    cards.add(header.findCard("CD2_1"));
    cards.add(header.findCard("CD2_2"));
    cards.add(header.findCard("CRPIX1"));
    cards.add(header.findCard("CRPIX2"));
    cards.add(header.findCard("END"));

    cards.forEach(
        (card) -> {
          if (card != null) {
            try {
              filteredHeader.addLine(card);
            } catch (Exception e) {
              e.printStackTrace();
            }
          }
        });
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream ps = new PrintStream(baos);
    filteredHeader.dumpHeader(ps);
    String wcsHdrString = baos.toString();
    try {
      baos.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
    ps.close();

    return wcsHdrString;
  }
Exemple #7
0
 public double getCRVAL2() {
   return hdu.getHeader().getDoubleValue("CRVAL2");
 }