Examples of FitsException


Examples of net.ivoa.fits.FitsException

    Class baseClass;

    int gCount = h.getIntValue("GCOUNT", 1);
    int pCount = h.getIntValue("PCOUNT", 0);
    if (gCount > 1 || pCount != 0) {
      throw new FitsException("Group data treated as images");
    }

    bitpix = (int) h.getIntValue("BITPIX", 0);

    baseClass = getType(h);

    ndim = h.getIntValue("NAXIS", 0);
    dims = new int[ndim];

    // Note that we have to invert the order of the axes
    // for the FITS file to get the order in the array we
    // are generating.

    byteSize = 1;
    for (i = 0; i < ndim; i += 1) {
      int cdim = h.getIntValue("NAXIS" + (i + 1), 0);
      if (cdim < 0) {
        throw new FitsException("Invalid array dimension:" + cdim);
      }
      byteSize *= cdim;
      dims[ndim - i - 1] = (int) cdim;
    }
    byteSize *= Math.abs(bitpix) / 8;
View Full Code Here

Examples of net.ivoa.fits.FitsException

    String classname = dataArray.getClass().getName();

    int[] dimens = ArrayFuncs.getDimensions(dataArray);

    if (dimens == null || dimens.length == 0) {
      throw new FitsException("Image data object not array");
    }

    int bitpix = getBitPix();

    // if this is neither a primary header nor an image extension,
    // make it a primary header
    head.setSimple(true);
    head.setBitpix(bitpix);
    head.setNaxes(dimens.length);

    for (int i = 1; i <= dimens.length; i += 1) {
      if (dimens[i - 1] == -1) {
        throw new FitsException("Unfilled array for dimension: " + i);
      }
      head.setNaxis(i, dimens[dimens.length - i]);
    }
    head.addValue("EXTEND", true, "Extension permitted"); // Just in case!
    head.addValue("PCOUNT", 0, "No extra parameters");
View Full Code Here

Examples of net.ivoa.fits.FitsException

      tiler = new ImageDataTiler((RandomAccess) i, ((RandomAccess) i)
          .getFilePointer(), dataDescription);
      try {
        i.skipBytes((int) byteSize);
      } catch (IOException e) {
        throw new FitsException("Unable to skip over data:" + e);
      }

    } else {
      dataArray = ArrayFuncs.newInstance(dataDescription.type,
          dataDescription.dims);
      try {
        i.readArray(dataArray);
      } catch (IOException e) {
        throw new FitsException("Unable to read image data:" + e);
      }

      tiler = new ImageDataTiler(null, 0, dataDescription);
    }

    int pad = FitsUtil.padding(getTrueSize());
    try {
      if (i.skipBytes(pad) != pad) {
        throw new FitsException("Error skipping padding");
      }
    } catch (IOException e) {
      throw new FitsException("Error reading image padding (" + pad
          + " bytes) :" + e);
    }
  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

        // Need to read in the whole image first.
        try {
          dataArray = tiler.getCompleteImage();
        } catch (IOException e) {
          throw new FitsException("Error attempting to fill image");
        }

      } else if (dataArray == null && dataDescription != null) {
        // Need to create an array to match a specified header.
        dataArray = ArrayFuncs.newInstance(dataDescription.type,
            dataDescription.dims);

      } else {
        // This image isn't ready to be written!
        throw new FitsException("Null image data");
      }
    }

    try {
      o.writeArray(dataArray);
    } catch (IOException e) {
      throw new FitsException("IO Error on image write" + e);
    }

    byte[] padding = new byte[FitsUtil.padding(getTrueSize())];
    try {
      o.write(padding);
      o.flush();
    } catch (IOException e) {
      throw new FitsException("Error writing padding: " + e);
    }

  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

    String classname = dataArray.getClass().getName();

    int[] dimens = ArrayFuncs.getDimensions(dataArray);

    if (dimens == null || dimens.length == 0) {
      throw new FitsException("Image data object not array");
    }

    switch (classname.charAt(dimens.length)) {
      case 'B' :
        return 8;
      case 'S' :
        return 16;
      case 'C' :
        return -16;
      case 'I' :
        return 32;
      case 'J' :
        return 64;
      case 'F' :
        return -32;
      case 'D' :
        return -64;
      default :
        throw new FitsException("Invalid Object Type for FITS data:"
            + classname.charAt(dimens.length));
    }
  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

   *             when file isn't image
   */
  public int[] getAxesDimens() throws FitsException {
    int[] dimensinv = ArrayFuncs.getDimensions(dataArray);
    if (dimensinv == null || dimensinv.length == 0) {
      throw new FitsException("Image data object not array");
    }
    int[] dimens = new int[dimensinv.length];
    for (int i = 1; i <= dimens.length; i += 1)
      dimens[i - 1] = dimensinv[dimens.length - i];

View Full Code Here

Examples of net.ivoa.fits.FitsException

    } else if (bitpix == -32) {
      return Float.TYPE;
    } else if (bitpix == -64) {
      return Double.TYPE;
    } else {
      throw new FitsException("Invalid BITPIX:" + bitpix);
    }
  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

    } else if (dbase == float.class) {
      return -32;
    } else if (dbase == double.class) {
      return -64;
    } else {
      throw new FitsException("Data type:" + dbase + " not supported.");
    }
  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

    if (heapOffset > 0) {
      heapOffset -= nRow * rwsz;
    }

    if (heapOffset > heapSize) {
      throw new FitsException("Inconsistent THEAP and PCOUNT");
    }

    heap = new FitsHeap(heapSize - heapOffset);
    nCol = myHeader.getIntValue("TFIELDS");
    rowLen = 0;
