IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27384


Ignore:
Timestamp:
Mar 21, 2010, 6:06:42 PM (16 years ago)
Author:
eugene
Message:

update dvomerge to handle complete dvo dbs, and merging into an existing db

Location:
branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge
Files:
4 added
10 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/Makefile

    r24745 r27384  
    2222DVOMERGE = \
    2323$(SRC)/dvomerge.$(ARCH).o \
     24$(SRC)/dvomergeUpdate.$(ARCH).o \
     25$(SRC)/dvomergeCreate.$(ARCH).o \
    2426$(SRC)/SetSignals.$(ARCH).o \
    2527$(SRC)/ConfigInit.$(ARCH).o \
    2628$(SRC)/Shutdown.$(ARCH).o \
    27 $(SRC)/usage.$(ARCH).o \
     29$(SRC)/help.$(ARCH).o \
     30$(SRC)/args.$(ARCH).o \
     31$(SRC)/psps_ids.$(ARCH).o \
    2832$(SRC)/SkyTablePopulatedRange.$(ARCH).o \
    2933$(SRC)/LoadCatalog.$(ARCH).o \
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/include/dvomerge.h

    r27368 r27384  
    2222char   CATMODE[16];    /* raw, mef, split, mysql */
    2323char   CATFORMAT[16];  /* internal, elixir, loneos, panstarrs */
     24char   ImageCat[256];
    2425float  RADIUS;
    2526int    SKY_DEPTH;
     
    2829
    2930int        main                   PROTO((int argc, char **argv));
     31int        dvomergeCreate         PROTO((int argc, char **argv));
     32int        dvomergeUpdate         PROTO((int argc, char **argv));
    3033
    3134int        ConfigInit             PROTO((int *argc, char **argv));
     
    3841
    3942void       usage                  PROTO((void));
    40 int        SkyTablePopulatedRange PROTO((int *ns, int *ne, SkyTable *sky, int Nstart));
     43void       help                   PROTO((int argc, char **argv));
     44int        args                   PROTO((int *argc, char **argv));
     45
     46int        SkyTablePopulatedRange PROTO((off_t *ns, off_t *ne, SkyTable *sky, off_t Nstart));
    4147
    4248SkyList   *SkyTablePopulatedList  PROTO((SkyTable *sky));
    43 SkyList   *SkyTablePopulatedList_old  PROTO((SkyTable *sky, int Ns, int Ne));
     49SkyList   *SkyTablePopulatedList_old  PROTO((SkyTable *sky, off_t Ns, off_t Ne));
    4450
    4551int        LoadCatalog            PROTO((Catalog *catalog, SkyRegion *region, char *filename, char *mode));
     
    4854int        merge_catalogs_old     PROTO((SkyRegion *region, Catalog *output, Catalog *input, double RADIUS));
    4955
    50 int       *init_measure_links     PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure));
    51 int       *init_missing_links     PROTO((Average *average, int Naverage, Missing *missing, int Nmissing));
    52 int       *build_measure_links    PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure));
    53 int        add_meas_link          PROTO((Average *average, int *next, int Nmeasure, int NMEASURE));
    54 int        add_miss_link          PROTO((Average *average, int *next, int Nmissing));
    55 Measure   *sort_measure           PROTO((Average *average, int Naverage, Measure *measure, int Nmeasure, int *next));
    56 Missing   *sort_missing           PROTO((Average *average, int Naverage, Missing *missing, int Nmissing, int *next_miss));
     56off_t     *init_measure_links     PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure));
     57off_t     *init_missing_links     PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing));
     58off_t     *build_measure_links    PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure));
     59int        add_meas_link          PROTO((Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE));
     60int        add_miss_link          PROTO((Average *average, off_t *next, off_t Nmissing));
     61Measure   *sort_measure           PROTO((Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next));
     62Missing   *sort_missing           PROTO((Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next_miss));
     63
     64uint64_t   CreatePSPSDetectionID  PROTO((double tobs, int ccdid, int detID));
     65uint64_t   CreatePSPSObjectID     PROTO((double ra, double dec));
     66
     67int        dvo_image_merge_dbs    PROTO((FITS_DB *out, FITS_DB *in));
     68
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/ConfigInit.c

    r24750 r27384  
    44
    55  double ZERO_POINT;
     6  char RadiusWord[80];
    67  char *config, *file;
    7   char CatdirPhotcodeFile[256];
    8   char MasterPhotcodeFile[256];
    98
    109  /*** load configuration info ***/
    1110  file = SelectConfigFile (argc, argv, "ptolemy");
     11
    1212  config = LoadConfigFile (file);
    1313  if (config == (char *) NULL) {
     
    1818  if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
    1919
    20   GetConfig (config, "PHOTCODE_FILE",           "%s",  0, MasterPhotcodeFile);
     20
    2121  GetConfig (config, "GSCFILE",                 "%s",  0, GSCFILE);
    2222  ScanConfig (config, "CATMODE",                "%s",  0, CATMODE);
    2323  ScanConfig (config, "CATFORMAT",              "%s",  0, CATFORMAT);
    24   ScanConfig (config, "RADIUS",                 "%f",  0, &RADIUS);
    2524  GetConfig (config, "SKY_DEPTH",              "%d",  0, &SKY_DEPTH);
    2625  if (SKY_DEPTH > 4) {
     
    3635  SetZeroPoint (ZERO_POINT);
    3736
     37  /* set the default search radius */
     38  if (!ScanConfig (config, "ADDSTAR_RADIUS", "%s", 0, RadiusWord)) {
     39    GetConfig (config, "RADIUS", "%s", 0, RadiusWord);
     40  }
     41  RADIUS = atof (RadiusWord);
    3842  if (RADIUS < 1e-6) {
    3943      fprintf (stderr, "non-sensical correlation radius %f\n", RADIUS);
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/SkyTablePopulatedRange.c

    r24745 r27384  
    11# include "dvomerge.h"
    22
    3 int SkyTablePopulatedRange (int *ns, int *ne, SkyTable *sky, int Nstart) {
     3int SkyTablePopulatedRange (off_t *ns, off_t *ne, SkyTable *sky, off_t Nstart) {
    44
    5   int Ns, Ne;
     5  off_t Ns, Ne;
    66
    77  // given the starting sky region, find the populated range at or below this region
     
    2626SkyList *SkyTablePopulatedList (SkyTable *sky) {
    2727
    28   int i, N, NREGIONS;
    29   SkyList *list, *subset;
     28  off_t i, N, NREGIONS;
     29  SkyList *list;
    3030
    3131  N = 0;
     
    5454}
    5555
    56 SkyList *SkyTablePopulatedList_old (SkyTable *sky, int Ns, int Ne) {
     56SkyList *SkyTablePopulatedList_old (SkyTable *sky, off_t Ns, off_t Ne) {
    5757
    58   int i, ns, ne, N, NREGIONS;
     58  off_t i, ns, ne, N, NREGIONS;
    5959  SkyList *list, *subset;
    6060
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/args.c

    r24745 r27384  
    11# include "dvomerge.h"
    2 static void help (void);
    32
    4 int args (int argc, char **argv) {
     3/*** check for command line options ***/
     4int args (int *argc, char **argv) {
    55 
    6   int i, N, CONFIRM;
    7 
    8   /* check for help request */
    9   if (get_argument (argc, argv, "-help") ||
    10       get_argument (argc, argv, "-h")) {
    11     help ();
    12   }
    13 
    14   /*** check for command line options ***/
     6  int N, CONFIRM;
    157
    168  /*** provide additional data ***/
     
    2113  UserPatch.Dmax = +90;
    2214  CONFIRM = TRUE;
    23   if ((N = get_argument (argc, argv, "-region"))) {
    24     remove_argument (N, &argc, argv);
     15  if ((N = get_argument (*argc, argv, "-region"))) {
     16    remove_argument (N, argc, argv);
    2517    UserPatch.Rmin = atof (argv[N]);
    26     remove_argument (N, &argc, argv);
     18    remove_argument (N, argc, argv);
    2719    UserPatch.Rmax = atof (argv[N]);
    28     remove_argument (N, &argc, argv);
     20    remove_argument (N, argc, argv);
    2921    UserPatch.Dmin = atof (argv[N]);
    30     remove_argument (N, &argc, argv);
     22    remove_argument (N, argc, argv);
    3123    UserPatch.Dmax = atof (argv[N]);
    32     remove_argument (N, &argc, argv);
     24    remove_argument (N, argc, argv);
    3325    CONFIRM = FALSE;
    3426  }
     
    3628  /* extra error messages */
    3729  VERBOSE = FALSE;
    38   if ((N = get_argument (argc, argv, "-v"))) {
     30  if ((N = get_argument (*argc, argv, "-v"))) {
    3931    VERBOSE = TRUE;
    40     remove_argument (N, &argc, argv);
     32    remove_argument (N, argc, argv);
    4133  }
    4234
    43   if (argc == 2) {
    44     if (CONFIRM) {
    45       fprintf (stderr, "you are splitting the entire sky in one pass\n");
    46       fprintf (stderr, "this could be a time consuming operation.  type Ctrl-C within 5 seconds to cancel\n");
    47       for (i = 5; i > 0; i--) {
    48         fprintf (stderr, "%d.. ", i);
    49         usleep (1000000);
    50       }
    51       fprintf (stderr, "\n");
    52     }   
    53     return (TRUE);
    54   }
    55 
    56   fprintf (stderr, "USAGE: dvosplit (newlevel) [-region (Rmin) (Rmax) (Dmin) (Dmax)]\n");
    57   exit (2);
     35  if ((*argc != 6) && (*argc != 4)) usage();
     36  return TRUE;
    5837}
    59 
    60 static void help () {
    61 
    62   fprintf (stderr, "USAGE\n");
    63   fprintf (stderr, "  dvosplit (newlevel)\n\n");
    64   fprintf (stderr, "  optional flags:\n");
    65   fprintf (stderr, "  -region ra ra dec dec       : migrate catalogs in specified region\n");
    66   fprintf (stderr, "  -v                          : verbose mode\n");
    67   fprintf (stderr, "  -help                       : this list\n");
    68   fprintf (stderr, "  -h                          : this list\n\n");
    69   exit (2);
    70 }
    71 
    72 /** addstar modes:
    73  
    74     addstar (image.smp)  - add cmp/smp image data to db
    75     addstar -ref (file.dat) (photcode)
    76     addstar -cat (USNO/2MASS/GSC) -region (ra dec - ra dec)
    77 
    78     -replace : ref/cat - replace existing match (photcode/time)
    79     -match   : ref/cat - only add measures to existing averages
    80 
    81     ref types:
    82     ASCII - RA,DEC,M,dM in a table
    83 
    84     addstar
    85 
    86 **/
    87 
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/build_links.c

    r24745 r27384  
    33/* build the initial links assuming the table is sorted,
    44   not partial, and has a correct set of average[].measureOffset,Nmeasure values */
    5 int *init_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure) {
    6 
    7   int i, j, N;
    8   int *next;
     5off_t *init_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) {
     6
     7  off_t i, j, N;
     8  off_t *next;
    99
    1010  N = 0;
    1111
    12   ALLOCATE (next, int, Nmeasure);
     12  ALLOCATE (next, off_t, Nmeasure);
    1313  for (i = 0; i < Naverage; i++, N++) {
    1414    for (j = 0; j < average[i].Nmeasure - 1; j++, N++) {
     
    3131}
    3232
     33/* average[].measureOffset, average[].Nmeasure are valid within an addstar run */
     34int add_meas_link (Average *average, off_t *next, off_t Nmeasure, off_t NMEASURE) {
     35
     36  off_t k, m;
     37
     38  /* if we have trouble, check validity of next[m] : m < Nmeasure */
     39  m = average[0].measureOffset; 
     40
     41  for (k = 0; k < average[0].Nmeasure - 1; k++)  {
     42    m = next[m];
     43    if (m >= NMEASURE) {
     44      fprintf (stderr, "WARNING: m out of bounds (3)\n");
     45    }
     46  }
     47
     48  /* set up references */
     49  next[Nmeasure] = -1;
     50  if (Nmeasure >= NMEASURE) {
     51    fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n");
     52  }
     53
     54  if (m == -1) {
     55    average[0].measureOffset = Nmeasure;
     56  } else {
     57    next[m] = Nmeasure;
     58    if (m >= NMEASURE) {
     59      fprintf (stderr, "WARNING: m out of bounds (4)\n");
     60    }
     61  }
     62
     63  return (TRUE);
     64}
     65
     66Measure *sort_measure (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure, off_t *next) {
     67
     68  off_t i, k, n, N;
     69  Measure *tmpmeasure;
     70
     71  /* fix order of Measure (memory intensive, but fast) */
     72  N = 0;
     73  ALLOCATE (tmpmeasure, Measure, Nmeasure);
     74  for (i = 0; i < Naverage; i++) {
     75    n = average[i].measureOffset;
     76    average[i].measureOffset = N;
     77    for (k = 0; k < average[i].Nmeasure; k++, N++) {
     78      tmpmeasure[N] = measure[n];
     79      tmpmeasure[N].averef = i;
     80      n = next[n];
     81    }
     82  }
     83  free (measure);
     84  return (tmpmeasure);
     85}
     86
     87/* construct measure links which are valid FOR THIS LOAD
     88 * - if we have a full load, we will get links which can
     89 *   be used by other programs (eg, relphot, etc)
     90 * - if we have a partial load, the links are only valid
     91 *   for that partial load
     92 */
     93
     94off_t *build_measure_links (Average *average, off_t Naverage, Measure *measure, off_t Nmeasure) {
     95
     96  off_t i, m, k, Nm, averef;
     97  off_t *next;
     98
     99  ALLOCATE (next, off_t, Nmeasure);
     100
     101  /* reset the Nm, offset values for average */
     102  for (i = 0; i < Naverage; i++) {
     103    average[i].measureOffset = -1;
     104    average[i].Nmeasure     =  0;
     105  }
     106
     107  for (Nm = 0; Nm < Nmeasure; Nm++) {
     108    averef = measure[Nm].averef;
     109    m = average[averef].measureOffset; 
     110    next[Nm] = -1;
     111
     112    if (m == -1) { /* no links yet for source */
     113      average[averef].measureOffset = Nm;
     114      average[averef].Nmeasure     = 1;
     115      continue;
     116    }
     117
     118    for (k = 0; next[m] != -1; k++) {
     119      m = next[m];
     120      if (m >= Nmeasure) {
     121        fprintf (stderr, "WARNING: m out of bounds (1)\n");
     122      }
     123    }
     124
     125    average[averef].Nmeasure = k + 2;
     126    next[m] = Nm;
     127    if (m >= Nmeasure) {
     128      fprintf (stderr, "WARNING: m out of bounds (2)\n");
     129    }
     130  }
     131  return (next);
     132}
     133
    33134/* build the initial links assuming the table is sorted */
    34 int *init_missing_links (Average *average, int Naverage, Missing *missing, int Nmissing) {
    35 
    36   int i, j, N;
    37   int *next;
     135off_t *init_missing_links (Average *average, off_t Naverage, Missing *missing, off_t Nmissing) {
     136
     137  off_t i, j, N;
     138  off_t *next;
    38139
    39140  N = 0;
    40141
    41   ALLOCATE (next, int, Nmissing);
     142  ALLOCATE (next, off_t, Nmissing);
    42143  for (i = 0; i < Naverage; i++) {
    43144    for (j = 0; j < average[i].Nmissing - 1; j++, N++) {
     
    57158}
    58159
    59 /* average[].measureOffset, average[].Nmeasure are valid within an addstar run */
    60 int add_meas_link (Average *average, int *next, int Nmeasure, int NMEASURE) {
    61 
    62   int k, m;
    63 
    64   /* if we have trouble, check validity of next[m] : m < Nmeasure */
    65   m = average[0].measureOffset; 
    66 
    67   for (k = 0; k < average[0].Nmeasure - 1; k++)  {
    68     m = next[m];
    69     if (m >= NMEASURE) {
    70       fprintf (stderr, "WARNING: m out of bounds (3)\n");
    71     }
    72   }
    73 
    74   /* set up references */
    75   next[Nmeasure] = -1;
    76   if (Nmeasure >= NMEASURE) {
    77     fprintf (stderr, "WARNING: Nmeasure out of bounds (1)\n");
    78   }
    79 
    80   if (m == -1) {
    81     average[0].measureOffset = Nmeasure;
    82   } else {
    83     next[m] = Nmeasure;
    84     if (m >= NMEASURE) {
    85       fprintf (stderr, "WARNING: m out of bounds (4)\n");
    86     }
    87   }
    88 
    89   return (TRUE);
    90 }
    91 
    92 int add_miss_link (Average *average, int *next, int Nmissing) {
    93 
    94   int k, m;
     160int add_miss_link (Average *average, off_t *next, off_t Nmissing) {
     161
     162  off_t k, m;
    95163
    96164  /* there may be 0 Nmiss; this is not true for Nmeas */
     
    109177}
    110178
    111 /* construct measure links which are valid FOR THIS LOAD
    112  * - if we have a full load, we will get links which can
    113  *   be used by other programs (eg, relphot, etc)
    114  * - if we have a partial load, the links are only valid
    115  *   for that partial load
    116  */
    117 
    118 int *build_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure) {
    119 
    120   int i, m, k, Nm, averef;
    121   int *next;
    122 
    123   ALLOCATE (next, int, Nmeasure);
    124 
    125   /* reset the Nm, offset values for average */
    126   for (i = 0; i < Naverage; i++) {
    127     average[i].measureOffset = -1;
    128     average[i].Nmeasure     =  0;
    129   }
    130 
    131   for (Nm = 0; Nm < Nmeasure; Nm++) {
    132     averef = measure[Nm].averef;
    133     m = average[averef].measureOffset; 
    134     next[Nm] = -1;
    135 
    136     if (m == -1) { /* no links yet for source */
    137       average[averef].measureOffset = Nm;
    138       average[averef].Nmeasure     = 1;
    139       continue;
    140     }
    141 
    142     for (k = 0; next[m] != -1; k++) {
    143       m = next[m];
    144       if (m >= Nmeasure) {
    145         fprintf (stderr, "WARNING: m out of bounds (1)\n");
    146       }
    147     }
    148 
    149     average[averef].Nmeasure = k + 2;
    150     next[m] = Nm;
    151     if (m >= Nmeasure) {
    152       fprintf (stderr, "WARNING: m out of bounds (2)\n");
    153     }
    154   }
    155   return (next);
    156 }
    157 
    158179/* Missing does not carry enough information to reconstruct the links
    159180   we must always save the missing table, if it exists */
    160181
    161 Measure *sort_measure (Average *average, int Naverage, Measure *measure, int Nmeasure, int *next) {
    162 
    163   int i, k, n, N;
    164   Measure *tmpmeasure;
    165 
    166   /* fix order of Measure (memory intensive, but fast) */
    167   N = 0;
    168   ALLOCATE (tmpmeasure, Measure, Nmeasure);
    169   for (i = 0; i < Naverage; i++) {
    170     n = average[i].measureOffset;
    171     average[i].measureOffset = N;
    172     for (k = 0; k < average[i].Nmeasure; k++, N++) {
    173       tmpmeasure[N] = measure[n];
    174       tmpmeasure[N].averef = i;
    175       n = next[n];
    176     }
    177   }
    178   free (measure);
    179   return (tmpmeasure);
    180 }
    181 
    182 Missing *sort_missing (Average *average, int Naverage, Missing *missing, int Nmissing, int *next) {
    183 
    184   int i, k, n, N;
     182Missing *sort_missing (Average *average, off_t Naverage, Missing *missing, off_t Nmissing, off_t *next) {
     183
     184  off_t i, k, n, N;
    185185  Missing *tmpmissing;
    186186
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/dvomerge.c

    r25757 r27384  
    11# include "dvomerge.h"
    22
    3 // dvomerge (catdir.in1) and (catdir.in2) to (catdir.output) [-region Rmin Rmax Dmin Dmax] [
    4 // merge sources from (catdir.from) into (catdir.to)
    53int main (int argc, char **argv) {
    64
    7   int i, j, Ns, Ne, depth1, depth2;
    8   SkyTable *outsky, *insky1, *insky2;
    9   SkyList *inlist;
    10   Catalog incatalog, outcatalog;
    11   char filename[256], *input1, *input2, *output;
     5  SetSignals ();
     6  help (argc, argv);
     7  ConfigInit (&argc, argv);
     8  args (&argc, argv);
    129
    13   SetSignals ();
    14   ConfigInit (&argc, argv);
    15 
    16   if (argc != 6) usage();
    17   if (strcasecmp (argv[2], "and")) usage();
    18   if (strcasecmp (argv[4], "to")) usage();
    19 
    20   input1 = argv[1];
    21   input2 = argv[3];
    22   output = argv[5];
    23 
    24   // the first input define the photcode table & db layout
    25   sprintf (filename, "%s/Photcodes.dat", input1);
    26   if (!LoadPhotcodes (filename, NULL, FALSE)) {
    27     fprintf (stderr, "error loading photcode table %s\n", filename);
    28     exit (1);
    29   }
    30   // save the photcodes in the output catdir
    31   sprintf (filename, "%s/Photcodes.dat", output);
    32   if (!check_file_access (filename, TRUE, TRUE, TRUE)) {
    33     fprintf (stderr, "error creating output catdir %s\n", output);
    34     exit (1);
    35   }
    36   if (!SavePhotcodesFITS (filename)) {
    37     fprintf (stderr, "error saving photcode table %s\n", filename);
    38     exit (1);
    39   }
    40 
    41   // load the sky table for the existing database
    42   insky1 = SkyTableLoadOptimal (input1, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
    43   SkyTableSetFilenames (insky1, input1, "cpt");
    44 
    45   insky2 = SkyTableLoadOptimal (input2, NULL, NULL, FALSE, SKY_DEPTH_HST, VERBOSE);
    46   SkyTableSetFilenames (insky2, input2, "cpt");
    47 
    48   // generate an output table populated at the desired depth
    49   outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    50   SkyTableSetFilenames (outsky, output, "cpt");
    51 
    52   // loop over the populatable output tables; check for data in input1 and/or input2
    53   // in the corresponding regions
    54 
    55   SkyTablePopulatedRange (&Ns, &Ne, insky1, 0);
    56   depth1 = insky1[0].regions[Ns].depth;
    57  
    58   SkyTablePopulatedRange (&Ns, &Ne, insky2, 0);
    59   depth2 = insky2[0].regions[Ns].depth;
    60 
    61   // loop over the populatable output regions
    62   for (i = 0; i < outsky[0].Nregions; i++) {
    63     if (!outsky[0].regions[i].table) continue;
    64     fprintf (stderr, "output: %s\n", outsky[0].regions[i].name);
    65 
    66     // load / create output catalog
    67     LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w");
    68 
    69     // combine only tables at equal or larger depth
    70      
    71     // load in all of the tables from input1 for this region
    72     inlist = SkyListByBounds (insky1, depth1, outsky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax);
    73     for (j = 0; j < inlist[0].Nregions; j++) {
    74       fprintf (stderr, "input 1: %s\n", inlist[0].regions[j][0].name);
    75 
    76       // load input catalog (1)
    77       LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r");
    78 
    79       // skip empty input catalogs
    80       if (!incatalog.Naves_disk) {
    81         dvo_catalog_unlock (&incatalog);
    82         dvo_catalog_free (&incatalog);
    83         continue;
    84       }
    85       merge_catalogs_new (&outsky[0].regions[i], &outcatalog, &incatalog);
    86       dvo_catalog_unlock (&incatalog);
    87       dvo_catalog_free (&incatalog);
    88     }
    89     SkyListFree (inlist);
    90 
    91     // load in all of the tables from input2 for this region
    92     inlist = SkyListByBounds (insky2, depth2, outsky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax);
    93     for (j = 0; j < inlist[0].Nregions; j++) {
    94       fprintf (stderr, "input 2: %s\n", inlist[0].regions[j][0].name);
    95 
    96       // load input catalog (1)
    97       LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r");
    98 
    99       // skip empty input catalogs
    100       if (!incatalog.Naves_disk) {
    101         dvo_catalog_unlock (&incatalog);
    102         dvo_catalog_free (&incatalog);
    103         continue;
    104       }
    105       merge_catalogs_old (&outsky[0].regions[i], &outcatalog, &incatalog, RADIUS);
    106       dvo_catalog_unlock (&incatalog);
    107       dvo_catalog_free (&incatalog);
    108     }
    109     SkyListFree (inlist);
    110 
    111     outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    112     dvo_catalog_save (&outcatalog, VERBOSE);
    113     dvo_catalog_unlock (&outcatalog);
    114     dvo_catalog_free (&outcatalog);
    115   }
    116 
    117   // save the output sky table copy
    118   sprintf (filename, "%s/SkyTable.fits", output);
    119   check_file_access (filename, TRUE, TRUE, VERBOSE);
    120   if (!SkyTableSave (outsky, filename)) {
    121     fprintf (stderr, "ERROR: failed to save sky table for %s\n", output);
    122     exit (1);
    123   }
    124 
    125   exit (0);
     10  if (argc == 6) dvomergeCreate (argc, argv);
     11  if (argc == 4) dvomergeUpdate (argc, argv);
     12  usage();
     13  exit (2); // cannot reach here.
    12614}
    12715
    128 /*
     16/* we have two possible modes of operation:
    12917
    130    for the upgrade of the synth database, at a minimum I need to use an output format that uses
    131    doubles for the astrometry.  Optionally I should merge in the 2MASS photometry measurements, since that
    132    would be quite useful for comparison. 
     18   Create : dvomerge (in1) and (in2) to (out) -- create a new db from two input dbs
     19   Update : dvomerge (in) into (out)          -- merge a new db into an existing db
    13320
    134    generality questions:
    135    * optional
    136 
    137 
    138 
    139    */
    140 
     21*/
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_new.c

    r27295 r27384  
    6666 
    6767  if (VERBOSE) {
    68       fprintf (stderr, "%d: using %d stars (%d measures) for catalog\n", i,
    69                output[0].Naverage, output[0].Nmeasure);
     68      fprintf (stderr, "%lld: using %lld stars (%lld measures) for catalog\n",
     69               (long long) i,
     70               (long long) output[0].Naverage,
     71               (long long) output[0].Nmeasure);
    7072  }
    7173  return (TRUE);
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/merge_catalogs_old.c

    r27295 r27384  
    11# include "dvomerge.h"
     2# define PSPS_ID TRUE
    23
    34# define IN_REGION(R,D) ( \
     
    119120    /* negative dX: j is too large */
    120121    dX = X1[i] - X2[j];
    121     if (dX <= -2*RADIUS) {
     122    if (dX <= -1.02*RADIUS) {
    122123      i++;
    123124      continue;
    124125    }
    125126    /* positive dX, i is too large */
    126     if (dX >= 2*RADIUS) {
     127    if (dX >= 1.02*RADIUS) {
    127128      j++;
    128129      continue;
     
    131132    Jmin = -1;
    132133    Rmin = RADIUS2;
    133     for (J = j; (dX > -2*RADIUS) && (J < Nave); J++) {
     134    for (J = j; (dX > -1.02*RADIUS) && (J < Nave); J++) {
    134135      /* find closest match for this detection */
    135136      dX = X1[i] - X2[J];
     
    161162    }
    162163
    163     /** add measurements for this input average object **/
     164    /** add ALL measurements for this input average object **/
    164165    for (Nin = 0; Nin < input[0].average[N].Nmeasure; Nin ++) {
    165166      offset = input[0].average[N].measureOffset + Nin;
     
    169170       
    170171      // set the new measurements
    171       output[0].measure[Nmeas]          = input[0].measure[offset];
     172      output[0].measure[Nmeas] = input[0].measure[offset];
    172173
    173174      Rin = input[0].average[N].R - input[0].measure[offset].dR / 3600.0;
     
    177178      output[0].measure[Nmeas].dR       = 3600.0*(output[0].average[n].R - Rin);  // XXX update these based on choice of astromety
    178179      output[0].measure[Nmeas].dD       = 3600.0*(output[0].average[n].D - Din);  // XXX update these based on choice of astromety
    179       output[0].measure[Nmeas].dbFlags  = 0;
     180      output[0].measure[Nmeas].dbFlags  = 0;  // XXX why reset these?
    180181      output[0].measure[Nmeas].averef   = n;
    181182      output[0].measure[Nmeas].objID    = output[0].average[n].objID;
    182183      output[0].measure[Nmeas].catID    = output[0].catID;
     184
     185      // fprintf (stderr, "Nave : %lld, Nmeas : %lld, dR: %f, dD: %f, catID: %d\n", (long long) n, (long long) Nmeas, output[0].measure[Nmeas].dR, output[0].measure[Nmeas].dD, output[0].measure[i].catID);
    183186
    184187      // rationalize dR
     
    197200                 output[0].average[n].R, output[0].average[n].D, Rin, Din,
    198201                 X1[i], X2[Jmin], Y1[i], Y2[Jmin]);
     202        // XXX abort on this? -- this is a bad failure...
    199203      }
    200204      input[0].found[N] = Nmeas;
     205      output[0].average[n].Nmeasure ++;
    201206      Nmeas ++;
    202207    }
     
    205210       Nm is recalculated in build_meas_links if loaded table is not sorted */
    206211    output[0].found[n] = Nmeas;
    207     output[0].average[n].Nmeasure ++;
    208212    i++;
    209213  }
     214
     215# if (0)
     216  fprintf (stderr, "--- 1 ---\n");
     217  for (i = 0; i < Nmeas; i++) {
     218    fprintf (stderr, "Nave : %d, Nmeas : %lld, dR: %f, dD: %f, catID: %d\n", output[0].measure[i].averef, (long long) i, output[0].measure[i].dR, output[0].measure[i].dD, output[0].measure[i].catID);
     219  }
     220# endif
    210221
    211222  /** incorporate unmatched image stars, if this star is in field of this catalog **/
    212223  /* these new entries are all written out in UPDATE mode */
    213224  for (i = 0; i < Nstars; i++) {
    214 
    215     N = N1[i];
    216     if (input[0].found[N] >= 0) continue;
    217     if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue;
    218 
    219225    /* make sure there is space for next entry */
    220226    if (Nmeas + input[0].average[N].Nmeasure >= NMEAS) {
     
    229235    }
    230236
     237    N = N1[i];
     238    if (input[0].found[N] >= 0) continue;
     239    if (!IN_REGION (input[0].average[N].R, input[0].average[N].D)) continue;
     240
    231241    output[0].average[Nave].R              = input[0].average[N].R;
    232242    output[0].average[Nave].D              = input[0].average[N].D;
     
    238248    output[0].average[Nave].Nextend        = 0;
    239249
    240     output[0].average[Nave].measureOffset = Nmeas;
    241     output[0].average[Nave].missingOffset = -1;
    242     output[0].average[Nave].extendOffset  = -1;
     250    output[0].average[Nave].measureOffset  = Nmeas;
     251    output[0].average[Nave].missingOffset  = -1;
     252    output[0].average[Nave].extendOffset   = -1;
    243253
    244254    output[0].average[Nave].uR             = 0;
     
    253263    output[0].average[Nave].Npos           = 0;
    254264
    255     output[0].average[Nave].objID          = objID;
    256     output[0].average[Nave].catID          = catID;
    257     output[0].average[Nave].flags         = 0;
     265    output[0].average[Nave].objID          = objID; // we create objID values in the context of the output db
     266    output[0].average[Nave].catID          = catID; // we create catID values in the context of the output db
     267    output[0].average[Nave].flags          = 0;  // XXX why reset these?
     268    if (PSPS_ID) {
     269      output[0].average[Nave].extID = CreatePSPSObjectID(output[0].average[Nave].R, output[0].average[Nave].D);
     270    } else {
     271      output[0].average[Nave].extID = 0;
     272    }
    258273
    259274    objID ++;
     
    288303      Nmeas ++;
    289304    }
     305    int Ngroup = input[0].average[N].Nmeasure;
     306    for (j = 0; j < Ngroup - 1; j++) {
     307        next_meas[Nmeas - Ngroup + j] = Nmeas - Ngroup + j + 1;
     308    }
    290309    Nave ++;
    291310  }
     
    294313  REALLOCATE (output[0].measure, Measure, Nmeas);
    295314 
    296 # define NOSORT TRUE
     315# if (0)
     316  fprintf (stderr, "--- 2 ---\n");
     317  for (i = 0; i < Nmeas; i++) {
     318    fprintf (stderr, "Nave : %d, Nmeas : %lld, dR: %f, dD: %f, catID: %d\n", output[0].measure[i].averef, (long long) i, output[0].measure[i].dR, output[0].measure[i].dD, output[0].measure[i].catID);
     319  }
     320# endif
     321
     322# define NOSORT FALSE
    297323  if (NOSORT) {
    298324    output[0].sorted = FALSE;
     
    301327    output[0].measure = sort_measure (output[0].average, Nave, output[0].measure, Nmeas, next_meas);
    302328  }
     329
     330# if (0)
     331  fprintf (stderr, "--- 3 ---\n");
     332  for (i = 0; i < Nmeas; i++) {
     333    fprintf (stderr, "Nave : %d, Nmeas : %lld, dR: %f, dD: %f, catID: %d\n", output[0].measure[i].averef, (long long) i, output[0].measure[i].dR, output[0].measure[i].dD, output[0].measure[i].catID);
     334  }
     335# endif
    303336
    304337  /* note stars which have been found in this catalog */
     
    316349  output[0].Nmeasure = Nmeas;
    317350  output[0].Nsecf_mem = Nave*Nsecfilt;
    318   if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmatch);
     351  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %lld %lld %lld, (%lld matches)\n", (long long) Nstars, (long long) Nave, (long long) Nmeas, (long long) Nmatch);
    319352
    320353  free (next_meas);
  • branches/eam_branches/largefiles.20100314/Ohana/src/dvomerge/src/usage.c

    r24745 r27384  
    33void usage (void) {
    44  fprintf (stderr, "USAGE: dvomerge (input1) and (input2) to (output)\n");
     5  fprintf (stderr, "   OR: dvomerge (input) into (output)\n");
    56  exit (2);
    67}
Note: See TracChangeset for help on using the changeset viewer.