Пример #1
0
 public static void printResults(int order, double lon, double lat, double radius)
     throws Exception {
   HealpixImpl gHpi = new Healpix();
   HealpixImpl pHpi = PixtoolsHealpix.getInstance();
   printPixels(gHpi.queryDisc(order, lon, lat, radius));
   printPixels(pHpi.queryDisc(order, lon, lat, radius));
 }
Пример #2
0
  @Override
  protected HealpixMoc createMoc() throws IOException {

    /* Initialise a MOC object with the right resolution. */
    Nsider nsider = new Nsider();
    int maxOrder = Math.min(nsider.calcOrder(resolutionDeg_), HealpixMoc.MAXORDER);
    HealpixMoc moc;
    try {
      moc = new HealpixMoc(maxOrder);
    } catch (Exception e) {
      throw (Error) new AssertionError("Trouble creating HealpixMoc??").initCause(e);
    }

    /* Add coverage for each item in the query sequence. */
    MocMode.setChecked(moc, false);
    try {
      HealpixImpl healpix = PixtoolsHealpix.getInstance();
      while (qseq_.next()) {
        if (Thread.interrupted()) {
          throw new InterruptedIOException();
        }
        double ra = qseq_.getRa();
        double dec = qseq_.getDec();
        double radius = qseq_.getRadius();
        if (!Double.isNaN(ra) && dec >= -90 && dec <= +90 && radius >= 0) {
          int order = radius <= resolutionDeg_ ? maxOrder : nsider.calcOrder(radius);
          long[] pixels;
          try {
            pixels = healpix.queryDisc(order, ra, dec, radius);
          } catch (Exception e) {
            throw (IOException) new IOException("HEALPix processing error").initCause(e);
          }
          for (int ip = 0; ip < pixels.length; ip++) {
            try {
              moc.add(order, pixels[ip]);
            } catch (Exception e) {
              throw (IOException) new IOException("HEALPix processing error").initCause(e);
            }
          }
        }
      }
      MocMode.setChecked(moc, true);
      return moc;
    } finally {
      try {
        qseq_.close();
      } catch (IOException e) {
      }
      qseq_ = null;
    }
  }