IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 5, 2012, 2:15:02 PM (14 years ago)
Author:
eugene
Message:

boundary tree needs DEC_min and DEC_max for each zone, even though zone centers are evenly spaced (projection cells not quite large enough to cover exact midpoints)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/findskycell.c

    r34260 r34291  
    66                                        4.044944,   4.090909,   4.186047,   4.285714,   4.390244,   4.556962,   4.736842,   5.000000,   
    77                                        5.294118,   5.625000,   6.000000,   6.545455,   7.200000,   8.000000,   9.230769,  10.909091, 
    8                                       13.333333,  17.142857,  24.000000,  40.000000, 360.000000};
     8                                       13.333333,  17.142857,  24.000000,  40.000000, 360.000000};
    99
    1010// in the general case, projection cell centers are arbitrary
     
    113113  ALLOCATE (tree.NBAND, int, tree.Nzone);
    114114
    115   ALLOCATE (tree.RA_origin, double, tree.Nzone);
    116   ALLOCATE (tree.RA_offset, double, tree.Nzone);
     115  ALLOCATE (tree.RA_origin,   double, tree.Nzone);
     116  ALLOCATE (tree.RA_offset,   double, tree.Nzone);
     117  ALLOCATE (tree.DEC_min,     double, tree.Nzone);
     118  ALLOCATE (tree.DEC_max,     double, tree.Nzone);
     119  ALLOCATE (tree.DEC_min_raw, double, tree.Nzone);
     120  ALLOCATE (tree.DEC_max_raw, double, tree.Nzone);
    117121
    118122  ALLOCATE (tree.ra,   double *, tree.Nzone);
     
    138142    tree.RA_origin[zone] = -0.5*RA_offset_RINGS_V3[zone];
    139143    tree.RA_offset[zone] = RA_offset_RINGS_V3[zone];
     144
     145    // set the starting values here.  In fact, the MIN and MAX values need to be tweaked
     146    // on the basis of the real images...
     147    tree.DEC_min_raw[zone] = +90.0;
     148    tree.DEC_max_raw[zone] = -90.0;
     149    tree.DEC_min[zone] = NAN;
     150    tree.DEC_max[zone] = NAN;
     151
    140152    ALLOCATE (tree.ra[zone],   double, tree.NBAND[zone]);
    141153    ALLOCATE (tree.dec[zone],  double, tree.NBAND[zone]);
     
    179191    tree.dec[zone][band] = dec;
    180192    tree.cell[zone][band] = i;
     193
     194    // what are the min and max DEC values for this zone? (test center and corners of top and bottom edge) 
     195
     196    if (dec > 0.0) {
     197      // min DEC at bottom of the cell at the center
     198      x = 0.5*image[i].NX;
     199      y = 0.0*image[i].NY;
     200      XY_to_RD (&ra, &dec, x, y, &image[i].coords);
     201      tree.DEC_min_raw[zone] = MIN(tree.DEC_min_raw[zone], dec);
     202 
     203      // max DEC : find the intersection between the RA boundary and the top of the cell
     204      double ra_band_min = tree.RA_origin[zone] + tree.RA_offset[zone] * band;
     205 
     206      // does the parity matter?
     207      x = 0.0*image[i].NX;
     208      y = 1.0*image[i].NY;
     209 
     210      int Niter;
     211      for (Niter = 0; Niter < 3; Niter ++) {
     212        XY_to_RD (&ra, &dec, x, y, &image[i].coords);
     213        RD_to_XY (&x, &y, ra_band_min, dec, &image[i].coords);
     214        y = 1.0*image[i].NY;
     215      }
     216      tree.DEC_max_raw[zone] = MAX(tree.DEC_max_raw[zone], dec);
     217    } else {
     218      // max DEC at top of the cell at the center
     219      x = 0.5*image[i].NX;
     220      y = 1.0*image[i].NY;
     221      XY_to_RD (&ra, &dec, x, y, &image[i].coords);
     222      tree.DEC_max_raw[zone] = MAX(tree.DEC_max_raw[zone], dec);
     223 
     224      // max DEC : find the intersection between the RA boundary and the bottom of the cell
     225      double ra_band_min = tree.RA_origin[zone] + tree.RA_offset[zone] * band;
     226 
     227      // does the parity matter? (NO)
     228      x = 0.0*image[i].NX;
     229      y = 0.0*image[i].NY;
     230 
     231      int Niter;
     232      for (Niter = 0; Niter < 3; Niter ++) {
     233        XY_to_RD (&ra, &dec, x, y, &image[i].coords);
     234        RD_to_XY (&x, &y, ra_band_min, dec, &image[i].coords);
     235        y = 0.0*image[i].NY;
     236      }
     237      tree.DEC_min_raw[zone] = MIN(tree.DEC_min_raw[zone], dec);
     238    }
    181239    memcpy (tree.name[zone][band], image[i].name, BOUNDARY_TREE_NAME_LENGTH);
    182240  }
     
    206264  }
    207265
     266  // figure out the max band value for each zone?
     267  int Nm = 0;
     268  tree.DEC_min[Nm] = -90.0;
     269  tree.DEC_max[Nm] = 0.5*(tree.DEC_max_raw[Nm] + tree.DEC_min_raw[Nm + 1]);
     270
     271  int Np = tree.Nzone - 1;
     272  tree.DEC_min[Np] = 0.5*(tree.DEC_min_raw[Np] + tree.DEC_max_raw[Np - 1]);
     273  tree.DEC_max[Np] = +90.0;
     274
     275  for (zone = 1; zone < tree.Nzone - 1; zone++) {
     276    tree.DEC_min[zone] = 0.5*(tree.DEC_min_raw[zone] + tree.DEC_max_raw[zone - 1]);
     277    tree.DEC_max[zone] = 0.5*(tree.DEC_max_raw[zone] + tree.DEC_min_raw[zone + 1]);
     278  }
     279
    208280  struct timeval start, stop;
    209281  gettimeofday (&start, (void *) NULL);
Note: See TracChangeset for help on using the changeset viewer.