IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 11, 2016, 10:23:42 PM (10 years ago)
Author:
eugene
Message:

modify to pass with extremely pedantic build; force consistency for signed vs unsigned and int sizes; various relastro updates

Location:
trunk/Ohana
Files:
44 edited
11 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

  • trunk/Ohana/src/relastro/Makefile

    r39375 r39457  
    4141$(SRC)/Shutdown.$(ARCH).o            \
    4242$(SRC)/UpdateChips.$(ARCH).o         \
     43$(SRC)/UpdateStacks.$(ARCH).o         \
    4344$(SRC)/UpdateMosaic.$(ARCH).o        \
    4445$(SRC)/UpdateObjects.$(ARCH).o       \
     
    4748$(SRC)/UpdateMeasures.$(ARCH).o      \
    4849$(SRC)/GetAstromError.$(ARCH).o      \
     50$(SRC)/MeasFilterTest.$(ARCH).o            \
    4951$(SRC)/args.$(ARCH).o                \
    5052$(SRC)/bcatalog.$(ARCH).o            \
     
    120122$(SRC)/UpdateMeasures.$(ARCH).o      \
    121123$(SRC)/GetAstromError.$(ARCH).o      \
     124$(SRC)/MeasFilterTest.$(ARCH).o            \
    122125$(SRC)/args.$(ARCH).o                \
    123126$(SRC)/bcatalog.$(ARCH).o            \
     
    195198$(SRC)/mkpolyterm.$(ARCH).o            \
    196199$(SRC)/GetAstromError.$(ARCH).o            \
    197 $(SRC)/ImageOps.$(ARCH).o            \
    198 $(SRC)/MosaicOps.$(ARCH).o            \
     200$(SRC)/MeasFilterTest.$(ARCH).o            \
    199201$(SRC)/extra.$(ARCH).o            \
    200202$(SRC)/plotstuff.$(ARCH).o            \
     
    218220$(SRC)/mkpolyterm.$(ARCH).o            \
    219221$(SRC)/GetAstromError.$(ARCH).o            \
    220 $(SRC)/ImageOps.$(ARCH).o            \
    221 $(SRC)/MosaicOps.$(ARCH).o            \
     222$(SRC)/MeasFilterTest.$(ARCH).o            \
    222223$(SRC)/extra.$(ARCH).o            \
    223224$(SRC)/plotstuff.$(ARCH).o            \
     
    241242$(SRC)/mkpolyterm.$(ARCH).o            \
    242243$(SRC)/GetAstromError.$(ARCH).o            \
    243 $(SRC)/ImageOps.$(ARCH).o            \
    244 $(SRC)/MosaicOps.$(ARCH).o            \
     244$(SRC)/MeasFilterTest.$(ARCH).o            \
    245245$(SRC)/extra.$(ARCH).o            \
    246246$(SRC)/plotstuff.$(ARCH).o            \
    247247$(SRC)/fitpoly.$(ARCH).o
     248
     249# stupid dependencies:
     250# UpdateObjects.c:UpdateObjects_Chips needs
     251# ImageOps.c:MeasFilterTiny forces
     252# load_images.c:free_astrom_table needs
     253# select_images.c
     254# MosaicOps.c
    248255
    249256$(FITSTK): $(INC)/relastro.h
  • trunk/Ohana/src/relastro/include/relastro.h

    r39396 r39457  
    8888  off_t *NMEASURE;            // allocated Measures per catalog
    8989  int   *index;               // lookup table catID -> catalog[i]
    90   int  *catIDs;              // lookup table catID <- catalog[i]
    91   int    maxID;               // max catID value to date
     90  unsigned int *catIDs;       // lookup table catID <- catalog[i]
     91  unsigned int  maxID;        // max catID value to date
    9292} CatalogSplitter;
    9393
     
    259259int    REGION_HOST_ID;
    260260int    PARALLEL_REGIONS_MANUAL;
     261char  *MANUAL_UNIQUER;
    261262
    262263int          HOST_ID;
     
    416417int SetSignals (void);
    417418
    418 void relastro_client_free ();
     419void relastro_free (SkyTable *sky, SkyList *skylist);
     420void relastro_client_free (SkyTable *sky, SkyList *skylist);
    419421
    420422GSCRegion    *find_regions        PROTO((Image *image, off_t Nimage, int *Nregions, GSCRegion *fullregion));
     
    438440void          initImageBins       PROTO((Catalog *catalog, int Ncatalog, int FULLINIT));
    439441void          initImages          PROTO((Image *input, off_t *line_number, off_t N));
     442void          freeImages          PROTO(());
    440443void          initMosaicBins      PROTO((Catalog *catalog, int Ncatalog));
    441444void          initMosaicGrid      PROTO((Image *image, off_t Nimage));
     
    528531int UpdateSimple (Catalog *catalog, int Ncatalog);
    529532int UpdateChips (Catalog *catalog, int Ncatalog, int Nloop);
     533int UpdateStacks (Catalog *catalog, int Ncatalog);
    530534int UpdateMosaic (Catalog *catalog, int Ncatalog);
    531535int UpdateMeasures (Catalog *catalog, int Ncatalog);
     
    552556Mosaic *getmosaics (off_t *N);
    553557void initMosaics (Image *image, off_t Nimage);
     558void freeMosaics ();
    554559StarData *getMosaicRaw (Catalog *catalog, int Ncatalog, off_t mos, off_t *Nstars);
    555560StarData *getMosaicRef (Catalog *catalog, int Ncatalog, off_t mos, off_t *Nstars);
     
    588593
    589594int initStarMaps ();
     595void freeStarMaps ();
    590596int updateStarMaps(Catalog *catalog);
    591597int createStarMapPoints();
     
    653659
    654660int indexCatalogs (Catalog *catalog, int Ncatalog);
    655 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq);
     661int catID_and_objID_to_seq (unsigned int catID, unsigned int objID, int *catSeq, off_t *objSeq);
     662void freeCatalogIndexes (int Ncatalog);
    656663
    657664int markObjects (Catalog *catalog, int Ncatalog);
     
    682689AstromOffsetTable *get_astrom_table ();
    683690void put_astrom_table (AstromOffsetTable *myTable);
     691void free_astrom_table ();
    684692
    685693int fit_map (AstromOffsetMap *map, StarData *raw, StarData *ref, int Npts);
  • trunk/Ohana/src/relastro/src

  • trunk/Ohana/src/relastro/src/BootstrapOps.c

    r39364 r39457  
    9898      myAbort ("invalid option");
    9999  }
     100  free (values);
    100101
    101102  return TRUE;
  • trunk/Ohana/src/relastro/src/BrightCatalog.c

    r39396 r39457  
    358358    ohana_memcheck (1);
    359359
    360     my_memdump("start of define_bintable");
    361360    gfits_define_bintable_column (&theader, "D", "RA",       "ra",                         "degrees", 1.0, 0.0);
    362     my_memdump("after define_bintable RA");
    363 
    364361    gfits_define_bintable_column (&theader, "D", "DEC",      "dec",                        "degrees", 1.0, 0.0);
    365     my_memdump("after define_bintable DEC");
    366 
    367362    gfits_define_bintable_column (&theader, "E", "MAG_SYS",  "magnitude (sys)",             NULL,    1.0, 0.0);
    368363    gfits_define_bintable_column (&theader, "E", "MAG_CAL",  "magnitude (cal)",             NULL,    1.0, 0.0);
     
    433428    // add the columns to the output array
    434429    gfits_set_bintable_column (&theader, &ftable, "RA",         R,         catalog->Nmeasure);
     430
     431    fprintf (stderr, "--------------- after set_bintable RA --------------");
     432    ohana_memdump_file (stderr, TRUE);
     433   
    435434    gfits_set_bintable_column (&theader, &ftable, "DEC",        D,         catalog->Nmeasure);
    436435    gfits_set_bintable_column (&theader, &ftable, "MAG_SYS",    M,         catalog->Nmeasure);
     
    798797  catalogs->maxID = 0;
    799798  ALLOCATE (catalogs->index, int, catalogs->maxID + 1);
    800   for (i = 0; i <= catalogs->maxID; i++) catalogs->index[i] = -1;
     799
     800  unsigned int ID;
     801  for (ID = 0; ID <= catalogs->maxID; ID++) catalogs->index[ID] = -1;
    801802
    802803  catalogs->Nsecfilt = Nsecfilt;
     
    807808  ALLOCATE (catalogs->catalog, Catalog, catalogs->NCATALOG);
    808809
    809   ALLOCATE (catalogs->catIDs,   int,  catalogs->NCATALOG);
    810   ALLOCATE (catalogs->NAVERAGE, off_t, catalogs->NCATALOG);
    811   ALLOCATE (catalogs->NMEASURE, off_t, catalogs->NCATALOG);
     810  ALLOCATE (catalogs->catIDs,   unsigned int, catalogs->NCATALOG);
     811  ALLOCATE (catalogs->NAVERAGE, off_t,        catalogs->NCATALOG);
     812  ALLOCATE (catalogs->NMEASURE, off_t,        catalogs->NCATALOG);
    812813
    813814  for (i = 0; i < catalogs->NCATALOG; i++) {
     
    828829int BrightCatalogSplitFree (CatalogSplitter *catalogs) {
    829830
    830   free (catalogs->catIDs);
    831   free (catalogs->NAVERAGE);
    832   free (catalogs->NMEASURE);
    833   free (catalogs->index);
    834   free (catalogs);
     831# if (0)
     832  int i;
     833
     834  for (i = 0; i < catalogs->NCATALOG; i++) {
     835    FREE (catalogs->catalog[i].average);
     836    FREE (catalogs->catalog[i].secfilt);
     837    FREE (catalogs->catalog[i].measureT);
     838  }
     839  FREE (catalogs->catalog);
     840# endif
     841
     842  FREE (catalogs->catIDs);
     843  FREE (catalogs->NAVERAGE);
     844  FREE (catalogs->NMEASURE);
     845  FREE (catalogs->index);
     846  FREE (catalogs);
    835847  return TRUE;
    836848}
     
    844856
    845857  // find the max value of catID in this BrightCatalog
    846   int catIDmax = 0;
     858  unsigned int catIDmax = 0;
    847859  for (i = 0; i < bcatalog->Naverage; i++) {
    848860    catIDmax = MAX(catIDmax, bcatalog->average[i].catID);
     
    850862  // XXX validate the measure ID range here
    851863   
    852   int maxIDold = catalogs->maxID;
     864  unsigned int maxIDold = catalogs->maxID;
    853865  catalogs->maxID = MAX (maxIDold, catIDmax);
    854866   
    855867  // extend the index array and init
    856868  REALLOCATE (catalogs->index, int, catalogs->maxID + 1);
    857   for (i = maxIDold + 1; i <= catalogs->maxID; i++) catalogs->index[i] = -1;
     869
     870  unsigned int id;
     871  for (id = maxIDold + 1; id <= catalogs->maxID; id++) catalogs->index[id] = -1;
    858872
    859873  // identify the new catID values
    860874  for (i = 0; i < bcatalog->Naverage; i++) {
    861     int catID = bcatalog->average[i].catID;
     875    unsigned int catID = bcatalog->average[i].catID;
    862876    assert (catID > 0);
    863877    assert (catID < catalogs->maxID + 1);
     
    881895
    882896    if (catalogs->Ncatalog >= catalogs->NCATALOG) {
     897      int oldNCATALOG = catalogs->NCATALOG;
    883898      catalogs->NCATALOG += 16;
    884899      // fprintf (stderr, "realloc catalogs->catalog: old: %llx  ", (long long) catalogs->catalog);
     
    894909      // fprintf (stderr, "new: %llx  -  %llx\n", (long long) catalogs->NMEASURE, (long long) (catalogs->NMEASURE + sizeof(off_t)*catalogs->NCATALOG));
    895910
    896       REALLOCATE (catalogs->catIDs,   int,  catalogs->NCATALOG);
     911      REALLOCATE (catalogs->catIDs, unsigned int, catalogs->NCATALOG);
    897912
    898913      int j;
    899       for (j = catalogs->NCATALOG - 16; j < catalogs->NCATALOG; j++) {
     914      for (j = oldNCATALOG; j < catalogs->NCATALOG; j++) {
    900915        dvo_catalog_init (&catalogs->catalog[j], TRUE);
    901916        catalogs->catIDs[j] = 0;
     
    917932  // assign the averages to the corresponding catalog
    918933  for (i = 0; i < bcatalog->Naverage; i++) {
    919     int ID = bcatalog->average[i].catID;
     934    unsigned int ID = bcatalog->average[i].catID;
    920935    int Nc = catalogs->index[ID];
    921936    assert (Nc > -1);
     
    942957  // XXX what about averef and related links?  Do I need them?
    943958  for (i = 0; i < bcatalog->Nmeasure; i++) {
    944     int ID = bcatalog->measure[i].catID;
     959    unsigned int ID = bcatalog->measure[i].catID;
    945960    int Nc = catalogs->index[ID];
    946961    assert (Nc > -1);
  • trunk/Ohana/src/relastro/src/FitAstromOps.c

    r39375 r39457  
    297297    median = x[(int)(0.5*Npoints)];
    298298  }
     299  free (x);
    299300
    300301  return median;
  • trunk/Ohana/src/relastro/src/FitChip.c

    r38986 r39457  
    221221
    222222  int i, Ns;
    223   float dL, dM, dLsum, dLsum2, dMsum, dMsum2, *dR;
    224 
    225   ALLOCATE (dR, float, Nstars);
     223  float dL, dM;
     224
     225  ALLOCATE_PTR (dRvec, double, Nstars);
     226  ALLOCATE_PTR (dLvec, double, Nstars);
     227  ALLOCATE_PTR (dMvec, double, Nstars);
    226228
    227229  Ns = 0;
    228   dLsum = dLsum2 = dMsum = dMsum2 = 0.0;
    229230  for (i = 0; i < Nstars; i++) {
    230231    if (raw[i].mask) continue;
     
    235236    dM = raw[i].M - ref[i].M;
    236237
    237     dLsum  += dL;
    238     dLsum2 += dL*dL;
    239     dMsum  += dM;
    240     dMsum2 += dM*dM;
    241 
    242     dR[Ns] = hypot (dL, dM);
     238    dLvec[Ns] = dL;
     239    dMvec[Ns] = dM;
     240    dRvec[Ns] = hypot (dL, dM);
    243241    Ns++;
    244242  }
    245243
    246   *dLsig = sqrt((dLsum2 / Ns) - SQ(dLsum/Ns));
    247   *dMsig = sqrt((dMsum2 / Ns) - SQ(dMsum/Ns));
     244  dsort (dLvec, Ns);
     245  dsort (dMvec, Ns);
     246
     247  double Slo, Shi;
     248  Slo = VectorFractionInterpolate (dLvec, 0.158655, Ns);
     249  Shi = VectorFractionInterpolate (dLvec, 0.841345, Ns);
     250  *dLsig = (Shi - Slo) / 2.0;
     251  free (dLvec);
     252
     253  Slo = VectorFractionInterpolate (dMvec, 0.158655, Ns);
     254  Shi = VectorFractionInterpolate (dMvec, 0.841345, Ns);
     255  *dMsig = (Shi - Slo) / 2.0;
     256  free (dMvec);
     257
    248258  *nKeep = Ns;
    249259
    250260  if (Ns < 5) {
    251261    *dRsig = NAN;
    252     free  (dR);
     262    free  (dRvec);
    253263    return (FALSE);
    254264  }
    255265
    256266  // for a 2D Gaussian, 40% of the points are within R = 1 sigma
    257   fsort (dR, Ns);
    258   *dRsig = dR[(int)(0.40*Ns)];
     267  dsort (dRvec, Ns);
     268  *dRsig = dRvec[(int)(0.40*Ns)];
    259269 
    260   free  (dR);
     270  free  (dRvec);
    261271  return (TRUE);
    262272}
  • trunk/Ohana/src/relastro/src/GetAstromError.c

    r39225 r39457  
    7676  // weight to ensure the image is tied down to the 2mass frame
    7777
    78   if (has2MASS && LoopWeight2MASS) {
     78  if (has2MASS && LoopWeight2MASS && (Nloop >= 0)) {
    7979    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
    8080  }
    81   if (is2MASS && LoopWeight2MASS) {
     81  if (is2MASS && LoopWeight2MASS && (Nloop >= 0)) {
    8282    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
    8383  }
    84   if (isTycho && LoopWeightTycho) {
     84  if (isTycho && LoopWeightTycho && (Nloop >= 0)) {
    8585    dPtotal = dPtotal / LoopWeightTycho[Nloop];
    8686  }
  • trunk/Ohana/src/relastro/src/ImageOps.c

    r39381 r39457  
    11# include "relastro.h"
    2 int isGPC1chip (int photcode);
    32
    43# define USE_IMAGE_ID 1
     
    109// if we read only a subset of the rows from the Image FITS, LineNumber tells us to which row
    1110// each image belongs
    12 static off_t       *LineNumber; // match of subset to full image table
    13 
    14 static off_t        *N_onImage;   // number of measurements on image
    15 static off_t        *N_ONIMAGE;   // allocated number of measurements on image   
    16 
    17 static int          *Ncatlist;  // catalogs associated with each image
    18 static int          *NCATLIST;  // catalogs associated with each image
    19 static int         **catlist;  // catalogs associated with each image
    20 
    21 static IDX_T       **MeasureToImage;     // link from catalog,measure to image
    22 static IDX_T       **ImageToCatalog;   // catalog which supplied measurement on image
    23 static IDX_T       **ImageToMeasure;   // measure reference for measurement on image
     11static off_t       *LineNumber = NULL; // match of subset to full image table
     12
     13static off_t        *N_onImage = NULL;   // number of measurements on image
     14static off_t        *N_ONIMAGE = NULL;   // allocated number of measurements on image   
     15
     16static int          *Ncatlist = NULL;  // catalogs associated with each image
     17static int          *NCATLIST = NULL;  // catalogs associated with each image
     18static int         **catlist  = NULL;  // catalogs associated with each image
     19
     20static IDX_T       **MeasureToImage = NULL;     // link from catalog,measure to image
     21static IDX_T       **ImageToCatalog = NULL;   // catalog which supplied measurement on image
     22static IDX_T       **ImageToMeasure = NULL;   // measure reference for measurement on image
    2423
    2524// if we search by image ID, we sort (imageIDs, imageIdx) by imageIDs to get a sorted
     
    2726
    2827# if USE_IMAGE_ID
    29 static off_t        *imageIDs; // list of all image IDs
    30 static off_t        *imageIdx; // list of index for image IDs
     28static off_t        *imageIDs = NULL; // list of all image IDs
     29static off_t        *imageIdx = NULL; // list of index for image IDs
    3130
    3231// as an alternative, we generate imageSeq, which directly maps imageID -> seq
    33 static off_t        *imageSeq; // list of index for image IDs
     32static off_t        *imageSeq = NULL; // list of index for image IDs
    3433
    3534// MAX_ID requires 512M to store the image index
     
    120119  }
    121120# endif
     121}
     122
     123void freeImages () {
     124
     125  FREE (LineNumber);
     126
     127# if USE_IMAGE_ID
     128  FREE (imageIDs);
     129  FREE (imageIdx);
     130  FREE (imageSeq);
     131# else
     132  FREE (start);
     133  FREE (stop);
     134# endif
     135
     136  free_astrom_table();
    122137}
    123138
     
    197212
    198213  for (i = 0; i < Ncatalog; i++) {
    199     free (MeasureToImage[i]);
    200   }
    201   free (MeasureToImage);
     214    FREE (MeasureToImage[i]);
     215  }
     216  FREE (MeasureToImage);
    202217  for (i = 0; i < Nimage; i++) {
    203     if (ImageToCatalog[i]) { free (ImageToCatalog[i]); }
    204     if (ImageToMeasure[i]) { free (ImageToMeasure[i]); }
    205   }
    206   free (ImageToCatalog);
    207   free (ImageToMeasure);
    208   free (N_onImage);
    209   free (N_ONIMAGE);
     218    FREE (ImageToCatalog[i]);
     219    FREE (ImageToMeasure[i]);
     220    if (catlist) { FREE (catlist[i]); }
     221  }
     222  FREE (Ncatlist);
     223  FREE (NCATLIST);
     224  FREE (catlist);
     225  Ncatlist = NULL;
     226  NCATLIST = NULL;
     227  catlist  = NULL;
     228
     229  FREE (ImageToCatalog);
     230  FREE (ImageToMeasure);
     231  FREE (N_onImage);
     232  FREE (N_ONIMAGE);
    210233}
    211234
     
    240263      name = GetPhotcodeNamebyCode (image[i].photcode);
    241264      int showExample = (Nfew < 30);
    242       if (showExample) fprintf (stderr, "image "OFF_T_FMT" (%d, %s) has "OFF_T_FMT" of %d measures (%s, %s) ",  i,  image[i].imageID, image[i].name, N_onImage[i], image[i].nstar,
    243                ohana_sec_to_date(image[i].tzero), name);
     265      if (showExample) {
     266        char *myDate = ohana_sec_to_date(image[i].tzero);
     267        fprintf (stderr, "image "OFF_T_FMT" (%d, %s) has "OFF_T_FMT" of %d measures (%s, %s) ",  i,  image[i].imageID, image[i].name, N_onImage[i], image[i].nstar, myDate, name);
     268        free (myDate);
     269      }
    244270      if (N_onImage[i] < 20) {
    245271        if (showExample) fprintf (stderr, "*");
     
    508534    m = ImageToMeasure[im][i];
    509535    c = ImageToCatalog[im][i];
     536    myAssert (c < Ncatalog, "oops");
    510537
    511538    Measure *measure = &catalog[c].measure[m];
     
    653680    m = ImageToMeasure[im][i];
    654681    c = ImageToCatalog[im][i];
     682    myAssert (c < Ncatalog, "oops");
    655683
    656684    MeasureTiny *measure = &catalog[c].measureT[m];
     
    753781    m = ImageToMeasure[im][i];
    754782    c = ImageToCatalog[im][i];
     783    myAssert (c < Ncatalog, "oops");
    755784
    756785    MeasureTiny *measure = &catalog[c].measureT[m];
     
    829858    m = ImageToMeasure[im][i];
    830859    c = ImageToCatalog[im][i];
     860    myAssert (c < Ncatalog, "oops");
    831861
    832862    // XXX should I use the raw coords or just measure.X,Y -> R,D?
     
    871901    m = ImageToMeasure[im][i];
    872902    c = ImageToCatalog[im][i];
     903    myAssert (c < Ncatalog, "oops");
    873904
    874905    MeasureTiny *measure = &catalog[c].measureT[m];
     
    900931}
    901932
     933# if (0)
    902934/** lifted from relphot/StarOps.clean_measures */
    903935void FlagOutliers2D(Catalog *catalog);
     
    12671299  return TRUE;
    12681300}
     1301# endif
  • trunk/Ohana/src/relastro/src/ImageTable.c

    r38441 r39457  
    3333  }
    3434
     35  // gfits_db_free (&db);
     36  gfits_free_header (&db.header);
     37  gfits_free_matrix (&db.matrix);
     38  gfits_free_header (&db.theader);
     39  free (db.filename);
     40
    3541  *nimage = Nimage;
    3642  return image;
     
    6167  dvo_image_unlock (&db);
    6268
     69  gfits_db_free (&db);
     70
    6371  return TRUE;
    6472}
  • trunk/Ohana/src/relastro/src/MosaicOps.c

    r37038 r39457  
    33// array of mosaic definition structures
    44static off_t   Nmosaic;
    5 static Mosaic *mosaic;
     5static Mosaic *mosaic = NULL;
    66
    77// list of all images associated with a mosaic
     
    185185}
    186186
     187void freeMosaics () {
     188
     189  off_t i;
     190
     191  if (!mosaic) return;
     192
     193  for (i = 0; i < Nmosaic; i++) {
     194    FREE (mosaic_own_images[i]);
     195  }
     196
     197  FREE (mosaic);
     198  FREE (Nmosaic_own_images);
     199  FREE (Amosaic_own_images);
     200  FREE (mosaic_own_images);
     201  FREE (mosaic_for_images);
     202}
     203
    187204// return StarData values for detections in the specified image, converting coordinates from the
    188205// chip positions: X,Y -> L,M -> P,Q -> R,D
     
    274291// extend each host image table to include the mosaic 'images' needed by the host
    275292int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage) {
     293  OHANA_UNUSED_PARAM(Nimage);
    276294
    277295  int i;
     
    324342    }
    325343   
     344    free (addMosaic);
     345
    326346    host->Nimage += Nadd;
    327347  }
     348  free (mosaicUsed);
     349
    328350  return TRUE;
    329351}
  • trunk/Ohana/src/relastro/src/SetSignals.c

    r39402 r39457  
    5454
    5555void my_memdump (char *message) {
     56
     57  return;
    5658
    5759  fprintf (stderr, "%s\n", message);
  • trunk/Ohana/src/relastro/src/StarMaps.c

    r38986 r39457  
    2525} StarMap;
    2626
    27 static StarMap     *starmap;       
     27static StarMap *starmap = NULL;
    2828// static int         Nstarmap;  -- is it always == Nimages?
    2929
     
    5555}
    5656
     57void freeStarMaps () {
     58
     59  off_t i, Nimages;
     60
     61  getimages(&Nimages, NULL);
     62
     63  for (i = 0; i < Nimages; i++) {
     64    FREE (starmap[i].points);
     65    FREE (starmap[i].stars);
     66  }
     67
     68  FREE (starmap);
     69  return;
     70}
     71
    5772int updateStarMaps(Catalog *catalog) {
    5873
  • trunk/Ohana/src/relastro/src/UpdateChips.c

    r38986 r39457  
    152152      }
    153153    }
     154
     155    AstromOffsetMapFree (oldCoords.offsetMap);
    154156
    155157    // Apply the modified coords back to the measure.R,D.  Note that raw.R,D, ref.L,M, etc
     
    356358    }
    357359
     360    AstromOffsetMapFree (oldCoords.offsetMap);
     361
    358362    // apply the modified R,D back to the measures
    359363    setImageRaw (threadinfo->catalog, threadinfo->Ncatalog, i, raw, Nraw, MODE_MOSAIC);
     
    569573    AstromOffsetMapSetOrder (truMap, tmpMap->Nx, tmpMap->Ny, image);
    570574    AstromOffsetMapCopyData (truMap, tmpMap);
     575    AstromOffsetMapFree (tmpMap);
    571576    return;
    572577  }
     
    579584    unlockUpdateChips ();
    580585    AstromOffsetMapCopyData (image->coords.offsetMap, tmpMap);
     586    AstromOffsetMapFree (tmpMap);
    581587    return;
    582588  }
  • trunk/Ohana/src/relastro/src/UpdateMeasures.c

    r39385 r39457  
    7171
    7272      double dR = 3600.0*fabs(csdec*(oldR - R));
    73       double dD = 3600.0*fabs(oldD - R);
     73      double dD = 3600.0*fabs(oldD - D);
    7474
    7575      // complain if the new location is far from the old location
  • trunk/Ohana/src/relastro/src/UpdateObjectOffsets.c

    r39171 r39457  
    6262    // uses MeasureTiny values, but will also update Measure values when populated
    6363    // if Galaxy Motion Model correction is active, do not apply at this last stage
    64     UpdateObjects (&catalog, 1, FALSE);
     64    UpdateObjects (&catalog, 1, -1);
    6565
    6666    free_tiny_values(&catalog);
     
    218218    fprintf (stderr, "command: %s\n", command);
    219219
    220     if (PARALLEL_MANUAL) continue;
     220    if (PARALLEL_MANUAL) {
     221      free (command);
     222      continue;
     223    }
    221224
    222225    if (PARALLEL_SERIAL) {
     
    236239      group->hosts[i][0].pid = pid; // save for future reference
    237240    }
     241    free (command);
    238242  }
    239243
     
    338342    fprintf (stderr, "command: %s\n", command);
    339343
    340     if (PARALLEL_MANUAL) continue;
     344    if (PARALLEL_MANUAL) {
     345      free (command);
     346      continue;
     347    }
    341348
    342349    if (PARALLEL_SERIAL) {
     
    356363      table->hosts[i].pid = pid; // save for future reference
    357364    }
     365    free (command);
    358366  }
    359367
     
    366374  }
    367375
     376  FreeHostTable (table);
     377
    368378  return TRUE;
    369379}     
  • trunk/Ohana/src/relastro/src/UpdateObjects.c

    r39390 r39457  
    121121// be called with just MeasureTiny set and Measure == NULL
    122122int UpdateObjects_Chips (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats, int cat, off_t measOff) {
     123  OHANA_UNUSED_PARAM(Nsecfilt);
    123124
    124125  int k;
     
    257258    }
    258259
     260    // if we have fitted (and accepted) a parallax model, get the best pm fit and chisq
     261    // given the set of points (mask is respected)
    259262    if (average[0].flags & ID_OBJ_USE_PAR) {
    260       // get the best pm fit and chisq given the set of points (mask is respected)
    261263      if (!FitPM_Basic (&fitPM, fitStats->fitdataPM, fitStats->points, fitStats->Npoints)) {
    262264        average[0].flags |= ID_OBJ_BAD_PM;
     
    551553// be called with just MeasureTiny set and Measure == NULL
    552554int UpdateObjects_Stack (Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int Nsecfilt, FitStats *fitStats) {
     555  OHANA_UNUSED_PARAM(Nsecfilt);
    553556
    554557  int status;
     
    650653
    651654int UpdateObjects_SelectMeasures (FitStats *fit, Average *average, SecFilt *secfilt, MeasureTiny *measure, Measure *measureBig, int isStack, int *stackEntry) {
     655  OHANA_UNUSED_PARAM(secfilt);
    652656
    653657  // I've already allocated fit->points (and fit->sample) with space for fit->NpointsAlloc entries
  • trunk/Ohana/src/relastro/src/args.c

    r39396 r39457  
    5151    remove_argument (N, &argc, argv);
    5252    RELASTRO_OP = OP_UPDATE_OFFSETS;
     53  }
     54
     55  // elements needed for parallel regions / parallel images
     56  MANUAL_UNIQUER = NULL;
     57  if ((N = get_argument (argc, argv, "-manual-uniquer"))) {
     58    remove_argument (N, &argc, argv);
     59    MANUAL_UNIQUER = strcreate (argv[N]);
     60    remove_argument (N, &argc, argv);
    5361  }
    5462
     
    372380      snprintf (PHOTCODE_SKIP_LIST, Ntotal, "%s,%s", SuperCOSMOS_SKIP, RawSkip);
    373381      free (RawSkip);
    374       free (SuperCOSMOS_SKIP);
    375382    } else {
    376383      PHOTCODE_SKIP_LIST = RawSkip;
     
    378385    remove_argument (N, &argc, argv);
    379386  }
     387  free (SuperCOSMOS_SKIP);
    380388
    381389  VERBOSE = VERBOSE2 = FALSE;
     
    562570  if (argc != 1) usage ();
    563571  return TRUE;
     572}
     573
     574void relastro_free (SkyTable *sky, SkyList *skylist) {
     575  FREE (REGION_FILE);
     576  FREE (IMAGE_TABLE);
     577  FREE (LoopWeight2MASSstr);
     578  FREE (LoopWeightTychostr);
     579
     580  FREE (PHOTCODE_SKIP_LIST);
     581  FREE (PHOTCODE_KEEP_LIST);
     582  FREE (PHOTCODE_RESET_LIST);
     583  FREE (DCR_RED_COLOR_POS);
     584  FREE (DCR_RED_COLOR_NEG);
     585  FREE (DCR_BLUE_COLOR_POS);
     586  FREE (DCR_BLUE_COLOR_NEG);
     587
     588  FREE (PHOTCODE_A_LIST);
     589  FREE (PHOTCODE_B_LIST);
     590  FREE (HIGH_SPEED_DIR);
     591  FREE (BCATALOG);
     592  FREE (HOSTDIR);
     593
     594  // these are set in initialize
     595  FREE(photcodesKeep);
     596  FREE(photcodesSkip); 
     597  FREE(photcodesReset);
     598  FREE(photcodesGroupA);
     599  FREE(photcodesGroupB);
     600 
     601  SkyTableFree (sky);
     602  SkyListFree(skylist);
     603  FreePhotcodeTable();
     604 
     605  ohana_memcheck (VERBOSE);
     606  ohana_memdump (VERBOSE);
    564607}
    565608
     
    922965}
    923966
    924 void relastro_client_free () {
     967void relastro_client_free (SkyTable *sky, SkyList *skylist) {
    925968  FREE (PHOTCODE_SKIP_LIST);
    926969  FREE (PHOTCODE_KEEP_LIST);
     
    936979  FREE(BCATALOG);
    937980  FREE (HOSTDIR);
     981
     982  // these are set in initialize
     983  FREE(photcodesKeep);
     984  FREE(photcodesSkip); 
     985  FREE(photcodesReset);
     986  FREE(photcodesGroupA);
     987  FREE(photcodesGroupB);
     988 
     989  SkyTableFree (sky);
     990  SkyListFree(skylist);
     991  FreePhotcodeTable();
     992 
     993  ohana_memcheck (VERBOSE);
     994  ohana_memdump (VERBOSE);
    938995}
    939996
  • trunk/Ohana/src/relastro/src/assign_images.c

    r38986 r39457  
    156156
    157157    // this is a bit memory expensive : I am making a complete copy of the image table here
     158    // XXX is adding an image, can we just add a pointer?
    158159    off_t Nsubset = host->Nimage;
    159160    host->image[Nsubset] = image[j];
     
    168169
    169170    // save the astrometry maps, where they exist
     171    // here we are adding an AstromOffsetTable, but the data are only pointers
     172    // we should NOT free this table with AstromOffsetTableFree()
    170173    if (image[j].coords.offsetMap) {
    171174      if (!host->astromTable) {
  • trunk/Ohana/src/relastro/src/bcatalog.c

    r39375 r39457  
    184184      offset = catalog[0].average[i].measureOffset + j;
    185185     
     186      // we do not measure astrometry for the warps, so skip:
     187      if (isGPC1warp(catalog[0].measure[offset].photcode)) continue;
     188
    186189      // filter objects based on user supplied criteria, including SIGMA_LIM
    187190      if (!MeasFilterTest(&catalog[0].measure[offset], TRUE)) {
  • trunk/Ohana/src/relastro/src/dvo_astrom_ops.c

    r37038 r39457  
    22/* the Measure carries the instantaneous mean position at the epoch t */
    33
     4// average & secfilt no longer used since R and D are now in measure
     5
    46double getMeanR (MeasureTiny *measure, Average *average, SecFilt *secfilt) {
     7  OHANA_UNUSED_PARAM(average);
     8  OHANA_UNUSED_PARAM(secfilt);
    59
    610  double ra;
     
    1418
    1519double getMeanD (MeasureTiny *measure, Average *average, SecFilt *secfilt) {
     20  OHANA_UNUSED_PARAM(average);
     21  OHANA_UNUSED_PARAM(secfilt);
    1622
    1723  double dec;
     
    2531
    2632int setMeanR (double ra_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt) {
     33  OHANA_UNUSED_PARAM(average);
     34  OHANA_UNUSED_PARAM(secfilt);
    2735
    2836  // old: measure[0].dR += (ra_fit - average[0].R) * 3600.0;
     
    3442
    3543int setMeanD (double dec_fit, MeasureTiny *measure, Average *average, SecFilt *secfilt) {
     44  OHANA_UNUSED_PARAM(average);
     45  OHANA_UNUSED_PARAM(secfilt);
    3646
    3747  // old: measure[0].dD += (dec_fit - average[0].D) * 3600.0;
     
    4353
    4454double getMeanR_Big (Measure *measure, Average *average, SecFilt *secfilt) {
     55  OHANA_UNUSED_PARAM(average);
     56  OHANA_UNUSED_PARAM(secfilt);
    4557
    4658  double ra;
     
    5466
    5567double getMeanD_Big (Measure *measure, Average *average, SecFilt *secfilt) {
     68  OHANA_UNUSED_PARAM(average);
     69  OHANA_UNUSED_PARAM(secfilt);
    5670
    5771  double dec;
     
    6579
    6680int setMeanR_Big (double ra_fit, Measure *measure, Average *average, SecFilt *secfilt) {
     81  OHANA_UNUSED_PARAM(average);
     82  OHANA_UNUSED_PARAM(secfilt);
    6783
    6884  // old: measure[0].dR += (ra_fit - average[0].R) * 3600.0;
     
    7490
    7591int setMeanD_Big (double dec_fit, Measure *measure, Average *average, SecFilt *secfilt) {
     92  OHANA_UNUSED_PARAM(average);
     93  OHANA_UNUSED_PARAM(secfilt);
    7694
    7795  // measure[0].dD += (dec_fit - average[0].D) * 3600.0;
  • trunk/Ohana/src/relastro/src/fitobj.c

    r39370 r39457  
    156156
    157157Catalog *mkstar (FitStats *fitStats, double Ro, double Do, double uR, double uD, double plx, int Npoints, int Nbad) {
     158  OHANA_UNUSED_PARAM(fitStats);
    158159 
    159160  int i;
     
    239240  return catalog;
    240241}
     242
     243// these dummy functions are used to avoid including ImageOps, etc
     244int areImagesMatched () {
     245  return FALSE;
     246}
     247float getColorBlue (off_t meas, int cat) {
     248  OHANA_UNUSED_PARAM(meas);
     249  OHANA_UNUSED_PARAM(cat);
     250  return (NAN);
     251}
     252float getColorRed (off_t meas, int cat) {
     253  OHANA_UNUSED_PARAM(meas);
     254  OHANA_UNUSED_PARAM(cat);
     255  return (NAN);
     256}
  • trunk/Ohana/src/relastro/src/fitobj2.c

    r39375 r39457  
    173173
    174174Catalog *mkstar (FitStats *fitStats, double Ro, double Do, double uR, double uD, double plx, int Npoints, int Nbad) {
     175  OHANA_UNUSED_PARAM(fitStats);
    175176 
    176177  int i;
     
    264265  return catalog;
    265266}
     267
     268// these dummy functions are used to avoid including ImageOps, etc
     269int areImagesMatched () {
     270  return FALSE;
     271}
     272float getColorBlue (off_t meas, int cat) {
     273  OHANA_UNUSED_PARAM(meas);
     274  OHANA_UNUSED_PARAM(cat);
     275  return (NAN);
     276}
     277float getColorRed (off_t meas, int cat) {
     278  OHANA_UNUSED_PARAM(meas);
     279  OHANA_UNUSED_PARAM(cat);
     280  return (NAN);
     281}
  • trunk/Ohana/src/relastro/src/fitstk.c

    r39387 r39457  
    279279  return catalog;
    280280}
     281
     282// these dummy functions are used to avoid including ImageOps, etc
     283int areImagesMatched () {
     284  return FALSE;
     285}
     286float getColorBlue (off_t meas, int cat) {
     287  OHANA_UNUSED_PARAM(meas);
     288  OHANA_UNUSED_PARAM(cat);
     289  return (NAN);
     290}
     291float getColorRed (off_t meas, int cat) {
     292  OHANA_UNUSED_PARAM(meas);
     293  OHANA_UNUSED_PARAM(cat);
     294  return (NAN);
     295}
  • trunk/Ohana/src/relastro/src/high_speed_utils.c

    r38601 r39457  
    88#define DEFAULT_WHERE_B  "((flags & 0x01000000) == 0) && ((flags & 0x04000000) && ((y:nphot > 1) || (z:nphot > 1)) &&((y:err < 0.2) || (z:err < 0.2)))"
    99
    10 
    11 extern char **isolate_elements(int, char **, int *);
    1210
    1311int print_error();
     
    7674    // parse it into elements of the where condition
    7775    char **cstack = NULL;
    78     int Ncstack;
     76    unsigned int Ncstack;
    7977    cstack = isolate_elements(nWords, words, &Ncstack);
    8078    free(words);
  • trunk/Ohana/src/relastro/src/indexCatalogs.c

    r36630 r39457  
    11# include "relastro.h"
    22
    3 static int   catIDmax = 0;
    4 static int  *catIDseq = NULL;
    5 static int  *objIDmax = NULL;
    6 static int **objIDseq = NULL;
     3static unsigned int   catIDmax = 0;
     4static          int  *catIDseq = NULL;
     5static unsigned int  *objIDmax = NULL;
     6static          int **objIDseq = NULL;
    77
    88int indexCatalogs (Catalog *catalog, int Ncatalog) {
     
    1919
    2020  ALLOCATE (catIDseq, int, catIDmax + 1);
    21   for (i = 0; i < catIDmax + 1; i++) {
    22     catIDseq[i] = -1;
     21
     22  unsigned int ID;
     23  for (ID = 0; ID < catIDmax + 1; ID++) {
     24    catIDseq[ID] = -1;
    2325  }
    2426
    2527  for (i = 0; i < Ncatalog; i++) {
    26     int catID = catalog[i].catID;
     28    unsigned int catID = catalog[i].catID;
    2729    catIDseq[catID] = i;
    2830  }
    2931 
    30   ALLOCATE (objIDmax, int,   Ncatalog);
    31   ALLOCATE (objIDseq, int *, Ncatalog);
     32  ALLOCATE (objIDmax, unsigned int,   Ncatalog);
     33  ALLOCATE (objIDseq,          int *, Ncatalog);
    3234  for (i = 0; i < Ncatalog; i++) {
    3335    objIDmax[i] = 0;
     
    3739
    3840    ALLOCATE (objIDseq[i], int, objIDmax[i] + 1);
    39     for (j = 0; j < objIDmax[i] + 1; j++) {
    40       objIDseq[i][j] = -1;
     41    for (ID = 0; ID < objIDmax[i] + 1; ID++) {
     42      objIDseq[i][ID] = -1;
    4143    }
    4244
    4345    for (j = 0; j < catalog[i].Naverage; j++) {
    44       int objID = catalog[i].average[j].objID;
     46      unsigned int objID = catalog[i].average[j].objID;
    4547      objIDseq[i][objID] = j;
    4648    }
     
    4951}
    5052
    51 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq) {
     53void freeCatalogIndexes (int Ncatalog) {
     54  int i;
     55
     56  for (i = 0; i < Ncatalog; i++) {
     57    free (objIDseq[i]);
     58  }
     59  free (objIDmax);
     60  free (objIDseq);
     61  free (catIDseq);
     62}
     63
     64int catID_and_objID_to_seq (unsigned int catID, unsigned int objID, int *catSeq, off_t *objSeq) {
    5265
    5366  if (catID > catIDmax) return FALSE;
  • trunk/Ohana/src/relastro/src/initialize.c

    r37807 r39457  
    22
    33void initialize (int argc, char **argv) {
     4
     5  photcodesKeep   = NULL;
     6  photcodesSkip   = NULL;
     7  photcodesReset  = NULL;
     8  photcodesGroupA = NULL;
     9  photcodesGroupB = NULL;
    410
    511  ConfigInit (&argc, argv);
  • trunk/Ohana/src/relastro/src/launch_region_hosts.c

    r39389 r39457  
    161161    fprintf (stderr, "command: %s\n", command);
    162162   
    163     if (PARALLEL_REGIONS_MANUAL) continue;
     163    if (PARALLEL_REGIONS_MANUAL) {
     164      free (command);
     165      continue;
     166    }
    164167
    165168    // launch the job, then wait for it to be done loading catalogs.  force the remote
     
    180183    check_sync_file (syncfile, 1);
    181184    free (syncfile);
     185
     186    free (command);
    182187  }
    183188
  • trunk/Ohana/src/relastro/src/load_catalogs.c

    r39396 r39457  
    142142  int TIME = time(NULL);
    143143  int PID = getpid();
    144   snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     144
     145  if (PARALLEL_MANUAL && MANUAL_UNIQUER) {
     146    snprintf (uniquer, 12, "%11s", MANUAL_UNIQUER);
     147  } else {
     148    snprintf (uniquer, 12, "%05d.%05d", PID, TIME % 100000);
     149  }
    145150
    146151  // load the list of hosts
     
    224229    fprintf (stderr, "command: %s\n", command);
    225230
    226     if (PARALLEL_MANUAL) continue;
     231    if (PARALLEL_MANUAL) {
     232      free (command);
     233      continue;
     234    }
    227235
    228236    if (PARALLEL_SERIAL) {
     
    242250      table->hosts[i].pid = pid; // save for future reference
    243251    }
     252    free (command);
    244253  }
    245254
     
    289298  }
    290299
     300  FreeHostTable (table);
     301
    291302  Catalog *catalog = catalogs->catalog;
    292303  *Ncatalog = catalogs->Ncatalog;
     304
     305  // need to free the place-holder catalogs:
     306  for (i = catalogs->Ncatalog; i < catalogs->NCATALOG; i++) {
     307    free (catalogs->catalog[i].average);
     308    free (catalogs->catalog[i].measureT);
     309    free (catalogs->catalog[i].secfilt);
     310  }
    293311
    294312  int Nmeasure = 0;
  • trunk/Ohana/src/relastro/src/load_images.c

    r38986 r39457  
    2727  MARKTIME("build chip match: %f sec\n", dtime);
    2828
    29   char mapfile[DVO_MAX_PATH];
    30   snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR);
    31   table = AstromOffsetMapLoad (mapfile, 100000, VERBOSE);
    32 
    33   // assign images.coords.offsetMap -> table->map[i]
    34   if (table) {
    35     AstromOffsetTableMatchChips (image, Nimage, table);
    36   } else {
    37     table = AstromOffsetTableInit ();
    38   }
    39 
    4029  // select the images which overlap the selected sky regions
    4130  if (UseAllImages) {
     
    5443  }
    5544   
     45  /* unlock, if we can (else, unlocked below) and free, if we can */
     46  int unlockImages = !UPDATE || (RELASTRO_OP == OP_UPDATE_OFFSETS);
     47  if (unlockImages) {
     48    if (subset != image) {
     49      // if we have generated an image subset and we are running UPDATE_OFFSETS, the we can free images here
     50      free (image);
     51      db[0].ftable.buffer = NULL;
     52      BuildChipMatch (subset, Nsubset);
     53    }
     54    dvo_image_unlock (db);
     55  }
     56
     57  char mapfile[DVO_MAX_PATH];
     58  snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR);
     59  table = AstromOffsetMapLoad (mapfile, 100000, VERBOSE);
     60
     61  // assign images.coords.offsetMap -> table->map[i]
     62  if (table) {
     63    AstromOffsetTableMatchChips (subset, Nsubset, table);
     64  } else {
     65    table = AstromOffsetTableInit ();
     66  }
     67
    5668  initImages (subset, LineNumber, Nsubset);
    5769  MARKTIME("  init images: %f sec\n", dtime);
     
    6072  MARKTIME("  init mosaics: %f sec\n", dtime);
    6173 
    62   /* unlock, if we can (else, unlocked below) */
    63   int unlockImages = !UPDATE || (RELASTRO_OP == OP_UPDATE_OFFSETS);
    64   if (unlockImages) dvo_image_unlock (db);
    65 
    6674  return TRUE;
    6775}
     
    102110}
    103111
     112void free_astrom_table () {
     113  if (!table) return;
     114  AstromOffsetTableFree (table);
     115  free (table);
     116}
  • trunk/Ohana/src/relastro/src/plot_scatter.c

    r17203 r39457  
    22   
    33void plot_scatter (Catalog *catalog, int Ncatalog) {
     4  OHANA_UNUSED_PARAM(catalog);
     5  OHANA_UNUSED_PARAM(Ncatalog);
    46
    57# if (0)   
  • trunk/Ohana/src/relastro/src/plotstuff.c

    r39396 r39457  
    4444
    4545void JpegPlot (Graphdata *graphmode, int N, char *filename) {
     46  OHANA_UNUSED_PARAM(graphmode);
    4647
    4748  if (Xgraph[N] == 0) return;
     
    5253
    5354void PSPlot (Graphdata *graphmode, int N, char *filename) {
     55  OHANA_UNUSED_PARAM(graphmode);
    5456
    5557  if (Xgraph[N] == 0) return;
     
    7981
    8082void PlotVector (int Npts, double *vect, int mode, int N, char *type) {
     83  OHANA_UNUSED_PARAM(mode);
    8184
    8285  float *values;
  • trunk/Ohana/src/relastro/src/relastro.c

    r39382 r39457  
    77  initialize (argc, argv);
    88
    9   SkyTable *sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
    10   SkyTableSetFilenames (sky, CATDIR, "cpt");
    11   SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
     9  SkyTable *sky = NULL;
     10  SkyList *skylist = NULL;
     11
     12  if ((RELASTRO_OP != OP_PARALLEL_IMAGES) && (RELASTRO_OP != OP_PARALLEL_REGIONS)) {
     13    sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
     14    SkyTableSetFilenames (sky, CATDIR, "cpt");
     15    skylist = SkyListByPatch (sky, -1, &UserPatch);
     16  }
    1217
    1318  switch (RELASTRO_OP) {
     
    1520      /* the object analysis is a separate process iterating over catalogs */
    1621      relastro_objects (skylist, 0, NULL);
    17       exit (0);
    18 
    19     case OP_HIGH_SPEED:
    20       /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */
    21       high_speed_catalogs (sky, skylist, 0, NULL);
    22       exit (0);
    23 
    24     case OP_HPM:
    25       hpm_catalogs (sky, skylist, 0, NULL);
    26       exit (0);
    27 
    28     case OP_MERGE_SOURCE:
    29       /* a special method to manually merge unlinked detections of sources togther (not parallel) */
    30       relastro_merge_source (sky);
     22      relastro_free (sky, skylist);
    3123      exit (0);
    3224
    3325    case OP_IMAGES:
    3426      relastro_images (skylist);
     27      relastro_free (sky, skylist);
    3528      exit (0);
    3629
    37     case OP_UPDATE_OFFSETS:
     30    case OP_UPDATE_OFFSETS: {
     31      FITS_DB db;
    3832      if (!PARALLEL) {
    39         FITS_DB db;
    4033     
    4134        set_db (&db);
     
    5548      // iterate over catalogs to make detection coordinates consistant
    5649      UpdateObjectOffsets (skylist, 0, NULL);
     50
     51      if (!PARALLEL) {
     52        gfits_db_free (&db);
     53        freeImages();
     54        freeMosaics ();
     55      }
     56
     57      relastro_free (sky, skylist);
    5758      exit (0);
     59    }
    5860
    5961    case OP_PARALLEL_REGIONS:
     
    6769      exit (0);
    6870
     71    case OP_HIGH_SPEED:
     72      /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */
     73      high_speed_catalogs (sky, skylist, 0, NULL);
     74      exit (0);
     75
     76    case OP_HPM:
     77      hpm_catalogs (sky, skylist, 0, NULL);
     78      exit (0);
     79
     80    case OP_MERGE_SOURCE:
     81      /* a special method to manually merge unlinked detections of sources togther (not parallel) */
     82      relastro_merge_source (sky);
     83      exit (0);
     84
    6985    default:
    7086      fprintf (stderr, "impossible!\n");
  • trunk/Ohana/src/relastro/src/relastro_client.c

    r39396 r39457  
    5555      }
    5656
    57       SkyTableFree (sky);
    58       SkyListFree(skylist);
    59       FreePhotcodeTable();
    60 
    6157      int i;
    6258      for (i = 0; i < Ncatalog; i++) {
     
    6662      BrightCatalogFree(bcatalog);
    6763
    68       relastro_client_free ();
    69       FREE(photcodesKeep);
    70       FREE(photcodesSkip); 
    71       FREE(photcodesReset);
    72       FREE(photcodesGroupA);
    73       FREE(photcodesGroupB);
    74 
    75       ohana_memcheck (TRUE);
    76       ohana_memdump (TRUE);
     64      relastro_client_free (sky, skylist);
    7765      break;
    7866    }
     
    8169      // USAGE: relastro_client -update-objects
    8270      relastro_objects (skylist, HOST_ID, HOSTDIR);
    83       break;
    84     }
    85 
    86     case OP_HIGH_SPEED: {
    87       // USAGE: relastro_client -high-speed
    88       high_speed_catalogs (sky, skylist, HOST_ID, HOSTDIR);
    89       break;
    90     }
    91 
    92     case OP_HPM: {
    93       // USAGE: relastro_client -high-speed
    94       hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR);
     71      relastro_client_free (sky, skylist);
    9572      break;
    9673    }
     
    11289      /* load regions and images based on specified sky patch (default depth) */
    11390      load_images (&db, skylist, FALSE, USE_ALL_IMAGES);
    114      
    115       // I can free the database after I have loaded the images...
    116 
    117       // // load the image subset table from the specified location
    118       // off_t Nimage;
    119       // ImageSubset *image = ImageSubsetLoad (IMAGES, &Nimage);
    120       // if (!image) {
    121       //          fprintf (stderr, "ERROR loading image subset %s\n", CATDIR);
    122       //          exit (2);
    123       // }
    124       //
    125       // // save the available image information in the static array in ImageOps.c
    126       // initImagesSubset (image, NULL, Nimage);
    127       //
    128       // // load the flat-field correction table from CATDIR
    129       // char flatcorrFile[1024];
    130       // snprintf (flatcorrFile, 1024, "%s/flatcorr.fits", CATDIR);
    131       // FlatCorrectionTable *flatcorr = FlatCorrectionLoad (flatcorrFile, VERBOSE);
    13291
    13392      UpdateObjectOffsets (skylist, HOST_ID, HOSTDIR);
    13493     
     94      gfits_db_free (&db);
     95      freeImages();
     96      freeMosaics ();
     97
     98      relastro_client_free (sky, skylist);
     99      break;
     100    }
     101
     102    case OP_HIGH_SPEED: {
     103      // USAGE: relastro_client -high-speed
     104      high_speed_catalogs (sky, skylist, HOST_ID, HOSTDIR);
     105      break;
     106    }
     107
     108    case OP_HPM: {
     109      // USAGE: relastro_client -high-speed
     110      hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR);
    135111      break;
    136112    }
  • trunk/Ohana/src/relastro/src/relastro_images.c

    r38986 r39457  
    1212  set_db (&db);
    1313  gfits_db_init (&db);
     14
     15  // final pass fit mode (use FIT_AVERAGE only for the image loop)
     16  int finalPassMode = FIT_MODE; // start with the globally-defined fit mode
     17  FIT_MODE = FIT_AVERAGE;
    1418
    1519  /* lock and load the image db table */
     
    7781        MARKTIME("update chips: %f sec\n", dtime);
    7882      }
     83
     84      // measure scatter for stacks
     85      UpdateStacks (catalog, Ncatalog);
     86      MARKTIME("UpdateStacks: %f sec\n", dtime);
     87
    7988      // create summary plots of the process
    8089      // relastroVisualSummaryChips();
     
    93102  }
    94103
    95   if (!UPDATE) exit (0);
     104  if (!UPDATE) {
     105    freeStarMaps();
     106    gfits_db_free (&db);
     107    ohana_memcheck (VERBOSE);
     108    ohana_memdump (VERBOSE);
     109    exit (0);
     110  }
    96111
    97112  // free the image / measurement pointers
    98   freeImageBins (1);
     113  freeImageBins (Ncatalog);
     114  for (i = 0; i < Ncatalog; i++) {
     115    dvo_catalog_free (&catalog[i]);
     116  }
     117  free (catalog);
     118  freeMosaics ();
    99119
    100120  // If we did NOT use all images, then we applied the measured corrections to a subset of
     
    105125    reload_images (&db);
    106126  }
     127  freeStarMaps();
    107128   
    108129  if (PARALLEL) {
     
    116137    }
    117138    dvo_image_unlock (&db);
     139    gfits_db_free (&db);
     140    freeImages();
    118141  }
    119142
     
    123146
    124147  // if we do NOT have parallel partitions, we must NOT write them out yet: the act of
    125   // writing out the files byte-swaps the data and makes the values invalide for the
     148  // writing out the files byte-swaps the data and makes the values invalid for the
    126149  // following calls to UpdateObjectOffsets (which attempt to apply the image values from
    127150  // the structure in memory)
     151
     152  FIT_MODE = finalPassMode; // use the user-selected mode for the final pass
    128153
    129154  // iterate over catalogs to make detection coordinates consistant
     
    141166    }
    142167    dvo_image_unlock (&db);
     168    gfits_db_free (&db);
     169    freeImages();
    143170  }
    144171
    145   exit (0);
     172  return TRUE;
    146173}
  • trunk/Ohana/src/relastro/src/relastro_merge_source.c

    r38986 r39457  
    2222  // load data from each region file, only use bright stars
    2323  for (i = 0; i < sky[0].Nregions; i++) {
    24     if (sky[0].regions[i].index == CAT_ID_SRC) {
     24    myAssert (sky[0].regions[i].index >= 0, "oops");
     25    if ((unsigned int) sky[0].regions[i].index == CAT_ID_SRC) {
    2526      catalog_src.filename = sky[0].filename[i];
    2627      region_src = &sky[0].regions[i];
    2728    }
    2829    // currently, we only accept dst == src...
    29     if (sky[0].regions[i].index == CAT_ID_DST) {
     30    if ((unsigned int) sky[0].regions[i].index == CAT_ID_DST) {
    3031      catalog_dst.filename = sky[0].filename[i];
    3132      // region_dst = &sky[0].regions[i];
  • trunk/Ohana/src/relastro/src/relastro_objects.c

    r39375 r39457  
    8484    populate_tiny_values(&catalog, DVO_TV_MEASURE);
    8585
    86     UpdateObjects (&catalog, 1, 0);
     86    // the 3rd argument (-1) is the loop number for re-weighting 2MASS and Tycho. -1 is a special value meaning "ignore"
     87    // we do NOT want to apply special weights to 2MASS and/or Tycho when calculating object final motions.
     88    UpdateObjects (&catalog, 1, -1);
    8789
    8890    free_tiny_values(&catalog);
     
    215217      table->hosts[i].pid = pid; // save for future reference
    216218    }
     219    free (command);
    217220  }
    218221
     
    224227    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
    225228  }
     229  FreeHostTable (table);
    226230
    227231  return TRUE;
  • trunk/Ohana/src/relastro/src/relastro_parallel_images.c

    r38986 r39457  
    1616
    1717  INITTIME;
     18
     19  // over-ride user selection here: this program does not set the final object
     20  // astrometry.  since it only sets the image parameters it should not use pm or par
     21  FIT_MODE = FIT_AVERAGE;
    1822
    1923  client_logger_init (CATDIR);
     
    141145        LOGRTIME("slurp_meas_pos loop %d on %s, host %d: %f sec\n", i, myHostName, REGION_HOST_ID, dtime);
    142146      }
     147
     148      // measure scatter for stacks
     149      UpdateStacks (catalog, Ncatalog);
     150      LOGRTIME("UpdateStacks on %s, host %d: %f sec\n", myHostName, REGION_HOST_ID, dtime);
     151
    143152      // create summary plots of the process
    144153      // relastroVisualSummaryChips();
     
    176185  LOGRTIME("share image pos loop %d on %s, host %d: %f sec\n", -1, myHostName, REGION_HOST_ID, dtime);
    177186
     187  // free the image / measurement pointers
     188  freeImageBins (Ncatalog);
     189  for (i = 0; i < Ncatalog; i++) {
     190    dvo_catalog_free (&catalog[i]);
     191  }
     192  free (catalog);
     193  freeCatalogIndexes(Ncatalog);
     194
     195  freeMosaics ();
     196
     197  freeStarMaps();
     198
     199  freeImages();
     200  free (image);
     201
     202  FreeRegionHostTable (regionHosts);
     203  relastro_free (sky, skylist);
     204
    178205  exit (0);
    179206}
  • trunk/Ohana/src/relastro/src/relastro_parallel_regions.c

    r38441 r39457  
    8383  }
    8484
     85// testjump:
     86
    8587  MARKTIME ("finished relastro -parallel-regions: %f sec total\n", dtime);
     88 
     89  gfits_db_free (&db);
     90  freeImages();
     91  freeMosaics ();
     92
     93  FreeRegionHostTable (regionHosts);
     94  relastro_free (sky, skylist);
    8695
    8796  exit (0);
  • trunk/Ohana/src/relastro/src/share_icrf_obj.c

    r37807 r39457  
    9999    int cat, ave, meas;
    100100    ICRFdata (i, &cat, &ave, &meas);
     101    myAssert (cat < Ncatalog, "oops");
    101102
    102103    Average *average = &catalog[cat].average[ave];
  • trunk/Ohana/src/relastro/src/share_images_pos.c

    r38986 r39457  
    141141
    142142    AstromOffsetTableFree(table);
     143    free (table);
    143144    LOGRTIME("image_maps_free host %d loop %d on %s, host %d: %f sec\n", i, nloop, myHostName, REGION_HOST_ID, dtime);
    144145  }
    145146
    146147  // apply the modified image parameters to my detections
     148  // This loop is skipped because the updated image parameters are applied to
     149  // all measurements in UpdateChips (and those modified measurements are saved
     150  // at the same time)
    147151  for (i = 0; FALSE && (Ncatalog > 0) && (i < Nimage_pos); i++) {
    148152    off_t seq = getImageByID (image_pos[i].imageID);
  • trunk/Ohana/src/relastro/src/share_mean_pos.c

    r38062 r39457  
    107107        continue;
    108108    }
    109 
     109    myAssert (catSeq < Ncatalog, "oops");
     110   
    110111    catalog[catSeq].average[objSeq].R = meanpos[i].R;
    111112    catalog[catSeq].average[objSeq].D = meanpos[i].D;
  • trunk/Ohana/src/relastro/src/share_meas_pos.c

    r38062 r39457  
    5858  off_t i, k;
    5959
    60   int Nmeaspos = 0;
    61   MeasPos *measpos = NULL;
    62   ALLOCATE (measpos, MeasPos, 1);
    63 
    6460  fprintf (stderr, "grabbing meas object pos from other hosts...\n");
    6561
     
    7874    LOGRTIME("meas_load_sync host %d loop %d on %s, host %d: %f sec\n", i, nloop, myHostName, REGION_HOST_ID, dtime);
    7975   
    80     off_t Nsubset = 0;
     76    off_t Nmeaspos = 0;
    8177    char *posfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "measpos.fits");
    82     MeasPos *measposSubset = MeasPosLoad (posfile, &Nsubset);
     78    MeasPos *measpos = MeasPosLoad (posfile, &Nmeaspos);
    8379    free (posfile);
    8480    LOGRTIME("MeasPosLoad host %d loop %d on %s, host %d: %f sec\n", i, nloop, myHostName, REGION_HOST_ID, dtime);
    8581
    86     // merge_meas_pos reallocs measpos and frees the input measposSubset
    87     measpos = merge_meas_pos (measpos, &Nmeaspos, measposSubset, Nsubset);
    88     LOGRTIME("merge_meas_pos host %d loop %d on %s, host %d: %f sec\n", i, nloop, myHostName, REGION_HOST_ID, dtime);
     82    // apply the loaded measurement positions:
     83    for (off_t j = 0; j < Nmeaspos; j++) {
     84      int objID = measpos[j].objID;
     85      int catID = measpos[j].catID;
     86
     87      // set the meas mag
     88      int catSeq;
     89      off_t objSeq;
     90      if (!catID_and_objID_to_seq (catID, objID, &catSeq, &objSeq)) {
     91        // XXX what should I do if this does not match?
     92        continue;
     93      }
     94      myAssert (catSeq < Ncatalog, "oops");
     95
     96      off_t m = catalog[catSeq].average[objSeq].measureOffset;
     97      for (k = 0; k < catalog[catSeq].average[objSeq].Nmeasure; k++, m++) {
     98        if (catalog[catSeq].measureT[m].imageID != measpos[j].imageID) continue;
     99        catalog[catSeq].measureT[m].R = measpos[j].R;
     100        catalog[catSeq].measureT[m].D = measpos[j].D;
     101        if (catalog[catSeq].measure) {
     102          catalog[catSeq].measure[m].R = measpos[j].R;
     103          catalog[catSeq].measure[m].D = measpos[j].D;
     104        }
     105      }
     106    }
     107    free (measpos);
     108    LOGRTIME("match_catID_and_objID/meas loop %d on %s, host %d: %f sec\n", nloop, myHostName, REGION_HOST_ID, dtime);
    89109  }
    90110  LOGRTIME("meas_load_done loop %d on %s, host %d: %f sec\n", nloop, myHostName, REGION_HOST_ID, dtime);
    91 
    92   for (i = 0; i < Nmeaspos; i++) {
    93     int objID = measpos[i].objID;
    94     int catID = measpos[i].catID;
    95 
    96     // set the meas mag
    97     int catSeq;
    98     off_t objSeq;
    99     if (!catID_and_objID_to_seq (catID, objID, &catSeq, &objSeq)) {
    100         // XXX what should I do if this does not match?
    101         continue;
    102     }
    103     off_t m = catalog[catSeq].average[objSeq].measureOffset;
    104     for (k = 0; k < catalog[catSeq].average[objSeq].Nmeasure; k++, m++) {
    105       if (catalog[catSeq].measureT[m].imageID != measpos[i].imageID) continue;
    106       catalog[catSeq].measureT[m].R = measpos[i].R;
    107       catalog[catSeq].measureT[m].D = measpos[i].D;
    108       if (catalog[catSeq].measure) {
    109         catalog[catSeq].measure[m].R = measpos[i].R;
    110         catalog[catSeq].measure[m].D = measpos[i].D;
    111       }
    112     }
    113   }
    114   free (measpos);
    115   LOGRTIME("match_catID_and_objID/meas loop %d on %s, host %d: %f sec\n", nloop, myHostName, REGION_HOST_ID, dtime);
    116111
    117112  fprintf (stderr, "DONE grabbing meas object pos from other hosts...\n");
Note: See TracChangeset for help on using the changeset viewer.