Examples of BasicHDU


Examples of net.ivoa.fits.hdu.BasicHDU

  public static void main(String[] args) throws Exception {

    FitsFactory.setUseHierarch(true);
    Fits f = new Fits(args[0]);

    BasicHDU h = f.readHDU();

    Header hdr = h.getHeader();
    Cursor c = hdr.iterator();

    while (c.hasNext()) {
      HeaderCard hc = (HeaderCard) c.next();
      System.out.print("Key= " + hc.getKey() + "  ");
View Full Code Here

Examples of nom.tam.fits.BasicHDU

     */
    private void _deleteBinaryTable(Fits fits, String extName) {
        int n = fits.getNumberOfHDUs();
        for (int i = 0; i < n; i++) {
            try {
                BasicHDU hdu = fits.getHDU(i);
                if (hdu instanceof BinaryTableHDU) {
                    if (extName.equals(hdu.getHeader().getStringValue("EXTNAME"))) {
                        fits.deleteHDU(i);
                        break;
                    }
                }
            } catch (Exception ignore) {
View Full Code Here

Examples of nom.tam.fits.BasicHDU

        if (n <= 1) {
            return;
        }

        for (int i = 0; i < n; i++) {
            BasicHDU hdu = fitsImage.getHDU(i);
            if (hdu instanceof TableHDU) {
                Header header = hdu.getHeader();
                String name = header.getStringValue("EXTNAME");
                if (name != null && name.equals(extName)) {
                    try {
                        loadGraphicsFromImage((TableHDU) hdu);
                    } catch (Exception e) {
View Full Code Here

Examples of nom.tam.fits.BasicHDU

     */
    public void deleteHDU(String extName) {
        FITSImage fitsImage = imageDisplay.getFitsImage();
        int n = fitsImage.getNumHDUs();
        for (int i = 0; i < n; i++) {
            BasicHDU hdu = fitsImage.getHDU(i);
            if (hdu instanceof TableHDU) {
                Header header = hdu.getHeader();
                String name = header.getStringValue("EXTNAME");
                if (name != null && name.equals(extName)) {
                    try {
                        fitsImage.getFits().deleteHDU(i);
                    } catch (Exception e) {
View Full Code Here

Examples of nom.tam.fits.BasicHDU

     * Update the display to show the values in the current FITS HDU.
     */
    public void updateDisplay(int hduIndex) {
        FITSImage fitsImage = _imageDisplay.getFitsImage();

        BasicHDU hdu = null;
        if (fitsImage == null || (hdu = fitsImage.getHDU(hduIndex)) == null) {
            _table.setModel(new DefaultTableModel());
            return;
        }

        String[] columnNames = {"Keyword", "Value", "Comment"};
        Header header = hdu.getHeader();
        int numKeywords = header.getNumberOfCards();
        String[][] values = new String[numKeywords][3];
        Iterator it = header.iterator();
        int n = 0;
        while (it.hasNext()) {
View Full Code Here

Examples of nom.tam.fits.BasicHDU

        Header header = hdu.getHeader();
        String name = header.getStringValue("EXTNAME");
        if (name != null) {
            // Check for a stored StarTable, which has a corresponding VOTMETA HDU with more info
            String votMetaName = VOTMETA + name.replace(TABLE_SUFFIX, "");
            BasicHDU votMetaHdu = findHDU(fits, votMetaName);
            if (votMetaHdu != null) {
                Fits tmpFits = new Fits();
                tmpFits.addHDU(votMetaHdu);
                tmpFits.addHDU(hdu);
                votMetaHdu.getHeader().removeCard("EXTNAME"); // not expected by FitsPlusTableBuilder
                votMetaHdu.getHeader().removeCard("EXTEND"); // not expected by FitsPlusTableBuilder
                ByteArrayOutputStream os = new ByteArrayOutputStream();
                BufferedDataOutputStream bos = new BufferedDataOutputStream(os);
                tmpFits.write(bos);
                bos.flush();
                // Restore the name that was removed above
                votMetaHdu.getHeader().addValue("EXTNAME", votMetaName, "Table metadata in VOTable format");
                ByteArrayDataSource dataSrc = new ByteArrayDataSource(filename, os.toByteArray());
                bos.close();
                StarTable starTable = new FitsPlusTableBuilder().makeStarTable(dataSrc, true,
                        StoragePolicy.getDefaultPolicy());
                dataSrc.close();
View Full Code Here

Examples of nom.tam.fits.BasicHDU

        int n = fits.getNumberOfHDUs();
        if (n != 2) {
            throw new IllegalArgumentException(
                    "Wrong file format: Expected FITS file with one table.");
        }
        BasicHDU basicHDU = fits.getHDU(1);
        if (!(basicHDU instanceof TableHDU)) {
            throw new IllegalArgumentException(
                    "Wrong file format: First FITS extension is not a table.");
        }
View Full Code Here

Examples of nom.tam.fits.BasicHDU

     *
     * @param fits object to use for FITS I/O
     * @param hduIndex the index of the HDU containing the FITS table
     */
    private static TableHDU getTableHDU(Fits fits, int hduIndex) throws IOException, FitsException {
        BasicHDU basicHDU = fits.getHDU(hduIndex);
        if (!(basicHDU instanceof TableHDU)) {
            throw new RuntimeException("HDU type not supported: " + basicHDU.getClass());
        }

        return (TableHDU) basicHDU;
    }
View Full Code Here

Examples of nom.tam.fits.BasicHDU

            return null;
        }

        int n = fits.getNumberOfHDUs();
        for (int hduIndex = 0; hduIndex < n; hduIndex++) {
            BasicHDU basicHDU = fits.getHDU(hduIndex);
            Header header = basicHDU.getHeader();
            String extName = header.getStringValue("EXTNAME");
            if (extName != null && extName.equals(name)) {
                return basicHDU;
            }
        }
View Full Code Here

Examples of nom.tam.fits.BasicHDU

     *
     * @param fits object to use for FITS I/O
     * @return a FITS binary table, or null if not found
     */
    protected static BinaryTableHDU findBinaryTableHDU(Fits fits, String name) throws FitsException, IOException {
        BasicHDU basicHDU = findHDU(fits, name);
        if (basicHDU instanceof BinaryTableHDU) {
            return (BinaryTableHDU) basicHDU;
        }
        return null;
    }
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.