IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38544


Ignore:
Timestamp:
Jun 25, 2015, 2:00:04 PM (11 years ago)
Author:
eugene
Message:

replace Stars with Catalog

Location:
branches/eam_branches/ipp-20150616/Ohana/src/addstar
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/Makefile

    r38542 r38544  
    7676$(SRC)/edge_check.$(ARCH).o \
    7777$(SRC)/fakeimage.$(ARCH).o \
     78$(SRC)/find_matches.$(ARCH).o \
    7879$(SRC)/find_matches_closest.$(ARCH).o \
    7980$(SRC)/GetZeroPointExposure.$(ARCH).o \
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/addstar.h

    r38542 r38544  
    220220
    221221int        find_matches_closest   PROTO((SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options));
     222int        find_matches           PROTO((SkyRegion *region, Catalog *newcat, Catalog *catalog, AddstarClientOptions options));
    222223
    223224# if (0)
    224 int        find_matches                  PROTO((SkyRegion *region, Stars *stars,  unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
    225225int        find_matches_refstars         PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
    226226int        find_matches_closest_refstars PROTO((SkyRegion *region, Stars **stars, unsigned int Nstars, Catalog *catalog, AddstarClientOptions options));
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/addstar.c

    r38536 r38544  
    150150          Nmatch += find_matches_closest (skylist[0].regions[i], newcat, &catalog, options);
    151151        } else {
    152           // XXX Nmatch += find_matches (skylist[0].regions[i], stars, Nstars, &catalog, options);
     152          Nmatch += find_matches (skylist[0].regions[i], newcat, &catalog, options);
    153153        }
    154154        break;
  • branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/find_matches.c

    r38467 r38544  
    11# include "addstar.h"
    22
    3 int find_matches (SkyRegion *region, Stars *stars, unsigned int NstarsIn, Catalog *catalog, AddstarClientOptions options) {
    4 
    5   off_t i, j, n, N, J, Nstars;
     3int find_matches (SkyRegion *region, Catalog *srccat, Catalog *tgtcat, AddstarClientOptions options) {
     4
     5  off_t i, j, n, N, J, Nstars, mSrc;
    66  double RADIUS, RADIUS2;
    77  double *X1, *Y1, *X2, *Y2;
    88  double dX, dY, dR;
    9   off_t *N1, *N2, *next_meas;
     9  off_t *N1, *N2;
    1010  off_t Nave, NAVE, Nmeas, NMEAS, Nmatch;
    1111  int Nsecfilt, Nsec, status;
     
    1313  Coords tcoords;
    1414
    15   if (NSTAR_GROUP <= 0) {
    16     fprintf (stderr, "ERROR: NSTAR_GROUP NOT SET!\n");
    17     exit (1);
    18   }
    19 
    2015  /* photcode data - must by of type DEP; options.photcode is equiv photcode for all input
    2116     images this function requires incoming stars to have the same photcode.equiv value.  if
     
    2722
    2823  /** allocate local arrays (stars) **/
    29   ALLOCATE (X1, double, NstarsIn);
    30   ALLOCATE (Y1, double, NstarsIn);
    31   ALLOCATE (N1, off_t,  NstarsIn);
    32 
    33   /** allocate local arrays (catalog) **/
    34   NAVE = Nave = catalog[0].Naverage;
     24  ALLOCATE (X1, double, srccat->Naverage);
     25  ALLOCATE (Y1, double, srccat->Naverage);
     26  ALLOCATE (N1, off_t,  srccat->Naverage);
     27
     28  myAbort ("figure out if found_t needs to be tracking Naverage or Nmeasure");
     29  if (!srccat->found_t) {
     30    ALLOCATE (srccat->found_t, off_t, srccat->Naverage);
     31    for (i = 0; i < srccat->Naverage; i++) {
     32      srccat->found_t[i] = -1;
     33    }
     34  }
     35
     36  /** allocate local arrays (tgtcat) **/
     37  NAVE = Nave = tgtcat[0].Naverage;
    3538  ALLOCATE (X2, double, NAVE);
    3639  ALLOCATE (Y2, double, NAVE);
    3740  ALLOCATE (N2, off_t,  NAVE);
    38   ALLOCATE (catalog[0].found_t, off_t, NAVE);
     41
     42  if (!tgtcat->found_t) {
     43    ALLOCATE (tgtcat[0].found_t, off_t, NAVE);
     44    for (i = 0; i < NAVE; i++) {
     45      tgtcat->found_t[i] = -1;
     46    }
     47  }
    3948  /* for secfilt j and star i, secfilt[i*Nsecfilt+j] */
    4049
    4150  /* internal counters */
    4251  Nmatch = 0;
    43   NMEAS = Nmeas = catalog[0].Nmeasure;
     52  NMEAS = Nmeas = tgtcat[0].Nmeasure;
    4453 
    45   // current max obj ID for this catalog
    46   objID = catalog[0].objID;
    47   catID = catalog[0].catID;
     54  off_t *next_meas = NULL;
     55
     56  // current max obj ID for this tgtcat
     57  objID = tgtcat[0].objID;
     58  catID = tgtcat[0].catID;
    4859
    4960  /* project onto rectilinear grid with 1 arcsec pixels. the choice of ZEA projection has the
     
    5162   * possible X,Y points map back to R,D and the local plate scale changes substantially far from
    5263   * the projection pole.  a better mapping might be ARC, not yet implemented (see
    53    * coordops.update.c).  We use the center of the region (catalog) for crval1,2.
     64   * coordops.update.c).  We use the center of the region (tgtcat) for crval1,2.
    5465   */
    5566  InitCoords (&tcoords, "DEC--ARC");
     
    6475  /* build spatial index (RA sort) referencing input array sequence */
    6576  Nstars = 0;
    66   for (i = 0; i < NstarsIn; i++) {
    67     status = RD_to_XY (&X1[Nstars], &Y1[Nstars], stars[i].average.R, stars[i].average.D, &tcoords);
     77  for (i = 0; i < srccat->Naverage; i++) {
     78    status = RD_to_XY (&X1[Nstars], &Y1[Nstars], srccat->average[i].R, srccat->average[i].D, &tcoords);
    6879    if (!status) continue;
    6980    N1[Nstars] = i;
     
    7182  }
    7283  if (Nstars < 1) {
    73     if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", catalog[0].filename);
     84    if (VERBOSE) fprintf (stderr, "skipping %s, no overlapping stars\n", tgtcat[0].filename);
    7485    free (X1);
    7586    free (Y1);
     
    8495  /* build spatial index (RA sort) */
    8596  for (i = 0; i < Nave; i++) {
    86     RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords);
     97    RD_to_XY (&X2[i], &Y2[i], tgtcat[0].average[i].R, tgtcat[0].average[i].D, &tcoords);
    8798    N2[i] = i;
    88     catalog[0].found_t[N2[i]] = -1;
     99    tgtcat[0].found_t[N2[i]] = -1;
    89100  }
    90101  if (Nave > 1) sort_coords_index (X2, Y2, N2, Nave);
    91102
    92103  /* set up pointers for linked list of measure */
    93   if (catalog[0].sorted && (catalog[0].Nmeasure == catalog[0].Nmeasure_disk)) {
    94     next_meas = init_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas);
     104  if (tgtcat[0].sorted && (tgtcat[0].Nmeasure == tgtcat[0].Nmeasure_disk)) {
     105    next_meas = init_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas);
    95106  } else {
    96     next_meas = build_measure_links (catalog[0].average, Nave, catalog[0].measure, Nmeas);
     107    next_meas = build_measure_links (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas);
    97108  }   
    98109
     
    102113
    103114  /** find matched stars **/
    104   // XXX could use NSTAR_GROUP to do this match more quicky if NSTAR_GROUP > 1
    105115  for (i = j = 0; (i < Nstars) && (j < Nave); ) {
    106116    if (!finite(X1[i]) || !finite(Y1[i])) {
     
    138148
    139149      /* make sure there is space for next entry */
    140       if (Nmeas >= NMEAS) {
    141         NMEAS = Nmeas + 1000;
     150      if (Nmeas >= NMEAS - srccat->average[N].Nmeasure) {
     151        NMEAS = Nmeas + 1000 + srccat->average[N].Nmeasure;
    142152        REALLOCATE (next_meas, off_t, NMEAS);
    143 
    144         REALLOCATE (catalog[0].measure, Measure, NMEAS);
    145       }
    146 
    147       /* add to end of measurement list */
    148       add_meas_link (&catalog[0].average[n], next_meas, Nmeas, NMEAS);
     153        REALLOCATE (tgtcat[0].measure, Measure, NMEAS);
     154      }
    149155
    150156      /** add measurements for this star **/
    151 
    152       // set the new measurements
    153       catalog[0].measure[Nmeas]          = stars[N].measure;
    154 
    155       // the following measure elements cannot be set until here:
    156       catalog[0].measure[Nmeas].dbFlags  = 0;
    157       catalog[0].measure[Nmeas].averef   = n; // this must be an absolute sequence number, if partial average is loaded
    158       catalog[0].measure[Nmeas].objID    = catalog[0].average[n].objID;
    159       catalog[0].measure[Nmeas].catID    = catalog[0].catID;
    160 
    161       float dRoff = dvoOffsetR(&catalog[0].measure[Nmeas], &catalog[0].average[n]);
    162 
    163       // rationalize R:
    164       if (dRoff > +180.0*3600.0) {
    165         // average on high end of boundary, move star up
    166         catalog[0].measure[Nmeas].R += 360.0;
    167         dRoff -= 360.0*3600.0;
    168       }
    169       if (dRoff < -180.0*3600.0) {
    170         // average on low end of boundary, move star down
    171         catalog[0].measure[Nmeas].R -= 360.0;
    172         dRoff += 360.0*3600.0;
    173       }
    174       if (fabs(dRoff) > 10*RADIUS) {
    175         // take declination into account and check again.
    176         double cosD = cos(RAD_DEG*catalog[0].average[n].D);
    177         if (fabs(dRoff*cosD) > 10*RADIUS) {
    178           fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n",
    179                    catalog[0].average[n].R, catalog[0].average[n].D,
    180                    stars[N].average.R, stars[N].average.D,
    181                    X1[i], X2[J],
    182                    Y1[i], Y2[J]);
    183         }
    184       }
    185 
    186       /* adds the measurement to the calibration if appropriate color terms are found */
    187       /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */
    188       if (options.calibrate) {
    189         AddToCalibration (&catalog[0].average[n], &catalog[0].secfilt[n*Nsecfilt], catalog[0].measure, &catalog[0].measure[Nmeas], next_meas, N);
    190       }
    191 
    192       /* set the average magnitude if not already set and if photcode.equiv is not 0 */
    193       /* in UPDATE mode, this value is not saved; use relphot to recalculate */
    194       if (Nsec > -1) {
    195         if (isnan(catalog[0].secfilt[n*Nsecfilt+Nsec].M)) {
    196           catalog[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF);
    197         }
    198       }
    199 
    200       /*** flag multiple stars */
    201       /* this image star matches more than one catalog star */
    202       if (stars[N].found > -1) {
    203         catalog[0].measure[stars[N].found].dbFlags |= ID_MEAS_BLEND_MEAS;
    204         catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS;
    205       }
    206       if (stars[N].found == -2) { /* this image star matches a catalog star on a neighboring catalog */
    207         catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS_X;
    208       }
    209       if (stars[N].found == -1) { /* this image star matches only this catalog star */
    210         stars[N].found = Nmeas;  /* save first match, in case coincidences are found */
    211       }
    212       /* this catalog star matches more than one image star */
    213       if (catalog[0].found_t[n] > -1) {
    214         catalog[0].measure[catalog[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ;
    215         catalog[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ;
    216       } else {
    217         catalog[0].found_t[n] = Nmeas;
    218       }
    219       /* Nm is updated, but not written out in -update mode (for existing entries)
    220          Nm is recalculated in build_meas_links if loaded table is not sorted */
    221       catalog[0].average[n].Nmeasure ++;
    222       Nmeas ++;
     157      off_t mOff = srccat->average[N].measureOffset;
     158      for (mSrc = 0; mSrc < srccat->average[N].Nmeasure; mSrc++) {
     159        /* add to end of measurement list */
     160        add_meas_link (&tgtcat[0].average[n], next_meas, Nmeas, NMEAS);
     161       
     162        /** add measurements for this star **/
     163       
     164        // set the new measurements
     165        tgtcat[0].measure[Nmeas]          = srccat->measure[mSrc + mOff];
     166       
     167        // the following measure elements cannot be set until here:
     168        tgtcat[0].measure[Nmeas].dbFlags  = 0;
     169        tgtcat[0].measure[Nmeas].averef   = n; // this must be an absolute sequence number, if partial average is loaded
     170        tgtcat[0].measure[Nmeas].objID    = tgtcat[0].average[n].objID;
     171        tgtcat[0].measure[Nmeas].catID    = tgtcat[0].catID;
     172
     173        float dRoff = dvoOffsetR(&tgtcat[0].measure[Nmeas], &tgtcat[0].average[n]);
     174
     175        // rationalize R:
     176        if (dRoff > +180.0*3600.0) {
     177          // average on high end of boundary, move star up
     178          tgtcat[0].measure[Nmeas].R += 360.0;
     179          dRoff -= 360.0*3600.0;
     180        }
     181        if (dRoff < -180.0*3600.0) {
     182          // average on low end of boundary, move star down
     183          tgtcat[0].measure[Nmeas].R -= 360.0;
     184          dRoff += 360.0*3600.0;
     185        }
     186        if (fabs(dRoff) > 10*RADIUS) {
     187          // take declination into account and check again.
     188          double cosD = cos(RAD_DEG*tgtcat[0].average[n].D);
     189          if (fabs(dRoff*cosD) > 10*RADIUS) {
     190            fprintf (stderr, "error: %10.6f,%10.6f vs %10.6f,%10.6f (%f,%f vs %f,%f)\n",
     191                     tgtcat[0].average[n].R, tgtcat[0].average[n].D,
     192                     srccat->average[N].R, srccat->average[N].D,
     193                     X1[i], X2[J],
     194                     Y1[i], Y2[J]);
     195          }
     196        }
     197
     198        /* adds the measurement to the calibration if appropriate color terms are found */
     199        /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */
     200        if (options.calibrate) {
     201          AddToCalibration (&tgtcat[0].average[n], &tgtcat[0].secfilt[n*Nsecfilt], tgtcat[0].measure, &tgtcat[0].measure[Nmeas], next_meas, N);
     202        }
     203
     204        /* set the average magnitude if not already set and if photcode.equiv is not 0 */
     205        /* in UPDATE mode, this value is not saved; use relphot to recalculate */
     206        if (Nsec > -1) {
     207          if (isnan(tgtcat[0].secfilt[n*Nsecfilt+Nsec].M)) {
     208            tgtcat[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
     209          }
     210        }
     211
     212        myAbort ("fix logic on multiple detections");
     213
     214        /*** flag multiple stars */
     215        /* this image star matches more than one tgtcat star */
     216        if (srccat->found_t[N] > -1) {
     217          tgtcat[0].measure[srccat->found_t[N]].dbFlags |= ID_MEAS_BLEND_MEAS;
     218          tgtcat[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS;
     219        }
     220        if (srccat->found_t[N] == -2) { /* this image star matches a tgtcat star on a neighboring tgtcat */
     221          tgtcat[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_MEAS_X;
     222        }
     223        if (srccat->found_t[N] == -1) { /* this image star matches only this tgtcat star */
     224          srccat->found_t[N] = Nmeas;  /* save first match, in case coincidences are found */
     225        }
     226        /* this tgtcat star matches more than one image star */
     227        if (tgtcat[0].found_t[n] > -1) {
     228          tgtcat[0].measure[tgtcat[0].found_t[n]].dbFlags |= ID_MEAS_BLEND_OBJ;
     229          tgtcat[0].measure[Nmeas].dbFlags |= ID_MEAS_BLEND_OBJ;
     230        } else {
     231          tgtcat[0].found_t[n] = Nmeas;
     232        }
     233        /* Nm is updated, but not written out in -update mode (for existing entries)
     234           Nm is recalculated in build_meas_links if loaded table is not sorted */
     235        tgtcat[0].average[n].Nmeasure ++;
     236        Nmeas ++;
     237      }
    223238
    224239      if (!options.update) {
    225240        /* in UPDATE mode, newly calculated coordinates are not saved */
    226         update_coords (&catalog[0].average[n], &catalog[0].measure[0], next_meas);
     241        update_coords (&tgtcat[0].average[n], &tgtcat[0].measure[0], next_meas);
    227242      }
    228243    }
     
    230245  }
    231246
    232 /* incorporate unmatched image stars, if this star is in field of this catalog */
     247/* incorporate unmatched image stars, if this star is in field of this tgtcat */
    233248/* these new entries are all written out in UPDATE mode */
    234   for (i = 0; (i < Nstars) && !options.only_match; i += NSTAR_GROUP) {
     249  for (i = 0; (i < Nstars) && !options.only_match; i ++) {
    235250    /* make sure there is space for next entry */
    236     if (Nmeas >= NMEAS - NSTAR_GROUP) {
    237       NMEAS = Nmeas + 1000;
     251    if (Nmeas >= NMEAS - srccat->average[i].Nmeasure) {
     252      NMEAS = Nmeas + 1000 + srccat->average[i].Nmeasure;
    238253      REALLOCATE (next_meas, off_t, NMEAS);
    239       REALLOCATE (catalog[0].measure, Measure, NMEAS);
     254      REALLOCATE (tgtcat[0].measure, Measure, NMEAS);
    240255    }
    241256    if (Nave >= NAVE) {
    242257      NAVE = Nave + 1000;
    243       REALLOCATE (catalog[0].average, Average, NAVE);
    244       REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt);
    245     }
    246 
    247     if (stars[i].found >= 0) continue;
    248     if (!IN_REGION (stars[i].average.R, stars[i].average.D)) continue;
    249 
    250     dvo_average_init (&catalog[0].average[Nave]);
    251     catalog[0].average[Nave].R             = stars[i].average.R;
    252     catalog[0].average[Nave].D             = stars[i].average.D;
    253 
    254     catalog[0].average[Nave].Nmeasure      = NSTAR_GROUP;
    255     catalog[0].average[Nave].measureOffset = Nmeas;
    256     catalog[0].average[Nave].objID         = objID;
    257     catalog[0].average[Nave].catID         = catID;
     258      REALLOCATE (tgtcat[0].average, Average, NAVE);
     259      if (tgtcat[0].secfilt) {
     260        // we only update the secfilt table if it has been allocated for output
     261        REALLOCATE (tgtcat[0].secfilt, SecFilt, NAVE*tgtcat[0].Nsecfilt);
     262      }
     263    }
     264
     265    if (srccat->found_t[i] >= 0) continue;
     266    if (!IN_REGION (srccat->average[i].R, srccat->average[i].D)) continue;
     267
     268    dvo_average_init (&tgtcat[0].average[Nave]);
     269    tgtcat[0].average[Nave].R              = srccat->average[i].R;
     270    tgtcat[0].average[Nave].D              = srccat->average[i].D;
     271
     272    tgtcat[0].average[Nave].Nmeasure       = srccat->average[i].Nmeasure;
     273    tgtcat[0].average[Nave].measureOffset  = Nmeas;
     274    tgtcat[0].average[Nave].objID          = objID;
     275    tgtcat[0].average[Nave].catID          = catID;
    258276
    259277    if (PSPS_ID) {
    260       catalog[0].average[Nave].extID = CreatePSPSObjectID(catalog[0].average[Nave].R, catalog[0].average[Nave].D);
     278      tgtcat[0].average[Nave].extID = CreatePSPSObjectID(tgtcat[0].average[Nave].R, tgtcat[0].average[Nave].D);
    261279    }
    262280
    263281    objID ++;
    264282
    265     for (j = 0; j < Nsecfilt; j++) {
    266       dvo_secfilt_init (&catalog[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL);
    267     }
    268 
    269     for (j = 0; j < NSTAR_GROUP; j++) {
     283    for (j = 0; tgtcat[0].secfilt && (j < Nsecfilt); j++) {
     284      dvo_secfilt_init (&tgtcat[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL);
     285    }
     286
     287    off_t mOff = srccat->average[i].measureOffset;
     288    for (mSrc = 0; mSrc < srccat->average[i].Nmeasure; mSrc++) {
    270289      // supply the measurments from this detection
    271       catalog[0].measure[Nmeas]           = stars[i + j].measure;
     290      dvo_measure_init (&tgtcat[0].measure[Nmeas]);
     291      tgtcat[0].measure[Nmeas] = srccat->measure[mSrc + mOff];
    272292
    273293      // the following measure elements cannot be set until here:
    274       catalog[0].measure[Nmeas].dbFlags   = 0;
    275       catalog[0].measure[Nmeas].averef    = Nave; // XXX EAM : must be absolute Nave if partial read
    276       catalog[0].measure[Nmeas].objID     = catalog[0].average[Nave].objID;
    277       catalog[0].measure[Nmeas].catID     = catalog[0].catID;
     294      tgtcat[0].measure[Nmeas].dbFlags   = 0;
     295      tgtcat[0].measure[Nmeas].averef    = Nave; // XXX EAM : must be absolute Nave if partial read
     296      tgtcat[0].measure[Nmeas].objID     = tgtcat[0].average[Nave].objID;
     297      tgtcat[0].measure[Nmeas].catID     = tgtcat[0].catID;
    278298
    279299      /* set the average magnitude if not already set and the photcode.equiv is not 0 */
    280300      /* in UPDATE mode, this value is not saved; use relphot to recalculate */
    281301      if (Nsec > -1) {
    282         catalog[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&catalog[0].measure[Nmeas], MAG_CLASS_PSF);
     302        tgtcat[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
    283303      }
    284304
    285305      /* next[Nmeas] should always be -1 in this context (it is always the only
    286306         measurement for the star) */
    287       stars[i].found = Nmeas;
    288       next_meas[Nmeas] = -1;  // initial value here update below
     307      srccat->found_t[i] = Nmeas;
    289308      Nmeas ++;
    290     }
    291     for (j = 0; j < NSTAR_GROUP - 1; j++) {
    292       next_meas[Nmeas - NSTAR_GROUP + j] = Nmeas - NSTAR_GROUP + j + 1;
     309
     310      // update the next_meas pointer for this entry (last one for this star is -1)
     311      next_meas[Nmeas-1] = (mSrc < srccat->average[i].Nmeasure - 1) ? Nmeas : -1;
    293312    }
    294313    Nave ++;
    295314  }
    296315     
    297   REALLOCATE (catalog[0].average, Average, Nave);
    298   REALLOCATE (catalog[0].measure, Measure, Nmeas);
     316  REALLOCATE (tgtcat[0].average, Average, Nave);
     317  REALLOCATE (tgtcat[0].measure, Measure, Nmeas);
    299318 
    300319  if (options.nosort) {
    301     catalog[0].sorted = FALSE;
     320    tgtcat[0].sorted = FALSE;
    302321  } else {
    303     catalog[0].sorted = TRUE;
    304     catalog[0].measure = sort_measure (catalog[0].average, Nave, catalog[0].measure, Nmeas, next_meas);
    305   }
    306 
    307 /* note stars which have been found in this catalog */
    308   for (i = 0; i < NstarsIn; i++) {
    309     if (stars[i].found > -1) {
    310       stars[i].found = -2;
    311     }
    312   }
    313 
    314 /* check if the catalog has changed?  if no change, no need to write */
    315   catalog[0].objID    = objID; // new max value, save on catalog close
    316   catalog[0].Naverage = Nave;
    317   catalog[0].Nmeasure = Nmeas;
    318   catalog[0].Nsecfilt_mem = Nave*Nsecfilt;
     322    tgtcat[0].sorted = TRUE;
     323    tgtcat[0].measure = sort_measure (tgtcat[0].average, Nave, tgtcat[0].measure, Nmeas, next_meas);
     324  }
     325
     326/* note stars which have been found in this tgtcat */
     327  for (i = 0; i < srccat->Nmeasure; i++) {
     328    if (srccat->found_t[i] > -1) {
     329      srccat->found_t[i] = -2;
     330    }
     331  }
     332
     333/* check if the tgtcat has changed?  if no change, no need to write */
     334  tgtcat[0].objID    = objID; // new max value, save on tgtcat close
     335  tgtcat[0].Naverage = Nave;
     336  tgtcat[0].Nmeasure = Nmeas;
     337  tgtcat[0].Nsecfilt_mem = Nave*Nsecfilt;
    319338  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: "OFF_T_FMT" "OFF_T_FMT" "OFF_T_FMT", ("OFF_T_FMT" matches)\n",  Nstars,  Nave,  Nmeas,  Nmatch);
    320339
     
    333352   notes:
    334353   
    335    for finding if a catalog star is in an image or an image star is in the catalog:
     354   for finding if a tgtcat star is in an image or an image star is in the tgtcat:
    336355   
    337    catalogs have boundaries defined by RA and DEC, but they may curve in projection
     356   tgtcats have boundaries defined by RA and DEC, but they may curve in projection
    338357   images have boundaries which are lines in pixels coords, but curve in RA and DEC
    339358   
    340    catalog[0].found[Ncat] but stars[Nstar].found
     359   tgtcat[0].found[Ncat] but stars[Nstar].found
    341360   
    342361*/
Note: See TracChangeset for help on using the changeset viewer.