View Full Code Here

Examples of net.ivoa.fits.FitsException

    String tform = header.getStringValue("TFORM" + (col + 1)).trim();
    String tdims = header.getStringValue("TDIM" + (col + 1), null);

    if (tform == null) {
      throw new FitsException("No TFORM for column:" + col);
    }
    if (tdims != null) {
      tdims = tdims.trim();
    }

    char type = getTformType(tform);
    if (type == 'P') {
      flags[col] |= COL_VARYING;
      type = getTformVarType(tform);
    }

    int size = getTformLength(tform);

    // Get number of bytes for a bit array.
    if (type == 'X') {
      size = (size + 7) / 8;
      flags[col] |= COL_BIT;

    } else if ((flags[col] & COL_VARYING) != 0) {
      size = 2;
    }
    int bSize = size;

    int[] dims = null;

    // Cannot really handle arbitrary arrays of bits.

    if (tdims != null && type != 'X' && (flags[col] & COL_VARYING) == 0) {
      dims = getTDims(tdims);
    }

    if (dims == null) {
      dims = new int[]{size};
    }

    if (type == 'C' || type == 'M') {
      flags[col] |= COL_COMPLEX;
    }

    Class colBase = null;

    switch (type) {
      case 'A' :
        colBase = byte.class;
        flags[col] |= COL_STRING;
        bases[col] = String.class;
        break;
      case 'L' :
        colBase = byte.class;
        bases[col] = boolean.class;
        flags[col] |= COL_BOOLEAN;
        break;
      case 'X' :
      case 'B' :
        colBase = byte.class;
        bases[col] = byte.class;
        break;

      case 'I' :
        colBase = short.class;
        bases[col] = short.class;
        bSize *= 2;
        break;

      case 'J' :
        colBase = int.class;
        bases[col] = int.class;
        bSize *= 4;
        break;

      case 'K' :
        colBase = long.class;
        bases[col] = long.class;
        bSize *= 8;
        break;
      case 'E' :
      case 'C' :
        colBase = float.class;
        bases[col] = float.class;
        bSize *= 4;
        break;
      case 'D' :
      case 'M' :
        colBase = double.class;
        bases[col] = double.class;
        bSize *= 8;
        break;

      default :
        throw new FitsException("Invalid type in column:" + col);
    }

    if ((flags[col] & COL_VARYING) != 0) {
      dims = new int[]{nRow, 2};
      colBase = int.class;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.