IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29788


Ignore:
Timestamp:
Nov 16, 2010, 6:40:37 PM (15 years ago)
Author:
eugene
Message:

created a dvomergeContinue function to finish a partially-complete merge process (does not update the image table, but matches the defined image IDs)

Location:
branches/eam_branches/ipp-20101103/Ohana/src/dvomerge
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/Makefile

    r29785 r29788  
    2626$(SRC)/dvomergeUpdate.$(ARCH).o \
    2727$(SRC)/dvomergeCreate.$(ARCH).o \
     28$(SRC)/dvomergeContinue.$(ARCH).o \
    2829$(SRC)/dvo_image_merge_dbs.$(ARCH).o \
    2930$(SRC)/SetSignals.$(ARCH).o \
  • branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/include/dvomerge.h

    r29779 r29788  
    105105int        RepairTableCPT         PROTO((char *cptFilenameSrc, char *cptFilenameTgt, char *cpsFilenameSrc, char *cpsFilenameTgt, Measure *measure, off_t Nmeasure, Image *image, off_t Nimage, char catformat));
    106106void       dvorepair_help         PROTO((int argc, char **argv));
     107
     108off_t      getTgtIndex            PROTO((e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt));
     109void       SortTgtByTimes         PROTO((e_time *S, off_t *I, short *C, off_t N));
     110int        dvo_image_match_dbs    PROTO((IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src));
     111int        dvomergeImagesGetMap   PROTO((IDmapType *IDmap, char *input, char *output));
     112int        dvomergeContinue       PROTO((int argc, char **argv));
  • branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/args.c

    r29001 r29788  
    3636  }
    3737
    38   if ((*argc != 6) && (*argc != 4)) dvomerge_usage();
     38  if ((*argc < 4) || (*argc > 6)) dvomerge_usage();
    3939  return TRUE;
    4040}
  • branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c

    r29001 r29788  
    22
    33void sort_IDmap (IDmapType *IDmap);
     4
     5off_t getTgtIndex (e_time start, e_time stop, short photcode, off_t *TgtIndex, e_time *TgtTimes, short *TgtCodes, off_t NimagesTgt) {
     6
     7  // use bisection to find the starting entry by time
     8
     9  off_t Nlo, Nhi, N;
     10
     11  // find the last TGT before start
     12  Nlo = 0; Nhi = NimagesTgt;
     13  while (Nhi - Nlo > 10) {
     14    N = 0.5*(Nlo + Nhi);
     15    if (TgtTimes[N] < start) {
     16      Nlo = MAX(N, 0);
     17    } else {
     18      Nhi = MIN(N + 1, NimagesTgt);
     19    }
     20  }
     21
     22  // check for the matched mosaic starting from Nlo
     23  // we may have to go much beyond Nlo since stop is not sorted
     24  // can we use a sorted version of stop to check when we are beyond the valid range??
     25  for (N = Nlo; N < NimagesTgt; N++) {
     26    if (TgtTimes[N] < start) continue;
     27    if (TgtTimes[N] > stop) return (-1);
     28    if (TgtCodes[N] != photcode) continue;
     29    return (TgtIndex[N]);
     30  }
     31  return (-1);
     32}
     33
     34// sort two times vectors and an index by first time vector
     35void SortTgtByTimes (e_time *S, off_t *I, short *C, off_t N) {
     36
     37# define SWAPFUNC(A,B){ e_time tmp_t; off_t tmp_i; short tmp_c;         \
     38  tmp_t = S[A]; S[A] = S[B]; S[B] = tmp_t; \
     39  tmp_i = I[A]; I[A] = I[B]; I[B] = tmp_i; \
     40  tmp_c = C[A]; C[A] = C[B]; C[B] = tmp_c; \
     41}
     42# define COMPARE(A,B)(S[A] < S[B])
     43
     44  OHANA_SORT (N, COMPARE, SWAPFUNC);
     45
     46# undef SWAPFUNC
     47# undef COMPARE
     48
     49}
     50
     51// we have two tables; 'tgt' contains some exposures from 'src' : find them and match a map
     52int dvo_image_match_dbs (IDmapType *IDmap, FITS_DB *tgt, FITS_DB *src) {
     53
     54  Image *imagesSrc, *imagesTgt;
     55  off_t NimagesSrc, NimagesTgt;
     56  off_t iSrc, iTgt;
     57  off_t  *TgtIndex;
     58  e_time *TgtTimes;
     59  short  *TgtCodes;
     60 
     61  imagesSrc = gfits_table_get_Image (&src[0].ftable, &NimagesSrc, &src[0].swapped);
     62  if (!imagesSrc) {
     63    fprintf (stderr, "ERROR: failed to read images from src\n");
     64    exit (2);
     65  }
     66
     67  imagesTgt = gfits_table_get_Image (&tgt[0].ftable, &NimagesTgt, &tgt[0].swapped);
     68  if (!imagesTgt) {
     69    fprintf (stderr, "ERROR: failed to read images from tgt\n");
     70    exit (2);
     71  }
     72
     73  ALLOCATE (IDmap->old, off_t, NimagesSrc);
     74  ALLOCATE (IDmap->new, off_t, NimagesSrc);
     75  IDmap->Nmap = NimagesSrc;
     76
     77  // match by time and photcode
     78  ALLOCATE (TgtIndex, off_t,  NimagesTgt);
     79  ALLOCATE (TgtTimes, e_time, NimagesTgt);
     80  ALLOCATE (TgtCodes, short,  NimagesTgt);
     81
     82  // save the Index, Times, Codes for all TGT images
     83  for (iTgt = 0; iTgt < NimagesTgt; iTgt++) {
     84    TgtIndex[iTgt] = iTgt;
     85    TgtTimes[iTgt] = imagesTgt[iTgt].tzero;
     86    TgtCodes[iTgt] = imagesTgt[iTgt].photcode;
     87  }
     88
     89  // sort the index, start, and stop by the start times:
     90  SortTgtByTimes (TgtTimes, TgtIndex, TgtCodes, NimagesTgt);
     91
     92  for (iSrc = 0; iSrc < NimagesSrc; iSrc++) {
     93    iTgt = getTgtIndex (imagesSrc[iSrc].tzero, imagesSrc[iSrc].tzero + (int) imagesSrc[iSrc].exptime, imagesSrc[iSrc].photcode, TgtIndex, TgtTimes, TgtCodes, NimagesTgt);
     94    if (iTgt < 0) Shutdown ("failure to match images: %s\n", imagesSrc[iSrc].name);
     95    IDmap[0].old[iSrc] = imagesSrc[iSrc].imageID;
     96    IDmap[0].new[iSrc] = imagesTgt[iTgt].imageID;
     97  }
     98
     99  FREE(TgtIndex);
     100  FREE(TgtTimes);
     101  FREE(TgtCodes);
     102
     103  // sort IDmap->old,new on the basis of IDmap->old:
     104  sort_IDmap (IDmap);
     105
     106  return TRUE;
     107}
    4108
    5109// merge db2 into db1
  • branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/dvomerge.c

    r28327 r29788  
    1212  if (argc == 6) dvomergeCreate (argc, argv);
    1313  if (argc == 4) dvomergeUpdate (argc, argv);
     14  if (argc == 5) dvomergeContinue (argc, argv);
    1415  dvomerge_usage();
    1516  exit (2); // cannot reach here.
     
    1819/* we have two possible modes of operation:
    1920
    20    Create : dvomerge (in1) and (in2) to (out) -- create a new db from two input dbs
    21    Update : dvomerge (in) into (out)          -- merge a new db into an existing db
     21   Create   : dvomerge (in1) and (in2) to (out) -- create a new db from two input dbs
     22   Update   : dvomerge (in) into (out)          -- merge a new db into an existing db
     23   Continue : dvomerge (in) into (out) continue -- merge a new db into an existing db
    2224
    2325*/
  • branches/eam_branches/ipp-20101103/Ohana/src/dvomerge/src/help.c

    r29787 r29788  
    44  fprintf (stderr, "USAGE: dvomerge (input1) and (input2) to (output)\n");
    55  fprintf (stderr, "   OR: dvomerge (input) into (output)\n");
     6  fprintf (stderr, "   OR: dvomerge (input) into (output) continue\n");
    67  fprintf (stderr, "   [-region Rmin Rmax Dmin Dmax]\n");
    78  exit (2);
     
    3334  fprintf (stderr, "USAGE\n");
    3435  fprintf (stderr, "  dvomerge (input1) and (input2) to (output)\n");
    35   fprintf (stderr, "  dvomerge (input) into (output)\n\n");
     36  fprintf (stderr, "  dvomerge (input) into (output)\n");
     37  fprintf (stderr, "  dvomerge (input) into (output) continue\n\n");
    3638  fprintf (stderr, "  merge DVO databases\n");
    3739  fprintf (stderr, "  optional flags:\n");
     
    3941  fprintf (stderr, "  -help                       : this list\n");
    4042  fprintf (stderr, "  -h                          : this list\n\n");
     43  fprintf (stderr, "  -region Rmin Rmax Dmin Dmax : region to merge\n\n");
    4144  exit (2);
    4245}
Note: See TracChangeset for help on using the changeset viewer.