IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 31535


Ignore:
Timestamp:
May 11, 2011, 6:21:03 PM (15 years ago)
Author:
eugene
Message:

do not realloc the extra Nmosaic copies of the image cross lists

Location:
branches/eam_branches/ipp-20110505/Ohana/src/relphot
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110505/Ohana/src/relphot/include/relphot.h

    r31493 r31535  
    140140void          dump_grid           PROTO((void));
    141141int           edge_check          PROTO((double *x1, double *y1, double *x2, double *y2));
    142 void          findImages          PROTO((Catalog *catalog, int Ncatalog));
    143 int           findMosaics         PROTO((Catalog *catalog, int Ncatalog));
     142void          findImages          PROTO((Catalog *catalog, int Ncatalog, int doImageList));
     143int           findMosaics         PROTO((Catalog *catalog, int Ncatalog, int doMosaicList));
    144144
    145145void set_db (FITS_DB *in);
     
    150150
    151151void          freeGridBins        PROTO((int Ncatalog));
    152 void          freeImageBins       PROTO((int Ncatalog));
    153 void          freeMosaicBins      PROTO((int Ncatalog));
     152void          freeImageBins       PROTO((int Ncatalog, int doImageList));
     153void          freeMosaicBins      PROTO((int Ncatalog, int doMosaicList));
    154154void          free_catalogs       PROTO((Catalog *catalog, int Ncatalog));
    155155int           gcatalog            PROTO((Catalog *catalog, int FINAL));
     
    165165void          initGrid            PROTO((int dX, int dY));
    166166void          initGridBins        PROTO((Catalog *catalog, int Ncatalog));
    167 void          initImageBins       PROTO((Catalog *catalog, int Ncatalog));
     167void          initImageBins       PROTO((Catalog *catalog, int Ncatalog, int doImageList));
    168168void          initImages          PROTO((Image *input, off_t *LineNumber, off_t N));
    169 void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog));
     169void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog, int doMosaicList));
    170170void          initMosaicGrid      PROTO((Image *image, off_t Nimage));
    171171void          initMosaics         PROTO((Image *image, off_t Nimage));
     
    180180int           main                PROTO((int argc, char **argv));
    181181void          mark_images         PROTO((Image *image, off_t Nimage, Image *timage, off_t Ntimage));
    182 void          matchImage          PROTO((Catalog *catalog, off_t meas, int cat));
    183 void          matchMosaics        PROTO((Catalog *catalog, off_t meas, int cat));
     182void          matchImage          PROTO((Catalog *catalog, off_t meas, int cat, int doImageList));
     183void          matchMosaics        PROTO((Catalog *catalog, off_t meas, int cat, int doMosaicList));
    184184double        opening_angle       PROTO((double x1, double y1, double x2, double y2, double x3, double y3));
    185185void          plot_chisq          PROTO((Catalog *catalog, int Ncatalog));
  • branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/ImageOps.c

    r31493 r31535  
    6969}
    7070
    71 void initImageBins (Catalog *catalog, int Ncatalog) {
     71void initImageBins (Catalog *catalog, int Ncatalog, int doImageList) {
    7272
    7373  off_t i, j;
     
    7979  }
    8080
    81   ALLOCATE (Nlist, off_t, Nimage);
    82   ALLOCATE (NLIST, off_t, Nimage);
    83   ALLOCATE (clist, off_t *, Nimage);
    84   ALLOCATE (mlist, off_t *, Nimage);
    85 
    86   for (i = 0; i < Nimage; i++) {
    87     Nlist[i] = 0;
    88     NLIST[i] = 100;
    89     ALLOCATE (clist[i], off_t, NLIST[i]);
    90     ALLOCATE (mlist[i], off_t, NLIST[i]);
    91   }
    92 }
    93 
    94 void freeImageBins (int Ncatalog) {
     81  if (doImageList) {
     82    ALLOCATE (Nlist, off_t, Nimage);
     83    ALLOCATE (NLIST, off_t, Nimage);
     84    ALLOCATE (clist, off_t *, Nimage);
     85    ALLOCATE (mlist, off_t *, Nimage);
     86
     87    for (i = 0; i < Nimage; i++) {
     88      Nlist[i] = 0;
     89      NLIST[i] = 100;
     90      ALLOCATE (clist[i], off_t, NLIST[i]);
     91      ALLOCATE (mlist[i], off_t, NLIST[i]);
     92    }
     93  }
     94}
     95
     96void freeImageBins (int Ncatalog, int doImageList) {
    9597
    9698  off_t i;
     
    100102  }
    101103  free (bin);
    102   for (i = 0; i < Nimage; i++) {
    103     free (clist[i]);
    104     free (mlist[i]);
    105   }
    106   free (clist);
    107   free (mlist);
    108   free (Nlist);
    109   free (NLIST);
     104
     105  if (doImageList) {
     106    for (i = 0; i < Nimage; i++) {
     107      free (clist[i]);
     108      free (mlist[i]);
     109    }
     110    free (clist);
     111    free (mlist);
     112    free (Nlist);
     113    free (NLIST);
     114  }
    110115}
    111116
    112117/* select all image equivalent to the active photcode set */
    113 void findImages (Catalog *catalog, int Ncatalog) {
     118void findImages (Catalog *catalog, int Ncatalog, int doImageList) {
    114119
    115120  off_t j;
     
    125130      }
    126131      if (!found) continue;
    127       matchImage (catalog, j, i);
     132      matchImage (catalog, j, i, doImageList);
    128133      Nmatch ++;
    129134    }
     
    181186}
    182187
    183 void matchImage (Catalog *catalog, off_t meas, int cat) {
     188void matchImage (Catalog *catalog, off_t meas, int cat, int doImageList) {
    184189
    185190  off_t idx, ID;
     
    207212  bin[cat][meas] = idx;
    208213
    209   // index for image, Nentry -> catalog
    210   clist[idx][Nlist[idx]] = cat;
    211 
    212   // index for image, Nentry -> measure
    213   mlist[idx][Nlist[idx]] = meas;
    214   Nlist[idx] ++;
    215 
    216   if (Nlist[idx] == NLIST[idx]) {
    217     NLIST[idx] += 100;
    218     REALLOCATE (clist[idx], off_t, NLIST[idx]);
    219     REALLOCATE (mlist[idx], off_t, NLIST[idx]);
    220   }     
     214  if (doImageList) {
     215    // index for image, Nentry -> catalog
     216    clist[idx][Nlist[idx]] = cat;
     217
     218    // index for image, Nentry -> measure
     219    mlist[idx][Nlist[idx]] = meas;
     220    Nlist[idx] ++;
     221
     222    if (Nlist[idx] == NLIST[idx]) {
     223      NLIST[idx] += 100;
     224      REALLOCATE (clist[idx], off_t, NLIST[idx]);
     225      REALLOCATE (mlist[idx], off_t, NLIST[idx]);
     226    }   
     227  }
    221228
    222229  return;
  • branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/MosaicOps.c

    r31525 r31535  
    211211}
    212212
    213 void initMosaicBins (Catalog *catalog, int Ncatalog) {
     213void initMosaicBins (Catalog *catalog, int Ncatalog, int doMosaicList) {
    214214
    215215  off_t i, j;
     
    224224  }
    225225
    226   /* mosaic -> measure */
    227   ALLOCATE (Nlist, off_t,   Nmosaic);
    228   ALLOCATE (NLIST, off_t,   Nmosaic);
    229   ALLOCATE (clist, int *,   Nmosaic);
    230   ALLOCATE (mlist, off_t *, Nmosaic);
    231 
    232   for (i = 0; i < Nmosaic; i++) {
    233     Nlist[i] = 0;
    234     NLIST[i] = 100;
    235     ALLOCATE (clist[i], int,   NLIST[i]);
    236     ALLOCATE (mlist[i], off_t, NLIST[i]);
    237   }
    238 }
    239 
    240 void freeMosaicBins (int Ncatalog) {
     226  if (doMosaicList) {
     227    /* mosaic -> measure */
     228    ALLOCATE (Nlist, off_t,   Nmosaic);
     229    ALLOCATE (NLIST, off_t,   Nmosaic);
     230    ALLOCATE (clist, int *,   Nmosaic);
     231    ALLOCATE (mlist, off_t *, Nmosaic);
     232
     233    for (i = 0; i < Nmosaic; i++) {
     234      Nlist[i] = 0;
     235      NLIST[i] = 100;
     236      ALLOCATE (clist[i], int,   NLIST[i]);
     237      ALLOCATE (mlist[i], off_t, NLIST[i]);
     238    }
     239  }
     240}
     241
     242void freeMosaicBins (int Ncatalog, int doMosaicList) {
    241243
    242244  off_t i;
     
    250252  free (bin);
    251253
    252   /* mosaic -> measure */
    253   for (i = 0; i < Nmosaic; i++) {
    254     free (clist[i]);
    255     free (mlist[i]);
    256   }
    257   free (Nlist);
    258   free (NLIST);
    259   free (clist);
    260   free (mlist);
    261 }
    262 
    263 int findMosaics (Catalog *catalog, int Ncatalog) {
     254  if (doMosaicList) {
     255    /* mosaic -> measure */
     256    for (i = 0; i < Nmosaic; i++) {
     257      free (clist[i]);
     258      free (mlist[i]);
     259    }
     260    free (Nlist);
     261    free (NLIST);
     262    free (clist);
     263    free (mlist);
     264  }
     265}
     266
     267int findMosaics (Catalog *catalog, int Ncatalog, int doMosaicList) {
    264268 
    265269  int i, ecode, found, Ns;
     
    281285      }
    282286      if (!found) continue;
    283       matchMosaics (catalog, j, i);
     287      matchMosaics (catalog, j, i, doMosaicList);
    284288      Nmatch ++;
    285289    }
     
    289293}
    290294
    291 void matchMosaics (Catalog *catalog, off_t meas, int cat) {
     295void matchMosaics (Catalog *catalog, off_t meas, int cat, int doMosaicList) {
    292296
    293297  off_t idx, ID, mosID;
     
    322326  bin[cat][meas] = mosID;
    323327
    324   clist[mosID][Nlist[mosID]] = cat;
    325   mlist[mosID][Nlist[mosID]] = meas;
    326   Nlist[mosID] ++;
     328  if (doMosaicList) {
     329    clist[mosID][Nlist[mosID]] = cat;
     330    mlist[mosID][Nlist[mosID]] = meas;
     331    Nlist[mosID] ++;
    327332   
    328   if (Nlist[mosID] == NLIST[mosID]) {
    329     NLIST[mosID] += 100;
    330     REALLOCATE (clist[mosID], int,   NLIST[mosID]);
    331     REALLOCATE (mlist[mosID], off_t, NLIST[mosID]);
    332   }     
     333    if (Nlist[mosID] == NLIST[mosID]) {
     334      NLIST[mosID] += 100;
     335      REALLOCATE (clist[mosID], int,   NLIST[mosID]);
     336      REALLOCATE (mlist[mosID], off_t, NLIST[mosID]);
     337    }   
     338  }
    333339  return;
    334340}
  • branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/bcatalog.c

    r31524 r31535  
    340340int free_tiny_values (Catalog *catalog) {
    341341
    342   free (catalog[0].averageT);
    343   free (catalog[0].measureT);
    344   return (TRUE);
    345 }
    346 
     342  if (catalog[0].averageT) free (catalog[0].averageT);
     343  if (catalog[0].measureT) free (catalog[0].measureT);
     344  return (TRUE);
     345}
     346
  • branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/reload_catalogs.c

    r31524 r31535  
    6060    TIMESTAMP(time3a);
    6161
    62     initImageBins  (&catalog, 1);
    63     initMosaicBins (&catalog, 1);
     62    initImageBins  (&catalog, 1, FALSE);
     63    initMosaicBins (&catalog, 1, FALSE);
    6464    initGridBins   (&catalog, 1);
    6565    TIMESTAMP(time3b);
    6666
    67     findImages (&catalog, 1);  // FX
    68     findMosaics (&catalog, 1); //
     67    findImages (&catalog, 1, FALSE);
     68    findMosaics (&catalog, 1, FALSE);
    6969    TIMESTAMP(time4);
    7070
     
    7979    TIMESTAMP(time6);
    8080
    81     freeImageBins (1);
    82     freeMosaicBins (1);
     81    freeImageBins (1, FALSE);
     82    freeMosaicBins (1, FALSE);
    8383    freeGridBins (1);
    8484    TIMESTAMP(time7);
  • branches/eam_branches/ipp-20110505/Ohana/src/relphot/src/relphot.c

    r31524 r31535  
    6666
    6767  /* match measurements with images, mosaics */
    68   initImageBins  (catalog, Ncatalog);
     68  initImageBins  (catalog, Ncatalog, TRUE);
    6969  MARKTIME("-- make image bins: %f sec\n", dtime);
    7070
    71   initMosaicBins (catalog, Ncatalog);
     71  initMosaicBins (catalog, Ncatalog, TRUE);
    7272  initGridBins   (catalog, Ncatalog);
    7373  initMrel (catalog, Ncatalog);
    7474
    75   findImages (catalog, Ncatalog);
     75  findImages (catalog, Ncatalog, TRUE);
    7676  MARKTIME("-- set up image indexes: %f sec\n", dtime);
    7777
    78   findMosaics (catalog, Ncatalog);  /* also sets Grid values */
     78  findMosaics (catalog, Ncatalog, TRUE);  /* also sets Grid values */
    7979  MARKTIME("-- set up mosaic indexes: %f sec\n", dtime);
    8080
     
    220220    dvo_catalog_free (&catalog[i]);
    221221  }
    222   freeImageBins (Ncatalog);
    223   freeMosaicBins (Ncatalog);
     222  freeImageBins (Ncatalog, TRUE);
     223  freeMosaicBins (Ncatalog, TRUE);
    224224  freeGridBins (Ncatalog);
    225225
Note: See TracChangeset for help on using the changeset viewer.