Package net.ivoa.fits

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


    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

   *             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

    } 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

    } 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

    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

    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

    } else if (bases[col] == boolean.class) {
      tform += "L";
    } else if (bases[col] == String.class) {
      tform += "A";
    } else {
      throw new FitsException("Invalid column data class:" + bases[col]);
    }

    String key = "TFORM" + (col + 1);
    iter.add(key, new HeaderCard(key, tform, null));
View Full Code Here

    ColumnTable table;

    try {
      table = new ColumnTable(arrCol, sizes);
    } catch (TableException e) {
      throw new FitsException("Unable to create table:" + e);
    }

    return table;
  }
View Full Code Here

   * @return A row of data.
   */
  public Object[] getRow(int row) throws FitsException {

    if (!validRow(row)) {
      throw new FitsException("Invalid row");
    }

    Object[] res;
    if (table != null) {
      res = getMemoryRow(row);
View Full Code Here

TOP

Related Classes of net.ivoa.fits.FitsException

Copyright © 2018 www.massapicom. 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.