IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 5229


Ignore:
Timestamp:
Oct 6, 2005, 6:11:02 AM (21 years ago)
Author:
eugene
Message:

added CLOSEST match method, added SPLIT table support, made catmode and catformat case-insensitive, added -nosort concept, cleaned find_matches

Location:
trunk/Ohana/src/addstar
Files:
2 added
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/Makefile

    r4864 r5229  
    2525$(SRC)/airmass.$(ARCH).o \
    2626$(SRC)/args.$(ARCH).o \
     27$(SRC)/build_links.$(ARCH).o \
    2728$(SRC)/calibrate.$(ARCH).o \
    2829$(SRC)/check_permissions.$(ARCH).o \
     
    3132$(SRC)/edge_check.$(ARCH).o \
    3233$(SRC)/find_matches.$(ARCH).o \
     34$(SRC)/find_matches_closest.$(ARCH).o \
    3335$(SRC)/find_matches_refstars.$(ARCH).o \
    3436$(SRC)/find_subset.$(ARCH).o \
  • trunk/Ohana/src/addstar/doc/Changes.txt

    r4826 r5229  
    11
    2 2005.02.24 : I am adding the mosaic two-level astrometry information to the Image table.
     22005.10.04
     3        - moved measure/missing list manipulation to separate functions
     4        - added concept of sorted / unsorted measure catalog
     5        - defined build_meas_links and reorder_measure,missing
     6        - some cleanup of both find_matches.c and find_matches_closest.c
     7
     82005.10.03:
     9        - dropping GSCRegion *region entry from find_matches (unused!)
     10        - adding function find_matches_closest (alternate matches)
     11
     122005.08.19:
     13        changed load_photcode to handle CATMODE and CATFORMAT variations
     14        - addstar.h: added CATMODE and CATFORMAT globals
     15        - ConfigInit: read CATMODE and CATFORMAT from config
     16        - gcatalog: set catalog.catmode from CATMODE
     17        - mkcatalog: set CATFORMAT and CATMODE for new catalog
     18        - wcatalog: set CATFORMAT for new catalog
     19       
     20        using full photometry conversions in find_matches
     21        added SetZeroPoint to gstars to enable phot conversions
     22       
     232005.08.15:
     24        cleanup of the minor Wall,Werror messages
    325
    4262005.07.06 : current release is addstar-1.1
     
    2143        need to know about the mysql backend interface. 
    2244
    23 2005.08.15:
    24         cleanup of the minor Wall,Werror messages
     452005.02.24 : I am adding the mosaic two-level astrometry information to the Image table.
    2546
    26 2005.08.19:
    27         changed load_photcode to handle CATMODE and CATFORMAT variations
    28         - addstar.h: added CATMODE and CATFORMAT globals
    29         - ConfigInit: read CATMODE and CATFORMAT from config
    30         - gcatalog: set catalog.catmode from CATMODE
    31         - mkcatalog: set CATFORMAT and CATMODE for new catalog
    32         - wcatalog: set CATFORMAT for new catalog
    33        
    34         using full photometry conversions in find_matches
    35         added SetZeroPoint to gstars to enable phot conversions
    36        
  • trunk/Ohana/src/addstar/doc/notes.txt

    r3392 r5229  
     1
     2- measure <-> average matches and reordering
     3
     4  next[i] = i + 1
     5 
     6
     7 
     8
    19
    2102005.03.07 : notes related to new version of addstar
  • trunk/Ohana/src/addstar/include/addstar.h

    r5144 r5229  
    102102int REPLACE;
    103103int ONLY_MATCH;
     104int CLOSEST;
     105int REORDER;
    104106
    105107int MODE;
     
    110112
    111113/*** addstar prototypes ***/
    112 void       AddToCalibration       PROTO((Average *average, Measure *measure, Measure *new, int Nstar));
     114void       AddToCalibration       PROTO((Average *average, Measure *measure, Measure *new, int *next, int Nstar));
    113115void       ConfigInit             PROTO((int *argc, char **argv));
    114116void       FindCalibration        PROTO((Image *image));
     
    132134int        edge_check             PROTO((double *x1, double *y1, double *x2, double *y2));
    133135void       find_matches           PROTO((GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap));
     136void       find_matches_closest   PROTO((GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap));
    134137void       find_matches_refstars  PROTO((GSCRegion *region, Stars **stars, int Nstars, Catalog *catalog));
    135138Stars    **find_subset            PROTO((GSCRegion *region, Stars *stars, int Nstars, int *NSTARS));
     
    182185void       fsort2                 PROTO((float *X, float *Y, int N));
    183186
     187int *init_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure);
     188int *init_missing_links (Average *average, int Naverage, Missing *missing, int Nmissing);
     189int add_meas_link (Average *average, int *next, int Nmeasure);
     190int add_miss_link (Average *average, int *next, int Nmissing);
     191int *build_measure_links (Average *average, int Naverage, Measure *measure, int Nmeasure);
     192Measure *reorder_measure (Average *average, int Naverage, Measure *measure, int Nmeasure, int *next);
     193Missing *reorder_missing (Average *average, int Naverage, Missing *missing, int Nmissing, int *next_miss);
     194
    184195/**
    185196  there is an inconsistency to be resolved: fixed structures (like Image)
  • trunk/Ohana/src/addstar/src/ConfigInit.c

    r5144 r5229  
    6262  }
    6363
     64  /* default mode, format, if not specified */
    6465  if (*CATMODE == 0) strcpy (CATMODE, "RAW");
    6566  if (*CATFORMAT == 0) strcpy (CATFORMAT, "ELIXIR");
  • trunk/Ohana/src/addstar/src/addstar.c

    r4864 r5229  
    6161    case M_IMAGE:
    6262      Nsubset = Nstars;
    63       find_matches (&regions[i], stars, Nstars, &catalog, &image, overlap, Noverlap);
     63      if (CLOSEST) {
     64        find_matches_closest (&regions[i], stars, Nstars, &catalog, &image, overlap, Noverlap);
     65      } else {
     66        find_matches (&regions[i], stars, Nstars, &catalog, &image, overlap, Noverlap);
     67      }
    6468      break;
    6569    case M_REFCAT:
  • trunk/Ohana/src/addstar/src/args.c

    r5144 r5229  
    2222  fprintf (stderr, "  -missed                     : skipped 'missed' entries\n");
    2323  fprintf (stderr, "  -replace                    : replace time/photcode measurements (no duplication)\n");
     24  fprintf (stderr, "  -closest                    : use closest-star algorith\n");
    2425  fprintf (stderr, "  -image                      : only insert image data\n");
    2526  fprintf (stderr, "  -cal                        : perform zero-point calibration\n");
     
    144145    remove_argument (N, &argc, argv);
    145146  }
     147  /* use 'closest star' matching, rather than traditional method */
     148  CLOSEST = FALSE;
     149  if ((N = get_argument (argc, argv, "-closest"))) {
     150    CLOSEST = TRUE;
     151    remove_argument (N, &argc, argv);
     152  }
     153  /* only add new rows (-update) or re-write complete measure table */
     154  REORDER = TRUE;
     155  if ((N = get_argument (argc, argv, "-update"))) {
     156    REORDER = FALSE;
     157    remove_argument (N, &argc, argv);
     158  }
    146159  /* only add image potion to image table */
    147160  ONLY_IMAGES = FALSE;
  • trunk/Ohana/src/addstar/src/calibrate.c

    r5014 r5229  
    4141}
    4242
    43 /* this does not use the linked list to navigate the measure structure
    44    this is OK for old measures, but will break for entries which have
    45    already added a new measure to the list.  */
    46 void AddToCalibration (Average *average, Measure *measure, Measure *new, int Nstar) {
     43/* use the linked list to navigate the measures; safe for unsorted measures */
     44void AddToCalibration (Average *average, Measure *measure, Measure *new, int *next, int Nstar) {
    4745
    48   int i, found0, found1, found2;
     46  int i, m, found0, found1, found2;
    4947  float CalM0, CalM1, CalM2, dCalM;
    5048  short CalC0, CalC1, CalC2;
     
    5755  CalC2 = thiscode[0].c2;
    5856
     57  m = average[0].offset;
    5958  for (i = 0; i < average[0].Nm; i++) {
    60     if (measure[0].source == CalC0) {
     59    if (measure[m].source == CalC0) {
    6160      found0 = TRUE;
    62       CalM0  = measure[i].M_PS;
    63       dCalM  = measure[i].dM_PS;
     61      CalM0  = measure[m].M_PS;
     62      dCalM  = measure[m].dM_PS;
    6463    }
    65     if (measure[i].source == CalC1) {
     64    if (measure[m].source == CalC1) {
    6665      found1 = TRUE;
    67       CalM1  = measure[i].M_PS;
     66      CalM1  = measure[m].M_PS;
    6867    }
    69     if (measure[i].source == CalC2) {
     68    if (measure[m].source == CalC2) {
    7069      found2 = TRUE;
    71       CalM2  = measure[i].M_PS;
     70      CalM2  = measure[m].M_PS;
    7271    }
    7372    if (found0 && found1 && found2) {
     
    7574      return;
    7675    }
    77     /* n = next[n]; - if we use this, we need to pass in measure[0] above */
     76    m = next[m];
    7877  }
    7978  return;
  • trunk/Ohana/src/addstar/src/find_matches.c

    r5014 r5229  
    33void find_matches (GSCRegion *region, Stars *stars, int Nstars, Catalog *catalog, Image *image, Image *overlap, int Noverlap) {
    44
    5   int i, j, k, n, m, N, J;
     5  int i, j, n, N, J;
    66  double X, Y, RADIUS, RADIUS2, secz;
    77  float *X1, *Y1, *X2, *Y2;
    88  float dX, dY, dR;
    9   int *N1, *N2,  *next, *next_miss, last, last_miss;
     9  int *N1, *N2,  *next_meas, *next_miss;
    1010  int Nave, NAVE, Nmeas, NMEAS, Nmiss, NMISS, Nmatch;
    11   Measure *tmpmeasure;
    12   Missing *tmpmissing;
    1311  Coords tcoords;
    1412  int Nsecfilt, Nsec;
    1513  float Mcat, *Mval, MTIME;
     14  double dtime;
     15  struct timeval start, stop;
     16
     17  gettimeofday (&start, NULL);
    1618
    1719  /* photcode data - must by of type DEP, (PRI, SEC) - probably should restrict to DEP */
     
    2830
    2931  /** allocate local arrays (catalog) **/
    30   Nave = catalog[0].Naverage;
    31   NAVE = Nave + 1000;
     32  NAVE = Nave = catalog[0].Naverage;
    3233  ALLOCATE (X2, float, NAVE);
    3334  ALLOCATE (Y2, float, NAVE);
    3435  ALLOCATE (N2, int,   NAVE);
    3536  ALLOCATE (catalog[0].found, int, NAVE);
    36   REALLOCATE (catalog[0].average, Average, NAVE);
    37   REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt);
    3837  /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */
    3938
     39  /* internal counters */
    4040  Nmatch = 0;
    41   Nmeas = catalog[0].Nmeasure;
    42   NMEAS = Nmeas + 1000;
    43   ALLOCATE (next, int, NMEAS);
    44   REALLOCATE (catalog[0].measure, Measure, NMEAS);
    45  
    46   Nmiss = catalog[0].Nmissing;
    47   NMISS = Nmiss + 1000;
    48   ALLOCATE (next_miss, int, NMISS);
    49   REALLOCATE (catalog[0].missing, Missing, NMISS);
     41  NMEAS = Nmeas = catalog[0].Nmeasure;
     42  NMISS = Nmiss = catalog[0].Nmissing;
    5043 
    5144  /* project onto rectilinear grid with 1 arcsec pixels */
     
    6760  }
    6861
     62  /* build spatial index (RA sort) */
    6963  for (i = 0; i < Nstars; i++) {
    7064    fRD_to_XY (&X1[i], &Y1[i], stars[i].R, stars[i].D, &tcoords);
     
    7367  if (Nstars > 1) sort_lists (X1, Y1, N1, Nstars);
    7468 
     69  /* build spatial index (RA sort) */
    7570  for (i = 0; i < Nave; i++) {
    7671    fRD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R_PS, catalog[0].average[i].D_PS, &tcoords);
     
    8075  if (Nave > 1) sort_lists (X2, Y2, N2, Nave);
    8176
    82   /* set up pointers for linked list of measurements */
    83   for (i = 0; i < Nmeas - 1; i++) {
    84     next[i] = i+1;
    85   }
    86   next[i] = -1;
    87   last = i;
    88 
    89   for (i = 0; i < Nmiss - 1; i++) {
    90     next_miss[i] = i+1;
    91   }
    92   next_miss[i] = -1;
    93   last_miss = i;
     77  /* set up pointers for linked list of measure, missing */
     78  if (catalog[0].ordered) {
     79    next_meas = init_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas);
     80  } else {
     81    next_meas = build_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas);
     82  }   
     83  next_miss = init_missing_links (catalog[0].average, Nave, catalog[0].missing, Nmiss);
     84  /* missing MUST be written ordered, or not at all */
    9485
    9586  /* choose a radius for matches */
     
    10293
    10394  /* correct instrumental mags for exposure time */
    104   if (image[0].exptime > 0) {
    105     MTIME = 2.500*log10(image[0].exptime);
    106   } else {
    107     MTIME = 0;
    108   }
     95  MTIME = (image[0].exptime > 0) ? 2.500*log10(image[0].exptime) : 0.0;
    10996
    11097  /** find matched stars **/
    11198  for (i = j = 0; (i < Nstars) && (j < Nave); ) {
    11299   
     100    /* negative dX: j is too large */
    113101    dX = X1[i] - X2[j];
    114102    if (dX <= -2*RADIUS) {
     
    116104      continue;
    117105    }
     106    /* positive dX, i is too large */
    118107    if (dX >= 2*RADIUS) {
    119108      j++;
     
    121110    }
    122111
    123     /* negative dX: j is too large, positive dX, i is too large */
     112    /* within match range; look for matches */
    124113    for (J = j; (dX > -2*RADIUS) && (J < Nave); J++) {
    125114      dX = X1[i] - X2[J];
     
    128117      if (dR > RADIUS2) continue;
    129118
     119      /* make sure there is space for next entry */
     120      if (Nmeas >= NMEAS) {
     121        NMEAS = Nmeas + 1000;
     122        REALLOCATE (next_meas, int, NMEAS);
     123        REALLOCATE (catalog[0].measure, Measure, NMEAS);
     124      }
     125
    130126      Nmatch ++;
    131127      n = N2[J];
    132128      N = N1[i];
    133       m = catalog[0].average[n].offset; 
    134 
    135       /** insert star in measurement list */
    136       /* find last measurement of this star */
    137       for (k = 0; k < catalog[0].average[n].Nm - 1; k++) m = next[m];
    138       /* set up references */
    139       next[Nmeas] = next[m];
    140       next[m] = Nmeas;
    141       /* last just was moved */
    142       if (next[Nmeas] == -1) last = Nmeas;
    143        
     129
     130      /* add to end of measurement list */
     131      add_meas_link (&catalog[0].average[n], next_meas, Nmeas);
     132
    144133      /* calculate accurate per-star airmass */
    145134      secz = airmass (image[0].secz_PS, stars[N].R, stars[N].D, SiderealTime, Latitude);
     
    171160      if (*Mval == NO_MAG) *Mval = Mcat;
    172161
    173       /** this is a little tricky: the new measures are not in the measure sequence
    174           this call can run into the next star if we have had two measures found at this location. **/
     162      /* adds the measurement to the calibration if appropriate color terms are found */
    175163      if (CALIBRATE) {
    176         AddToCalibration (&catalog[0].average[n], &catalog[0].measure[m], &catalog[0].measure[Nmeas], N);
     164        AddToCalibration (&catalog[0].average[n], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N);
    177165      }
    178166
     
    196184        catalog[0].found[n] = Nmeas;
    197185      }
    198 
    199186      catalog[0].average[n].Nm ++;
    200187      Nmeas ++;
    201       if (Nmeas == NMEAS) {
    202         NMEAS = Nmeas + 1000;
    203         REALLOCATE (next, int, NMEAS);
    204         REALLOCATE (catalog[0].measure, Measure, NMEAS);
    205       }
    206 
    207       update_coords (&catalog[0].average[n], &catalog[0].measure[0], next);
     188
     189      update_coords (&catalog[0].average[n], &catalog[0].measure[0], next_meas);
    208190    }
    209191    i++;
     
    215197    n = N2[j];
    216198    if (catalog[0].found[n] < 0) {
     199      /* make sure there is space for next entry */
     200      if (Nmiss >= NMISS) {
     201        NMISS = Nmiss + 1000;
     202        REALLOCATE (next_miss, int, NMISS);
     203        REALLOCATE (catalog[0].missing, Missing, NMISS);
     204      }
     205
    217206      /* should the catalog star be on this image? project into image coords */
    218207      if (!in_image (catalog[0].average[n].R_PS, catalog[0].average[n].D_PS, image)) continue;
    219       /* find last missing meas */
    220       if (catalog[0].average[n].Nn < 1) { /* no previous missing obs */
    221         catalog[0].average[n].missing = Nmiss;
    222         next_miss[last_miss] = Nmiss;
    223         next_miss[Nmiss] = -1;
    224         last_miss = Nmiss;
    225       } else {
    226         m = catalog[0].average[n].missing;
    227         for (k = 0; k < catalog[0].average[n].Nn - 1; k++)
    228           m = next_miss[m];
    229         next_miss[Nmiss] = next_miss[m];
    230         next_miss[m] = Nmiss;
    231         if (next_miss[Nmiss] == -1) { /* last just was moved */
    232           last_miss = Nmiss;
    233         }
    234       }
     208      add_miss_link (&catalog[0].average[n], next_miss, Nmiss);
     209
    235210      /* calculate time of exposure for this coordinate in the image */
    236211      RD_to_XY (&X, &Y, catalog[0].average[n].R_PS, catalog[0].average[n].D_PS, &image[0].coords);       
     
    238213      catalog[0].average[n].Nn ++;
    239214      Nmiss ++;
    240       if (Nmiss == NMISS) {
    241         NMISS = Nmiss + 1000;
    242         REALLOCATE (next_miss, int, NMISS);
    243         REALLOCATE (catalog[0].missing, Missing, NMISS);
    244       }
    245215    }
    246216  }
     
    248218  /* incorporate unmatched image stars, if this star is in field of this catalog */
    249219  for (i = 0; (i < Nstars) && !ONLY_MATCH; i++) {
     220    /* make sure there is space for next entry */
     221    if (Nmeas >= NMEAS) {
     222      NMEAS = Nmeas + 1000;
     223      REALLOCATE (next_meas, int, NMEAS);
     224      REALLOCATE (catalog[0].measure, Measure, NMEAS);
     225    }
     226    if (Nave >= NAVE) {
     227      NAVE = Nave + 1000;
     228      REALLOCATE (catalog[0].average, Average, NAVE);
     229      REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt);
     230    }
     231
    250232    N = N1[i];
    251233    if (stars[N].found >= 0) continue;
     
    297279    /** now add references from all previous non-detection observations of this spot on the sky */
    298280    for (j = 0; (j < Noverlap) && !SKIP_MISSED; j++) {
     281      /* make sure there is space for next entry */
     282      if (Nmiss >= NMISS) {
     283        NMISS = Nmiss + 1000;
     284        REALLOCATE (next_miss, int, NMISS);
     285        REALLOCATE (catalog[0].missing, Missing, NMISS);
     286      }
    299287      if (!FindMosaicForImage (overlap, Noverlap, j)) continue;
    300288      if (!in_image (catalog[0].average[Nave].R_PS, catalog[0].average[Nave].D_PS, &overlap[j])) continue;
    301       if (catalog[0].average[Nave].Nn < 1) {
    302         catalog[0].average[Nave].missing = Nmiss;
    303       }
    304       next_miss[last_miss] = Nmiss;
    305       next_miss[Nmiss] = -1;
    306       last_miss = Nmiss;
     289      add_miss_link (&catalog[0].average[Nave], next_miss, Nmiss);
     290
    307291      /* get time of exposure of this portion of the image */
    308292      RD_to_XY (&X, &Y, catalog[0].average[Nave].R_PS, catalog[0].average[Nave].D_PS, &overlap[j].coords);       
     
    310294      catalog[0].average[Nave].Nn ++;
    311295      Nmiss ++;
    312       if (Nmiss == NMISS) {
    313         NMISS = Nmiss + 1000;
    314         REALLOCATE (next_miss, int, NMISS);
    315         REALLOCATE (catalog[0].missing, Missing, NMISS);
    316       }
    317296    }
    318297
    319298    stars[N].found = Nmeas;
    320     next[last] = Nmeas;
    321     next[Nmeas] = -1;
    322     last = Nmeas;
     299    next_meas[Nmeas] = -1;
    323300    Nmeas ++;
    324     if (Nmeas == NMEAS) {
    325       NMEAS = Nmeas + 1000;
    326       REALLOCATE (next, int, NMEAS);
    327       REALLOCATE (catalog[0].measure, Measure, NMEAS);
    328     }
    329301    Nave ++;
    330     if (Nave == NAVE) {
    331       NAVE = Nave + 1000;
    332       REALLOCATE (catalog[0].average, Average, NAVE);
    333       REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt);
    334     }
    335302  }
    336303     
     
    338305  REALLOCATE (catalog[0].average, Average, Nave);
    339306  REALLOCATE (catalog[0].measure, Measure, Nmeas);
     307  REALLOCATE (catalog[0].missing, Missing, Nmiss);
    340308 
    341   /* fix order of Measure (memory intensive, but fast) */
    342   N = 0;
    343   ALLOCATE (tmpmeasure, Measure, Nmeas);
    344   for (i = 0; i < Nave; i++) {
    345     n = catalog[0].average[i].offset;
    346     catalog[0].average[i].offset = N;
    347     for (k = 0; k < catalog[0].average[i].Nm; k++, N++) {
    348       tmpmeasure[N] = catalog[0].measure[n];
    349       tmpmeasure[N].averef = i;
    350       n = next[n];
    351     }
    352   }
    353   free (catalog[0].measure);
    354   catalog[0].measure = tmpmeasure;
    355    
    356   /* fix order of Missing (memory intensive, but fast) */
    357   N = 0;
    358   ALLOCATE (tmpmissing, Missing, Nmiss);
    359   for (i = 0; i < Nave; i++) {
    360     if (catalog[0].average[i].Nn > 0) {
    361       n = catalog[0].average[i].missing;
    362       catalog[0].average[i].missing = N;
    363       for (k = 0; k < catalog[0].average[i].Nn; k++, N++) {
    364         tmpmissing[N] = catalog[0].missing[n];
    365         n = next_miss[n];
    366       }
    367     }
    368   }
    369   free (catalog[0].missing);
    370   catalog[0].missing = tmpmissing;
     309  /* XXX EAM - temporary examination of next_meas
     310  for (i = 0; i < 5; i++) {
     311    m = catalog[0].average[i].offset;
     312    for (j = 0; j < catalog[0].average[i].Nm; j++) {
     313      fprintf (stderr, "this: %d (%f), next: %d\n", m, catalog[0].measure[m].M_PS, next_meas[m]);
     314      m = next_meas[m];
     315    }
     316  } */
     317
     318  if (REORDER) {
     319    catalog[0].measure = reorder_measure (catalog[0].average, Nave, catalog[0].measure, Nmeas, next_meas);
     320    catalog[0].ordered = TRUE;
     321  } else {
     322    catalog[0].ordered = FALSE;
     323  }
     324  catalog[0].missing = reorder_missing (catalog[0].average, Nave, catalog[0].missing, Nmiss, next_miss);
     325  /* missing is REQUIRED to be sorted */
    371326
    372327  /* note stars which have been found in this catalog */
     
    384339  catalog[0].Nmissing = Nmiss;
    385340  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nmiss: %d %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmiss, Nmatch);
     341
     342  gettimeofday (&stop, NULL);
     343  dtime = DTIME (stop, start);
     344  fprintf (stderr, "  match time %8.3f sec for %5d stars, %6d average\n", dtime, Nstars, Nave);
     345
     346  return;
    386347}
    387348
  • trunk/Ohana/src/addstar/src/gcatalog.c

    r5014 r5229  
    33int gcatalog (Catalog *catalog) {
    44 
    5   int Nsecfilt;
     5  int Nsecfilt, status;
    66  char mode;
    77
     
    1414    exit (1);
    1515  }
     16
     17  /* should this be moved into save_catalog?? */
     18  status = fits_scan (&catalog[0].header, "ORDERED", "%t", 1, &catalog[0].ordered);
     19  if (!status) catalog[0].ordered = TRUE;
     20  /* XXX EAM - is this a good choice?  should the default be 'FALSE'? */
    1621
    1722  /* check Nsecfile value, update if needed */
  • trunk/Ohana/src/addstar/src/image-db.c

    r5014 r5229  
    4040
    4141  /* set the recommended mode */
    42   if (!strcmp (CATMODE, "RAW")) {
     42  db[0].mode = DVO_MODE_UNDEF;
     43  if (!strcasecmp (CATMODE, "RAW")) {
    4344    /* make header a fake image */
    4445    db[0].header.bitpix   = 16;
     
    4950    db[0].mode = DVO_MODE_RAW;
    5051  }
    51 
    52   if (!strcmp (CATMODE, "MEF") || !strcmp (CATMODE, "SPLIT")) {
     52  if (!strcasecmp (CATMODE, "MEF") || !strcasecmp (CATMODE, "SPLIT")) {
    5353    db[0].header.extend   = TRUE;
    5454    fits_create_header (&db[0].header);
    5555    db[0].mode = DVO_MODE_MEF;
    5656  }
     57  if (db[0].mode == DVO_MODE_UNDEF) {
     58    fprintf (stderr, "invalid output catalog mode\n");
     59    exit (1);
     60  }
    5761
    5862  /* set the recommended format */
    5963  db[0].format = DVO_FORMAT_UNDEF;
    60   if (!strcmp (CATFORMAT, "INTERNAL"))  db[0].format = DVO_FORMAT_INTERNAL;
    61   if (!strcmp (CATFORMAT, "LONEOS"))    db[0].format = DVO_FORMAT_LONEOS;
    62   if (!strcmp (CATFORMAT, "ELIXIR"))    db[0].format = DVO_FORMAT_ELIXIR;
    63   if (!strcmp (CATFORMAT, "PANSTARRS")) db[0].format = DVO_FORMAT_PANSTARRS;
     64  if (!strcasecmp (CATFORMAT, "INTERNAL"))  db[0].format = DVO_FORMAT_INTERNAL;
     65  if (!strcasecmp (CATFORMAT, "LONEOS"))    db[0].format = DVO_FORMAT_LONEOS;
     66  if (!strcasecmp (CATFORMAT, "ELIXIR"))    db[0].format = DVO_FORMAT_ELIXIR;
     67  if (!strcasecmp (CATFORMAT, "PANSTARRS")) db[0].format = DVO_FORMAT_PANSTARRS;
    6468  if (db[0].format == DVO_FORMAT_UNDEF) {
    6569    fprintf (stderr, "invalid output catalog format\n");
  • trunk/Ohana/src/addstar/src/mkcatalog.c

    r5014 r5229  
    33void mkcatalog (GSCRegion *region, Catalog *catalog) {
    44 
    5   char *line;
     5  int length, status;
     6  char *path, *root, *file, *line;
    67  time_t now;
    78
     
    1011  /* set the recommended CATFORMAT */
    1112  catalog[0].catformat = DVO_FORMAT_UNDEF;
    12   if (!strcmp (CATFORMAT, "INTERNAL"))  catalog[0].catformat = DVO_FORMAT_INTERNAL;
    13   if (!strcmp (CATFORMAT, "LONEOS"))    catalog[0].catformat = DVO_FORMAT_LONEOS;
    14   if (!strcmp (CATFORMAT, "ELIXIR"))    catalog[0].catformat = DVO_FORMAT_ELIXIR;
    15   if (!strcmp (CATFORMAT, "PANSTARRS")) catalog[0].catformat = DVO_FORMAT_PANSTARRS;
     13  if (!strcasecmp (CATFORMAT, "INTERNAL"))  catalog[0].catformat = DVO_FORMAT_INTERNAL;
     14  if (!strcasecmp (CATFORMAT, "LONEOS"))    catalog[0].catformat = DVO_FORMAT_LONEOS;
     15  if (!strcasecmp (CATFORMAT, "ELIXIR"))    catalog[0].catformat = DVO_FORMAT_ELIXIR;
     16  if (!strcasecmp (CATFORMAT, "PANSTARRS")) catalog[0].catformat = DVO_FORMAT_PANSTARRS;
    1617  if (catalog[0].catformat == DVO_FORMAT_UNDEF) {
    1718    fprintf (stderr, "invalid output catalog format\n");
     
    2021
    2122  /* set the recommended CATMODE */
    22   catalog[0].catmode = DVO_MODE_RAW;
    23   if (!strcmp (CATMODE, "RAW"))  catalog[0].catmode = DVO_MODE_RAW;
    24   if (!strcmp (CATMODE, "MEF"))  catalog[0].catmode = DVO_MODE_MEF;
     23  catalog[0].catmode = DVO_MODE_UNDEF;
     24  if (!strcasecmp (CATMODE, "RAW"))  catalog[0].catmode = DVO_MODE_RAW;
     25  if (!strcasecmp (CATMODE, "MEF"))  catalog[0].catmode = DVO_MODE_MEF;
     26  if (!strcasecmp (CATMODE, "SPLIT"))  catalog[0].catmode = DVO_MODE_SPLIT;
     27  if (catalog[0].catmode == DVO_MODE_UNDEF) {
     28    fprintf (stderr, "invalid output catalog mode\n");
     29    exit (1);
     30  }
    2531
    2632  fits_init_header (&catalog[0].header);
     
    3642  fits_create_header (&catalog[0].header);
    3743 
     44  if (catalog[0].catmode == DVO_MODE_SPLIT) {
     45    path = pathname (catalog[0].filename);
     46    root = filerootname (catalog[0].filename);
     47    length = strlen(path) + strlen(root) + 6;
     48
     49    /* define measure catalog file */
     50    ALLOCATE (catalog[0].measure_catalog, Catalog, 1);
     51    fits_init_header (&catalog[0].measure_catalog[0].header);
     52    fits_create_header (&catalog[0].measure_catalog[0].header);
     53    ALLOCATE (catalog[0].measure_catalog[0].filename, char, length);
     54    sprintf (catalog[0].measure_catalog[0].filename, "%s/%s.cpm", path, root);
     55    status = lock_catalog (catalog[0].measure_catalog, catalog[0].lockmode);
     56    if (status != 2) {
     57      fprintf (stderr, "error with file lock\n");
     58      exit (2);
     59    }
     60    file = filebasename (catalog[0].measure_catalog[0].filename);
     61    fits_modify (&catalog[0].header, "MEASURE", "%s", 1, file);
     62    free (file);
     63
     64    /* define missing catalog file */
     65    ALLOCATE (catalog[0].missing_catalog, Catalog, 1);
     66    fits_init_header (&catalog[0].missing_catalog[0].header);
     67    fits_create_header (&catalog[0].missing_catalog[0].header);
     68    ALLOCATE (catalog[0].missing_catalog[0].filename, char, length);
     69    sprintf (catalog[0].missing_catalog[0].filename, "%s/%s.cpn", path, root);
     70    if (lock_catalog (catalog[0].missing_catalog, catalog[0].lockmode) != 2) {
     71      fprintf (stderr, "error with file lock\n");
     72      exit (2);
     73    }
     74    file = filebasename (catalog[0].missing_catalog[0].filename);
     75    fits_modify (&catalog[0].header, "MISSING", "%s", 1, file);
     76    free (file);
     77
     78    /* define secfilt catalog file */
     79    ALLOCATE (catalog[0].secfilt_catalog, Catalog, 1);
     80    fits_init_header (&catalog[0].secfilt_catalog[0].header);
     81    fits_create_header (&catalog[0].secfilt_catalog[0].header);
     82    ALLOCATE (catalog[0].secfilt_catalog[0].filename, char, length);
     83    sprintf (catalog[0].secfilt_catalog[0].filename, "%s/%s.cps", path, root);
     84    if (lock_catalog (catalog[0].secfilt_catalog, catalog[0].lockmode) != 2) {
     85      fprintf (stderr, "error with file lock\n");
     86      exit (2);
     87    }
     88    file = filebasename (catalog[0].secfilt_catalog[0].filename);
     89    fits_modify (&catalog[0].header, "SECFILT", "%s", 1, file);
     90    free (file);
     91    free (path);
     92    free (root);
     93  }   
     94
    3895  /* write RA,DEC range in header */
    3996  fits_modify (&catalog[0].header, "RA0",  "%lf", 1, region[0].RA[0]);
     
    48105  free (line);
    49106
     107  /* dummy allocation so realloc will succeed */
    50108  ALLOCATE (catalog[0].average, Average, 1);
    51109  ALLOCATE (catalog[0].measure, Measure, 1);
    52110  ALLOCATE (catalog[0].missing, Missing, 1);
     111  ALLOCATE (catalog[0].secfilt, SecFilt, 1);
    53112  catalog[0].Naverage = catalog[0].Nmeasure = catalog[0].Nmissing = 0;
     113  catalog[0].Nsecfilt = GetPhotcodeNsecfilt ();
    54114
    55115  /* setup secondary filters to match photcodes:
    56    *  Nsecfilt is number of filters.  Number of entries in array is
    57    *  Nsecfilt * Naverage.  At this point, N entries == 0
     116   * Nsecfilt is number of filters.  Number of entries in array is
     117   * Nsecfilt * Naverage.  At this point, N entries == 0
    58118   */
    59   ALLOCATE (catalog[0].secfilt, SecFilt, 1);
    60   catalog[0].Nsecfilt = GetPhotcodeNsecfilt ();
    61119}
  • trunk/Ohana/src/addstar/src/wcatalog.c

    r5014 r5229  
    55  /* output CATMODE and CATFORMAT are set by mkcatalog
    66     or by mode and format of existing data */
     7
     8  /* should this be moved into save_catalog?? */
     9  fits_modify (&catalog[0].header, "ORDERED",  "%t", 1, catalog[0].ordered);
    710
    811  if (!save_catalog (catalog, VERBOSE)) {
Note: See TracChangeset for help on using the changeset viewer.