Examples of FitsException


Examples of net.ivoa.fits.FitsException

      myData.write(stream);
    }
    try {
      stream.flush();
    } catch (java.io.IOException e) {
      throw new FitsException("Error flushing at end of HDU: "
          + e.getMessage());
    }
  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

    if (rewriteable()) {
      myHeader.rewrite();
      myData.rewrite();
    } else {
      throw new FitsException("Invalid attempt to rewrite HDU");
    }
  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

      case BITPIX_INT :
      case BITPIX_FLOAT :
      case BITPIX_DOUBLE :
        break;
      default :
        throw new FitsException("Unknown BITPIX type " + bitpix);
    }

    return bitpix;
  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

  }

  public int[] getAxes() throws FitsException {
    int nAxis = myHeader.getIntValue("NAXIS", 0);
    if (nAxis < 0) {
      throw new FitsException("Negative NAXIS value " + nAxis);
    }
    if (nAxis > 999) {
      throw new FitsException("NAXIS value " + nAxis + " too large");
    }

    if (nAxis == 0) {
      return null;
    }
View Full Code Here

Examples of net.ivoa.fits.FitsException

  /** Indicate that an HDU is the first element of a FITS file. */
  public void setPrimaryHDU(boolean newPrimary) throws FitsException {

    if (newPrimary && !canBePrimary()) {
      throw new FitsException("Invalid attempt to make HDU of type:"
          + this.getClass().getName() + " primary.");
    } else {
      this.isPrimary = newPrimary;
    }

View Full Code Here

Examples of net.ivoa.fits.FitsException

    if (i instanceof RandomAccess) {
      try {
        i.skipBytes((int) byteSize);
      } catch (IOException e) {
        throw new FitsException("Unable to skip over data:" + e);
      }

    } else {
      try {
        i.readFully(data);
      } catch (IOException e) {
        throw new FitsException("Unable to read unknown data:" + e);
      }

    }

    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 unknown padding:" + e);
    }
  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

    if (data == null) {
      getData();
    }

    if (data == null) {
      throw new FitsException("Null unknown data");
    }

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

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

  }
View Full Code Here

Examples of net.ivoa.fits.FitsException

        setFileOffset(str);

        try {
            str.readArray(dataArray);
        } catch (IOException e) {
            throw new FitsException("IO error reading Random Groups data " + e);
        }
        int pad = FitsUtil.padding(getTrueSize());
        try {
            str.skipBytes(pad);
        } catch (IOException e) {
            throw new FitsException("IO error reading padding.");
        }
    }
View Full Code Here

Examples of net.ivoa.fits.FitsException

            str.writeArray(dataArray);
            byte[] padding = new byte[FitsUtil.padding(getTrueSize())];
            str.write(padding);
            str.flush();
        } catch (IOException e) {
            throw new FitsException("IO error writing random groups data " + e);
        }
    }
View Full Code Here

Examples of net.ivoa.fits.FitsException

    }

    public void fillHeader(Header h) throws FitsException {

        if (dataArray.length <= 0 || dataArray[0].length != 2) {
            throw new FitsException("Data not conformable to Random Groups");
        }

        int gcount = dataArray.length;
        Object paraSamp = dataArray[0][0];
        Object dataSamp = dataArray[0][1];

        Class pbase = net.ivoa.util.ArrayFuncs.getBaseClass(paraSamp);
        Class dbase = net.ivoa.util.ArrayFuncs.getBaseClass(dataSamp);

        if (pbase != dbase) {
            throw new FitsException(
                    "Data and parameters do not agree in type for random group");
        }

        int[] pdims = net.ivoa.util.ArrayFuncs.getDimensions(paraSamp);
        int[] ddims = net.ivoa.util.ArrayFuncs.getDimensions(dataSamp);

        if (pdims.length != 1) {
            throw new FitsException(
                    "Parameters are not 1 d array for random groups");
        }

        // Got the information we need to build the header.

        h.setSimple(true);
        if (dbase == byte.class) {
            h.setBitpix(8);
        } else if (dbase == short.class) {
            h.setBitpix(16);
        } else if (dbase == char.class) {
            h.setBitpix(-16);
        } else if (dbase == int.class) {
            h.setBitpix(32);
        } else if (dbase == long.class) { // Non-standard
            h.setBitpix(64);
        } else if (dbase == float.class) {
            h.setBitpix(-32);
        } else if (dbase == double.class) {
            h.setBitpix(-64);
        } else {
            throw new FitsException("Data type:" + dbase
                    + " not supported for random groups");
        }

        h.setNaxes(ddims.length + 1);
        h.addValue("NAXIS1", 0, "");
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.