IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27594 for trunk


Ignore:
Timestamp:
Apr 4, 2010, 9:54:36 AM (16 years ago)
Author:
eugene
Message:

adding function avmatch to extract average fields based on a coordinate match

Location:
trunk/Ohana/src/opihi
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/dvo/Makefile

    r27435 r27594  
    2828$(SRC)/dvomisc.$(ARCH).o                \
    2929$(SRC)/region_list.$(ARCH).o            \
     30$(SRC)/find_matches.$(ARCH).o           \
    3031$(SRC)/photometry.$(ARCH).o             \
    3132$(SRC)/dbBooleanCond.$(ARCH).o          \
     
    4344cmds = \
    4445$(SRC)/avextract.$(ARCH).o              \
     46$(SRC)/avmatch.$(ARCH).o                \
    4547$(SRC)/badimages.$(ARCH).o              \
    4648$(SRC)/calextract.$(ARCH).o             \
  • trunk/Ohana/src/opihi/dvo/avextract.c

    r27587 r27594  
    182182
    183183  if ((argc > N + 1) && !strcasecmp (argv[N+1], "fields")) {
    184     gprint (GP_ERR, " USAGE: avextract field[,field,field...] where (expression)\n");
    185184    gprint (GP_ERR, "  RA : right ascension (J2000) [degrees]\n");
    186185    gprint (GP_ERR, "  DEC : declination [degrees]\n");
  • trunk/Ohana/src/opihi/dvo/dbCmdlineFields.c

    r27491 r27594  
    5757  status = FALSE;
    5858
    59   // examine each argv[i] entry until we reach a 'where' or a 'matched'
     59  // examine each argv[i] entry until we reach a 'where', a 'matched', or the end of the line
    6060  for (i = 1; (i < argc) && strcasecmp (argv[i], "where") && strcasecmp (argv[i], "match"); i++) {
    6161    // split the word by ","
  • trunk/Ohana/src/opihi/dvo/init.c

    r25757 r27594  
    22
    33int avextract       PROTO((int, char **));
     4int avmatch         PROTO((int, char **));
    45int badimages       PROTO((int, char **));
    56int calextract      PROTO((int, char **));
     
    5556static Command cmds[] = { 
    5657  {1, "avextract",   avextract,    "extract average data values"},
     58  {1, "avmatch",     avmatch,      "extract average data values matched to RA,DEC points"},
    5759  {1, "badimages",   badimages,    "look for images with anomalous astrometry"},
    5860  {1, "calextract",  calextract,   "extract photometry calibration"},
  • trunk/Ohana/src/opihi/dvo/mextract.c

    r27587 r27594  
    202202
    203203  if ((argc > N + 1) && !strcasecmp (argv[N+1], "fields")) {
    204     gprint (GP_ERR, " USAGE: avextract field[,field,field...] where (expression)\n");
    205204    gprint (GP_ERR, "  RA : right ascension (J2000) for detection [degrees]\n");
    206205    gprint (GP_ERR, "  DEC : declination for detection [degrees]\n");
  • trunk/Ohana/src/opihi/dvo/skyregion.c

    r14402 r27594  
    4444  return TRUE;
    4545}
     46
     47/* find region which overlaps c at given depth (-1 : populated ) */
     48int SkyRegionByPoint_r (SkyTable *table, SkyList *list, int depth, double ra, double dec) {
     49 
     50  int i, Ns, Ne, No;
     51  SkyRegion *skyregion;
     52
     53  list[0].Nregions = 0;
     54  list[0].ownElements = FALSE; // this list is only holding a view to the elements
     55
     56  skyregion = table[0].regions;
     57
     58  Ns = 0;
     59  Ne = 1;
     60
     61  while (1) {
     62    No = -1;
     63    for (i = Ns; (i < Ne) && (i < table[0].Nregions); i++) {
     64      if (ra  < skyregion[i].Rmin) continue;
     65      if (ra  > skyregion[i].Rmax) continue;
     66      if (dec < skyregion[i].Dmin) continue;
     67      if (dec > skyregion[i].Dmax) continue;
     68      No = i;
     69      break;
     70    }
     71    if (No == -1) return (FALSE);
     72    if ((depth == -1) && (skyregion[No].table)) break;
     73    if (depth == skyregion[No].depth) break;
     74    if ((depth > skyregion[No].depth) && !skyregion[No].child) return (FALSE);
     75
     76    /* need to check Ns, Ne, or guarantee valid range */
     77    Ns = skyregion[No].childS;
     78    Ne = skyregion[No].childE;
     79  }
     80
     81  list[0].regions[0] = &skyregion[No];
     82  list[0].filename[0] = table[0].filename[No];
     83  list[0].Nregions = 1;
     84  return (TRUE);
     85}
     86
     87SkyList *SelectRegionsByCoordVectors (Vector *RA, Vector *DEC) {
     88 
     89  int i, j, Npts, Nout, NOUT, *found;
     90  double ra, dec;
     91  SkyList *new, *list;
     92  SkyTable *sky;
     93
     94  sky = GetSkyTable ();
     95
     96  Npts = RA->Nelements;
     97  ALLOCATE (found, int, Npts);
     98  memset (found, 0, Npts*sizeof(int));
     99
     100  ALLOCATE (new, SkyList, 1);
     101  ALLOCATE (new[0].regions,  SkyRegion *, 1);
     102  ALLOCATE (new[0].filename,  char *, 1);
     103
     104  // output list
     105  Nout = 0;
     106  NOUT = 100;
     107  ALLOCATE (list, SkyList, 1);
     108  ALLOCATE (list[0].regions,  SkyRegion *, NOUT);
     109  ALLOCATE (list[0].filename,  char *, NOUT);
     110  list[0].Nregions = 0;
     111  list[0].ownElements = FALSE; // this list is only holding a view to the elements
     112
     113  for (i = 0; i < Npts; i++) {
     114    if (found[i]) continue;
     115
     116    SkyRegionByPoint_r (sky, new, -1, RA->elements.Flt[i], DEC->elements.Flt[i]);
     117    if (new->Nregions == 0) continue;
     118    assert (new->Nregions == 1);
     119    // append new region to output list
     120    list[0].regions[Nout] = new[0].regions[0];
     121    list[0].filename[Nout] = new[0].filename[0];
     122    Nout ++;
     123    if (Nout >= NOUT) {
     124        NOUT += 100;
     125        REALLOCATE (list[0].regions, SkyRegion *, NOUT);
     126        REALLOCATE (list[0].filename, char *, NOUT);
     127    }
     128    found[i] = TRUE;
     129
     130    // scan over the remaining points to find any that lie within this region
     131    // if we sorted the ra,dec inputs we could break out of this more quickly
     132    for (j = i + 1; j < Npts; j++) {
     133      ra = RA->elements.Flt[j];
     134      dec = DEC->elements.Flt[j];
     135      if (ra  < new[0].regions[0][0].Rmin) continue;
     136      if (ra  > new[0].regions[0][0].Rmax) continue;
     137      if (dec < new[0].regions[0][0].Dmin) continue;
     138      if (dec > new[0].regions[0][0].Dmax) continue;
     139      found[j] = TRUE;
     140    }
     141  }
     142
     143  free (found);
     144  SkyListFree (new);
     145
     146  return (list);
     147}
     148
  • trunk/Ohana/src/opihi/include/dvoshell.h

    r27587 r27594  
    314314SkyRegionSelection *SetRegionSelection    PROTO((int *argc, char **argv));
    315315
     316int           SkyRegionByPoint_r    PROTO((SkyTable *table, SkyList *list, int depth, double ra, double dec));
     317SkyList      *SelectRegionsByCoordVectors PROTO((Vector *RA, Vector *DEC));
     318
     319int           find_matches_by_vectors PROTO((SkyRegion *region, Catalog *catalog, Vector *RAvec, Vector *DECvec, float RADIUS, off_t *index));
     320
    316321int           SetImageSelection     PROTO((int mode, SkyRegionSelection *selection));
    317322int           SetPhotSelections     PROTO((int *argc, char **argv, int Nparams));
Note: See TracChangeset for help on using the changeset viewer.