Package nom.tam.fits

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


        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

     */
    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

     * 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

        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

        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

     *
     * @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

            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

     *
     * @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

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        new FitsPlusTableWriter().writeStarTable(table.getStarTable(), os);
        ByteArrayInputStream is = new ByteArrayInputStream(os.toByteArray());
        Fits tableFits = new Fits(is);

        BasicHDU votMetaHdu = tableFits.getHDU(0);
        votMetaHdu.getHeader().addValue("EXTNAME", votMetaName, "Table metadata in VOTable format");

        TableHDU hdu = (TableHDU) tableFits.getHDU(1);
        hdu.getHeader().addValue("EXTNAME", tableName, "Contains saved query results");
        is.close();
        os.close();
View Full Code Here

TOP

Related Classes of nom.tam.fits.BasicHDU

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.