IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33515


Ignore:
Timestamp:
Mar 13, 2012, 4:11:23 PM (14 years ago)
Author:
eugene
Message:

change image index names to match the relphot names; use IDX_T to allow switch from int/off_t for index size

Location:
branches/eam_branches/ipp-20111122/Ohana/src/relastro
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/include/relastro.h

    r33475 r33515  
    44# include <signal.h>
    55# include <assert.h>
     6
     7// choose off_t or int depending on full-scale relphot analysis resources
     8// # define IDX_T off_t
     9# define IDX_T int
    610
    711typedef enum {
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/ImageOps.c

    r33448 r33515  
    33# define USE_IMAGE_ID 1
    44
    5 static off_t       **bin;     // link from catalog,measure to image
    6 static int         **clist;   // catalog which supplied measurement on image
    7 static off_t       **mlist;   // measure reference for measurement on image
    8 static off_t        *Nlist;   // number of measurements on image
    9 static off_t        *NLIST;   // allocated number of measurements on image   
    10 
     5// we have an array of images: image[ImageIndex] (ImageIndex : 0 < Nimage)
    116static Image        *image;   // list of available images
    127static off_t        Nimage;   // number of available images
     8
     9// if we read only a subset of the rows from the Image FITS, LineNumber tells us to which row
     10// each image belongs
    1311static off_t       *LineNumber; // match of subset to full image table
    1412
    15 static int         *Ncatlist;  // catalogs associated with each image
    16 static int         *NCATLIST;  // catalogs associated with each image
     13static off_t        *N_onImage;   // number of measurements on image
     14static off_t        *N_ONIMAGE;   // allocated number of measurements on image   
     15
     16static int          *Ncatlist;  // catalogs associated with each image
     17static int          *NCATLIST;  // catalogs associated with each image
    1718static int         **catlist;  // catalogs associated with each image
     19
     20static IDX_T       **MeasureToImage;     // link from catalog,measure to image
     21static IDX_T       **ImageToCatalog;   // catalog which supplied measurement on image
     22static IDX_T       **ImageToMeasure;   // measure reference for measurement on image
    1823
    1924// if we search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted
     
    2833# endif
    2934
     35// MeasureToImage was 'bin'
     36// ImageToCatalog was 'clist'
     37// ImageToMeasure was 'mlist'
     38
     39// N_onImage was 'Nlist'
     40// N_ONIMAGE was 'NLIST'
     41
    3042Image *getimages (off_t *N, off_t **line_number) {
    3143
     
    105117  off_t i, j;
    106118
    107   ALLOCATE (bin, off_t *, Ncatalog);
     119  ALLOCATE (MeasureToImage, IDX_T *, Ncatalog);
    108120  for (i = 0; i < Ncatalog; i++) {
    109     ALLOCATE (bin[i], off_t, MAX (catalog[i].Nmeasure, 1));
    110     for (j = 0; j < catalog[i].Nmeasure; j++) bin[i][j] = -1;
    111   }
    112 
    113   ALLOCATE (Nlist, off_t,   Nimage);
    114   ALLOCATE (NLIST, off_t,   Nimage);
    115   ALLOCATE (clist, int *,   Nimage);
    116   ALLOCATE (mlist, off_t *, Nimage);
     121    ALLOCATE (MeasureToImage[i], IDX_T, MAX (catalog[i].Nmeasure, 1));
     122    for (j = 0; j < catalog[i].Nmeasure; j++) MeasureToImage[i][j] = -1;
     123  }
     124
     125  ALLOCATE (N_onImage, off_t,   Nimage);
     126  ALLOCATE (N_ONIMAGE, off_t,   Nimage);
     127  ALLOCATE (ImageToCatalog, IDX_T *,   Nimage);
     128  ALLOCATE (ImageToMeasure, IDX_T *, Nimage);
    117129
    118130  for (i = 0; i < Nimage; i++) {
    119     Nlist[i] =   0;
    120     NLIST[i] = 100;
    121     clist[i] = NULL;  // we allocate these iff they are needed in matchImage
    122     mlist[i] = NULL;  // we allocate these iff they are needed in matchImage
     131    N_onImage[i] =   0;
     132    N_ONIMAGE[i] =  30;
     133    ImageToCatalog[i] = NULL;  // we allocate these iff they are needed in matchImage
     134    ImageToMeasure[i] = NULL;  // we allocate these iff they are needed in matchImage
    123135  }
    124136
     
    141153
    142154  for (i = 0; i < Ncatalog; i++) {
    143     free (bin[i]);
    144   }
    145   free (bin);
     155    free (MeasureToImage[i]);
     156  }
     157  free (MeasureToImage);
    146158  for (i = 0; i < Nimage; i++) {
    147     if (clist[i]) { free (clist[i]); }
    148     if (mlist[i]) { free (mlist[i]); }
    149   }
    150   free (clist);
    151   free (mlist);
    152   free (Nlist);
    153   free (NLIST);
     159    if (ImageToCatalog[i]) { free (ImageToCatalog[i]); }
     160    if (ImageToMeasure[i]) { free (ImageToMeasure[i]); }
     161  }
     162  free (ImageToCatalog);
     163  free (ImageToMeasure);
     164  free (N_onImage);
     165  free (N_ONIMAGE);
    154166}
    155167
     
    171183  for (i = 0; VERBOSE2 && (i < Nimage); i++) {
    172184    name = GetPhotcodeNamebyCode (image[i].photcode);
    173     fprintf (stderr, "image "OFF_T_FMT" has "OFF_T_FMT" measures (%s, %s)\n",  i,  Nlist[i],
     185    fprintf (stderr, "image "OFF_T_FMT" has "OFF_T_FMT" measures (%s, %s)\n",  i,  N_onImage[i],
    174186             ohana_sec_to_date(image[i].tzero), name);
    175187  }
     
    194206
    195207  // index for (catalog, measure) -> image
    196   bin[cat][meas] = idx;
     208  MeasureToImage[cat][meas] = idx;
    197209
    198210  // if we need to allocate an image index table, do so here
    199   if (!clist[idx]) {
    200       ALLOCATE (clist[idx], int, NLIST[idx]);
    201   }
    202   if (!mlist[idx]) {
    203       ALLOCATE (mlist[idx], off_t, NLIST[idx]);
     211  if (!ImageToCatalog[idx]) {
     212      ALLOCATE (ImageToCatalog[idx], IDX_T, N_ONIMAGE[idx]);
     213  }
     214  if (!ImageToMeasure[idx]) {
     215      ALLOCATE (ImageToMeasure[idx], IDX_T, N_ONIMAGE[idx]);
    204216  }
    205217
    206218  // index for image, Nentry -> catalog
    207   clist[idx][Nlist[idx]] = cat;
     219  ImageToCatalog[idx][N_onImage[idx]] = cat;
    208220
    209221  // index for image, Nentry -> measure
    210   mlist[idx][Nlist[idx]] = meas;
    211   Nlist[idx] ++;
    212 
    213   if (Nlist[idx] == NLIST[idx]) {
    214     NLIST[idx] += 100;
    215     REALLOCATE (clist[idx], int,   NLIST[idx]);
    216     REALLOCATE (mlist[idx], off_t, NLIST[idx]);
     222  ImageToMeasure[idx][N_onImage[idx]] = meas;
     223  N_onImage[idx] ++;
     224
     225  if (N_onImage[idx] == N_ONIMAGE[idx]) {
     226    N_ONIMAGE[idx] += 30;
     227    REALLOCATE (ImageToCatalog[idx], IDX_T, N_ONIMAGE[idx]);
     228    REALLOCATE (ImageToMeasure[idx], IDX_T, N_ONIMAGE[idx]);
    217229  }
    218230
     
    255267
    256268    // index for (catalog, measure) -> image
    257     bin[cat][meas] = i;
     269    MeasureToImage[cat][meas] = i;
    258270
    259271    // index for image, Nentry -> catalog
    260     clist[i][Nlist[i]] = cat;
     272    ImageToCatalog[i][N_onImage[i]] = cat;
    261273
    262274    // index for image, Nentry -> measure
    263     mlist[i][Nlist[i]] = meas;
    264     Nlist[i] ++;
    265 
    266     if (Nlist[i] == NLIST[i]) {
    267       NLIST[i] += 100;
    268       REALLOCATE (clist[i], int,   NLIST[i]);
    269       REALLOCATE (mlist[i], off_t, NLIST[i]);
     275    ImageToMeasure[i][N_onImage[i]] = meas;
     276    N_onImage[i] ++;
     277
     278    if (N_onImage[i] == N_ONIMAGE[i]) {
     279      N_ONIMAGE[i] += 30;
     280      REALLOCATE (ImageToCatalog[i], IDX_T, N_ONIMAGE[i]);
     281      REALLOCATE (ImageToMeasure[i], IDX_T, N_ONIMAGE[i]);
    270282    }
    271283    return;
     
    281293  off_t i;
    282294
    283   i = bin[cat][meas];
     295  i = MeasureToImage[cat][meas];
    284296  if (i == -1) return (NULL);
    285297  return (&image[i].coords);
     
    402414  }     
    403415
    404   for (i = 0; i < Nlist[im]; i++) {
    405     m = mlist[im][i];
    406     c = clist[im][i];
     416  for (i = 0; i < N_onImage[im]; i++) {
     417    m = ImageToMeasure[im][i];
     418    c = ImageToCatalog[im][i];
    407419
    408420    Measure *measure = &catalog[c].measure[m];
     
    512524  imcoords = &image[im].coords;
    513525
    514   for (i = 0; i < Nlist[im]; i++) {
    515     m = mlist[im][i];
    516     c = clist[im][i];
     526  for (i = 0; i < N_onImage[im]; i++) {
     527    m = ImageToMeasure[im][i];
     528    c = ImageToCatalog[im][i];
    517529
    518530    // XXX unclear if this should use Measure or MeasureTiny; it is only called by FixProblemImages, which has not been updated
     
    575587  }
    576588
    577   ALLOCATE (raw, StarData, Nlist[im]);
    578 
    579   for (i = 0; i < Nlist[im]; i++) {
    580     m = mlist[im][i];
    581     c = clist[im][i];
     589  ALLOCATE (raw, StarData, N_onImage[im]);
     590
     591  for (i = 0; i < N_onImage[im]; i++) {
     592    m = ImageToMeasure[im][i];
     593    c = ImageToCatalog[im][i];
    582594
    583595    MeasureTiny *measure = &catalog[c].measureT[m];
     
    623635  }
    624636
    625   *Nstars = Nlist[im];
     637  *Nstars = N_onImage[im];
    626638  return (raw);
    627639}
     
    649661  }
    650662
    651   ALLOCATE (ref, StarData, Nlist[im]);
    652 
    653   for (i = 0; i < Nlist[im]; i++) {
    654     m = mlist[im][i];
    655     c = clist[im][i];
     663  ALLOCATE (ref, StarData, N_onImage[im]);
     664
     665  for (i = 0; i < N_onImage[im]; i++) {
     666    m = ImageToMeasure[im][i];
     667    c = ImageToCatalog[im][i];
    656668
    657669    MeasureTiny *measure = &catalog[c].measureT[m];
     
    687699  }
    688700
    689   *Nstars = Nlist[im];
     701  *Nstars = N_onImage[im];
    690702  return (ref);
    691703}
  • branches/eam_branches/ipp-20111122/Ohana/src/relastro/src/load_catalogs.c

    r33480 r33515  
    8282  }
    8383
    84   // XXX keep this test?
    8584  Nstar = 0;
    8685  for (i = 0; i < Ncat; i++) {
    8786    Nstar += catalog[i].Naverage;
     87    if ((sizeof(IDX_T) == 8) && (catalog[i].Nmeasure > 0xffffffff)) {
     88      fprintf (stderr, "ERROR: using small-sized IDX_T on data with more than 2G detections per table will cause errors\n");
     89      fprintf (stderr, "  If you need to do this, and you can afford the RAM, rebuild with IDX_T set to off_t (see relastro.h, ImagesOps.c)\n");
     90      exit (3);
     91    }
    8892  }
    8993  if (Nstar < 2) {
Note: See TracChangeset for help on using the changeset viewer.