IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36466


Ignore:
Timestamp:
Feb 1, 2014, 6:04:48 AM (12 years ago)
Author:
eugene
Message:

extending boundary tree stuff to support local tessallations (not ready yet)

Location:
branches/eam_branches/ipp-20131211/Ohana/src/relphot/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/BoundaryTreeOps.c

    r35759 r36466  
    11# include "relphot.h"
    22
    3 // XXX for the moment, only load one boundary tree at a time
    4 // XXX in fact, only allow RINGS.V3...
     3static int Nfail = 0;
     4static int Ntess = 0;
     5static TessllationBoundary *tess = NULL;
    56
    6 static BoundaryTree *tree = NULL;
    7 
    8 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec) {
     7// for the given ra,dec : find the valid tessallation and the containing projection / skycell IDs
     8int TessallationPrimaryCellIDs (int *tessID, int *projID, int *skycellID, double ra, double dec) {
    99
    1010  int zone, band;
    1111
    12   if (!primaryCellName) return FALSE;
    13 
    14   primaryCellName[0] = 0;
    15 
    16   if (!tree) return FALSE;
    17 
    18   if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) {
    19     fprintf (stderr, "mismatch!\n");
    20     return FALSE;
    21   }
    22  
    23 # define USE_PROJECTION_CELL 0
    24 # if (USE_PROJECTION_CELL)
    25   snprintf (primaryCellName, DVO_MAX_PATH, "RINGS.V3.%s", tree->name[zone][band]);
    26 # else
    27 
    28   // I have ra, dec, and the primary projection cell.  In order to choose the primary skycell,
    29   // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right.
    30    
    31   double x = 0.0;
    32   double y = 0.0;
    33   BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band);
    34  
    35   int xi = x / tree->dX[zone][band];
    36   int yi = y / tree->dY[zone][band];
    37   int N = xi + tree->NX_SUB * yi;
    38  
    39   // XXX short-circuit this for now (we should use this code if we make tree have more variable NX,NY values
    40   // char format[24], skycellname[128];
    41   // int Ndigit = (int)(log10(tree->NX_SUB*tree->NY_SUB)) + 1 ;
    42   // snprintf (format, 24, "%s.%%0%dd", tree->name[zone][band], Ndigit);
    43   // snprintf (skycellname, 128, format, N);
    44 
    45   snprintf (primaryCellName, DVO_MAX_PATH, "RINGS.V3.%s.%03d", tree->name[zone][band], N);
    46 # endif
    47 
    48   return TRUE;
    49 }
    50 
    51 int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec) {
    52 
    53   int zone, band;
    54 
     12  *tessID = -1;
    5513  *projID = -1;
    5614  *skycellID = -1;
    5715
    58   if (!tree) return FALSE;
     16  if (!tess) return FALSE;
    5917
    60   if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) {
    61     fprintf (stderr, "mismatch!\n");
     18  // find the tessellation which includes this location
     19  int myTess = -1;
     20  for (i = 0; i < Ntess; i++) {
     21    if (ra  <  tess[i].Rmin) continue;
     22    if (ra  >= tess[i].Rmax) continue;
     23    if (dec <  tess[i].Dmin) continue;
     24    if (dec >= tess[i].Dmax) continue;
     25    myTess = i;
     26    break;
     27  }
     28  if (myTess < 0) {
     29    if (Nfail < 100) {
     30      fprintf (stderr, "no matching tessallation @ %f,%f\n", ra, dec);
     31    }
     32    Nfail ++;
    6233    return FALSE;
    6334  }
     35
     36  if (tess[myTess].type == TESS_NONE) {
     37    if (Nfail < 100) {
     38      fprintf (stderr, "tess has invalid type\n");
     39      Nfail ++;
     40    }
     41    return FALSE;
     42  }
     43
     44  if (tess[myTess].type == TESS_LOCAL) {
     45    // I have ra, dec, and the primary projection cell.  In order to choose the primary skycell,
     46    // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right.
     47   
     48    double x = 0.0;
     49    double y = 0.0;
     50    TessallationLocalProjection (&x, &y, ra, dec, &tess[myTess]);
    6451 
    65   // I have ra, dec, and the primary projection cell.  In order to choose the primary skycell,
    66   // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right.
     52    int xi = x / tess[myTess].dX;
     53    int yi = y / tess[myTess].dY;
     54    int N = xi + tess[myTess].NX_SUB * yi;
     55 
     56    *tessID = myTess;
     57    *projID = tess[myTess].projID;
     58    *skycellID = N;
     59
     60    return TRUE;
     61  }
     62
     63  if (tess[myTess].type == TESS_RINGS) {
     64    if (!BoundaryTreeCellCoords (tess[myTess].tree, &zone, &band, ra, dec)) {
     65      fprintf (stderr, "mismatch!\n");
     66      return FALSE;
     67    }
     68 
     69    // I have ra, dec, and the primary projection cell.  In order to choose the primary skycell,
     70    // I just need to project to ra,dec to X,Y based on the center of the cell and then get the subdivision right.
    6771   
    68   double x = 0.0;
    69   double y = 0.0;
    70   BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band);
     72    double x = 0.0;
     73    double y = 0.0;
     74    BoundaryTreeProjection (&x, &y, ra, dec, tess[myTess].tree, zone, band);
    7175 
    72   int xi = x / tree->dX[zone][band];
    73   int yi = y / tree->dY[zone][band];
    74   int N = xi + tree->NX_SUB * yi;
     76    int xi = x / tess[myTess].tree->dX[zone][band];
     77    int yi = y / tess[myTess].tree->dY[zone][band];
     78    int N = xi + tess[myTess].tree->NX_SUB * yi;
    7579 
    76   *projID = tree->projID[zone][band];
    77   *skycellID = N;
     80    *tessID = myTess;
     81    *projID = tess[myTess].tree->projID[zone][band];
     82    *skycellID = N;
    7883
    79   return TRUE;
     84    return TRUE;
     85  }
    8086}
    8187
    82 int load_tree (char *treefile) {
     88int TessallationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name) {
    8389
    84   tree = BoundaryTreeLoad (treefile);
    85   if (!tree) {
    86     fprintf (stderr, "failed to load boundary tree %s\n", treefile);
     90  *tessID = -1;
     91  *projID = -1;
     92  *skycellID = -1;
     93
     94  if (!tess) return FALSE;
     95
     96  for (i = 0; i < Ntess; i++) {
     97    // do this with a strhash of some kind?
     98    if (!strncmp (name, tess[i].basename, tess[i].Nbasename)) {
     99      *tessID    = i;
     100      *projID    = atoi(&name[tess[i].projectIDoff]);
     101      *skycellID = atoi(&name[tess[i].skycellIDoff]);
     102      return TRUE;
     103    }
     104  }
     105  return FALSE;
     106}
     107
     108int load_tess (char *tessfile) {
     109
     110  tess = TessBoundaryLoad (tessfile, &Ntess);
     111  if (!tess) {
     112    fprintf (stderr, "failed to load tessallation boundary file %s\n", tessfile);
    87113    exit (2);
    88114  }
  • branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/ImageOps.c

    r35759 r36466  
    8787    imageIdx[i] = i;
    8888    imageIDs[i] = image[i].imageID;
     89
     90    tessID[i] = -1;
    8991    projectID[i] = -1;
    9092    skycellID[i] = -1;
    91     if (!strncmp (image[i].name, "RINGS.V3.skycell", strlen("RINGS.V3.skycell"))) {
    92       projectID[i] = atoi(&image[i].name[17]);
    93       skycellID[i] = atoi(&image[i].name[22]);
    94     }
     93
     94    TessallationIDsByImageName (&tessID[i], &projectID[i], &skycellID[i], image[i].name);
    9595  }
    9696
    9797  // sort the image index by the IDs
     98  // XXX does this break the imageID <-> projectID, etc match?
    9899  llsortpair (imageIDs, imageIdx, Nimage);
    99100}
  • branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/args.c

    r35806 r36466  
    217217  }
    218218
     219  // XXX should we load a tree from CATDIR by default?
     220  // NOTE: a given catdir needs an appropriate boundary tree
    219221  BOUNDARY_TREE = NULL;
    220222  if ((N = get_argument (argc, argv, "-boundary-tree"))) {
  • branches/eam_branches/ipp-20131211/Ohana/src/relphot/src/setMrelCatalog.c

    r36189 r36466  
    405405  float Msys = 0, Mcal= 0, Mmos = 0, Mgrid = 0;
    406406
    407   // set the name of the primary skycell (this is used in a strcmp to match the skycells in stack detections)
    408   // XXX drop BoundaryTreePrimaryCell(primaryCell, average[0].R, average[0].D);
     407  // set the primary projection cell and skycell for this coordinate
     408  int tessID    = -1;
    409409  int projectID = -1;
    410410  int skycellID = -1;
    411   BoundaryTreePrimaryCellIDs(&projectID, &skycellID, average[0].R, average[0].D);
     411  TessallationTreePrimaryCellIDs(&tessID, &projectID, &skycellID, average[0].R, average[0].D);
    412412
    413413  int NstackGood = 0;
Note: See TracChangeset for help on using the changeset viewer.