IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 36491


Ignore:
Timestamp:
Feb 6, 2014, 12:46:42 PM (12 years ago)
Author:
eugene
Message:

support for TessellationTable (instead of only BoundaryTree)

Location:
trunk/Ohana/src/relphot
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/relphot/include/relphot.h

    r35806 r36491  
    116116  unsigned int photom_map_id;
    117117  unsigned int flags;
     118  int tessID;
    118119  int projID;
    119120  int skycellID;
     
    401402
    402403int MatchImageName (off_t meas, int cat, char *name);
    403 int MatchImageSkycellID (off_t meas, int cat, int myProjectionID, int mySkycellID);
    404 
    405 int load_tree (char *treefile);
    406 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec);
    407 int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec);
     404int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID);
     405
     406int load_tess (char *treefile);
     407int get_tess_ids (int *tessID, int *projID, int *skycellID, double ra, double dec);
     408int TessellationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name);
     409
     410// int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec);
     411// int BoundaryTreePrimaryCellIDs (int *projID, int *skycellID, double ra, double dec);
    408412
    409413int print_measure_set_alt (Average *average, SecFilt *secfilt, Measure *measure);
  • trunk/Ohana/src/relphot/src/BoundaryTreeOps.c

    r35759 r36491  
    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 Ntess = 0;
     4static TessellationTable *tess = NULL;
    55
    6 static BoundaryTree *tree = NULL;
     6int TessellationIDsByImageName (int *tessID, int *projID, int *skycellID, char *name) {
    77
    8 int BoundaryTreePrimaryCell (char *primaryCellName, double ra, double dec) {
     8  int i;
    99
    10   int zone, band;
    11 
    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 
     10  *tessID = -1;
    5511  *projID = -1;
    5612  *skycellID = -1;
    5713
    58   if (!tree) return FALSE;
     14  if (!tess) return FALSE;
    5915
    60   if (!BoundaryTreeCellCoords (tree, &zone, &band, ra, dec)) {
    61     fprintf (stderr, "mismatch!\n");
    62     return FALSE;
     16  for (i = 0; i < Ntess; i++) {
     17    // do this with a strhash of some kind?
     18    if (!strncmp (name, tess[i].basename, tess[i].Nbasename)) {
     19      *tessID    = i;
     20      if (tess[i].projectIDoff >= 0) {
     21        *projID    = atoi(&name[tess[i].projectIDoff]);
     22      } else {
     23        *projID    = 0;
     24      }
     25      if (tess[i].skycellIDoff >= 0) {
     26        *skycellID = atoi(&name[tess[i].skycellIDoff]);
     27      } else {
     28        *skycellID = 0;
     29      }
     30      return TRUE;
     31    }
    6332  }
    64  
    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.
    67    
    68   double x = 0.0;
    69   double y = 0.0;
    70   BoundaryTreeProjection (&x, &y, ra, dec, tree, zone, band);
    71  
    72   int xi = x / tree->dX[zone][band];
    73   int yi = y / tree->dY[zone][band];
    74   int N = xi + tree->NX_SUB * yi;
    75  
    76   *projID = tree->projID[zone][band];
    77   *skycellID = N;
    78 
    79   return TRUE;
     33  return FALSE;
    8034}
    8135
    82 int load_tree (char *treefile) {
     36int load_tess (char *tessfile) {
    8337
    84   tree = BoundaryTreeLoad (treefile);
    85   if (!tree) {
    86     fprintf (stderr, "failed to load boundary tree %s\n", treefile);
     38  tess = TessellationTableLoad (tessfile, &Ntess);
     39  if (!tess) {
     40    fprintf (stderr, "failed to load tessellation boundary file %s\n", tessfile);
    8741    exit (2);
    8842  }
     
    9044  return TRUE;
    9145}
     46
     47int get_tess_ids (int *tessID, int *projID, int *skycellID, double ra, double dec) {
     48
     49  int status;
     50
     51  if (!tess) return FALSE;
     52
     53  status = TessellationPrimaryCellIDs(tess, Ntess, tessID, projID, skycellID, ra, dec);
     54  return status;
     55}
  • trunk/Ohana/src/relphot/src/ImageOps.c

    r35759 r36491  
    4848// stack image.  for now, we generate these ID arrays based on the image names when we load in the image table (initImages).
    4949// When we pass data to the remote clients via the ImageSubset, the projID/skycellID values are carried directly in the table.
     50int *tessID    = NULL;
    5051int *projectID = NULL;
    5152int *skycellID = NULL;
     
    8182
    8283  // for stack images, assign projection cell ID and skycell ID based on filenames
     84  ALLOCATE (tessID,      int, Nimage);
    8385  ALLOCATE (projectID,   int, Nimage);
    8486  ALLOCATE (skycellID,   int, Nimage);
     
    8789    imageIdx[i] = i;
    8890    imageIDs[i] = image[i].imageID;
     91
     92    tessID[i]    = -1;
    8993    projectID[i] = -1;
    9094    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     }
     95
     96    TessellationIDsByImageName (&tessID[i], &projectID[i], &skycellID[i], image[i].name);
    9597  }
    9698
    9799  // sort the image index by the IDs
     100  // XXX does this break the imageID <-> projectID, etc match?
    98101  llsortpair (imageIDs, imageIdx, Nimage);
    99102}
     
    106109  // create full a Image array and save the needed values
    107110  ALLOCATE (image, Image, N);
     111
     112  ALLOCATE (tessID,    int, N);
    108113  ALLOCATE (projectID, int, N);
    109114  ALLOCATE (skycellID, int, N);
     
    118123    image[i].trate         = input[i].trate        ;
    119124    image[i].ubercalDist   = input[i].ubercalDist  ;
     125    tessID[i]              = input[i].tessID       ;
    120126    projectID[i]           = input[i].projID       ;
    121127    skycellID[i]           = input[i].skycellID    ;
     
    153159    subset[i].trate         = image[i].trate        ;
    154160    subset[i].ubercalDist   = image[i].ubercalDist  ;
     161    subset[i].tessID        = tessID[i];
    155162    subset[i].projID        = projectID[i];
    156163    subset[i].skycellID     = skycellID[i];
     
    461468
    462469// returns image.Mcal - ff(x,y)
    463 int MatchImageSkycellID (off_t meas, int cat, int myProjectionID, int mySkycellID) {
     470int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID) {
    464471
    465472  off_t i;
     
    470477  if (i == -1) return FALSE;
    471478
     479  if (tessID[i]    == -1) return FALSE;
    472480  if (projectID[i] == -1) return FALSE;
    473481  if (skycellID[i] == -1) return FALSE;
    474482
     483  if (tessID[i]    != myTessID) return FALSE;
    475484  if (projectID[i] != myProjectionID) return FALSE;
    476485  if (skycellID[i] != mySkycellID) return FALSE;
  • trunk/Ohana/src/relphot/src/ImageSubset.c

    r35759 r36491  
    6363  GET_COLUMN (map,       "PHOTOM_MAP",   int);
    6464  GET_COLUMN (flags,     "FLAGS",        int);
     65  GET_COLUMN (tessID,    "TESS_ID",      int);
    6566  GET_COLUMN (projID,    "PROJ_ID",      int);
    6667  GET_COLUMN (skycellID, "SKYCELL_ID",   int);
     
    7879    image[i].photom_map_id = map[i];
    7980    image[i].flags         = flags[i];
     81    image[i].tessID        = tessID[i];
    8082    image[i].projID        = projID[i];
    8183    image[i].skycellID     = skycellID[i];
     
    9193  free (map);
    9294  free (flags);
     95  free (tessID);
    9396  free (projID);
    9497  free (skycellID);
     
    130133  gfits_define_bintable_column (&theader, "J", "FLAGS", "flags", NULL, 1.0, 1.0*0x8000);
    131134
     135  gfits_define_bintable_column (&theader, "J", "TESS_ID", "ID", NULL, 1.0, 0.0);
    132136  gfits_define_bintable_column (&theader, "J", "PROJ_ID", "ID", NULL, 1.0, 0.0);
    133137  gfits_define_bintable_column (&theader, "J", "SKYCELL_ID", "ID", NULL, 1.0, 0.0);
     
    143147  float *Mcal, *dMcal;
    144148  unsigned int *imageID, *map, *flags, *tzero;
    145   int *projID, *skycellID;
     149  int *tessID, *projID, *skycellID;
    146150  unsigned short *trate;
    147151  short *ucdist;
     
    153157  ALLOCATE (map,       unsigned int,   Nimage);
    154158  ALLOCATE (flags,     unsigned int,   Nimage);
     159  ALLOCATE (tessID,    int,            Nimage);
    155160  ALLOCATE (projID,    int,            Nimage);
    156161  ALLOCATE (skycellID, int,            Nimage);
     
    169174    trate[i]     = image[i].trate;
    170175    ucdist[i]    = image[i].ubercalDist;
     176    tessID[i]    = image[i].tessID;
    171177    projID[i]    = image[i].projID;
    172178    skycellID[i] = image[i].skycellID;
     
    179185  gfits_set_bintable_column (&theader, &ftable, "PHOTOM_MAP",   map,       Nimage);
    180186  gfits_set_bintable_column (&theader, &ftable, "FLAGS",        flags,     Nimage);
     187  gfits_set_bintable_column (&theader, &ftable, "TESS_ID",      tessID,    Nimage);
    181188  gfits_set_bintable_column (&theader, &ftable, "PROJ_ID",      projID,    Nimage);
    182189  gfits_set_bintable_column (&theader, &ftable, "SKYCELL_ID",   skycellID, Nimage);
     
    190197  free (map);
    191198  free (flags);
     199  free (tessID);
    192200  free (projID);
    193201  free (skycellID);
  • trunk/Ohana/src/relphot/src/MosaicOps.c

    r35806 r36491  
    412412    }
    413413    dS /= MosaicN_Image[i];
    414     strcpy (mosaic[i].coords.ctype, "RA---TAN");
     414    strcpy (mosaic[i].coords.ctype, "DEC--TAN");
    415415    mosaic[i].coords.crval1 = Rmin;
    416416    mosaic[i].coords.crval2 = Dmin;
  • trunk/Ohana/src/relphot/src/StarOps.c

    r35759 r36491  
    328328int setMrel_catalog (Catalog *catalog, int Nc, int pass, FlatCorrectionTable *flatcorr, SetMrelInfo *results, int Nsecfilt) {
    329329
     330  fprintf (stderr, "??? should you still be using the old version of setMrel_catalog??\n");
     331  exit (3);
     332
    330333  off_t j, k, m, ID;
    331334  int N;
     
    366369    if (isSetMrelFinal) {
    367370      // set the name of the primary skycell (this is used in a strcmp to match the skycells in stack detections)
    368       BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D);
     371      // XXX : this whole function is deprecated
     372      // BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D);
    369373    }
    370374
  • trunk/Ohana/src/relphot/src/args.c

    r35806 r36491  
    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"))) {
    221223    remove_argument (N, &argc, argv);
    222224    BOUNDARY_TREE = strcreate(argv[N]);
    223     load_tree (BOUNDARY_TREE);
     225    load_tess (BOUNDARY_TREE);
    224226    remove_argument (N, &argc, argv);
    225227  }
     
    424426    remove_argument (N, &argc, argv);
    425427    BOUNDARY_TREE = strcreate(argv[N]);
    426     load_tree (BOUNDARY_TREE);
     428    load_tess (BOUNDARY_TREE);
    427429    remove_argument (N, &argc, argv);
    428430  }
  • trunk/Ohana/src/relphot/src/select_images.c

    r35806 r36491  
    4040  tcoords.pc1_1  = tcoords.pc2_2 = 1.0;
    4141  tcoords.pc1_2  = tcoords.pc2_1 = 0.0;
    42   strcpy (tcoords.ctype, "RA---TAN");
     42  strcpy (tcoords.ctype, "DEC--TAN");
    4343
    4444  double RminSkyRegion = region[0].Rmin;
     
    412412  tcoords.Npolyterms = 0;
    413413  memset (tcoords.polyterms, 0, 14*sizeof(float));
    414   strcpy (tcoords.ctype, "RA---TAN");
     414  strcpy (tcoords.ctype, "DEC--TAN");
    415415
    416416  /* compare with each region file */
  • trunk/Ohana/src/relphot/src/setMrelCatalog.c

    r36189 r36491  
    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  get_tess_ids(&tessID, &projectID, &skycellID, average[0].R, average[0].D);
    412412
    413413  int NstackGood = 0;
     
    477477      // which stack image should we use for the mean value?
    478478      // if we request the primary (USE_TREE_FOR_PRIMARY), then find the min distances for data from the primary cell
    479       if (MatchImageSkycellID (meas, cat, projectID, skycellID)) {
     479      if (MatchImageSkycellID (meas, cat, tessID, projectID, skycellID)) {
    480480        float stackPrimaryOffset = getCenterOffset (meas, cat, &measure[k], &stackImageID);
    481481        if (stackPrimaryOffset < stackPrimaryOffsetMin) {
Note: See TracChangeset for help on using the changeset viewer.