Package nom.tam.fits

Examples of nom.tam.fits.BinaryTableHDU


      double minMagErr = Double.MAX_VALUE;
      double maxMagErr = Double.MIN_VALUE;

      for (BasicHDU hdu : hdus) {
        if (hdu instanceof BinaryTableHDU) {
          BinaryTableHDU tableHDU = (BinaryTableHDU) hdu;

          for (int row = 0; row < tableHDU.getNRows()
              && !wasInterrupted(); row++) {
            try {
              double barytime = ((double[]) tableHDU.getElement(
                  row, 0))[0];
              float ap_corr_flux = ((float[]) tableHDU
                  .getElement(row, 7))[0];
              float ap_corr_err = ((float[]) tableHDU.getElement(
                  row, 8))[0];

              // Include only valid magnitude fluxes.
              // Question: why do we see such values in Kepler
              // data sets?
              if (!Float.isInfinite(ap_corr_flux)
                  && !Float.isInfinite(ap_corr_err)
                  && !Float.isNaN(ap_corr_flux)
                  && !Float.isNaN(ap_corr_err)) {

                double hjd = barytime + 2454833.0;
                double mag = 15.0 - 2.5
                    * Math.log(ap_corr_flux)
                    / Math.log(10.0);

                double magErr = 1.086 * ap_corr_err
                    / ap_corr_flux;

                if (magErr < minMagErr) {
                  minMagErr = magErr;
                } else if (magErr > maxMagErr) {
                  maxMagErr = magErr;
                }

                ValidObservation ob = new ValidObservation();
                ob.setDateInfo(new DateInfo(hjd));
                ob.setMagnitude(new Magnitude(mag, magErr));
                ob.setBand(keplerSeries);
                ob.setRecordNumber(row);
                collectObservation(ob);
              }
            } catch (Exception e) {
              String input = tableHDU.getRow(row).toString();
              String error = e.getLocalizedMessage();
              InvalidObservation ob = new InvalidObservation(
                  input, error);
              ob.setRecordNumber(row);
              addInvalidObservation(ob);
View Full Code Here


      double minMagErr = Double.MAX_VALUE;
      double maxMagErr = Double.MIN_VALUE;

      for (BasicHDU hdu : hdus) {
        if (hdu instanceof BinaryTableHDU) {
          BinaryTableHDU tableHDU = (BinaryTableHDU) hdu;

          for (int row = 0; row < tableHDU.getNRows()
              && !wasInterrupted(); row++) {
            try {
              int tmid = ((int[]) tableHDU.getElement(row, 0))[0];
              float flux = ((float[]) tableHDU.getElement(row, 1))[0];
              float fluxErr = ((float[]) tableHDU.getElement(row,
                  2))[0];

              float tamFlux = ((float[]) tableHDU.getElement(row,
                  3))[0];
              float tamFluxErr = ((float[]) tableHDU.getElement(
                  row, 4))[0];
              String imageId = (String) tableHDU.getElement(row,
                  5);
              short ccdX = ((short[]) tableHDU.getElement(row, 6))[0];
              short ccdY = ((short[]) tableHDU.getElement(row, 7))[0];
              // short flag = ((short[]) tableHDU.getElement(row,
              // 8))[0];

              if (flux > 1 && flux - fluxErr > 0) {
                double hjd = tmid / 86400.0 + jdRef;
                double mag = 15.0 - 2.5 * Math.log(flux)
                    / Math.log(10.0);
                double magErr = 1.086 * fluxErr / flux;

                if (magErr < minMagErr) {
                  minMagErr = magErr;
                } else if (magErr > maxMagErr) {
                  maxMagErr = magErr;
                }

                ValidObservation ob = new ValidObservation();
                ob.setDateInfo(new DateInfo(hjd));
                ob.setMagnitude(new Magnitude(mag, magErr));
                ob.setBand(superWaspSeries);
                ob.setRecordNumber(row);
                ob.addDetail("IMAGE_ID", imageId, "Image ID");
                ob.addDetail("CCDX", ccdX + "", "CCD X");
                ob.addDetail("CCDY", ccdY + "", "CCD Y");
                ob.addDetail("FLUX", tamFlux + "", "Flux");
                ob.addDetail("FLUXERR", tamFluxErr + "",
                    "Flux Error");
//                ob.addDetail("FLAG", flag + "", "Flag");
                obs.add(ob);
              }
            } catch (Exception e) {
              String input = tableHDU.getRow(row).toString();
              String error = e.getLocalizedMessage();
              InvalidObservation ob = new InvalidObservation(
                  input, error);
              ob.setRecordNumber(row);
              addInvalidObservation(ob);
View Full Code Here

        BinaryTable table = new BinaryTable();
        FitsFactory.setUseAsciiTables(false);
        table.addColumn(typeList.toArray(new String[typeList.size()]));
        table.addColumn(coordList.toArray(new String[coordList.size()]));
        table.addColumn(configList.toArray(new String[configList.size()]));
        BinaryTableHDU hdu = (BinaryTableHDU) Fits.makeHDU(table);
        hdu.getHeader().addValue("EXTNAME", extName, "Contains saved JSkyCat graphics");
        hdu.setColumnName(0, "type", null);
        hdu.setColumnName(1, "coords", null);
        hdu.setColumnName(2, "config", null);
        deleteHDU(extName);
        fits.addHDU(hdu);
        imageDisplay.checkExtensions(true);
    }
View Full Code Here

        if (name == null) {
            return null;
        }

        // find the "CATINFO" table, if it exists
        BinaryTableHDU hdu = findBinaryTableHDU(fits, CATINFO);
        if (hdu == null) {
            return null;
        }

        int ncols = hdu.getNCols();

        // find the entry for this table
        int rowIndex = findConfigEntryRow(hdu, name);
        if (rowIndex == -1) {
            return null;
        }

        // if we get here, we found the entry
        Object[] row = hdu.getRow(rowIndex);
        Properties properties = new Properties();
        properties.setProperty("serv_type", "local");
        properties.setProperty("long_name", name);
        properties.setProperty("url", getFilename());
        for (int colIndex = 0; colIndex < ncols; colIndex++) {
            String value = (String) row[colIndex];
            if (value.length() != 0) {
                properties.setProperty(hdu.getColumnName(colIndex).toLowerCase(), value);
            }
        }
        return new SkycatConfigEntry(properties);
    }
View Full Code Here

        //
        // XXX Note: the Fits class doesn't currently handle empty columns correctly,
        //           so we have to add one row with dummy values ("-").
        int ncols = CATINFO_COLUMNS.length;
        Object[][] data;
        BinaryTableHDU hdu = findBinaryTableHDU(fits, CATINFO);
        int newRowIndex = 0;
        if (hdu != null) {
            // merge data from old table to new table
            int nrows = hdu.getNRows();
            int entryIndex = findConfigEntryRow(hdu, name);
            int dummyIndex = findConfigEntryRow(hdu, "-");
            int n = nrows;
            if (entryIndex == -1) {
                n++;
            }
            if (dummyIndex == -1) {
                n++;
            }
            data = new Object[n][];
            for (int rowIndex = 0; rowIndex < nrows; rowIndex++) {
                if (rowIndex == entryIndex) {
                    continue;
                }
                if (rowIndex == dummyIndex) {
                    continue;
                }
                data[newRowIndex++] = _copyCatInfoRow(hdu, hdu.getRow(rowIndex));
            }
            deleteTable(fits, CATINFO);
        } else {
            data = new Object[2][];
        }

        // add a new row for the given table
        Object[] row = new Object[ncols];
        row[0] = name;  // use the given name rather than the original one
        if (table instanceof SkycatTable) {
            SkycatConfigEntry entry = ((SkycatTable) table).getConfigEntry();
            Properties properties = entry.getProperties();
            for (int colIndex = 1; colIndex < ncols; colIndex++) {
                String value = properties.getProperty(CATINFO_COLUMNS[colIndex].toLowerCase());
                if (value != null) {
                    row[colIndex] = value;
                } else {
                    row[colIndex] = "";
                }
            }
        } else {
            for (int colIndex = 1; colIndex < ncols; colIndex++) {
                row[colIndex] = "";
            }
        }
        data[newRowIndex++] = row;

        // add a dummy row as a workaround to a Fits lib bug with empty columns
        row = new Object[ncols];
        for (int colIndex = 0; colIndex < ncols; colIndex++) {
            row[colIndex] = "-";
        }
        data[newRowIndex] = row;

        BinaryTable binTable = new BinaryTable(data);
        FitsFactory.setUseAsciiTables(false);
        hdu = (BinaryTableHDU) Fits.makeHDU(binTable);
        hdu.getHeader().addValue("EXTNAME", CATINFO, "Contains catalog config info");
        for (int i = 0; i < ncols; i++) {
            hdu.setColumnName(i, CATINFO_COLUMNS[i], null);
        }
        fits.addHDU(hdu);
    }
View Full Code Here

     * @param name the name to give the FITS table
     */
    private static void _removeCatInfo(Fits fits, String name)
            throws FitsException, IOException {

        BinaryTableHDU hdu = findBinaryTableHDU(fits, CATINFO);
        if (hdu != null) {
            int rowIndex = findConfigEntryRow(hdu, name);
            if (rowIndex != -1) {
                hdu.deleteRows(rowIndex, 1);
            }
            if (hdu.getNRows() <= 1) {
                deleteTable(fits, CATINFO);
            }
        }
    }
View Full Code Here

     * @param filename The name of the FITS file
     * @param fits object to use for FITS I/O
     * @param navigator window object managing the table display and plotting
     */
    public static void plotTables(String filename, Fits fits, Navigator navigator) throws FitsException, IOException {
        BinaryTableHDU hdu = findBinaryTableHDU(fits, CATINFO);
        if (hdu == null) {
            return;
        }
        int nrows = hdu.getNRows();
        for (int rowIndex = 0; rowIndex < nrows; rowIndex++) {
            Object[] row = hdu.getRow(rowIndex);
            String name = (String) row[0];
            _plotTable(filename, fits, navigator, name);
        }
    }
View Full Code Here

     * @param filename The name of the FITS file
     * @param fits object to use for FITS I/O
     * @param name the name of the table to plot (FITS keyword EXTNAME)
     */
    private static TableQueryResult _findTable(String filename, Fits fits, String name) throws FitsException, IOException {
        BinaryTableHDU hdu = findBinaryTableHDU(fits, name);
        if (hdu == null) {
            return null;
        }

        return getTable(filename, fits, hdu);
View Full Code Here

TOP

Related Classes of nom.tam.fits.BinaryTableHDU

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.