IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 26283


Ignore:
Timestamp:
Nov 27, 2009, 1:07:41 PM (16 years ago)
Author:
eugene
Message:

fix alloc error in find_matches variant

Location:
trunk/Ohana/src/addstar/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/find_matches.c

    r26277 r26283  
    115115    /* negative dX: j is too large */
    116116    dX = X1[i] - X2[j];
    117     if (dX <= -2*RADIUS) {
     117    if (dX <= -1.02*RADIUS) {
    118118      i++;
    119119      continue;
    120120    }
    121121    /* positive dX, i is too large */
    122     if (dX >= 2*RADIUS) {
     122    if (dX >= 1.02*RADIUS) {
    123123      j++;
    124124      continue;
     
    126126
    127127    /* within match range; look for matches */
    128     for (J = j; (dX > -2*RADIUS) && (J < Nave); J++) {
     128    for (J = j; (dX > -1.02*RADIUS) && (J < Nave); J++) {
    129129      dX = X1[i] - X2[J];
    130130      dY = Y1[i] - Y2[J];
    131131      dR = dX*dX + dY*dY;
    132132      if (dR > RADIUS2) continue;
     133
     134      /*** a match is found, add to average, measure ***/
     135      Nmatch ++;
     136      n = N2[J];
     137      N = N1[i];
    133138
    134139      /* make sure there is space for next entry */
     
    138143        REALLOCATE (catalog[0].measure, Measure, NMEAS);
    139144      }
    140 
    141       Nmatch ++;
    142       n = N2[J];
    143       N = N1[i];
    144145
    145146      /* add to end of measurement list */
  • trunk/Ohana/src/addstar/src/find_matches_closest.c

    r26277 r26283  
    148148
    149149    /*** a match is found, add to average, measure ***/
     150    Nmatch ++;
     151    n = N2[Jmin];
     152    N = N1[i];
    150153
    151154    /* make sure there is space for next entry */
     
    155158      REALLOCATE (catalog[0].measure, Measure, NMEAS);
    156159    }
    157 
    158     Nmatch ++;
    159     n = N2[Jmin];
    160     N = N1[i];
    161160
    162161    /* add to end of measurement list */
  • trunk/Ohana/src/addstar/src/find_matches_closest_refstars.c

    r26280 r26283  
    152152    }
    153153
     154    /*** a match is found, add to average, measure ***/
     155    Nmatch ++;
     156    n = N2[Jmin];
     157    N = N1[i];
     158
     159    /** in replace mode, search for entry and replace values M, dM, R, D */
     160    // XXX this fails for unsorted catalogs, right?
     161    if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) continue;
     162
    154163    /* make sure there is space for next entry */
    155164    if (Nmeas >= NMEAS) {
     
    158167      REALLOCATE (catalog[0].measure, Measure, NMEAS);
    159168    }
    160 
    161     /*** a match is found, add to average, measure ***/
    162     Nmatch ++;
    163     n = N2[Jmin];
    164     N = N1[i];
    165 
    166     /** in replace mode, search for entry and replace values M, dM, R, D */
    167     // XXX this fails for unsorted catalogs, right?
    168     if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) continue;
    169169
    170170    /* add to end of measurement list */
  • trunk/Ohana/src/addstar/src/find_matches_refstars.c

    r26279 r26283  
    3838
    3939  Nmatch = 0;
    40   Nmeas = catalog[0].Nmeasure;
    41   NMEAS = Nmeas + 1000;
    42   ALLOCATE (next_meas, int, NMEAS);
    43   REALLOCATE (catalog[0].measure, Measure, NMEAS);
     40  NMEAS = Nmeas = catalog[0].Nmeasure;
    4441 
    4542  // current max obj ID for this catalog
     
    9188  // XXX could use NREFSTAR_GROUP to do this match more quicky
    9289  for (i = j = 0; (i < Nstars) && (j < Nave); ) {
     90    if (!finite(X1[i]) || !finite(Y1[i])) {
     91      i++;
     92      continue;
     93    }
     94    if (!finite(X2[j]) || !finite(Y2[j])) {
     95      j++;
     96      continue;
     97    }
    9398   
    9499    dX = X1[i] - X2[j];
    95     if (dX <= -2*RADIUS) {
     100    if (dX <= -1.02*RADIUS) {
    96101      i++;
    97102      continue;
    98103    }
    99     if (dX >= 2*RADIUS) {
     104    if (dX >= 1.02*RADIUS) {
    100105      j++;
    101106      continue;
     
    103108
    104109    /* negative dX: j is too large, positive dX, i is too large */
    105     for (J = j; (dX > -2*RADIUS) && (J < Nave); J++) {
     110    for (J = j; (dX > -1.02*RADIUS) && (J < Nave); J++) {
    106111      dX = X1[i] - X2[J];
    107112      dY = Y1[i] - Y2[J];
     
    109114      if (dR > RADIUS2) continue;
    110115
     116      /*** a match is found, add to average, measure ***/
    111117      Nmatch ++;
    112118      n = N2[J];
     
    115121      /** in replace mode, search for entry and replace values M, dM, R, D */
    116122      if (options.replace && replace_match (&catalog[0].average[n], catalog[0].measure, stars[N])) continue;
     123
     124      if (Nmeas == NMEAS) {
     125        NMEAS = Nmeas + 1000;
     126        REALLOCATE (next_meas, int, NMEAS);
     127        REALLOCATE (catalog[0].measure, Measure, NMEAS);
     128      }
    117129
    118130      /* add to end of measurement list */
     
    127139      catalog[0].measure[Nmeas].dR       = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R);
    128140      catalog[0].measure[Nmeas].dD       = 3600.0*(catalog[0].average[n].D - stars[N][0].average.D);
     141      catalog[0].measure[Nmeas].dbFlags  = 0;
     142      catalog[0].measure[Nmeas].averef   = n;
     143      catalog[0].measure[Nmeas].objID    = catalog[0].average[n].objID;
     144      catalog[0].measure[Nmeas].catID    = catalog[0].catID;
    129145
    130146      // rationalize dR:
     
    139155          catalog[0].measure[Nmeas].dR = 3600.0*(catalog[0].average[n].R - stars[N][0].average.R);
    140156      }
    141 
    142       catalog[0].measure[Nmeas].averef   = n;
    143       catalog[0].measure[Nmeas].dbFlags  = 0;
    144       catalog[0].measure[Nmeas].objID    = catalog[0].average[n].objID;
    145       catalog[0].measure[Nmeas].catID    = catalog[0].catID;
    146157
    147158      catalog[0].measure[Nmeas].t        = (TIMEREF == 0) ? stars[N][0].measure.t      : TIMEREF; /** careful : time_t vs e_time **/
     
    181192      catalog[0].average[n].Nmeasure ++;
    182193      Nmeas ++;
    183       if (Nmeas == NMEAS) {
    184         NMEAS = Nmeas + 1000;
    185         REALLOCATE (next_meas, int, NMEAS);
    186         REALLOCATE (catalog[0].measure, Measure, NMEAS);
    187       }
    188 
    189       update_coords (&catalog[0].average[n], &catalog[0].measure[0], next_meas);
     194
     195      // update_coords (&catalog[0].average[n], &catalog[0].measure[0], next_meas);
    190196    }
    191197    i++;
     
    201207
    202208  for (i = 0; (i < Nstars) && !options.only_match; i+=NREFSTAR_GROUP) {
     209    if (Nmeas >= NMEAS - NREFSTAR_GROUP) {
     210      NMEAS = Nmeas + 1000;
     211      REALLOCATE (next_meas, int, NMEAS);
     212      REALLOCATE (catalog[0].measure, Measure, NMEAS);
     213    }
     214    if (Nave == NAVE) {
     215      NAVE = Nave + 1000;
     216      REALLOCATE (catalog[0].average, Average, NAVE);
     217      REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt);
     218    }
     219
    203220    N = N1[i];
    204221    if (stars[N][0].found > -1) continue;
     222    if (!IN_REGION (stars[N][0].average.R, stars[N][0].average.D)) continue;
    205223
    206224    catalog[0].average[Nave].R             = stars[N][0].average.R;
     
    272290
    273291      stars[N][0].found = Nmeas;
     292      next_meas[Nmeas] = -1;
    274293      Nmeas ++;
    275       if (Nmeas == NMEAS) {
    276         NMEAS = Nmeas + 1000;
    277         REALLOCATE (next_meas, int, NMEAS);
    278         REALLOCATE (catalog[0].measure, Measure, NMEAS);
    279       }
    280     }
    281 
     294    }
    282295    Nave ++;
    283     if (Nave == NAVE) {
    284       NAVE = Nave + 1000;
    285       REALLOCATE (catalog[0].average, Average, NAVE);
    286       REALLOCATE (catalog[0].secfilt, SecFilt, NAVE*catalog[0].Nsecfilt);
    287     }
    288296  }
    289297     
Note: See TracChangeset for help on using the changeset viewer.