Exemplo n.º 1
0
  /**
   * Imports the map "orig" to this object, adjusting pixel ordering and increasing resolution.
   *
   * @param orig map to import
   */
  public void importUpgrade(HealpixMapFloat orig) throws Exception {
    HealpixUtils.check(nside > orig.nside, "importUpgrade: this is no upgrade");
    int fact = (int) (nside / orig.nside);
    HealpixUtils.check(
        nside == orig.nside * fact, "the larger Nside must be a multiple of the smaller one");

    for (int m = 0; m < orig.npix; ++m) {
      Xyf xyf = orig.pix2xyf(m);
      int x = xyf.ix, y = xyf.iy, f = xyf.face;
      for (int j = fact * y; j < fact * (y + 1); ++j)
        for (int i = fact * x; i < fact * (x + 1); ++i) {
          long mypix = xyf2pix(i, j, f);
          data[(int) mypix] = orig.data[m];
        }
    }
  }
Exemplo n.º 2
0
  /**
   * Imports the map "orig" to this object, adjusting pixel ordering and reducing resolution.
   *
   * @param orig map to import
   * @param pessimistic if true, set a pixel to undefined if at least one the original subpixels was
   *     undefined; otherwise only set it to undefined if all original subpixels were undefined.
   */
  public void importDegrade(HealpixMapFloat orig, boolean pessimistic) throws Exception {
    HealpixUtils.check(nside < orig.nside, "importDegrade: this is no degrade");
    int fact = (int) (orig.nside / nside);
    HealpixUtils.check(
        orig.nside == nside * fact, "the larger Nside must be a multiple of the smaller one");

    int minhits = pessimistic ? fact * fact : 1;
    for (int m = 0; m < npix; ++m) {
      Xyf xyf = pix2xyf(m);
      int x = xyf.ix, y = xyf.iy, f = xyf.face;
      int hits = 0;
      double sum = 0;
      for (int j = fact * y; j < fact * (y + 1); ++j)
        for (int i = fact * x; i < fact * (x + 1); ++i) {
          int opix = (int) orig.xyf2pix(i, j, f);
          if (!HealpixUtils.approx(orig.data[opix], undef, 1e-5)) {
            ++hits;
            sum += orig.data[opix];
          }
        }
      data[m] = (hits < minhits) ? undef : (float) (sum / hits);
    }
  }