IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29001


Ignore:
Timestamp:
Aug 20, 2010, 12:05:07 PM (16 years ago)
Author:
eugene
Message:

optimizations for dvomerge and relastro; complete checks of db I/O success; fix overloaded image flags

Location:
trunk/Ohana
Files:
83 edited
4 copied

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

    • Property svn:mergeinfo deleted
  • trunk/Ohana/src/addstar/src/FilterStars.c

    r28965 r29001  
    11# include "addstar.h"
    2 #include "pslib/psMetadata.h"
    3 #include "psmodules/pmSourceMasks.h"
    42# define EXTERNAL_ID TRUE
    53
  • trunk/Ohana/src/addstar/src/LoadData.c

    r28966 r29001  
    8080         
    8181    inStars = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &images[0][Nvalid].nstar);
     82    if (!inStars) {
     83      // XXX need to free the data here or in ReadStarsFITS on error
     84      continue;
     85    }
    8286    inStars = FilterStars (inStars, &images[0][Nvalid], Nvalid, options);
    8387    *stars = MergeStars (*stars, Nstars, inStars, images[0][Nvalid].nstar);
  • trunk/Ohana/src/addstar/src/ReadStarsFITS.c

    r27435 r29001  
    4949  if (stars == NULL) {
    5050    fprintf (stderr, "ERROR: invalid table type %s\n", type);
    51     exit (1);
     51    return (NULL);
    5252  }
    5353  // Nstars is not necessarily == *nstars (The former is the number of detections, the
     
    6969  swapped = FALSE;
    7070  smpdata = gfits_table_get_SMPData (table, &Nstars, &swapped);
     71  if (!smpdata) {
     72    fprintf (stderr, "skipping inconsistent entry\n");
     73    return (NULL);
     74  }
    7175  ZeroPt = GetZeroPoint();
    7276
     
    108112
    109113  ps1data = gfits_table_get_PS1_DEV_0 (table, &Nstars, NULL);
     114  if (!ps1data) {
     115    fprintf (stderr, "skipping inconsistent entry\n");
     116    return (NULL);
     117  }
    110118  ZeroPt = GetZeroPoint();
    111119
     
    153161
    154162  ps1data = gfits_table_get_PS1_DEV_1 (table, &Nstars, NULL);
     163  if (!ps1data) {
     164    fprintf (stderr, "skipping inconsistent entry\n");
     165    return (NULL);
     166  }
    155167  ZeroPt = GetZeroPoint();
    156168
     
    212224
    213225  ps1data = gfits_table_get_CMF_PS1_V1 (table, &Nstars, NULL);
     226  if (!ps1data) {
     227    fprintf (stderr, "skipping inconsistent entry\n");
     228    return (NULL);
     229  }
    214230  ZeroPt = GetZeroPoint();
    215231
     
    284300
    285301  ps1data = gfits_table_get_CMF_PS1_V1_Alt (table, &Nstars, NULL);
     302  if (!ps1data) {
     303    fprintf (stderr, "skipping inconsistent entry\n");
     304    return (NULL);
     305  }
    286306  ZeroPt = GetZeroPoint();
    287307
     
    348368
    349369  ps1data = gfits_table_get_CMF_PS1_V2 (table, &Nstars, NULL);
     370  if (!ps1data) {
     371    fprintf (stderr, "skipping inconsistent entry\n");
     372    return (NULL);
     373  }
    350374  ZeroPt = GetZeroPoint();
    351375
  • trunk/Ohana/src/addstar/src/find_matches_refstars.c

    r28241 r29001  
    218218    }
    219219
    220     N = N1[i];
     220    N = i;
    221221    if (stars[N][0].found > -1) continue;
    222222    if (!IN_REGION (stars[N][0].average.R, stars[N][0].average.D)) continue;
     
    286286
    287287    for (j = 0; j < NREFSTAR_GROUP; j++) {
    288       N = N1[i + j];
     288      N = i + j;
    289289
    290290      catalog[0].measure[Nmeas]          = stars[N][0].measure;
  • trunk/Ohana/src/addstar/test/dvomerge.dvo

    r28368 r29001  
    9595    subset T = t if (id == imageID[$i])
    9696    set dT = T - time[$i]
    97     vstat -q dT
     97    vstat dT
    9898    tapOK {abs($MEAN)  < 0.00001} "time for measure ID $i (MEAN)"
    9999    tapOK {abs($SIGMA) < 0.00001} "time for measure ID $i (SIGMA)"
  • trunk/Ohana/src/delstar/src/delete_imagename.c

    r28241 r29001  
    1919
    2020  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     21  if (!image) {
     22    fprintf (stderr, "ERROR: failed to read images\n");
     23    exit (2);
     24  }
    2125
    2226  /* find image in db by name */
  • trunk/Ohana/src/delstar/src/delete_times.c

    r27435 r29001  
    2626
    2727  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     28  if (!image) {
     29    fprintf (stderr, "ERROR: failed to read images\n");
     30    exit (2);
     31  }
    2832
    2933  /* find images for time range, delete each image */
  • trunk/Ohana/src/delstar/src/find_image_db.c

    r27435 r29001  
    1717
    1818  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     19  if (!image) {
     20    fprintf (stderr, "ERROR: failed to read images\n");
     21    exit (2);
     22  }
    1923
    2024  Nlist = 0;
  • trunk/Ohana/src/dvomerge/Makefile

    r27583 r29001  
    2020dvomerge     : $(BIN)/dvoconvert.$(ARCH)
    2121
    22 all: dvomerge dvoconvert
     22all: dvomerge dvoconvert dvosecfilt
    2323
    2424DVOMERGE = \
     
    5858$(BIN)/dvoconvert.$(ARCH) : $(DVOCONVERT)
    5959
    60 INSTALL = dvomerge dvoconvert
     60DVOSECFILT = \
     61$(SRC)/dvosecfilt.$(ARCH).o \
     62$(SRC)/SetSignals.$(ARCH).o \
     63$(SRC)/ConfigInit.$(ARCH).o \
     64$(SRC)/Shutdown.$(ARCH).o \
     65$(SRC)/help.$(ARCH).o \
     66$(SRC)/args.$(ARCH).o
     67
     68$(DVOSECFILT)  : $(INC)/dvomerge.h
     69
     70$(BIN)/dvosecfilt.$(ARCH) : $(DVOSECFILT)
     71
     72INSTALL = dvomerge dvoconvert dvosecfilt
    6173
    6274# dependancy rules for binary code #########################
  • trunk/Ohana/src/dvomerge/include/dvomerge.h

    r28855 r29001  
    5555int        dvoconvert_args        PROTO((int *argc, char **argv));
    5656
     57void       dvosecfilt_usage       PROTO((void));
     58void       dvosecfilt_help        PROTO((int argc, char **argv));
     59int        dvosecfilt_args        PROTO((int *argc, char **argv));
     60
    5761int        SkyTablePopulatedRange PROTO((off_t *ns, off_t *ne, SkyTable *sky, off_t Nstart));
     62int        SkyListPopulatedRange  PROTO((off_t *ns, off_t *ne, SkyList *sky, off_t Nstart));
    5863
    5964SkyList   *SkyTablePopulatedList  PROTO((SkyTable *sky));
  • trunk/Ohana/src/dvomerge/src/SkyTablePopulatedRange.c

    r27435 r29001  
    1212    Ns = sky[0].regions[Nstart].childS;
    1313    Ne = sky[0].regions[Nstart].childE;
     14    if (Ns == 0) {
     15      fprintf (stderr, "no populated tables at an appropriate depth\n");
     16      exit (1);
     17    }
     18    Nstart = Ns;
     19  }
     20
     21  *ns = Ns;
     22  *ne = Ne;
     23  return (TRUE);
     24}
     25
     26int SkyListPopulatedRange (off_t *ns, off_t *ne, SkyList *sky, off_t Nstart) {
     27
     28  off_t Ns, Ne;
     29
     30  // given the starting sky region, find the populated range at or below this region
     31
     32  Ns = Nstart;
     33  Ne = Nstart + 1;
     34  while (!sky[0].regions[Nstart][0].table) {
     35    Ns = sky[0].regions[Nstart][0].childS;
     36    Ne = sky[0].regions[Nstart][0].childE;
    1437    if (Ns == 0) {
    1538      fprintf (stderr, "no populated tables at an appropriate depth\n");
  • trunk/Ohana/src/dvomerge/src/args.c

    r28855 r29001  
    1515    remove_argument (N, argc, argv);
    1616    ALTERNATE_PHOTCODE_FILE = strdup(argv[N]);
     17    remove_argument (N, argc, argv);
     18  }
     19
     20  /*** provide additional data ***/
     21  /* restrict to a portion of the sky? */
     22  UserPatch.Rmin = 0;
     23  UserPatch.Rmax= 360;
     24  UserPatch.Dmin = -90;
     25  UserPatch.Dmax = +90;
     26  if ((N = get_argument (*argc, argv, "-region"))) {
     27    remove_argument (N, argc, argv);
     28    UserPatch.Rmin = atof (argv[N]);
     29    remove_argument (N, argc, argv);
     30    UserPatch.Rmax = atof (argv[N]);
     31    remove_argument (N, argc, argv);
     32    UserPatch.Dmin = atof (argv[N]);
     33    remove_argument (N, argc, argv);
     34    UserPatch.Dmax = atof (argv[N]);
    1735    remove_argument (N, argc, argv);
    1836  }
     
    3755  return TRUE;
    3856}
     57
     58/*** check for command line options ***/
     59int dvosecfilt_args (int *argc, char **argv) {
     60 
     61  int N;
     62
     63  /* extra error messages */
     64  VERBOSE = FALSE;
     65  if ((N = get_argument (*argc, argv, "-v"))) {
     66    VERBOSE = TRUE;
     67    remove_argument (N, argc, argv);
     68  }
     69
     70  if (*argc != 3) dvosecfilt_usage();
     71  return TRUE;
     72}
  • trunk/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c

    r28354 r29001  
    1313 
    1414  images = gfits_table_get_Image (&in[0].ftable, &Nimages, &in[0].swapped);
     15  if (!images) {
     16    fprintf (stderr, "ERROR: failed to read images\n");
     17    exit (2);
     18  }
     19
    1520  ALLOCATE (IDmap->old, off_t, Nimages);
    1621  ALLOCATE (IDmap->new, off_t, Nimages);
     
    5964
    6065  off_t Nlo, Nhi, N;
     66
     67  if (!IDmap->Nmap) return 0;
    6168
    6269  // find the a close entry below desired ID
  • trunk/Ohana/src/dvomerge/src/dvoconvert.c

    r28855 r29001  
    148148  // convert the raw image table to Image type (byteswap if needed)
    149149  images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.swapped);
     150  if (!images) {
     151    fprintf (stderr, "ERROR: failed to read images\n");
     152    exit (2);
     153  }
    150154
    151155  // update additional metadata
  • trunk/Ohana/src/dvomerge/src/dvomergeUpdate.c

    r28857 r29001  
    66  off_t i, j, Ns, Ne;
    77  SkyTable *outsky, *insky;
    8   SkyList *inlist;
     8  SkyList *outlist, *inlist;
    99  Catalog incatalog, outcatalog;
    1010  char filename[256], *input, *output;
     
    7070  SkyTableSetFilenames (insky, input, "cpt");
    7171
     72  // XXX apply this...generate the subset matching the user-selected region
     73  inlist = SkyListByPatch (insky, -1, &UserPatch);
     74
    7275  // generate an output table populated at the desired depth
    7376  outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
     
    7982  // loop over the populatable output tables; check for data in input in the corresponding regions
    8083
    81   SkyTablePopulatedRange (&Ns, &Ne, insky, 0);
    82   depth = insky[0].regions[Ns].depth;
     84  SkyListPopulatedRange (&Ns, &Ne, inlist, 0);
     85  depth = inlist[0].regions[Ns][0].depth;
    8386 
    84   // loop over the populatable output regions
    85   for (i = 0; i < outsky[0].Nregions; i++) {
    86     if (!outsky[0].regions[i].table) continue;
    87     if (VERBOSE) fprintf (stderr, "output: %s\n", outsky[0].regions[i].name);
     87  // loop over the populated input regions
     88  for (i = 0; i < inlist[0].Nregions; i++) {
     89    if (!inlist[0].regions[i][0].table) continue;
     90    if (VERBOSE) fprintf (stderr, "input: %s\n", inlist[0].regions[i][0].name);
    8891
    89     SetPhotcodeTable(outputPhotcodes);
     92    SetPhotcodeTable(inputPhotcodes);
    9093    // load / create output catalog (if catalog does not exist, it will be created)
    91     LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w");
     94    LoadCatalog (&incatalog, &inlist[0].regions[i][0], inlist[0].filename[i], "r");
     95    // skip empty input catalogs
     96    if (!incatalog.Naves_disk) {
     97        dvo_catalog_unlock (&incatalog);
     98        dvo_catalog_free (&incatalog);
     99        continue;
     100    }
    92101
    93102    // combine only tables at equal or larger depth
     
    97106    // compare to a slightly reduced footprint
    98107    float dPos = 2.0/3600.0;
    99     inlist = SkyListByBounds (insky, depth, outsky[0].regions[i].Rmin + dPos, outsky[0].regions[i].Rmax - dPos, outsky[0].regions[i].Dmin + dPos, outsky[0].regions[i].Dmax - dPos);
    100     for (j = 0; j < inlist[0].Nregions; j++) {
    101       if (VERBOSE) fprintf (stderr, "input : %s\n", inlist[0].regions[j][0].name);
     108    outlist = SkyListByBounds (outsky, depth, inlist[0].regions[i][0].Rmin + dPos, inlist[0].regions[i][0].Rmax - dPos, inlist[0].regions[i][0].Dmin + dPos, inlist[0].regions[i][0].Dmax - dPos);
     109    for (j = 0; j < outlist[0].Nregions; j++) {
     110      if (VERBOSE) fprintf (stderr, "output : %s\n", outlist[0].regions[j][0].name);
    102111
    103112      // load input catalog
    104       SetPhotcodeTable(inputPhotcodes);
    105       LoadCatalog (&incatalog, inlist[0].regions[j], inlist[0].filename[j], "r");
     113      SetPhotcodeTable(outputPhotcodes);
     114      LoadCatalog (&outcatalog, outlist[0].regions[j], outlist[0].filename[j], "w");
    106115
    107       // skip empty input catalogs
    108       if (!incatalog.Naves_disk) {
    109         dvo_catalog_unlock (&incatalog);
    110         dvo_catalog_free (&incatalog);
    111         continue;
    112       }
    113116      dvo_update_image_IDs (&IDmap, &incatalog);
    114       merge_catalogs_old (&outsky[0].regions[i], &outcatalog, &incatalog, RADIUS, secfiltMap);
    115       dvo_catalog_unlock (&incatalog);
    116       dvo_catalog_free (&incatalog);
     117      merge_catalogs_old (&outsky[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap);
    117118
    118       fprintf (stderr, "merged %s into %s\n", outsky[0].regions[i].name, inlist[0].regions[j][0].name);
     119      outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
     120
     121      // if we receive a signal which would cause us to exit, wait until the full catalog is written
     122      SetProtect (TRUE);
     123      dvo_catalog_save (&outcatalog, VERBOSE);
     124      SetProtect (FALSE);
     125
     126      dvo_catalog_unlock (&outcatalog);
     127      dvo_catalog_free (&outcatalog);
     128
     129      fprintf (stderr, "merged %s into %s\n", inlist[0].regions[i][0].name, outlist[0].regions[j][0].name);
    119130    }
    120     SkyListFree (inlist);
     131    SkyListFree (outlist);
    121132
    122     outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    123     dvo_catalog_save (&outcatalog, VERBOSE);
    124     dvo_catalog_unlock (&outcatalog);
    125     dvo_catalog_free (&outcatalog);
     133    dvo_catalog_unlock (&incatalog);
     134    dvo_catalog_free (&incatalog);
    126135  }
    127136
     
    153162  // load the image table
    154163  if (inDB.dbstate == LCK_EMPTY) {
    155     Shutdown ("can't find input image catalog %s", inDB.filename);
     164    // Shutdown ("can't find input image catalog %s", inDB.filename);
     165    IDmap->Nmap = 0;
     166    return TRUE;
    156167  }
    157168  if (!dvo_image_load (&inDB, VERBOSE, TRUE)) {
  • trunk/Ohana/src/dvomerge/src/dvoverify.c

    r28268 r29001  
    154154  // convert the raw image table to Image type (byteswap if needed)
    155155  images = gfits_table_get_Image (&inDB.ftable, &Nimages, &inDB.swapped);
     156  if (!images) {
     157    fprintf (stderr, "ERROR: failed to read images\n");
     158    exit (2);
     159  }
    156160
    157161  // update additional metadata
  • trunk/Ohana/src/dvomerge/src/help.c

    r27583 r29001  
    44  fprintf (stderr, "USAGE: dvomerge (input1) and (input2) to (output)\n");
    55  fprintf (stderr, "   OR: dvomerge (input) into (output)\n");
     6  fprintf (stderr, "   [-region Rmin Rmax Dmin Dmax]\n");
    67  exit (2);
    78}
     
    1011
    1112  fprintf (stderr, "USAGE: dvoconvert (input) to (output)\n");
     13
     14  exit (2);
     15}
     16
     17void dvosecfilt_usage(void) {
     18
     19  fprintf (stderr, "USAGE: dvosecfilt (input) -photcodes (photcodes.txt)\n");
    1220
    1321  exit (2);
     
    5765}
    5866
     67void dvosecfilt_help (int argc, char **argv) {
     68
     69  /* check for help request */
     70  if (get_argument (argc, argv, "-help")) goto show_help;
     71  if (get_argument (argc, argv, "-h"))    goto show_help;
     72  return;
     73
     74show_help:
     75
     76  fprintf (stderr, "USAGE\n");
     77  fprintf (stderr, "  dvosecfilt (input) (Nsecfilt)\n\n");
     78
     79  fprintf (stderr, "  change number of secfilt entries in photcode table (updates secfilt tables only)\n");
     80 
     81  fprintf (stderr, "  optional flags:\n");
     82  fprintf (stderr, "  -v                          : verbose mode\n");
     83  fprintf (stderr, "  -help                       : this list\n");
     84  fprintf (stderr, "  -h                          : this list\n\n");
     85  exit (2);
     86}
     87
  • trunk/Ohana/src/gastro2/src/rfits.c

    r27435 r29001  
    1515
    1616  stars = gfits_table_get_SMPData (&table, &Nstars, NULL);
     17  if (!stars) {
     18    fprintf (stderr, "ERROR: failed to read stars\n");
     19    exit (2);
     20  }
    1721
    1822  ALLOCATE (stardata, StarData, Nstars);
  • trunk/Ohana/src/getstar/src/dvoImageExtract.c

    r27435 r29001  
    3232  // convert database table to internal structure
    3333  images = gfits_table_get_Image (&db.ftable, &Nimages, &db.swapped);
     34  if (!images) {
     35    fprintf (stderr, "ERROR: failed to read images\n");
     36    exit (2);
     37  }
    3438 
    3539  matches = SelectImages (argv[1], images, Nimages, &Nmatches);
  • trunk/Ohana/src/getstar/src/dvoImageOverlaps.c

    r27435 r29001  
    3535  // convert database table to internal structure
    3636  dbImages = gfits_table_get_Image (&db.ftable, &NdbImages, &db.swapped);
     37  if (!dbImages) {
     38    fprintf (stderr, "ERROR: failed to read images\n");
     39    exit (2);
     40  }
    3741 
    3842  // for (i = 1; i < 2; i++) {
  • trunk/Ohana/src/getstar/src/dvoImagesAtCoords.c

    r27435 r29001  
    5555    // convert database table to internal structure
    5656    dbImages = gfits_table_get_Image (&db.ftable, &NdbImages, &db.swapped);
     57    if (!dbImages) {
     58      fprintf (stderr, "ERROR: failed to read images\n");
     59      exit (2);
     60    }
    5761  }
    5862 
  • trunk/Ohana/src/imregister/src/detsearch.c

    r27435 r29001  
    3636  if (!output.Modify && !output.Delete && !output.Altpath) gfits_db_close (&db);
    3737  detrend = gfits_table_get_DetReg (&db.ftable, &Ndetrend, &db.swapped);
     38  if (!detrend) {
     39    fprintf (stderr, "ERROR: failed to read detrend info\n");
     40    exit (2);
     41  }
    3842 
    3943  match = MatchCriteria (detrend, Ndetrend, &Nmatch);          /* match basic criteria */
  • trunk/Ohana/src/imregister/src/imphotsearch.c

    r27435 r29001  
    3333
    3434  image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped);
     35  if (!image) {
     36    fprintf (stderr, "ERROR: failed to read images\n");
     37    exit (2);
     38  }
    3539
    3640  match = subset (image, Nimage, &Nmatch);
  • trunk/Ohana/src/imregister/src/imregtable.c

    r27435 r29001  
    3434
    3535  image = gfits_table_get_RegImage (&ftable, &Nimage, NULL);
     36  if (!image) {
     37    fprintf (stderr, "ERROR: failed to read images\n");
     38    exit (2);
     39  }
    3640
    3741  /* load database table */
  • trunk/Ohana/src/imregister/src/imsearch.c

    r27435 r29001  
    3030
    3131  image = gfits_table_get_RegImage (&db.ftable, &Nimage, &db.swapped);
     32  if (!image) {
     33    fprintf (stderr, "ERROR: failed to read images\n");
     34    exit (2);
     35  }
    3236 
    3337  match = match_criteria (image, Nimage, &Nmatch);
  • trunk/Ohana/src/imregister/src/imstatreg.c

    r27611 r29001  
    6767    }
    6868    subset = gfits_table_get_RegImage (&temp_db.ftable, &Nsubset, &temp_db.swapped);
     69    if (!subset) {
     70      fprintf (stderr, "ERROR: failed to read images\n");
     71      exit (2);
     72    }
    6973    fprintf (stderr, "temporary database read\n");
    7074
     
    9397    }
    9498    image = gfits_table_get_RegImage (&image_db.ftable, &Nimage, &image_db.swapped);
     99    if (!image) {
     100      fprintf (stderr, "ERROR: failed to read images\n");
     101    exit (2);
     102    }
    95103    fprintf (stderr, "main database read\n");
    96104
  • trunk/Ohana/src/imregister/src/photsearch.c

    r27435 r29001  
    4242  if (output.convert) {
    4343    photpars_old = gfits_table_get_PhotParsOld (&db.ftable, &Nphotpars, &db.swapped);
     44    if (!photpars_old) {
     45      fprintf (stderr, "ERROR: failed to read photometry parameters\n");
     46      exit (2);
     47    }
    4448    photpars = PhotParsOld_to_PhotPars (photpars_old, Nphotpars);
    4549  } else {
    4650    photpars = gfits_table_get_PhotPars (&db.ftable, &Nphotpars, &db.swapped);
     51    if (!photpars) {
     52      fprintf (stderr, "ERROR: failed to read photometry parameters\n");
     53      exit (2);
     54    }
    4755  }
    4856
  • trunk/Ohana/src/imregister/src/spsearch.c

    r27435 r29001  
    3030
    3131  spectrum = gfits_table_get_Spectrum (&db.ftable, &Nspectrum, &db.swapped);
     32  if (!spectrum) {
     33    fprintf (stderr, "ERROR: failed to read spectrum\n");
     34    exit (2);
     35  }
    3236 
    3337  match = match_criteria (spectrum, Nspectrum, &Nmatch);
  • trunk/Ohana/src/libautocode/def/autocode.c

    r28277 r29001  
    6666  if (Ncols != $SIZE) {
    6767    fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, $SIZE);
    68     exit (1);
     68    return NULL;
    6969  }
    7070
  • trunk/Ohana/src/libdvo/include/dvo.h

    r28855 r29001  
    8585# define PHOT_MAG 0x06  /* generic magnitude; never stored */
    8686
    87 /* Image.code values.  these are codes to note bad images */
    88 # define ID_IMAGE_NEW   0x0000  /* no nrphot attempted */
    89 # define ID_IMAGE_NOCAL 0x0001  /* used within nrphot to mean "don't apply fit" */
    90 # define ID_IMAGE_POOR  0x0002  /* relphot says image is bad */
    91 # define ID_IMAGE_SKIP  0x0004  /* external information image is bad */
    92 # define ID_IMAGE_FEW   0x0008  /* currently too few measurements for good value */
     87/* Image.code values -- these values are 32 bit (as of PS1_V1) */
     88typedef enum {
     89  ID_IMAGE_NEW          = 0x00000000,  /* no calibrations yet attempted */
     90  ID_IMAGE_PHOTOM_NOCAL = 0x00000001,  /* user-set value used within relphot: ignore */
     91  ID_IMAGE_PHOTOM_POOR  = 0x00000002,  /* relphot says image is bad (dMcal > limit) */
     92  ID_IMAGE_PHOTOM_SKIP  = 0x00000004,  /* user-set value: assert that this image has bad photometry */
     93  ID_IMAGE_PHOTOM_FEW   = 0x00000008,  /* currently too few measurements for photometry */
     94  ID_IMAGE_ASTROM_NOCAL = 0x00000010,  /* user-set value used within relastro: ignore */
     95  ID_IMAGE_ASTROM_POOR  = 0x00000020,  /* relastro says image is bad (dR,dD > limit) */
     96  ID_IMAGE_ASTROM_FAIL  = 0x00000040,  /* relastro fit diverged, fit not applied */
     97  ID_IMAGE_ASTROM_SKIP  = 0x00000080,  /* user-set value: assert that this image has bad astrometry */
     98  ID_IMAGE_ASTROM_FEW   = 0x00000100,  /* currently too few measurements for astrometry */
     99} DVOImageFlags;
    93100
    94101/* Measure.flags values -- these values are 32 bit (as of PS1_V1) */
    95102typedef enum {
    96   ID_MEAS_NOCAL        = 0x0001,  // detection ignored for this analysis (photcode, time range) -- internal only
    97   ID_MEAS_POOR_PHOTOM  = 0x0002,  // detection is photometry outlier                                             
    98   ID_MEAS_SKIP_PHOTOM  = 0x0004,  // detection was ignored for photometry measurement                             
    99   ID_MEAS_AREA         = 0x0008,  // detection near image edge                                               
    100   ID_MEAS_POOR_ASTROM  = 0x0010,  // detection is astrometry outlier                                             
    101   ID_MEAS_SKIP_ASTROM  = 0x0020,  // detection was ignored for astrometry measurement                             
    102   ID_MEAS_USED_OBJ     = 0x0040,  // detection was used during opdate objects                               
    103   ID_MEAS_USED_CHIP    = 0x0080,  // detection was used during update chips                                         
    104   ID_MEAS_BLEND_MEAS   = 0x0100,  // detection is within radius of multiple objects                                 
    105   ID_MEAS_BLEND_OBJ    = 0x0200,  // multiple detections within radius of object                                     
    106   ID_MEAS_UNDEF_3      = 0x0400,  // unused                                                                         
    107   ID_MEAS_UNDEF_4      = 0x0800,  // unused                                                                         
    108   ID_MEAS_BLEND_MEAS_X = 0x1000,  // detection is within radius of multiple objects across catalogs                 
    109   ID_MEAS_ARTIFACT     = 0x2000,  // detection is thought to be non-astronomical                                     
    110   ID_MEAS_UNDEF_5      = 0x4000,  // unused                                                                         
    111   ID_MEAS_UNDEF_6      = 0x8000,  // unused                                                                         
     103  ID_MEAS_NOCAL        = 0x00000001,  // detection ignored for this analysis (photcode, time range) -- internal only
     104  ID_MEAS_POOR_PHOTOM  = 0x00000002,  // detection is photometry outlier                                                 
     105  ID_MEAS_SKIP_PHOTOM  = 0x00000004,  // detection was ignored for photometry measurement                                 
     106  ID_MEAS_AREA         = 0x00000008,  // detection near image edge                                                   
     107  ID_MEAS_POOR_ASTROM  = 0x00000010,  // detection is astrometry outlier                                                 
     108  ID_MEAS_SKIP_ASTROM  = 0x00000020,  // detection was ignored for astrometry measurement                                 
     109  ID_MEAS_USED_OBJ     = 0x00000040,  // detection was used during opdate objects                                   
     110  ID_MEAS_USED_CHIP    = 0x00000080,  // detection was used during update chips                                     
     111  ID_MEAS_BLEND_MEAS   = 0x00000100,  // detection is within radius of multiple objects                             
     112  ID_MEAS_BLEND_OBJ    = 0x00000200,  // multiple detections within radius of object                                 
     113  ID_MEAS_UNDEF_3      = 0x00000400,  // unused                                                                     
     114  ID_MEAS_UNDEF_4      = 0x00000800,  // unused                                                                     
     115  ID_MEAS_BLEND_MEAS_X = 0x00001000,  // detection is within radius of multiple objects across catalogs             
     116  ID_MEAS_ARTIFACT     = 0x00002000,  // detection is thought to be non-astronomical                                 
     117  ID_MEAS_UNDEF_5      = 0x00004000,  // unused                                                                     
     118  ID_MEAS_UNDEF_6      = 0x00008000,  // unused                                                                     
    112119} DVOMeasureFlags;
    113120
     
    147154  ID_STAR_USE_PM  = 0x00100000, // proper motion used (not AVE or PAR)
    148155  ID_STAR_USE_PAR = 0x00200000, // parallax used (not AVE or PM)
     156  ID_OBJ_EXT      = 0x01000000, // extended in our data (eg, PS)
     157  ID_OBJ_EXT_ALT  = 0x02000000, // extended in external data (eg, 2MASS)
     158  ID_OBJ_GOOD     = 0x04000000, // good-quality measurement in our data (eg, PS)
     159  ID_OBJ_GOOD_ALT = 0x08000000, // good-quality measurement in external data (eg, 2MASS)
    149160} DVOAverageFlags;
    150161
  • trunk/Ohana/src/libdvo/src/LoadPhotcodesFITS.c

    r27580 r29001  
    4343  if (!strcmp (extname, "DVO_PHOTCODE")) {
    4444    PhotCode_Elixir *photcode_elixir = gfits_table_get_PhotCode_Elixir (&db.ftable, &Ncode, &db.swapped);
     45    if (!photcode_elixir) {
     46      fprintf (stderr, "ERROR: failed to read photcodes\n");
     47      exit (2);
     48    }
    4549    photcode = PhotCode_Elixir_To_Internal (photcode_elixir, Ncode);
    4650    free (photcode_elixir);
     
    4953  if (!strcmp (extname, "DVO_PHOTCODE_ELIXIR")) {
    5054    PhotCode_Elixir *photcode_elixir = gfits_table_get_PhotCode_Elixir (&db.ftable, &Ncode, &db.swapped);
     55    if (!photcode_elixir) {
     56      fprintf (stderr, "ERROR: failed to read photcodes\n");
     57      exit (2);
     58    }
    5159    photcode = PhotCode_Elixir_To_Internal (photcode_elixir, Ncode);
    5260    free (photcode_elixir);
     
    5563  if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_1")) {
    5664    PhotCode_PS1_DEV_1 *photcode_ps1_dev_1 = gfits_table_get_PhotCode_PS1_DEV_1 (&db.ftable, &Ncode, &db.swapped);
     65    if (!photcode_ps1_dev_1) {
     66      fprintf (stderr, "ERROR: failed to read photcodes\n");
     67      exit (2);
     68    }
    5769    photcode = PhotCode_PS1_DEV_1_To_Internal (photcode_ps1_dev_1, Ncode);
    5870    free (photcode_ps1_dev_1);
     
    6173  if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_2")) {
    6274    PhotCode_PS1_DEV_2 *photcode_ps1_dev_2 = gfits_table_get_PhotCode_PS1_DEV_2 (&db.ftable, &Ncode, &db.swapped);
     75    if (!photcode_ps1_dev_2) {
     76      fprintf (stderr, "ERROR: failed to read photcodes\n");
     77      exit (2);
     78    }
    6379    photcode = PhotCode_PS1_DEV_2_To_Internal (photcode_ps1_dev_2, Ncode);
    6480    free (photcode_ps1_dev_2);
     
    6783  if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_3")) {
    6884    PhotCode_PS1_DEV_3 *photcode_ps1_dev_3 = gfits_table_get_PhotCode_PS1_DEV_3 (&db.ftable, &Ncode, &db.swapped);
     85    if (!photcode_ps1_dev_3) {
     86      fprintf (stderr, "ERROR: failed to read photcodes\n");
     87      exit (2);
     88    }
    6989    photcode = PhotCode_PS1_DEV_3_To_Internal (photcode_ps1_dev_3, Ncode);
    7090    free (photcode_ps1_dev_3);
     
    7393  if (!strcmp (extname, "DVO_PHOTCODE_PS1_V1")) {
    7494    PhotCode_PS1_V1 *photcode_ps1_v1 = gfits_table_get_PhotCode_PS1_V1 (&db.ftable, &Ncode, &db.swapped);
     95    if (!photcode_ps1_v1) {
     96      fprintf (stderr, "ERROR: failed to read photcodes\n");
     97      exit (2);
     98    }
    7599    photcode = PhotCode_PS1_V1_To_Internal (photcode_ps1_v1, Ncode);
    76100    free (photcode_ps1_v1);
     
    79103  if (!strcmp (extname, "DVO_PHOTCODE_PS1_V2")) {
    80104    PhotCode_PS1_V2 *photcode_ps1_v2 = gfits_table_get_PhotCode_PS1_V2 (&db.ftable, &Ncode, &db.swapped);
     105    if (!photcode_ps1_v2) {
     106      fprintf (stderr, "ERROR: failed to read photcodes\n");
     107      exit (2);
     108    }
    81109    photcode = PhotCode_PS1_V2_To_Internal (photcode_ps1_v2, Ncode);
    82110    free (photcode_ps1_v2);
     
    85113  if (!strcmp (extname, "DVO_PHOTCODE_PS1_REF")) {
    86114    PhotCode_PS1_REF *photcode_ps1_ref = gfits_table_get_PhotCode_PS1_REF (&db.ftable, &Ncode, &db.swapped);
     115    if (!photcode_ps1_ref) {
     116      fprintf (stderr, "ERROR: failed to read photcodes\n");
     117      exit (2);
     118    }
    87119    photcode = PhotCode_PS1_REF_To_Internal (photcode_ps1_ref, Ncode);
    88120    free (photcode_ps1_ref);
  • trunk/Ohana/src/libdvo/src/cmf-ps1-v1-alt.c

    r28241 r29001  
    1414  if (ftable[0].header[0].Naxis[0] != 136) {
    1515    fprintf (stderr, "ERROR: wrong format for CMF_PS1_V1_Alt: "OFF_T_FMT" vs %d\n",  ftable[0].header[0].Naxis[0], 136);
    16     exit (2);
     16    return (NULL);
    1717  }
    1818
  • trunk/Ohana/src/libdvo/src/coordops.c

    r28837 r29001  
    2020int XY_to_LM (double *L, double *M, double x, double y, Coords *coords) {
    2121
     22  OhanaProjection proj;
     23  OhanaProjectionMode mode;
    2224  double X, Y, X2, XY, Y2, X3, Y3;
     25
     26  proj = GetProjection (coords[0].ctype);
     27  mode = GetProjectionMode (proj);
    2328
    2429  /** convert pixel coordinates to cartesian system **/
     
    4550  }
    4651
     52  if (mode == PROJ_MODE_CARTESIAN) {
     53    *L += coords[0].crval1;
     54    *M += coords[0].crval2;
     55  }
     56
    4757  return (TRUE);
    4858}
     
    6474  /** Locally Cartesian Projections **/
    6575  if (mode == PROJ_MODE_CARTESIAN) {
    66     *ra  = L + coords[0].crval1;
    67     *dec = M + coords[0].crval2;
    68 
    6976    /* mosaic astrometry : WRP is chip astrometry; apply mosaic (DIS) term */
    7077    if (proj == PROJ_WRP) {
    7178      if (!gotMosaic) return (FALSE);
    72       XY_to_RD (ra, dec, *ra, *dec, &mosaic);
     79      XY_to_RD (ra, dec, L, M, &mosaic);
    7380    }
    7481    return (TRUE);
     
    183190
    184191  double phi, theta;
    185   double Lo, Mo;
    186192  double sphi, cphi, stht, ctht;
    187193  double salp, calp, sdel, cdel, sdp, cdp;
     
    201207    if (proj == PROJ_WRP) {
    202208      if (!gotMosaic) return (FALSE);
    203       RD_to_XY (&Lo, &Mo, ra, dec, &mosaic);
    204       *L = (Lo - coords[0].crval1);
    205       *M = (Mo - coords[0].crval2);
     209      RD_to_XY (L, M, ra, dec, &mosaic);
    206210      return (TRUE);
    207211    }
    208     *L = (ra  - coords[0].crval1);
    209     *M = (dec - coords[0].crval2);
     212    *L = ra;
     213    *M = dec;
    210214    return (TRUE);
    211215  }
     
    310314  double dX, dY, Lo, Mo, dL, dM;
    311315  double dLdX, dLdY, dMdX, dMdY, Do;
     316  OhanaProjection proj;
     317  OhanaProjectionMode mode;
     318
     319  proj = GetProjection (coords[0].ctype);
     320  mode = GetProjectionMode (proj);
    312321
    313322  *x = 0;
    314323  *y = 0;
     324
     325  if (mode == PROJ_MODE_CARTESIAN) {
     326    L -= coords[0].crval1;
     327    M -= coords[0].crval2;
     328  }
    315329
    316330  /* start with linear solution for X,Y */
     
    422436}
    423437
     438enum {COORD_TYPE_NONE, COORD_TYPE_PC, COORD_TYPE_ROT, COORD_TYPE_CD, COORD_TYPE_LIN};
     439
    424440int GetCoords (Coords *coords, Header *header) {
    425441 
     
    428444  double equinox;
    429445  char *ctype;
     446  int mode;
    430447 
    431448  rotate = 0.0;
     
    437454  strcpy (coords[0].ctype, "NONE");
    438455 
    439   status = FALSE;
    440   if (gfits_scan (header, "CTYPE2", "%s", 1, coords[0].ctype)) {
    441     status  = gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
    442     status &= gfits_scan (header, "CRPIX1", "%f", 1, &coords[0].crpix1);
    443     status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2); 
    444     status &= gfits_scan (header, "CRPIX2", "%f", 1, &coords[0].crpix2);
    445 
    446     if (gfits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1)) {
    447       status &= gfits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2);
    448       if (gfits_scan (header, "CROTA2", "%lf", 1, &rotate)) {
    449         Lambda = coords[0].cdelt2 / coords[0].cdelt1;
    450         coords[0].pc1_1 =  cos(rotate*RAD_DEG);
    451         coords[0].pc1_2 = -sin(rotate*RAD_DEG) * Lambda;
    452         coords[0].pc2_1 =  sin(rotate*RAD_DEG) / Lambda;
    453         coords[0].pc2_2 =  cos(rotate*RAD_DEG);
    454       }
    455       if (gfits_scan (header, "PC001001", "%f", 1, &coords[0].pc1_1)) {
    456         status &= gfits_scan (header, "PC001002", "%f", 1, &coords[0].pc1_2);
    457         status &= gfits_scan (header, "PC002001", "%f", 1, &coords[0].pc2_1);
    458         status &= gfits_scan (header, "PC002002", "%f", 1, &coords[0].pc2_2);
    459       }
     456  mode = COORD_TYPE_NONE;
     457  {   
     458    int haveCTYPE, haveCDELT, haveCROTA, haveCDij, havePCij, haveRAo;
     459    float tmp;
     460    char stmp[80];
     461   
     462    // there are a few different representations for scale and rotation.  choose an appropriate
     463    // set: (CDELTi + CROTAi), (CDELTi + PCij), (CDij),
     464
     465    haveCTYPE = gfits_scan (header, "CTYPE2",   "%s", 1, stmp);
     466    haveCDELT = gfits_scan (header, "CDELT1",   "%f", 1, &tmp);
     467    haveCROTA = gfits_scan (header, "CROTA1",   "%f", 1, &tmp);
     468    haveCDij  = gfits_scan (header, "CD1_1",    "%f", 1, &tmp);
     469    havePCij  = gfits_scan (header, "PC001001", "%f", 1, &tmp);
     470    haveRAo   = gfits_scan (header, "RA_O",     "%f", 1, &tmp);
     471   
     472    if (haveCTYPE && havePCij  && haveCDELT) { mode = COORD_TYPE_PC;   goto gotit; }
     473    if (haveCTYPE && haveCROTA && haveCDELT) { mode = COORD_TYPE_ROT;  goto gotit; }
     474    if (haveCTYPE && haveCDij)               { mode = COORD_TYPE_CD;   goto gotit; }
     475    if (haveRAo)                             { mode = COORD_TYPE_LIN;  goto gotit; }
     476    // fprintf (stderr, "no valid WCS keywords\n");
     477    return (FALSE);
     478  }
     479 
     480gotit:
     481
     482  status = TRUE;
     483  switch (mode) {
     484    case COORD_TYPE_PC:
     485      status &= gfits_scan (header, "CTYPE2",   "%s",  1, coords[0].ctype);
     486      status &= gfits_scan (header, "CRVAL1",   "%lf", 1, &coords[0].crval1);
     487      status &= gfits_scan (header, "CRPIX1",   "%f",  1, &coords[0].crpix1);
     488      status &= gfits_scan (header, "CRVAL2",   "%lf", 1, &coords[0].crval2); 
     489      status &= gfits_scan (header, "CRPIX2",   "%f",  1, &coords[0].crpix2);
     490
     491      status &= gfits_scan (header, "CDELT1",   "%f",  1, &coords[0].cdelt1);
     492      status &= gfits_scan (header, "CDELT2",   "%f",  1, &coords[0].cdelt2);
     493      status &= gfits_scan (header, "PC001001", "%f",  1, &coords[0].pc1_1);
     494      status &= gfits_scan (header, "PC001002", "%f",  1, &coords[0].pc1_2);
     495      status &= gfits_scan (header, "PC002001", "%f",  1, &coords[0].pc2_1);
     496      status &= gfits_scan (header, "PC002002", "%f",  1, &coords[0].pc2_2);
    460497
    461498      /* set NPLYTERM based on header.  if NPLYTERM is missing, it should have a
     
    491528          break;
    492529      }
    493     } else {
    494       if (gfits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1)) {
    495         status &= gfits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2);
    496         status &= gfits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1);
    497         status &= gfits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2);
    498         /* renormalize */
    499         scale = hypot (coords[0].pc1_1, coords[0].pc1_2);
    500         coords[0].cdelt1 = coords[0].cdelt2 = scale;
    501         coords[0].pc1_1 /= scale;
    502         coords[0].pc1_2 /= scale;
    503         coords[0].pc2_1 /= scale;
    504         coords[0].pc2_2 /= scale;
    505       } else {
    506         status = FALSE;
    507       }
    508     }
    509   } else {
    510     /* some of my thesis data uses this simple linear model - convert on read? */
    511     if (gfits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1)) {
    512       status  = gfits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1);
     530      break;
     531
     532    case COORD_TYPE_ROT:
     533      status &= gfits_scan (header, "CTYPE2", "%s",  1, coords[0].ctype);
     534      status &= gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
     535      status &= gfits_scan (header, "CRPIX1", "%f",  1, &coords[0].crpix1);
     536      status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2); 
     537      status &= gfits_scan (header, "CRPIX2", "%f",  1, &coords[0].crpix2);
     538
     539      status &= gfits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1);
     540      status &= gfits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2);
     541
     542      status &= gfits_scan (header, "CROTA2", "%lf", 1, &rotate);
     543      Lambda = coords[0].cdelt2 / coords[0].cdelt1;
     544      coords[0].pc1_1 =  cos(rotate*RAD_DEG);
     545      coords[0].pc1_2 = -sin(rotate*RAD_DEG) * Lambda;
     546      coords[0].pc2_1 =  sin(rotate*RAD_DEG) / Lambda;
     547      coords[0].pc2_2 =  cos(rotate*RAD_DEG);
     548      break;
     549
     550    case COORD_TYPE_CD:
     551      status &= gfits_scan (header, "CTYPE2", "%s",  1, coords[0].ctype);
     552      status &= gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
     553      status &= gfits_scan (header, "CRPIX1", "%f",  1, &coords[0].crpix1);
     554      status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2); 
     555      status &= gfits_scan (header, "CRPIX2", "%f",  1, &coords[0].crpix2);
     556
     557      status &= gfits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1);
     558      status &= gfits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2);
     559      status &= gfits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1);
     560      status &= gfits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2);
     561      /* renormalize */
     562      scale = hypot (coords[0].pc1_1, coords[0].pc1_2);
     563      coords[0].cdelt1 = coords[0].cdelt2 = scale;
     564      coords[0].pc1_1 /= scale;
     565      coords[0].pc1_2 /= scale;
     566      coords[0].pc2_1 /= scale;
     567      coords[0].pc2_2 /= scale;
     568      break;
     569
     570    case COORD_TYPE_LIN:
     571      /* some of my thesis data uses this simple linear model - convert on read? */
     572      status &= gfits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1);
     573      status &= gfits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1);
    513574      status &= gfits_scan (header, "RA_Y", "%f", 1, &coords[0].pc1_2);
    514575      status &= gfits_scan (header, "DEC_O", "%lf", 1, &coords[0].crval2); 
     
    518579      coords[0].cdelt1 = coords[0].cdelt2 = 1.0;
    519580      strcpy (coords[0].ctype, "GENE");
    520     }
    521   }
     581      break;
     582  }
     583
    522584  if (status) {
    523585    if (!gfits_scan (header, "EQUINOX", "%lf", 1, &equinox)) {
     
    530592    }
    531593  }
     594
    532595  if (!status) {
    533     fprintf (stderr, "error getting all elements for coordinate mode %s\n", coords[0].ctype);
     596    // fprintf (stderr, "error getting all elements for coordinate mode %s\n", coords[0].ctype);
    534597    coords[0].crval1 = coords[0].crpix1 = coords[0].cdelt1 = 0.0;
    535598    coords[0].crval2 = coords[0].crpix2 = coords[0].cdelt2 = 0.0;
  • trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c

    r28241 r29001  
    125125    /* no conversions currently defined */
    126126    catalog[0].missing = gfits_table_get_Missing (&ftable, &catalog[0].Nmissing, NULL);
     127    if (!catalog[0].missing) {
     128      fprintf (stderr, "ERROR: failed to read missing\n");
     129      exit (2);
     130    }
    127131    if (Nmissing != catalog[0].Nmiss_disk) {
    128132      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n",  Nmissing,  catalog[0].Nmiss_disk);
  • trunk/Ohana/src/libdvo/src/dvo_catalog_split.c

    r28241 r29001  
    285285    /* no conversions currently defined : this just does the byte swap */
    286286    catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);
     287    if (!catalog[0].missing) {
     288      fprintf (stderr, "ERROR: failed to read missing\n");
     289      exit (2);
     290    }
    287291    if (Nmissing != catalog[0].Nmiss_disk) {
    288292      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n",  Nmissing,  catalog[0].Nmiss_disk);
     
    473477    /* no conversions currently defined : this just does the byte swap */
    474478    catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);
     479    if (!catalog[0].missing) {
     480      fprintf (stderr, "ERROR: failed to read missing\n");
     481      exit (2);
     482    }
    475483    if (Nmissing != Nrows) {
    476484      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n",  Nmissing,  Nrows);
  • trunk/Ohana/src/libdvo/src/dvo_convert.c

    r28241 r29001  
    3232    Average_##TYPE *tmpAverage; \
    3333    tmpAverage = gfits_table_get_Average_##TYPE (ftable, Naverage, NULL); \
     34    if (!tmpAverage) { \
     35      fprintf (stderr, "ERROR: failed to read averages\n"); \
     36      exit (2); \
     37    } \
    3438    average = Average_##TYPE##_ToInternal (tmpAverage, *Naverage, primary); \
    3539    free (tmpAverage); \
     
    3943  if (!strcmp (extname, "DVO_AVERAGE")) {
    4044    average = gfits_table_get_Average (ftable, Naverage, NULL);
     45    if (!average) {
     46      fprintf (stderr, "ERROR: failed to read averages\n");
     47      exit (2);
     48    }
    4149    *format = DVO_FORMAT_INTERNAL;
    4250    return (average);
     
    111119    Measure_##TYPE *tmpMeasure; \
    112120    tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL); \
     121    if (!tmpMeasure) { \
     122      fprintf (stderr, "ERROR: failed to read measures\n"); \
     123      exit (2); \
     124    } \
    113125    measure = Measure_##TYPE##_ToInternal (tmpMeasure, *Nmeasure); \
    114126    free (tmpMeasure); \
     
    118130  if (!strcmp (extname, "DVO_MEASURE")) {
    119131    measure = gfits_table_get_Measure (ftable, Nmeasure, NULL);
     132    if (!measure) {
     133      fprintf (stderr, "ERROR: failed to read measures\n");
     134      exit (2);
     135    }
    120136    *format = DVO_FORMAT_INTERNAL;
    121137    return (measure);
     
    190206    SecFilt_##TYPE *tmpSecFilt; \
    191207    tmpSecFilt = gfits_table_get_SecFilt_##TYPE (ftable, Nsecfilt, NULL); \
     208    if (!tmpSecFilt) { \
     209      fprintf (stderr, "ERROR: failed to read secfilts\n"); \
     210      exit (2); \
     211    } \
    192212    secfilt = SecFilt_##TYPE##_ToInternal (tmpSecFilt, *Nsecfilt); \
    193213    free (tmpSecFilt); \
     
    197217  if (!strcmp (extname, "DVO_SECFILT")) {
    198218    secfilt = gfits_table_get_SecFilt (ftable, Nsecfilt, NULL);
     219    if (!secfilt) {
     220      fprintf (stderr, "ERROR: failed to read secfilts\n");
     221      exit (2);
     222    }
    199223    *format = DVO_FORMAT_INTERNAL;
    200224    return (secfilt);
     
    263287    Image_Elixir *tmpimage;
    264288    tmpimage = gfits_table_get_Image_Elixir (ftable, &Nimage, NULL);
     289    if (!tmpimage) {
     290      fprintf (stderr, "ERROR: failed to read images\n");
     291      exit (2);
     292    }
    265293    ftable[0].buffer = (char *) Image_Elixir_ToInternal (tmpimage, Nimage);
    266294    free (tmpimage);
     
    284312    *format = DVO_FORMAT_##FORMAT; \
    285313    tmpimage = gfits_table_get_Image_##TYPE (ftable, &Nimage, NULL); \
     314    if (!tmpimage) { \
     315      fprintf (stderr, "ERROR: failed to read images\n"); \
     316      exit (2); \
     317    } \
    286318    ftable[0].buffer = (char *) Image_##TYPE##_ToInternal (tmpimage, Nimage); \
    287319    free (tmpimage); \
     
    296328    Image *image;
    297329    image = gfits_table_get_Image (ftable, &Nimage, NULL);
     330    if (!image) {
     331      fprintf (stderr, "ERROR: failed to read images\n");
     332      exit (2);
     333    }
    298334    *format = DVO_FORMAT_INTERNAL;
    299335    return (TRUE);
  • trunk/Ohana/src/libdvo/src/skyregion_io.c

    r27435 r29001  
    4040  ALLOCATE (skytable, SkyTable, 1);
    4141  skytable[0].regions = gfits_table_get_SkyRegion (&ftable, &skytable[0].Nregions, NULL);
     42  if (!skytable[0].regions) {
     43    fprintf (stderr, "ERROR: failed to read sky regions\n");
     44    exit (2);
     45  }
     46
    4247  ALLOCATE (skytable[0].filename, char *, skytable[0].Nregions);
    4348  for (i = 0; i < skytable[0].Nregions; i++) {
  • trunk/Ohana/src/markstar/src/find_images.c

    r7080 r29001  
    2626
    2727  timage = gfits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].swapped);
     28  if (!timage) {
     29    fprintf (stderr, "ERROR: failed to read images\n");
     30    exit (2);
     31  }
    2832
    2933  /* set up buffers for images, temporary storage */
  • trunk/Ohana/src/mosastro/src/rfits.c

    r27435 r29001  
    3232  off_t Nstars;
    3333  stars = gfits_table_get_SMPData (&table, &Nstars, NULL);
     34  if (!stars) {
     35    fprintf (stderr, "ERROR: failed to read stars\n");
     36    exit (2);
     37  }
     38
    3439  mychip[0].Nstars = Nstars;
    3540  gfits_scan (table.header, "NAXIS1", "%d", 1, &Nx);
  • trunk/Ohana/src/opihi/cmd.astro/cgrid.c

    r26258 r29001  
    153153  SetVector (&Yvec, OPIHI_FLT, NELEMENTS);
    154154 
     155  { // sanity check
     156    float Nelem;
     157    Nelem = 180.0 / minorRA;
     158    if (!isfinite(Nelem) || (fabs(Nelem) > 10000)) { fprintf (stderr, "absurd cgrid spacing %f\n", minorRA); return FALSE; }
     159    Nelem = 180.0 / minorDEC;
     160    if (!isfinite(Nelem) || (fabs(Nelem) > 10000)) { fprintf (stderr, "absurd cgrid spacing %f\n", minorDEC); return FALSE; }
     161  }
     162
    155163  /***  do consecutive RA lines, first increasing **/
    156164  OnPic = TRUE;
  • trunk/Ohana/src/opihi/cmd.data/Makefile

    r27817 r29001  
    1919$(SRC)/init.$(ARCH).o          \
    2020$(SRC)/accum.$(ARCH).o          \
     21$(SRC)/applyfit1d.$(ARCH).o     \
    2122$(SRC)/applyfit2d.$(ARCH).o     \
    22 $(SRC)/applyfit1d.$(ARCH).o     \
     23$(SRC)/applyfit3d.$(ARCH).o     \
    2324$(SRC)/box.$(ARCH).o            \
    2425$(SRC)/book.$(ARCH).o           \
     
    4647$(SRC)/fit1d.$(ARCH).o          \
    4748$(SRC)/fit2d.$(ARCH).o          \
     49$(SRC)/fit3d.$(ARCH).o          \
    4850$(SRC)/gaussj.$(ARCH).o \
    4951$(SRC)/gaussdeviate.$(ARCH).o   \
  • trunk/Ohana/src/opihi/cmd.data/applyfit2d.c

    r20936 r29001  
    1010
    1111  if (argc != 4) {
    12     gprint (GP_ERR, "USAGE: applyfit x y z\n");
     12    gprint (GP_ERR, "USAGE: applyfit2d x y z\n");
    1313    return (FALSE);
    1414  }
  • trunk/Ohana/src/opihi/cmd.data/fit2d.c

    r27817 r29001  
    168168    }
    169169
     170    /** test print **/
     171    if (VERBOSE) {
     172      for (i = 0; i < wterm; i++) {
     173        for (j = 0; j < wterm; j++) {
     174          gprint (GP_ERR, "%g  ", c[i][j]);
     175        }
     176        gprint (GP_ERR, "\n");
     177      }
     178      gprint (GP_ERR, "-----\n");
     179    }
     180
    170181    dgaussjordan (c, b, wterm, 1);
    171182
     
    176187          gprint (GP_ERR, "x^%d y^%d: %g\n", nx, ny, b[i][0]);
    177188        }
     189      }
     190    }
     191
     192    /** test print **/
     193    if (VERBOSE) {
     194      for (i = 0; i < wterm; i++) {
     195        for (j = 0; j < wterm; j++) {
     196          gprint (GP_ERR, "%g  ", c[i][j]);
     197        }
     198        gprint (GP_ERR, "\n");
    178199      }
    179200    }
  • trunk/Ohana/src/opihi/cmd.data/init.c

    r27817 r29001  
    55int applyfit1d       PROTO((int, char **));
    66int applyfit2d       PROTO((int, char **));
     7int applyfit3d       PROTO((int, char **));
    78int box              PROTO((int, char **));
    89int book_command     PROTO((int, char **));
     
    3435int fit1d            PROTO((int, char **));
    3536int fit2d            PROTO((int, char **));
     37int fit3d            PROTO((int, char **));
    3638int gaussjordan      PROTO((int, char **));
    3739int gaussdeviate     PROTO((int, char **));
     
    138140  {1, "applyfit1d",   applyfit1d,       "apply 1-d fit to new vector"},
    139141  {1, "applyfit2d",   applyfit2d,       "apply 2-d fit to new vector"},
     142  {1, "applyfit3d",   applyfit3d,       "apply 3-d fit to new vector"},
    140143  {1, "book",         book_command,     "commands to manipulate book/page/word data"},
    141144  {1, "box",          box,              "draw a box on the plot"},
     
    168171  {1, "fit1d",        fit1d,            "fit polynomial to vector pair"},
    169172  {1, "fit2d",        fit2d,            "fit 2-d polynomial to vector triplet"},
     173  {1, "fit3d",        fit3d,            "fit 3-d polynomial to vector quad"},
    170174  {1, "gaussdev",     gaussdeviate,     "generate a gaussian deviate vector"},
    171175  {1, "gaussint",     gaussintegral,    "return the integrated gaussian vector"},
  • trunk/Ohana/src/opihi/cmd.data/vgauss.c

    r20936 r29001  
    4242  if ((ovec = SelectVector (argv[4], ANYVECTOR, TRUE)) == NULL) return (FALSE);
    4343
    44   REQUIRE_VECTOR_FLT (xvec, FALSE);
    45   REQUIRE_VECTOR_FLT (yvec, FALSE);
    46   REQUIRE_VECTOR_FLT (svec, FALSE);
     44  CastVector (xvec, OPIHI_FLT);
     45  CastVector (yvec, OPIHI_FLT);
     46  CastVector (svec, OPIHI_FLT);
    4747
    4848  Npts = xvec[0].Nelements;
  • trunk/Ohana/src/opihi/dvo/LoadImages.c

    r28958 r29001  
    6565
    6666  image = gfits_table_get_Image (&db.ftable, Nimage, &db.swapped);
     67  if (!image) {
     68    fprintf (stderr, "ERROR: failed to read images\n");
     69    return (NULL);
     70  }
    6771  if (dvoUseImageCache && image) {
    6872    cacheNimage = *Nimage;
     
    7175    lastModified = getLastModified(filename);
    7276  }
    73 
    7477  return (image);
    7578}
  • trunk/Ohana/src/opihi/dvo/cmpReadFile.c

    r27435 r29001  
    2020
    2121  smpdata = gfits_table_get_SMPData (&table, &Nstars, NULL);
     22  if (!smpdata) {
     23    fprintf (stderr, "ERROR: failed to read stars\n");
     24    exit (2);
     25  }
    2226
    2327  ALLOCATE (stars, CMPstars, Nstars);
  • trunk/Ohana/src/photdbc/src/copy_images.c

    r28331 r29001  
    4646   
    4747  image = gfits_table_get_Image (&in.ftable, &Nimage, &in.swapped);
     48  if (!image) {
     49      fprintf (stderr, "ERROR: failed to read images\n");
     50      exit (2);
     51  }
    4852  dvo_image_addrows (&out, image, Nimage);
    4953
  • trunk/Ohana/src/photdbc/src/find_images.c

    r12332 r29001  
    2828
    2929  timage = gfits_table_get_Image (&db[0].ftable, &Ntimage, &db[0].swapped);
     30  if (!timage) {
     31      fprintf (stderr, "ERROR: failed to read images\n");
     32      exit (2);
     33  }
    3034
    3135  nimage = 0;
     
    97101      if (found) {
    98102        image[nimage] = timage[i];
    99         if (image[nimage].code == ID_IMAGE_NOCAL) {
    100           image[nimage].code &= ~ID_IMAGE_NOCAL;
     103        if (image[nimage].code == ID_IMAGE_PHOTOM_NOCAL) {
     104          image[nimage].code &= ~ID_IMAGE_PHOTOM_NOCAL;
    101105        }           
    102106        line_number[nimage] = i;
  • trunk/Ohana/src/photdbc/src/flag_measures.c

    r12332 r29001  
    1616
    1717  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     18  if (!image) {
     19      fprintf (stderr, "ERROR: failed to read images\n");
     20      exit (2);
     21  }
    1822
    1923  PhotNsec = GetPhotcodeNsecfilt ();
  • trunk/Ohana/src/relastro/Makefile

    r28184 r29001  
    5858$(SRC)/CoordOps.$(ARCH).o            \
    5959$(SRC)/FixProblemImages.$(ARCH).o    \
     60$(SRC)/StarMaps.$(ARCH).o    \
    6061$(SRC)/high_speed_catalogs.$(ARCH).o  \
    6162$(SRC)/high_speed_objects.$(ARCH).o  \
  • trunk/Ohana/src/relastro/doc/notes.txt

    r27435 r29001  
     1
     22010.07.15
     3
     4  Some issues:
     5
     6  * when I apply the fitted image parameters (UpdateObjectOffsets), I
     7    currently check for good/bad fits and warn if the image is bad.
     8    But the correction requires multiple re-loads of the catalog
     9    tables.
     10
     11  * I would like to check for bad fits by defining a grid of test
     12    points and seeing how much they move.  However, for some chips,
     13    the region of valid data is much smaller than the regino with any
     14    data. 
     15
     16  * I would like to define a grid (say, Nx * Ny with Nx >> polynomial
     17    order) and only use those grid regions in testing the solution
     18
     19  * This means knowing which detections belong on a specific image.
     20    I'm not sure if there is a good way to do this.  at the moment, it
     21    is easy to do detection -> image, but not so easy to do
     22    image->detection.
     23
     24  * That might argue for generating the grid for each image, then
     25    running through all detections and, as detections are examined,
     26    populate the grid elements for their own image.
    127
    2282010.03.24
  • trunk/Ohana/src/relastro/include/relastro.h

    r28184 r29001  
    33# include <kapa.h>
    44# include <signal.h>
     5# include <assert.h>
    56
    67typedef enum {
     
    7677  int    Nmeas;
    7778} StatType;
     79
     80# define MARKTIME(MSG,...) { \
     81  float dtime; \
     82  gettimeofday (&stop, (void *) NULL); \
     83  dtime = DTIME (stop, start); \
     84  fprintf (stderr, MSG, __VA_ARGS__); }
    7885
    7986/* global variables set in parameter file */
     
    145152int DoUpdateChips;
    146153int DoUpdateMosaics;
     154
     155// StarMap parameters:
     156int NX_MAP;
     157int NY_MAP;
     158double DPOS_MAX;
     159double ADDSTAR_RADIUS;
    147160
    148161/*** relphot prototypes ***/
     
    207220void create_image_db (FITS_DB *db);
    208221void save_catalogs (Catalog *catalog, int Ncatalog);
     222
     223int reload_images (FITS_DB *db);
    209224
    210225int           main                PROTO((int argc, char **argv));
     
    267282double **poly2d_copy (double **poly, int Nx, int Ny);
    268283double poly2d_eval (double **poly, int Nx, int Ny, double x, double y);
    269 int fit_apply_coords (CoordFit *fit, Coords *coords);
     284int fit_apply_coords (CoordFit *fit, Coords *coords, int keepRef);
    270285int CoordsGetCenter (CoordFit *fit, double tol, double *xo, double *yo);
    271286CoordFit *CoordsSetCenter (CoordFit *input, double Xo, double Yo);
    272 int FitChip (StarData *raw, StarData *ref, int Nmatch, Coords *coords);
     287int FitChip (StarData *raw, StarData *ref, int Nmatch, Image *image);
    273288void FitMosaic (StarData *raw, StarData *ref, int Nmatch, Coords *coords);
    274289void FitSimple (StarData *raw, StarData *ref, int Nmatch, Coords *coords);
     
    293308StarData *getImageRef (Catalog *catalog, int Ncatalog, off_t im, off_t *Nstars, CoordMode mode);
    294309StarData *getImageRaw (Catalog *catalog, int Ncatalog, off_t im, off_t *Nstars, CoordMode mode);
     310off_t getImageByID (off_t ID);
    295311
    296312Mosaic *getmosaics (off_t *N);
     
    331347int high_speed_objects (SkyRegion *region, Catalog *catalog);
    332348int MeasMatchesPhotcode(Measure *measure, PhotCode **photcodeSet, int Nset);
     349
     350int initStarMaps ();
     351int updateStarMaps(Catalog *catalog);
     352int createStarMapPoints();
     353int checkStarMap(int N);
  • trunk/Ohana/src/relastro/src/ConfigInit.c

    r25757 r29001  
    3232  GetConfig (config, "PM_TOOFEW",              "%d",  0, &PM_TOOFEW);
    3333  GetConfig (config, "POS_TOOFEW",             "%d",  0, &POS_TOOFEW);
     34
     35  GetConfig (config, "RELASTRO_MAP_NX",        "%d",  0, &NX_MAP);
     36  GetConfig (config, "RELASTRO_MAP_NY",        "%d",  0, &NY_MAP);
     37  GetConfig (config, "RELASTRO_DPOS_MAX",      "%lf", 0, &DPOS_MAX);
     38  GetConfig (config, "ADDSTAR_RADIUS",         "%lf", 0, &ADDSTAR_RADIUS);
    3439
    3540  GetConfig (config, "GSCFILE",                "%s",  0, GSCFILE);
  • trunk/Ohana/src/relastro/src/FitChip.c

    r27581 r29001  
    33
    44// XXX make these user parameters
    5 # define FIT_CHIP_MAX_ERROR 0.05
    65# define FIT_CHIP_NITER     3
    76# define FIT_CHIP_NSIGMA    3.0
    8 
    9 
    10 // XXX we should test if the fit is sufficiently constrained across the chip, or if the
    11 // new positions deviate too much from the old positions
    12 
    13 // XXX add visualization tools: per chip residual plots
    147
    158// XXX save the fit[0].Npts value in the image table?
     
    1710// XXX save measurements of the fit quality (scatter, chisq) in the image table
    1811
    19 int FitChip (StarData *raw, StarData *ref, int Nmatch, Coords *coords) {
     12int FitChip (StarData *raw, StarData *ref, int Nmatch, Image *image) {
    2013
    2114  int i, Nscatter, Niter, skip;
     
    2922    for (i = Nscatter = 0; i < Nmatch; i++) {
    3023      if (raw[i].mask) continue;
    31       if (isnan(raw[i].dMag) || raw[i].dMag > FIT_CHIP_MAX_ERROR) continue;
     24      if (isnan(raw[i].dMag) || raw[i].dMag > SIGMA_LIM) continue;
    3225
    3326      dL = raw[i].L - ref[i].L;
     
    3932    }
    4033
    41     // for a 2D Gaussian, 40% of the points are within 1 sigma; dRmax is ~ 3 sigma
    42     dsort (values, Nscatter);
    43     dRmax = FIT_CHIP_NSIGMA*values[(int)(0.40*Nscatter)];
    44     relastroVisualPlotScatter(values, dRmax, Nscatter);
    45     relastroVisualPlotRawRef(raw, ref, dRmax, Nmatch);
     34    if (Nscatter > 5) {
     35      // for a 2D Gaussian, 40% of the points are within 1 sigma; dRmax is ~ 3 sigma
     36      // XXX this test is not sensible for Nscatter < XXX (5?)
     37      dsort (values, Nscatter);
     38      dRmax = FIT_CHIP_NSIGMA*values[(int)(0.40*Nscatter)];
     39      relastroVisualPlotScatter(values, dRmax, Nscatter);
     40      relastroVisualPlotRawRef(raw, ref, dRmax, Nmatch);
     41    } else {
     42      dRmax = 0;
     43    }
    4644
    4745    // fit the requested order polynomial
    4846    if (CHIPORDER > 0) {
    49       coords[0].Npolyterms = CHIPORDER;
     47      image[0].coords.Npolyterms = CHIPORDER;
    5048    }
    51     fit = fit_init (coords[0].Npolyterms);
     49    fit = fit_init (image[0].coords.Npolyterms);
    5250
    5351    // generate the fit matches
     
    5654        continue;
    5755      }
    58       if (isnan(raw[i].dMag) || raw[i].dMag > FIT_CHIP_MAX_ERROR) {
     56      if (isnan(raw[i].dMag) || raw[i].dMag > SIGMA_LIM) {
    5957        continue;
    6058      }
     
    6462      dM = raw[i].M - ref[i].M;
    6563      dR = hypot (dL, dM);
    66       if (dR > dRmax) continue;
     64
     65      // fprintf (stderr, "fit %f %f -> %f %f : %f %f (%f vs %f) wt: %f\n", raw[i].X, raw[i].Y, ref[i].L, ref[i].M, raw[i].L, raw[i].M, dR, dRmax, raw[i].dPos);
     66
     67      if ((dRmax > 0.0) && (dR > dRmax)) continue;
    6768
    6869      fit_add (fit, raw[i].X, raw[i].Y, ref[i].L, ref[i].M, raw[i].dPos);
     
    7172    // check if the fit has enough data points for the polynomial order
    7273    skip = FALSE;
    73     switch (coords[0].Npolyterms) {
     74    switch (image[0].coords.Npolyterms) {
    7475      case 0:
    7576      case 1:
     
    8384        break;
    8485      default:
    85         fprintf (stderr, "invalid chip order %d\n", coords[0].Npolyterms);
     86        fprintf (stderr, "invalid chip order %d\n", image[0].coords.Npolyterms);
    8687        skip = TRUE;
    8788    }
    8889    if (skip) {
    89       fprintf (stderr, "insufficient measurements (%d) for requested order (%d)\n", fit[0].Npts, coords[0].Npolyterms);
     90      if (VERBOSE) fprintf (stderr, "insufficient measurements (%d) for requested order (%d)\n", fit[0].Npts, image[0].coords.Npolyterms);
    9091      fit_free (fit);
    9192      free (values);
     93      image[0].flags |= ID_IMAGE_ASTROM_FEW;
    9294      return FALSE;
    9395    }
     
    98100    if (!fit_eval (fit)) {
    99101      fprintf (stderr, "failed to fit new model\n");
     102      image[0].flags |= ID_IMAGE_ASTROM_FAIL;
    100103      return FALSE;
    101104    }
    102105
    103     if (!fit_apply_coords (fit, coords)) {
     106    if (!fit_apply_coords (fit, &image[0].coords, FALSE)) {
    104107      fprintf (stderr, "failed to fit new model\n");
     108      image[0].flags |= ID_IMAGE_ASTROM_FAIL;
    105109      return FALSE;
    106110    }
     
    109113
    110114    for (i = 0; i < Nmatch; i++) {
    111       XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, coords);
     115      XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[0].coords);
    112116    }
    113117
  • trunk/Ohana/src/relastro/src/FitMosaic.c

    r16810 r29001  
    2626  }
    2727  fit_eval (fit);
    28   fit_apply_coords (fit, coords);
     28  fit_apply_coords (fit, coords, TRUE);
    2929  fit_free (fit);
    3030
  • trunk/Ohana/src/relastro/src/FitSimple.c

    r27435 r29001  
    2626  }
    2727  fit_eval (fit);
    28   fit_apply_coords (fit, coords);
     28  fit_apply_coords (fit, coords, TRUE);
    2929  fit_free (fit);
    3030
  • trunk/Ohana/src/relastro/src/ImageOps.c

    r28241 r29001  
    319319}
    320320
     321void dump_measures(Average *average, Measure *measure) {
     322
     323  off_t j, off;
     324
     325  for (j = 0; j < average[0].Nmeasure; j++) {
     326    off = average[0].measureOffset + j;
     327    fprintf (stderr, "%f, %f\n", measure[off].dR, measure[off].dD);
     328  }
     329  return;
     330}
     331
    321332// return StarData values for detections in the specified image, converting coordinates from the
    322333// chip positions: X,Y -> L,M -> P,Q -> R,D
     
    325336  off_t i, m, c, n, nPos;
    326337  double X, Y, L, M, P, Q, R, D, dR, dD;
    327   double dPos;
     338  double dPos, DPOS_MAX_ASEC;
    328339
    329340  Mosaic *mosaic;
     
    341352  }
    342353  imcoords = &image[im].coords;
     354
     355  if (moscoords) {
     356    DPOS_MAX_ASEC = 3600.0*DPOS_MAX*hypot(moscoords[0].cdelt1, moscoords[0].cdelt2);
     357  } else {
     358    DPOS_MAX_ASEC = 3600.0*DPOS_MAX*hypot(imcoords[0].cdelt1, imcoords[0].cdelt2);
     359  }
    343360
    344361  // accumulate the rms position offsets.  if this value, or any specific entry, is too
     
    372389
    373390    // complain if the new location is far from the average location
    374     if (fabs(dR) > 2.0) {
    375       fprintf (stderr, "!");
    376       setBadCoords (im); // report a failure for this image
    377       return;
    378     }
    379     if (fabs(dD) > 2.0) {
    380       fprintf (stderr, "*");
    381       setBadCoords (im); // report a failure for this image
    382       return;
     391    // NOTE: This should never happen, or our StarMap tests are not working
     392    if (fabs(dR) > 1.5*ADDSTAR_RADIUS) {
     393      fprintf (stderr, "measurement is far from average location (R): %f %f (%f %f)\n", catalog[c].average[n].R, catalog[c].average[n].D, dR, dD);
     394      dump_measures (&catalog[c].average[n], catalog[c].measure);
     395      // abort ();
     396    }
     397    if (fabs(dD) > 1.5*ADDSTAR_RADIUS) {
     398      fprintf (stderr, "measurement is far from average location (D): %f %f (%f %f)\n", catalog[c].average[n].R, catalog[c].average[n].D, dR, dD);
     399      dump_measures (&catalog[c].average[n], catalog[c].measure);
     400      // abort ();
    383401    }
    384402
    385403    // complain if the new location is far from the old location
    386     if (fabs(catalog[c].measure[m].dR - dR) > 2.0) {
    387       fprintf (stderr, "@");
    388       setBadCoords (im); // report a failure for this image
    389       return;
    390     }
    391     if (fabs(catalog[c].measure[m].dD - dD) > 2.0) {
    392       fprintf (stderr, "#");
    393       setBadCoords (im); // report a failure for this image
    394       return;
     404    if (fabs(catalog[c].measure[m].dR - dR) > DPOS_MAX_ASEC) {
     405      fprintf (stderr, "measurement is far from original location (R): %f %f (%f %f)\n", catalog[c].average[n].R, catalog[c].average[n].D, dR, dD);
     406      dump_measures (&catalog[c].average[n], catalog[c].measure);
     407      // abort();
     408    }
     409    if (fabs(catalog[c].measure[m].dD - dD) > DPOS_MAX_ASEC) {
     410      fprintf (stderr, "measurement is far from original location (D): %f %f (%f %f)\n", catalog[c].average[n].R, catalog[c].average[n].D, dR, dD);
     411      dump_measures (&catalog[c].average[n], catalog[c].measure);
     412      // abort();
    395413    }
    396414
     
    414432
    415433  saveOffsets (dPos, nPos, im);
     434
     435  // XXX this function should probably update the average positions as well.
    416436
    417437  return;
  • trunk/Ohana/src/relastro/src/UpdateChips.c

    r28241 r29001  
    3131    // FitChip does iterative, clipped fitting
    3232    // fprintf (stderr, "image "OFF_T_FMT" : Nstars: "OFF_T_FMT"\n",  i,  Nraw);
    33     if (!FitChip (raw, ref, Nraw, &image[i].coords)) {
    34       fprintf (stderr, "reject fit for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT"\n", image[i].name,  i,  Nraw);
     33    if (!FitChip (raw, ref, Nraw, &image[i])) {
     34      if (VERBOSE) fprintf (stderr, "reject fit for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT"\n", image[i].name,  i,  Nraw);
    3535      oldCoords = getCoords (i);
    3636      memcpy (&image[i].coords, oldCoords, sizeof(Coords));
     37      free (raw);
     38      free (ref);
     39      continue;
     40    }
     41
     42    if (!checkStarMap (i)) {
     43      if (VERBOSE) fprintf (stderr, "fit diverges too much for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT"\n", image[i].name,  i,  Nraw);
     44      oldCoords = getCoords (i);
     45      memcpy (&image[i].coords, oldCoords, sizeof(Coords));
     46      image[i].flags |= ID_IMAGE_ASTROM_POOR;
    3747    }
    3848
  • trunk/Ohana/src/relastro/src/UpdateMeasures.c

    r27435 r29001  
    55  off_t i, Nimage;
    66  Image *image;
     7
     8  int badImage =
     9    ID_IMAGE_ASTROM_NOCAL |
     10    ID_IMAGE_ASTROM_POOR |
     11    ID_IMAGE_ASTROM_FAIL |
     12    ID_IMAGE_ASTROM_SKIP |
     13    ID_IMAGE_ASTROM_FEW;
    714
    815  image = getimages (&Nimage);
     
    1320    if (!strcmp(&image[i].coords.ctype[4], "-DIS")) continue;
    1421
     22    // skip images that have failed solutions (divergent or otherwise)
     23    if (image[i].flags & badImage) continue;
     24
    1525    /* convert measure coordinates to raw entries */
    1626    fixImageRaw (catalog, Ncatalog, i);
  • trunk/Ohana/src/relastro/src/bcatalog.c

    r28241 r29001  
    4545      offset = catalog[0].average[i].measureOffset + j;
    4646     
    47       //filter objects based on user supplied criteria
     47      // filter objects based on user supplied criteria
    4848      if (!MeasFilterTest(&catalog[0].measure[offset])) {
    4949        catalog[0].measure[offset].dbFlags &= ~ID_MEAS_USED_CHIP;
     
    5151      }
    5252
    53       //filter out outliers
     53      // filter out outliers
    5454      if (FlagOutlier && (catalog[0].measure[offset].dbFlags & ID_MEAS_POOR_ASTROM)) {
    5555        catalog[0].measure[offset].dbFlags &= ~ID_MEAS_USED_CHIP;
  • trunk/Ohana/src/relastro/src/fitpoly.c

    r27581 r29001  
    110110  if (fit[0].Npts == 0) {
    111111    fprintf (stderr, "warning: no valid pts\n");
     112    return (FALSE);
    112113  }
    113114
     
    140141  }
    141142
    142   for (i = 0; i < fit[0].Nelems; i++) {
     143  for (i = 0; FALSE && (i < fit[0].Nelems); i++) {
    143144    ix = i % fit[0].Nterms;
    144145    iy = i / fit[0].Nterms;
    145     // fprintf (stderr, "x2 : x^%dy^%d: %10.4g    y2 : x^%dy^%d: %10.4g \n",
    146     // ix, iy, vector[i][0], ix, iy, vector[i][1]);
     146    fprintf (stderr, "x2 : x^%dy^%d: %10.4g    y2 : x^%dy^%d: %10.4g \n",
     147    ix, iy, vector[i][0], ix, iy, vector[i][1]);
    147148  }     
    148149 
     
    151152  }
    152153
    153   for (i = 0; i < fit[0].Nelems; i++) {
     154  for (i = 0; FALSE && i < fit[0].Nelems; i++) {
    154155    ix = i % fit[0].Nterms;
    155156    iy = i / fit[0].Nterms;
    156     // fprintf (stderr, "x2 : x^%dy^%d: %10.4g    y2 : x^%dy^%d: %10.4g \n",
    157     // ix, iy, vector[i][0], ix, iy, vector[i][1]);
     157    fprintf (stderr, "x2 : x^%dy^%d: %10.4g    y2 : x^%dy^%d: %10.4g \n",
     158    ix, iy, vector[i][0], ix, iy, vector[i][1]);
    158159  }     
    159160
     
    274275/* this should only apply to the polynomial, not the projection terms */
    275276/* compare with psastro supporting code */
    276 int fit_apply_coords (CoordFit *fit, Coords *coords) {
     277int fit_apply_coords (CoordFit *fit, Coords *coords, int keepRef) {
    277278
    278279  double Xo, Yo, R1, R2;
    279280  CoordFit *modfit;
    280281
    281   /* I have L,M = fit(X,Y). set corresponding terms for coords */
    282 
    283   // L = a[0][0] + a[1][0]x^1 y^0 + a[0][1] x^0 y^1 + ...
    284   // L = pc1_1*cd1*(x - cp1) + pc1_2*cd2*(y - cp2) + ...
    285 
    286   if (!CoordsGetCenter (fit, 0.001, &Xo, &Yo)) {
    287     fprintf (stderr, "failed to modify model\n");
    288     return (FALSE);
    289   }
    290   coords[0].crpix1 = Xo;
    291   coords[0].crpix2 = Yo;
    292  
    293   // resulting fit should have zero constant terms
    294   modfit = CoordsSetCenter (fit, Xo, Yo);
    295 
    296   /* we do not modify crval1,2: these are kept at the default values */
     282  if (keepRef) {
     283    // adjust crpix1,2 as needed:
     284    // L = a[0][0] + a[1][0]x^1 y^0 + a[0][1] x^0 y^1 + ...
     285    // L = pc1_1*cd1*(x - cp1) + pc1_2*cd2*(y - cp2) + ...
     286
     287    if (!CoordsGetCenter (fit, 0.001, &Xo, &Yo)) {
     288      fprintf (stderr, "failed to modify model\n");
     289      return (FALSE);
     290    }
     291    coords[0].crpix1 = Xo;
     292    coords[0].crpix2 = Yo;
     293    /* we do not modify crval1,2: these are kept at the default values */
     294 
     295    // resulting fit should have zero constant terms
     296    modfit = CoordsSetCenter (fit, Xo, Yo);
     297  } else {
     298    // L = a[0][0] + a[1][0]x^1 y^0 + a[0][1] x^0 y^1 + ...
     299    // P = cd1*x, Q = cd2*y
     300    // L = pc1_1*P + pc1_2*Q + ...
     301
     302    /* modify crval1,2: these are kept at the default values */
     303
     304    coords[0].crpix1 = 0.0;
     305    coords[0].crpix2 = 0.0;
     306    modfit = fit;
     307  }
    297308
    298309  // set cdelt1, cdelt2
     
    331342    coords[0].polyterms[6][1] = modfit[0].yfit[0][3]*R2*R2*R2;
    332343  }
    333 
    334   fit_free (modfit);
     344 
     345  if (keepRef) {
     346    fit_free (modfit);
     347  } else {
     348    fit_apply (fit, &coords[0].crval1, &coords[0].crval2, coords[0].crpix1, coords[0].crpix2);
     349  }
    335350  /* keep the order and type from initial values */
    336351 
  • trunk/Ohana/src/relastro/src/initialize.c

    r28184 r29001  
    100100  initstats (STATMODE);
    101101
    102   // IMAGE_BAD = ID_IMAGE_POOR | ID_IMAGE_FEW | ID_IMAGE_SKIP;
     102  // IMAGE_BAD = ID_IMAGE_ASTROM_POOR | ID_IMAGE_ASTROM_FEW | ID_IMAGE_ASTROM_SKIP;
    103103  // STAR_BAD  = ID_STAR_POOR | ID_STAR_FEW;
    104104  // MEAS_BAD  = ID_MEAS_NOCAL | ID_MEAS_POOR_ASTROM | ID_MEAS_SKIP_ASTROM | ID_MEAS_AREA;
  • trunk/Ohana/src/relastro/src/load_catalogs.c

    r24308 r29001  
    99
    1010  ALLOCATE (catalog, Catalog, skylist[0].Nregions);
     11
     12  initStarMaps();
    1113
    1214  // load data from each region file, only use bright stars
     
    3436      FlagOutliers(&tcatalog);
    3537    }
     38
     39    updateStarMaps (&tcatalog);
    3640
    3741    // select only the brighter stars
  • trunk/Ohana/src/relastro/src/load_images.c

    r27581 r29001  
    3333  // convert database table to internal structure
    3434  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     35  if (!image) {
     36      fprintf (stderr, "ERROR: failed to read images\n");
     37      exit (2);
     38  }
     39
    3540  MARKTIME("  convert image table: %f sec\n", dtime);
    3641
     
    5257  return (skylist);
    5358}
     59
     60int reload_images (FITS_DB *db) {
     61
     62  Image     *image;
     63  off_t     Nimage, Nx, i;
     64  VTable    *vtable;
     65
     66  image = getimages (&Nimage);
     67
     68  vtable = &db[0].vtable;
     69
     70  gfits_scan (vtable[0].header, "NAXIS1", OFF_T_FMT, 1,  &Nx);
     71  for (i = 0; i < Nimage; i++) {
     72    memcpy (vtable[0].buffer[i], &image[i], Nx);
     73  }
     74  return (TRUE);
     75}
  • trunk/Ohana/src/relastro/src/mkpolyterm.c

    r27581 r29001  
    6666      Xo -= beta[0][0];
    6767      Yo -= beta[1][0];
     68
    6869      dPos = hypot(beta[0][0], beta[1][0]);
    6970      if (i == 0) {
  • trunk/Ohana/src/relastro/src/relastro.c

    r28184 r29001  
    11# include "relastro.h"
    2 
    3 # define MARKTIME(MSG,...) { \
    4   float dtime; \
    5   gettimeofday (&stop, (void *) NULL); \
    6   dtime = DTIME (stop, start); \
    7   fprintf (stderr, MSG, __VA_ARGS__); }
    82
    93int main (int argc, char **argv) {
     
    4943
    5044  /* load catalog data from region files : subselect high-quality measurements */
     45  // XXX pass in the image table
     46  // XXX who carries the image grid?
    5147  catalog = load_catalogs (skylist, &Ncatalog, TRUE);
    5248  MARKTIME("load catalog data: %f sec\n", dtime);
     
    6359    // plot_mosaic_fields (catalog);
    6460  }
     61
     62  // set test points based on the starmap
     63  createStarMapPoints();
    6564
    6665  /* major modes */
     
    9897  freeImageBins (1);
    9998
     99  reload_images (&db);
     100   
    100101  // iterate over catalogs to make detection coordinates consistant
    101102  UpdateObjectOffsets (skylist);
    102103
    103104  // iterate over catalogs to make detection coordinates consistant
    104   FixProblemImages (skylist);
     105  // FixProblemImages (skylist);
    105106
    106107  // save the updated image parameters
  • trunk/Ohana/src/relastro/src/select_images.c

    r28241 r29001  
    2828  double *RmaxSky;
    2929  off_t *index;
     30
     31  int badImage =
     32    ID_IMAGE_ASTROM_POOR |
     33    ID_IMAGE_ASTROM_FAIL |
     34    ID_IMAGE_ASTROM_FEW;
    3035
    3136  if (skylist[0].Nregions < 1) {
     
    171176      image[nimage] = timage[i];
    172177      /* always allow 'few' images to succeed, if possible */
    173       if (image[nimage].flags & ID_IMAGE_FEW) {
    174         image[nimage].flags &= ~(ID_IMAGE_FEW | ID_IMAGE_POOR);
     178      if (image[nimage].flags & ID_IMAGE_ASTROM_FEW) {
     179        image[nimage].flags &= ~ID_IMAGE_ASTROM_FEW;
    175180      }
    176181      if (RESET) {
     
    178183        assignMcal (&image[nimage], (double *) NULL, -1);
    179184        image[nimage].dMcal = NAN;
    180         image[nimage].flags &= ~ID_IMAGE_POOR;
     185        image[nimage].flags &= ~badImage;
    181186      }
    182187      line_number[nimage] = i;
  • trunk/Ohana/src/relphot/src/ImageOps.c

    r28241 r29001  
    323323    /* on PoorImages run, skip good images */
    324324    if (PoorImages) {
    325       bad = image[i].flags & (ID_IMAGE_FEW | ID_IMAGE_POOR | ID_IMAGE_SKIP);
     325      bad = image[i].flags & (ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_POOR | ID_IMAGE_PHOTOM_SKIP);
    326326      if (!bad) continue;
    327327    }     
     
    369369      mark = (N < IMAGE_TOOFEW) || (N < IMAGE_GOOD_FRACTION*Nlist[i]);
    370370      if (mark) {
    371         image[i].flags |= ID_IMAGE_FEW;
     371        image[i].flags |= ID_IMAGE_PHOTOM_FEW;
    372372        Nfew ++;
    373373      } else {
    374         image[i].flags &= ~ID_IMAGE_FEW;
     374        image[i].flags &= ~ID_IMAGE_PHOTOM_FEW;
    375375      }     
    376376    }
     
    387387
    388388  if (PoorImages) {
    389     IMAGE_BAD = ID_IMAGE_POOR | ID_IMAGE_FEW | ID_IMAGE_SKIP;
     389    IMAGE_BAD = ID_IMAGE_PHOTOM_POOR | ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_SKIP;
    390390    STAR_BAD  = ID_STAR_POOR | ID_STAR_FEW;
    391391    MEAS_BAD  = ID_MEAS_NOCAL | ID_MEAS_POOR_PHOTOM | ID_MEAS_SKIP_PHOTOM | ID_MEAS_AREA;
     
    429429  for (i = 0; i < Nimage; i++) {
    430430    mark = FALSE;
    431     image[i].flags &= ~ID_IMAGE_POOR;
     431    image[i].flags &= ~ID_IMAGE_PHOTOM_POOR;
    432432    mark = (image[i].dMcal > MaxScatter) || (fabs(image[i].Mcal - MedOffset) > MaxOffset);
    433433    if (mark) {
    434434      Nmark ++;
    435       image[i].flags |= ID_IMAGE_POOR;
     435      image[i].flags |= ID_IMAGE_PHOTOM_POOR;
    436436    } else {
    437       image[i].flags &= ~ID_IMAGE_POOR;
     437      image[i].flags &= ~ID_IMAGE_PHOTOM_POOR;
    438438    }
    439439  }
  • trunk/Ohana/src/relphot/src/MosaicOps.c

    r28241 r29001  
    189189      image[im].dMcal = mosaic[i].dMcal;
    190190      image[im].Xm = mosaic[i].Xm;
    191       image[im].flags |= (mosaic[i].flags & ID_IMAGE_FEW);
    192       image[im].flags |= (mosaic[i].flags & ID_IMAGE_POOR);
     191      image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_FEW);
     192      image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_POOR);
    193193    }
    194194  }     
     
    351351    /* on PoorImages run, skip good images */
    352352    if (PoorImages) {
    353       bad = mosaic[i].flags & (ID_IMAGE_FEW | ID_IMAGE_POOR | ID_IMAGE_SKIP);
     353      bad = mosaic[i].flags & (ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_POOR | ID_IMAGE_PHOTOM_SKIP);
    354354      if (!bad) continue;
    355355    }     
     
    401401      if (mark) {
    402402        fprintf (stderr, "marked mosaic %s ("OFF_T_FMT"), ("OFF_T_FMT" < %d) || ("OFF_T_FMT" < %f*"OFF_T_FMT")\n", image[imlist[i][0]].name,  i,  N, IMAGE_TOOFEW,  N, IMAGE_GOOD_FRACTION,  Nlist[i]);
    403         mosaic[i].flags |= ID_IMAGE_FEW;
     403        mosaic[i].flags |= ID_IMAGE_PHOTOM_FEW;
    404404        Nfew ++;
    405405      } else {
    406         mosaic[i].flags &= ~ID_IMAGE_FEW;
     406        mosaic[i].flags &= ~ID_IMAGE_PHOTOM_FEW;
    407407      }
    408408    }
     
    421421
    422422  if (PoorImages) {
    423     IMAGE_BAD = ID_IMAGE_POOR | ID_IMAGE_FEW | ID_IMAGE_SKIP;
     423    IMAGE_BAD = ID_IMAGE_PHOTOM_POOR | ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_SKIP;
    424424    STAR_BAD  = ID_STAR_POOR | ID_STAR_FEW;
    425425    MEAS_BAD  = ID_MEAS_NOCAL | ID_MEAS_POOR_PHOTOM | ID_MEAS_SKIP_PHOTOM | ID_MEAS_AREA;
     
    593593    if (mark) {
    594594      Nmark ++;
    595       mosaic[i].flags |= ID_IMAGE_POOR;
     595      mosaic[i].flags |= ID_IMAGE_PHOTOM_POOR;
    596596    } else {
    597       mosaic[i].flags &= ~ID_IMAGE_POOR;
     597      mosaic[i].flags &= ~ID_IMAGE_PHOTOM_POOR;
    598598    }
    599599  }
  • trunk/Ohana/src/relphot/src/StarOps.c

    r28241 r29001  
    188188  StatType stats;
    189189  PhotCode *code;
     190  DVOAverageFlags flagBits;
     191
     192  flagBits = ID_OBJ_EXT | ID_OBJ_EXT_ALT | ID_OBJ_GOOD | ID_OBJ_GOOD_ALT;
    190193
    191194  // pre-allocate a list for stats purposes
     
    281284        }
    282285
     286        // we attempt to set a few flags here; reset those bits before trying:
     287        catalog[i].average[j].flags &= ~flagBits;
     288
    283289        if (nEXT && (nEXT > nPSF)) {
    284           catalog[i].average[j].flags |= 0x00010000;
     290          catalog[i].average[j].flags |= ID_OBJ_EXT;
    285291        }
    286292        if (goodPS1) {
    287           catalog[i].average[j].flags |= 0x00020000;
     293          catalog[i].average[j].flags |= ID_OBJ_GOOD;
    288294        }
    289295        if (Galaxy2MASS) {
    290           catalog[i].average[j].flags |= 0x00040000;
     296          catalog[i].average[j].flags |= ID_OBJ_EXT_ALT;
    291297        }
    292298        if (good2MASS) {
    293           catalog[i].average[j].flags |= 0x00080000;
     299          catalog[i].average[j].flags |= ID_OBJ_GOOD_ALT;
    294300        }
    295301      }
     
    302308}
    303309
    304 /* set measure.Mcal for all measures except ID_MEAS_NOCAL and ID_IMAGE_NOCAL */
     310/* set measure.Mcal for all measures except ID_MEAS_NOCAL and ID_IMAGE_PHOTOM_NOCAL */
    305311int setMcalOutput (Catalog *catalog, int Ncatalog) {
    306312
     
    310316
    311317  MEAS_BAD = ID_MEAS_NOCAL;
    312   IMAGE_BAD = ID_IMAGE_NOCAL;
     318  IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL;
    313319
    314320  for (i = 0; i < Ncatalog; i++) {
     
    470476      /* apply to list of all relevant measurements, including IMAGE_POOR & IMAGE_FEW */
    471477      image_bad = IMAGE_BAD;
    472       IMAGE_BAD = ID_IMAGE_NOCAL;
     478      IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL;
    473479      m = catalog[i].average[j].measureOffset;
    474480      N = 0;
  • trunk/Ohana/src/relphot/src/initialize.c

    r17242 r29001  
    2727  initstats (STATMODE);
    2828
    29   IMAGE_BAD = ID_IMAGE_POOR | ID_IMAGE_FEW | ID_IMAGE_SKIP;
     29  IMAGE_BAD = ID_IMAGE_PHOTOM_POOR | ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_SKIP;
    3030  STAR_BAD  = ID_STAR_POOR | ID_STAR_FEW;
    3131  MEAS_BAD  = ID_MEAS_NOCAL | ID_MEAS_POOR_PHOTOM | ID_MEAS_SKIP_PHOTOM | ID_MEAS_AREA;
  • trunk/Ohana/src/relphot/src/load_images.c

    r28241 r29001  
    2525  // convert database table to internal structure
    2626  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     27  if (!image) {
     28      fprintf (stderr, "ERROR: failed to read images\n");
     29      exit (2);
     30  }
    2731
    2832  // select the images which overlap the selected sky regions
  • trunk/Ohana/src/relphot/src/select_images.c

    r28241 r29001  
    157157      image[nimage] = timage[i];
    158158      /* always allow 'few' images to succeed, if possible */
    159       if (image[nimage].flags & ID_IMAGE_FEW) {
    160         image[nimage].flags &= ~(ID_IMAGE_FEW | ID_IMAGE_POOR);
     159      if (image[nimage].flags & ID_IMAGE_PHOTOM_FEW) {
     160        image[nimage].flags &= ~(ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_POOR);
    161161      }
    162162      if (RESET) {
    163163        assignMcal (&image[nimage], (double *) NULL, -1);
    164164        image[nimage].dMcal = NAN;
    165         image[nimage].flags &= ~ID_IMAGE_POOR;
     165        image[nimage].flags &= ~ID_IMAGE_PHOTOM_POOR;
    166166      }
    167167      line_number[nimage] = i;
  • trunk/Ohana/src/relphot/src/setMrelFinal.c

    r28241 r29001  
    7575
    7676  /* allow measures from images marked POOR and FEW */
    77   if (pass >= 3) IMAGE_BAD = ID_IMAGE_NOCAL;
     77  if (pass >= 3) IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL;
    7878 
    7979  /* allow measures marked as outliers (POOR) and off image region (AREA) */
  • trunk/Ohana/src/uniphot/src/find_image_sgroups.c

    r27435 r29001  
    1313  imlink = *Imlink;
    1414  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     15  if (!image) {
     16      fprintf (stderr, "ERROR: failed to read images\n");
     17      exit (2);
     18  }
    1519
    1620  coords.crpix1 = coords.crpix2 = 0.0;
     
    2832  for (i = 0; i < Nimage; i++) {
    2933    if (imlink[i].sgroup != NULL) continue;
    30     if (image[i].flags & ID_IMAGE_NOCAL) continue;
     34    if (image[i].flags & ID_IMAGE_PHOTOM_NOCAL) continue;
    3135
    3236    /* new sgroup, set ref coords */
     
    5357
    5458    for (j = 0; j < Nimage; j++) {
    55       if (image[j].flags & ID_IMAGE_NOCAL) continue;
     59      if (image[j].flags & ID_IMAGE_PHOTOM_NOCAL) continue;
    5660      if (imlink[j].sgroup != NULL) continue;
    5761
  • trunk/Ohana/src/uniphot/src/find_image_tgroups.c

    r27435 r29001  
    1212
    1313  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     14  if (!image) {
     15      fprintf (stderr, "ERROR: failed to read images\n");
     16      exit (2);
     17  }
     18
    1419  ALLOCATE (imlink, ImageLink, Nimage);
    1520
     
    6469      if (image[j].tzero < tmin[i]) continue;
    6570      if (image[j].tzero > tmax[i]) continue;
    66       if (image[j].flags & ID_IMAGE_NOCAL) continue;
     71      if (image[j].flags & ID_IMAGE_PHOTOM_NOCAL) continue;
    6772     
    6873      group[i].image[Nentry] = &image[j];
  • trunk/Ohana/src/uniphot/src/initialize.c

    r27790 r29001  
    1616  }
    1717
    18   IMAGE_BAD = ID_IMAGE_NOCAL | ID_IMAGE_POOR | ID_IMAGE_SKIP | ID_IMAGE_FEW;
     18  IMAGE_BAD = ID_IMAGE_PHOTOM_NOCAL | ID_IMAGE_PHOTOM_POOR | ID_IMAGE_PHOTOM_SKIP | ID_IMAGE_PHOTOM_FEW;
    1919
    2020  initstats (STATMODE);
  • trunk/Ohana/src/uniphot/src/load_images.c

    r28241 r29001  
    2222  /* use a vtable to keep the images to be calibrated */
    2323  image = gfits_table_get_Image (&db[0].ftable, Nimage, &db[0].swapped);
     24  if (!image) {
     25      fprintf (stderr, "ERROR: failed to read images\n");
     26      exit (2);
     27  }
    2428
    2529  fprintf (stderr, "loaded "OFF_T_FMT" images\n", *Nimage);
  • trunk/Ohana/src/uniphot/src/match_zpts_to_images.c

    r28717 r29001  
    7171    image[Ni].Mcal = SCALE*code[0].C - zpts[Nz].zpt;
    7272    image[Ni].dMcal = zpts[Nz].zpt_err;
    73     image[Ni].flags &= ~ID_IMAGE_NOCAL; // clear the NOCAL flag
     73    image[Ni].flags &= ~ID_IMAGE_PHOTOM_NOCAL; // clear the NOCAL flag
    7474    zpts[Nz].found = TRUE;
    7575    NImatch ++;
  • trunk/Ohana/src/uniphot/src/subset_images.c

    r27435 r29001  
    99  /* use a vtable to keep the images to be calibrated */
    1010  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     11  if (!image) {
     12      fprintf (stderr, "ERROR: failed to read images\n");
     13      exit (2);
     14  }
    1115
    1216  Nkeep = 0;
     
    1620  for (i = 0; i < Nimage; i++) {
    1721     
    18     image[i].flags |= ID_IMAGE_NOCAL;
     22    image[i].flags |= ID_IMAGE_PHOTOM_NOCAL;
    1923
    2024    /* select images by photcode */
     
    2731      if (image[i].tzero > TSTOP) continue;
    2832    }
    29     image[i].flags &= ~ID_IMAGE_NOCAL;
     33    image[i].flags &= ~ID_IMAGE_PHOTOM_NOCAL;
    3034    keep[Nkeep] = i;
    3135    Nkeep ++;
  • trunk/Ohana/src/uniphot/src/update.c

    r27435 r29001  
    1414
    1515  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
     16  if (!image) {
     17      fprintf (stderr, "ERROR: failed to read images\n");
     18      exit (2);
     19  }
    1620
    1721  /* clear the NOCAL flags */
    1822  for (i = 0; i < Nimage; i++) {
    19     image[i].flags &= ~ID_IMAGE_NOCAL;
     23    image[i].flags &= ~ID_IMAGE_PHOTOM_NOCAL;
    2024  }
    2125
Note: See TracChangeset for help on using the changeset viewer.