IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 34291


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)

Location:
trunk/Ohana/src
Files:
3 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);
  • trunk/Ohana/src/libdvo/include/dvo.h

    r34260 r34291  
    305305  double *RA_origin;
    306306  double *RA_offset;
     307  double *DEC_min;
     308  double *DEC_max;
     309  double *DEC_min_raw;
     310  double *DEC_max_raw;
    307311
    308312  int *Nband;
  • trunk/Ohana/src/libdvo/src/BoundaryTree.c

    r34260 r34291  
    5959 
    6060    // need to create and assign to flat-field correction
    61     GET_COLUMN_RAW(tree->Nband,     "NBAND",     int);
    62     GET_COLUMN_RAW(tree->RA_origin, "RA_ORIGIN", double);
    63     GET_COLUMN_RAW(tree->RA_offset, "RA_OFFSET", double);
     61    GET_COLUMN_RAW(tree->Nband,       "NBAND",           int);
     62    GET_COLUMN_RAW(tree->RA_origin,   "RA_ORIGIN",   double);
     63    GET_COLUMN_RAW(tree->RA_offset,   "RA_OFFSET",   double);
     64    GET_COLUMN_RAW(tree->DEC_min  ,   "DEC_MIN",     double);
     65    GET_COLUMN_RAW(tree->DEC_max  ,   "DEC_MAX",     double);
     66    GET_COLUMN_RAW(tree->DEC_min_raw, "DEC_MIN_RAW", double);
     67    GET_COLUMN_RAW(tree->DEC_max_raw, "DEC_MAX_RAW", double);
    6468    gfits_free_header (&theader);
    6569    gfits_free_table  (&ftable);
     
    171175    gfits_create_table_header (&theader, "BINTABLE", "ZONE_DATA");
    172176
    173     gfits_define_bintable_column (&theader, "J", "ZONE",      "zone sequence number", "none", 1.0, 0.0);
    174     gfits_define_bintable_column (&theader, "J", "NBAND",     "number of cells in each zone", "none", 1.0, 0.0);
    175     gfits_define_bintable_column (&theader, "D", "RA_ORIGIN", "origin of ra cell sequence", "degree", 1.0, 0.0);
    176     gfits_define_bintable_column (&theader, "D", "RA_OFFSET", "offset per cell of ra cell sequence", "degree/cell", 1.0, 0.0);
     177    gfits_define_bintable_column (&theader, "J", "ZONE",        "zone sequence number", "none", 1.0, 0.0);
     178    gfits_define_bintable_column (&theader, "J", "NBAND",       "number of cells in each zone", "none", 1.0, 0.0);
     179    gfits_define_bintable_column (&theader, "D", "RA_ORIGIN",   "origin of ra cell sequence", "degree", 1.0, 0.0);
     180    gfits_define_bintable_column (&theader, "D", "RA_OFFSET",   "offset per cell of ra cell sequence", "degree/cell", 1.0, 0.0);
     181    gfits_define_bintable_column (&theader, "D", "DEC_MIN",     "min dec for zone", "degree", 1.0, 0.0);
     182    gfits_define_bintable_column (&theader, "D", "DEC_MAX",     "max dec for zone", "degree", 1.0, 0.0);
     183    gfits_define_bintable_column (&theader, "D", "DEC_MIN_RAW", "min dec for zone", "degree", 1.0, 0.0);
     184    gfits_define_bintable_column (&theader, "D", "DEC_MAX_RAW", "max dec for zone", "degree", 1.0, 0.0);
    177185
    178186    // generate the output array that carries the data
     
    188196
    189197    // add the columns to the output array
    190     gfits_set_bintable_column (&theader, &ftable, "ZONE",       zone,            tree->Nzone);
    191     gfits_set_bintable_column (&theader, &ftable, "NBAND",      tree->Nband,     tree->Nzone);
    192     gfits_set_bintable_column (&theader, &ftable, "RA_ORIGIN",  tree->RA_origin, tree->Nzone);
    193     gfits_set_bintable_column (&theader, &ftable, "RA_OFFSET",  tree->RA_offset, tree->Nzone);
     198    gfits_set_bintable_column (&theader, &ftable, "ZONE",        zone,              tree->Nzone);
     199    gfits_set_bintable_column (&theader, &ftable, "NBAND",       tree->Nband,       tree->Nzone);
     200    gfits_set_bintable_column (&theader, &ftable, "RA_ORIGIN",   tree->RA_origin,   tree->Nzone);
     201    gfits_set_bintable_column (&theader, &ftable, "RA_OFFSET",   tree->RA_offset,   tree->Nzone);
     202    gfits_set_bintable_column (&theader, &ftable, "DEC_MIN",     tree->DEC_min,     tree->Nzone);
     203    gfits_set_bintable_column (&theader, &ftable, "DEC_MAX",     tree->DEC_max,     tree->Nzone);
     204    gfits_set_bintable_column (&theader, &ftable, "DEC_MIN_RAW", tree->DEC_min_raw, tree->Nzone);
     205    gfits_set_bintable_column (&theader, &ftable, "DEC_MAX_RAW", tree->DEC_max_raw, tree->Nzone);
    194206    free (zone);
    195207
     
    283295  if (*zone >= tree->Nzone) return FALSE;
    284296
     297  // test if:
     298  // (a) DEC_min,DEC_max of *zone are defined (not NAN)
     299  // (b) dec for *zone falls in range DEC_min[*zone] <= dec < DEC_max[*zone]
     300  //     migrate up or down
     301
     302  // TEST int zone_raw = *zone;
     303  if (isfinite(tree->DEC_min[*zone])) {
     304    if (dec >= tree->DEC_max[*zone]) (*zone) ++;
     305    if (dec <  tree->DEC_min[*zone]) (*zone) --;
     306    // TEST assert (dec <  tree->DEC_max[*zone]);
     307    // TEST assert (dec >= tree->DEC_min[*zone]);
     308  }
     309  // TEST assert (zone_raw > -1);
     310
    285311  // now select the RA bin for that zone
    286312  *band = (ra - tree->RA_origin[*zone]) / tree->RA_offset[*zone];
Note: See TracChangeset for help on using the changeset viewer.