IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15732


Ignore:
Timestamp:
Dec 4, 2007, 12:32:27 PM (18 years ago)
Author:
eugene
Message:

various changes to support the reworked dvo_catalog apis; most important is the better tracking of the disk and memory elements of each table

Location:
branches/eam_branch_20071130/Ohana/src
Files:
39 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branch_20071130/Ohana/src/addstar/src/SEDfit.c

    r15509 r15732  
    210210    }
    211211  }
    212   outcat[0].Naverage = Nave;
    213   outcat[0].Nmeasure = Nmeas;
     212  outcat[0].Naverage  = Nave;
     213  outcat[0].Nmeasure  = Nmeas;
     214  outcat[0].Nsecf_mem = Nave*Nsec;
    214215 
    215216  free (sourceValue.mags);
  • branches/eam_branch_20071130/Ohana/src/addstar/src/UpdateDatabase_Image.c

    r15723 r15732  
    1313
    1414  catalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    15   if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MEAS_META | LOAD_MISS | LOAD_SECF;
     15  if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;
    1616 
    1717  // XXX this is probably not needed anymore
     
    4949    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
    5050    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    51     if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MEAS_META | LOAD_MISS | LOAD_SECF;
     51    if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;
    5252
    5353    // an error exit status here is a significant error
     
    5757    }
    5858
    59     // Nave_disk == 0 implies an empty catalog file
     59    // Naves_disk == 0 implies an empty catalog file
    6060    // for only_match, skip empty catalogs
    61     if ((catalog.Nave_disk == 0) && options[0].only_match) {
     61    if ((catalog.Naves_disk == 0) && options[0].only_match) {
    6262      dvo_catalog_unlock (&catalog);
    6363      dvo_catalog_free (&catalog);
     
    7373    if (!options[0].only_images) {
    7474      SetProtect (TRUE);
    75       dvo_catalog_save (&catalog, VERBOSE);
     75      if (options[0].update) {
     76        dvo_catalog_update (&catalog, VERBOSE);
     77      } else {
     78        dvo_catalog_save (&catalog, VERBOSE);
     79      }
    7680      SetProtect (FALSE);
    7781    }
  • branches/eam_branch_20071130/Ohana/src/addstar/src/UpdateDatabase_Refcat.c

    r14401 r15732  
    3737    catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
    3838    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    39     if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MEAS_META | LOAD_MISS | LOAD_SECF;
     39    if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;
    4040 
    4141    // an error exit status here is a significant error
     
    4545    }
    4646
    47     // Nave_disk == 0 implies an empty catalog file
     47    // Naves_disk == 0 implies an empty catalog file
    4848    // for only_match, skip empty catalogs
    49     if ((catalog.Nave_disk == 0) && options[0].only_match) {
     49    if ((catalog.Naves_disk == 0) && options[0].only_match) {
    5050      dvo_catalog_unlock (&catalog);
    5151      dvo_catalog_free (&catalog);
     
    6262    if (!options[0].only_images) {
    6363      SetProtect (TRUE);
    64       dvo_catalog_save (&catalog, VERBOSE);
     64      if (options[0].update) {
     65        dvo_catalog_update (&catalog, VERBOSE);
     66      } else {
     67        dvo_catalog_save (&catalog, VERBOSE);
     68      }
    6569      SetProtect (FALSE);
    6670    }
  • branches/eam_branch_20071130/Ohana/src/addstar/src/UpdateDatabase_Reflist.c

    r14401 r15732  
    3737    catalog.catmode   = dvo_catalog_catmode (CATMODE);      // set the default catmode from config data
    3838    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
    39     if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MEAS_META | LOAD_MISS | LOAD_SECF;
     39    if (options[0].update) catalog.catflags = LOAD_AVES | LOAD_MISS | LOAD_SECF;
    4040
    4141    // an error exit status here is a significant error
     
    4646
    4747    /* for only_match, skip empty catalogs XXX EAM : this leaves behind empty files */
    48     if ((catalog.Nave_disk == 0) && options[0].only_match) {
     48    if ((catalog.Naves_disk == 0) && options[0].only_match) {
    4949      dvo_catalog_unlock (&catalog);
    5050      dvo_catalog_free (&catalog);
     
    5858    if (!options[0].only_images) {
    5959      SetProtect (TRUE);
    60       dvo_catalog_save (&catalog, VERBOSE);
     60      if (options[0].update) {
     61        dvo_catalog_update (&catalog, VERBOSE);
     62      } else {
     63        dvo_catalog_save (&catalog, VERBOSE);
     64      }
    6165      SetProtect (FALSE);
    6266    }
  • branches/eam_branch_20071130/Ohana/src/addstar/src/addstar.c

    r15731 r15732  
    105105    }
    106106
    107     // Nave_disk == 0 implies an empty catalog file
     107    // Naves_disk == 0 implies an empty catalog file
    108108    // for only_match, skip empty catalogs
    109     if ((catalog.Nave_disk == 0) && options.only_match) {
     109    if ((catalog.Naves_disk == 0) && options.only_match) {
    110110      dvo_catalog_unlock (&catalog);
    111111      dvo_catalog_free (&catalog);
  • branches/eam_branch_20071130/Ohana/src/addstar/src/find_matches.c

    r15509 r15732  
    361361  catalog[0].Naverage = Nave;
    362362  catalog[0].Nmeasure = Nmeas;
     363  catalog[0].Nsecf_mem = Nave*Nsecfilt;
    363364  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmatch);
    364365
  • branches/eam_branch_20071130/Ohana/src/addstar/src/find_matches_closest.c

    r15509 r15732  
    362362  catalog[0].Naverage = Nave;
    363363  catalog[0].Nmeasure = Nmeas;
     364  catalog[0].Nsecf_mem = Nave*Nsecfilt;
    364365  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas: %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmatch);
    365366
  • branches/eam_branch_20071130/Ohana/src/addstar/src/find_matches_refstars.c

    r15509 r15732  
    372372  catalog[0].Nmeasure = Nmeas;
    373373  catalog[0].Nmissing = Nmiss;
     374  catalog[0].Nsecf_mem = Nave*Nsecfilt;
    374375  if (VERBOSE) fprintf (stderr, "Nstars, Nave, Nmeas, Nmiss: %d %d %d %d, (%d matches)\n", Nstars, Nave, Nmeas, Nmiss, Nmatch);
    375376  return (Nmatch);
  • branches/eam_branch_20071130/Ohana/src/addstar/src/load2mass_catalog.c

    r15509 r15732  
    7979  catalog[0].Naverage = Nave;
    8080  catalog[0].Nmeasure = Nmeas;
     81  catalog[0].Nsecf_mem = Nave*Nsec;
    8182  return (TRUE);
    8283}
  • branches/eam_branch_20071130/Ohana/src/addstar/src/sedstar.c

    r8361 r15732  
    3434    }
    3535
    36     // Nave_disk == 0 implies an empty catalog file
    37     if ((incatalog.Nave_disk == 0) && options.only_match) {
     36    // Naves_disk == 0 implies an empty catalog file
     37    if ((incatalog.Naves_disk == 0) && options.only_match) {
    3838      if (VERBOSE) fprintf (stderr, "skipping empty region\n");
    3939      dvo_catalog_unlock (&incatalog);
  • branches/eam_branch_20071130/Ohana/src/delstar/src/delete_imagefile.c

    r12332 r15732  
    3333      exit (2);
    3434    }
    35     if (!catalog.Nave_disk) {
     35    if (!catalog.Naves_disk) {
    3636      dvo_catalog_unlock (&catalog);
    3737      dvo_catalog_free (&catalog);
  • branches/eam_branch_20071130/Ohana/src/delstar/src/delete_imagename.c

    r14590 r15732  
    4444        exit (2);
    4545      }
    46       if (!catalog.Nave_disk) {
     46      if (!catalog.Naves_disk) {
    4747        dvo_catalog_unlock (&catalog);
    4848        dvo_catalog_free (&catalog);
  • branches/eam_branch_20071130/Ohana/src/delstar/src/delete_orphans.c

    r8386 r15732  
    252252  catalog.Nmeasure = Nmeas;
    253253  catalog.Nmissing = Nmiss;
     254  catalog.Nsecf_mem = Nave*Nsecfilt;
     255
    254256  if (VERBOSE) fprintf (stderr, "  ending with Nave, Nmeas, Nmiss: %d %d %d\n", Nave, Nmeas, Nmiss);
    255257
  • branches/eam_branch_20071130/Ohana/src/delstar/src/delete_times.c

    r14401 r15732  
    6464      exit (2);
    6565    }
    66     if (!catalog.Nave_disk) {
     66    if (!catalog.Naves_disk) {
    6767      dvo_catalog_unlock (&catalog);
    6868      dvo_catalog_free (&catalog);
  • branches/eam_branch_20071130/Ohana/src/delstar/src/find_matches.c

    r12332 r15732  
    234234  catalog[0].Nmeasure = Nmeas;
    235235  catalog[0].Nmissing = Nmiss;
     236  catalog[0].Nsecf_mem = Nave*Nsecfilt;
     237
    236238  if (VERBOSE) fprintf (stderr, "  ending with Nave, Nmeas, Nmiss: %d %d %d\n", Nave, Nmeas, Nmiss);
    237239
  • branches/eam_branch_20071130/Ohana/src/dvosplit/src/split_averages.c

    r15729 r15732  
    99  AveLinks *avelinks;
    1010
    11   ALLOCATE (outref, int, incatalog[0].Nave_disk);
    12   ALLOCATE (outcat, int, incatalog[0].Nave_disk);
     11  ALLOCATE (outref, int, incatalog[0].Naves_disk);
     12  ALLOCATE (outcat, int, incatalog[0].Naves_disk);
    1313
    1414  Nsecfilt = GetPhotcodeNsecfilt ();
     
    2323  // split out the average & secfilt entries:
    2424  incatalog[0].catflags = LOAD_AVES | LOAD_SECF;
    25   Nblocks = incatalog[0].Nave_disk / NROWS;
     25  Nblocks = incatalog[0].Naves_disk / NROWS;
    2626  for (block = 0; block < Nblocks; block++) {
    2727
  • branches/eam_branch_20071130/Ohana/src/gastro/src/getptolemy.c

    r12332 r15732  
    3636    dvo_catalog_unlock (&catalog);
    3737
    38     // Nave_disk == 0 implies an empty catalog file
     38    // Naves_disk == 0 implies an empty catalog file
    3939    // for only_match, skip empty catalogs
    40     if (!catalog.Nave_disk) {
     40    if (!catalog.Naves_disk) {
    4141      dvo_catalog_free (&catalog);
    4242      continue;
  • branches/eam_branch_20071130/Ohana/src/gastro2/src/getptolemy.c

    r12332 r15732  
    3838    dvo_catalog_unlock (&catalog);
    3939
    40     // Nave_disk == 0 implies an empty catalog file
     40    // Naves_disk == 0 implies an empty catalog file
    4141    // for only_match, skip empty catalogs
    42     if (!catalog.Nave_disk) {
     42    if (!catalog.Naves_disk) {
    4343      dvo_catalog_free (&catalog);
    4444      continue;
  • branches/eam_branch_20071130/Ohana/src/getstar/src/getstar.c

    r15540 r15732  
    4747          exit (2);
    4848        }
    49         if (!catalog.Nave_disk) {
     49        if (!catalog.Naves_disk) {
    5050          dvo_catalog_unlock (&catalog);
    5151          dvo_catalog_free (&catalog);
     
    7878        }
    7979        /* skip empty catalogs */
    80         if (!catalog.Nave_disk) continue;
     80        if (!catalog.Naves_disk) continue;
    8181        stars = select_by_image (&catalog, &image, 0, 0, stars, &Nstars);
    8282      }
  • branches/eam_branch_20071130/Ohana/src/getstar/src/select_by_region.c

    r15543 r15732  
    9191  output[0].Naverage = Nave;
    9292  output[0].Nmeasure = Nmeas;
     93  output[0].Nsecf_mem = Nave*Nsecfilt;
     94
    9395  fprintf (stderr, "output catalog has %d stars (%d measures, %d secfilt)\n",
    9496           output[0].Naverage, output[0].Nmeasure, output[0].Nsecfilt);
  • branches/eam_branch_20071130/Ohana/src/libdvo/src/dvo_catalog.c

    r15731 r15732  
    357357    catalog[0].secfilt = outsec;
    358358    catalog[0].Nsecfilt = Nsecfilt;
     359    catalog[0].Nsecf_mem = Nsecfilt * catalog[0].Naverage;
    359360  }
    360361  return (TRUE);
     
    410411    case DVO_MODE_MEF:
    411412      if (VERBOSE) fprintf (stderr, "reading catalog (mode DVO_MODE_MEF)\n");
    412       dvo_catalog_load_segment_mef (catalog, VERBOSE, start, Nrows);
     413      fprintf (stderr, "cannot do this in mef mode\n");
     414      // dvo_catalog_load_segment_mef (catalog, VERBOSE, start, Nrows);
    413415      break;
    414416    case DVO_MODE_SPLIT:
  • branches/eam_branch_20071130/Ohana/src/libdvo/src/dvo_catalog_mef.c

    r15728 r15732  
    5959    /* old versions of DVO stored one of the average magnitudes in Average. we save this if needed */
    6060    catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary);
    61     if (Naverage != catalog[0].Naverage) {
     61    if (Naverage != catalog[0].Naves_disk) {
    6262      fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers (%d vs %d)\n", Naverage, catalog[0].Naves_disk);
    6363    }
     
    8686    }
    8787    catalog[0].measure = FtableToMeasure (&ftable, &catalog[0].Nmeasure, &catalog[0].catformat);
    88     if (Nmeasure != catalog[0].Nmeasure) {
    89       fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%d vs %d)\n", Nmeasure, catalog[0].Nmeasure);
     88    if (Nmeasure != catalog[0].Nmeas_disk) {
     89      fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%d vs %d)\n", Nmeasure, catalog[0].Nmeas_disk);
    9090    }
    9191    catalog[0].Nmeasure = catalog[0].Nmeas_disk;
     
    112112    /* no conversions currently defined */
    113113    catalog[0].missing = gfits_table_get_Missing (&ftable, &catalog[0].Nmissing, NULL);
    114     if (Nmissing != catalog[0].Nmissing) {
    115       fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%d vs %d)\n", Nmissing, catalog[0].Nmissing);
     114    if (Nmissing != catalog[0].Nmiss_disk) {
     115      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%d vs %d)\n", Nmissing, catalog[0].Nmiss_disk);
    116116    }
    117117    catalog[0].Nmissing = catalog[0].Nmiss_disk;
  • branches/eam_branch_20071130/Ohana/src/libdvo/src/dvo_catalog_raw.c

    r15731 r15732  
    171171      }         
    172172      catalog[0].Nsecfilt = Nsecfilt;
     173      catalog[0].Nsecf_mem = Ntotal;
    173174      free (primary);
    174175    }
  • branches/eam_branch_20071130/Ohana/src/libdvo/src/dvo_catalog_split.c

    r15731 r15732  
    4040  *mySecfilt = secfilt;
    4141  *myNsecfilt = Nsecfilt;
     42}
     43
     44int dvo_catalog_primary_to_secfilt (Catalog *catalog, SecFilt *primary, int Naves) {
     45
     46  int Ntmpfilt, Nsecfilt, Ntotal, i, j;
     47  SecFilt *tmpfilt;
     48
     49  tmpfilt  = catalog[0].secfilt;
     50  Ntmpfilt = catalog[0].Nsecfilt;
     51
     52  // we do NOT modify Nsecf_disk; this operation only modifies in in-memory values
     53
     54  catalog[0].Nsecfilt ++;
     55  Nsecfilt = catalog[0].Nsecfilt;
     56  Ntotal = Nsecfilt * Naves;
     57
     58  catalog[0].Nsecf_mem = Ntotal;
     59
     60  ALLOCATE (catalog[0].secfilt, SecFilt, Ntotal);
     61  for (i = 0; i < Naves; i++) {
     62    catalog[0].secfilt[i*Nsecfilt + 0] = primary[i];
     63    for (j = 0; j < Ntmpfilt; j++) {
     64      catalog[0].secfilt[i*Nsecfilt + j + 1] = tmpfilt[i*Ntmpfilt + j];
     65    }
     66  }             
     67  free (primary);
     68  return (TRUE);
    4269}
    4370
     
    279306      fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%d vs %d)\n", Nitems, catalog[0].Nsecf_disk);
    280307    }
     308    catalog[0].Nsecf_mem = catalog[0].Nsecf_disk;
     309    catalog[0].Nsecf_off = 0;
    281310
    282311    /* if primary is defined, we were supplied with one additional average magnitude from Average
    283312       we need to interleave these magnitudes with the secfilt entries just loaded */
    284313    if (primary != NULL) {
    285       int Ntmpfilt, Ntotal, i, j;
    286       SecFilt *tmpfilt;
    287       tmpfilt  = catalog[0].secfilt;
    288       Ntmpfilt = catalog[0].Nsecfilt;
    289 
    290       catalog[0].Nsecfilt ++;
    291       catalog[0].Nsecf_disk = catalog[0].Nsecfilt * catalog[0].Naves_disk;
    292       Nsecfilt = catalog[0].Nsecfilt;
    293 
    294       ALLOCATE (catalog[0].secfilt, SecFilt, catalog[0].Nsecf_disk);
    295       for (i = 0; i < catalog[0].Naves_disk; i++) {
    296         catalog[0].secfilt[i*Nsecfilt + 0] = primary[i];
    297         for (j = 0; j < Ntmpfilt; j++) {
    298           catalog[0].secfilt[i*Nsecfilt + j + 1] = tmpfilt[i*Ntmpfilt + j];
    299         }
    300       }         
    301       free (primary);
     314      // this modifies catalog.Nsecf_mem,Nsecfilt
     315      dvo_catalog_primary_to_secfilt (catalog, primary, catalog[0].Naves_disk);
    302316    }
    303     catalog[0].Nsecf_mem = catalog[0].Nsecf_disk;
    304     catalog[0].Nsecf_off = 0;
    305317  } else {
    306318    if (primary != NULL) {
    307319      free (primary);
    308320      catalog[0].Nsecfilt ++;
    309       catalog[0].Nsecf_disk =  catalog[0].Nsecfilt * catalog[0].Naves_disk;
    310321    }
    311322    gfits_create_header (&catalog[0].secfilt_catalog[0].header);
     
    326337  Header header;
    327338  Matrix matrix;
    328   VTable vtable;
     339  FTable ftable;
    329340  SecFilt *primary;
    330341
    331   /* vtable header storage for below */
    332   vtable.header = &header;
    333   vtable.buffer = NULL;
     342  /* ftable header storage for below */
     343  ftable.header = &header;
     344  ftable.buffer = NULL;
    334345  header.buffer = NULL;
    335346
     
    351362    }
    352363    /* read Average table data : format is irrelevant here */
    353     if (!gfits_fread_vtable_range (catalog[0].f, &vtable, start, Nrows)) {
     364    if (!gfits_fread_ftable_range (catalog[0].f, &ftable, start, Nrows)) {
    354365      if (VERBOSE) fprintf (stderr, "can't read table average data");
    355366      return (FALSE);
     
    359370     * one of the average magnitudes in Average.  We save this in case it is needed below.  NOTE:
    360371     * primary is only used if we read in the secfilt table, otherwise it should be freed */
    361 
    362     // XXX Vtable version is needed (merge Ftable and Vtable versions?)
    363     catalog[0].average = VtableToAverage (&vtable, &Naverage, &catalog[0].catformat, &primary);
    364 
    365     // XXX validate the sizes?  start + Nrows < Naves_disk (no other constraints)
     372    catalog[0].average = FtableToAverage (&ftable, &Naverage, &catalog[0].catformat, &primary);
    366373    if (Naverage != Nrows) {
     374      // XXX this is only an error if Nrows or more are available...
     375      // XXX allow Nrows to go beyond end of the data?
    367376      fprintf (stderr, "Warning: mismatch between Naverage in PHU and Table headers (%d vs %d)\n", Naverage, Nrows);
    368377    }
     
    387396    }
    388397    /* read Measure table data : format is irrelevant here */
    389     if (!gfits_fread_vtable_range (subcat[0].f, &vtable, start, Nrows)) {
     398    if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {
    390399      if (VERBOSE) fprintf (stderr, "can't read table measure data");
    391400      return (FALSE);
     
    393402
    394403    Nexpect = Nrows * Nsecfilt;
    395     catalog[0].secfilt = VtableToSecFilt (&vtable, &Nitems, &catalog[0].catformat);
     404    catalog[0].secfilt = FtableToSecFilt (&ftable, &Nitems, &catalog[0].catformat);
    396405    if (Nitems != Nexpect) {
    397       fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%d vs %d)\n", Nitems, catalog[0].Nsecf_disk);
    398     }
     406      fprintf (stderr, "Warning: mismatch between Nsecfilt items in PHU and Table headers (%d vs %d)\n", Nitems, Nexpect);
     407    }
     408    catalog[0].Nsecf_mem = Nrows * Nsecfilt;
     409    catalog[0].Nsecf_off = start * Nsecfilt;
    399410
    400411    /* if primary is defined, we were supplied with one additional average magnitude from Average
    401412       we need to interleave these magnitudes with the secfilt entries just loaded */
    402413    if (primary != NULL) {
    403       int Ntmpfilt, i, j;
    404       SecFilt *tmpfilt;
    405       tmpfilt  = catalog[0].secfilt;
    406       Ntmpfilt = catalog[0].Nsecfilt;
    407 
    408       catalog[0].Nsecfilt ++;
    409       catalog[0].Nsecf_disk = catalog[0].Nsecfilt * catalog[0].Naves_disk;
    410       Nsecfilt = catalog[0].Nsecfilt;
    411 
    412       // the loaded average rows correspond to the loaded secfilt rows
    413       // supplement with the loaded primary secfilt data
    414       Nexpect = Nrows * Nsecfilt;
    415       ALLOCATE (catalog[0].secfilt, SecFilt, Nexpect);
    416       for (i = 0; i < Nrows; i++) {
    417         catalog[0].secfilt[i*Nsecfilt + 0] = primary[i];
    418         for (j = 0; j < Ntmpfilt; j++) {
    419           catalog[0].secfilt[i*Nsecfilt + j + 1] = tmpfilt[i*Ntmpfilt + j];
    420         }
    421       }         
    422       free (primary);
     414      dvo_catalog_primary_to_secfilt (catalog, primary, Nrows);
    423415    }
    424416    gfits_free_header (&header);
    425417    gfits_free_matrix (&matrix);
    426     catalog[0].Nsecf_mem = Nexpect;
    427     catalog[0].Nsecf_off = start * Nsecfilt;
    428 
    429     // CAREFUL: note that Nsecf_disk and Nsecf_off are set to the values if there were no primary data
    430418  }
    431419
     
    448436    }
    449437    /* read Measure table data : format is irrelevant here */
    450     if (!gfits_fread_vtable_range (subcat[0].f, &vtable, start, Nrows)) {
     438    if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {
    451439      if (VERBOSE) fprintf (stderr, "can't read table measure data");
    452440      return (FALSE);
     
    454442
    455443    /* convert data format to internal : returns number of row read in Nmeasure */
    456     catalog[0].measure = VtableToMeasure (&vtable, &Nmeasure, &catalog[0].catformat);
     444    catalog[0].measure = FtableToMeasure (&ftable, &Nmeasure, &catalog[0].catformat);
    457445    if (Nmeasure != Nrows) {
    458446      fprintf (stderr, "Warning: mismatch between Nmeasure in PHU and Table headers (%d vs %d)\n", Nmeasure, Nrows);
     
    482470    }
    483471    /* read Missing table data : format is irrelevant here */
    484     if (!gfits_fread_vtable_range (subcat[0].f, &vtable, start, Nrows)) {
     472    if (!gfits_fread_ftable_range (subcat[0].f, &ftable, start, Nrows)) {
    485473      if (VERBOSE) fprintf (stderr, "can't read table missing data");
    486474      return (FALSE);
    487475    }
    488476
    489     /* convert data format to internal : returns number of row read in Nmissing */
    490     catalog[0].missing = VtableToMissing (&vtable, &Nmissing, &catalog[0].catformat);
     477    /* no conversions currently defined : this just does the byte swap */
     478    catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);
    491479    if (Nmissing != Nrows) {
    492480      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers (%d vs %d)\n", Nmissing, Nrows);
     
    568556    }
    569557
    570     if (!dvo_catalog_save_subset (catalog, ftable, start, Nrows, catalog[0].Naves_disk, Naves_disk_new)) {
     558    if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Naves_disk, Naves_disk_new)) {
    571559      fprintf (stderr, "failure writing Average table\n");
    572560      goto failure;
     
    606594
    607595    // write out Measure table
    608     if (!dvo_catalog_save_subset (catalog[0].measure_catalog, ftable, start, Nrows, catalog[0].Nmeas_disk, Nmeas_disk_new)) {
     596    if (!dvo_catalog_save_subcat (catalog[0].measure_catalog, &ftable, start, Nrows, catalog[0].Nmeas_disk, Nmeas_disk_new)) {
    609597      fprintf (stderr, "trouble writing Measure table\n");
    610598      goto failure;
     
    629617
    630618    // write out Missing table (must write out entire table)
    631     if (!dvo_catalog_save_subset (catalog[0].missing_catalog, ftable, 0, catalog[0].Nmissing, catalog[0].Nmissing, catalog[0].Nmissing)) {
     619    if (!dvo_catalog_save_subcat (catalog[0].missing_catalog, &ftable, 0, catalog[0].Nmissing, catalog[0].Nmissing, catalog[0].Nmissing)) {
    632620      fprintf (stderr, "trouble writing Missing Table\n");
    633621      goto failure;
     
    649637    assert (first < Nitems);
    650638    assert (catalog[0].Nsecf_disk >= catalog[0].Nsecf_off);
     639    // XXX check these for consistency...
    651640
    652641    // convert to external table format
     
    654643
    655644    // write out SecFilt table
    656     if (!dvo_catalog_save_subset (catalog[0].secfilt_catalog, ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) {
     645    if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) {
    657646      fprintf (stderr, "failure writing SecFilt table\n");
    658647      goto failure;
     
    688677  Header header;
    689678  FTable ftable;
    690   VTable vtable;
    691679  Catalog *catfile;
    692680  SecFilt *primary, *secfilt;
     
    750738    }
    751739
    752     if (!dvo_catalog_save_subset (catalog, ftable, start, Nrows, catalog[0].Naves_disk, Naves_disk_new)) {
     740    if (!dvo_catalog_save_subcat (catalog, &ftable, start, Nrows, catalog[0].Naves_disk, Naves_disk_new)) {
    753741      fprintf (stderr, "failure writing Average table\n");
    754742      goto failure;
     
    788776
    789777    // write out Measure table
    790     if (!dvo_catalog_save_subset (catalog[0].measure_catalog, ftable, start, Nrows, catalog[0].Nmeas_disk, Nmeas_disk_new)) {
     778    if (!dvo_catalog_save_subcat (catalog[0].measure_catalog, &ftable, start, Nrows, catalog[0].Nmeas_disk, Nmeas_disk_new)) {
    791779      fprintf (stderr, "trouble writing Measure table\n");
    792780      goto failure;
     
    815803
    816804    // write out Missing table (must write out entire table)
    817     if (!dvo_catalog_save_subset (catalog[0].missing_catalog, ftable, 0, catalog[0].Nmissing, catalog[0].Nmissing, catalog[0].Nmissing)) {
     805    if (!dvo_catalog_save_subcat (catalog[0].missing_catalog, &ftable, 0, catalog[0].Nmissing, catalog[0].Nmissing, catalog[0].Nmissing)) {
    818806      fprintf (stderr, "trouble writing Missing Table\n");
    819807      goto failure;
     
    840828
    841829    // write out SecFilt table
    842     if (!dvo_catalog_save_subset (catalog[0].secfilt_catalog, ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) {
     830    if (!dvo_catalog_save_subcat (catalog[0].secfilt_catalog, &ftable, start, Nrows, catalog[0].Nsecf_disk, Nsecf_disk_new)) {
    843831      fprintf (stderr, "failure writing SecFilt table\n");
    844832      goto failure;
     
    875863/* XXX EAM : update is not efficient.  MeasureToFtable should only
    876864   convert the new rows (Nmeas_disk to Nmeasure). the resulting
    877    table represents the end rows of the vtable.  we need to define
     865   table represents the end rows of the ftable.  we need to define
    878866   the vtable based on the ftable, but with Ny = Nmeasure */ 
    879867 
  • branches/eam_branch_20071130/Ohana/src/libfits/include/gfitsio.h

    r15731 r15732  
    172172int     gfits_fread_ftable             PROTO((FILE *f, FTable *ftable, char *extname));
    173173int     gfits_fread_ftable_data        PROTO((FILE *f, FTable *ftable));
     174int     gfits_fread_ftable_range       PROTO((FILE *f, FTable *ftable, int start, int Nrows));
    174175int     gfits_fread_vtable             PROTO((FILE *f, VTable *vtable, char *extname, int Nrow, int *row));
    175176int     gfits_fread_vtable_range       PROTO((FILE *f, VTable *vtable, int start, int Nrows));
  • branches/eam_branch_20071130/Ohana/src/libfits/table/F_read_T.c

    r15487 r15732  
    6363  }
    6464  table[0].size = Nbytes;
     65  return (TRUE);
     66}       
     67
     68/*********************** fits read ftable data ***********************************/
     69int gfits_fread_ftable_range (FILE *f, FTable *table, int start, int Nrows) {
     70
     71  int Nbytes, Nread, Nskip, Nx, Ny;
     72  char *buffer;
     73
     74  /* find disk table size */
     75  Nx = table[0].header[0].Naxis[0];
     76  Ny = table[0].header[0].Naxis[1];
     77
     78  if (start < 0) return (FALSE);
     79  if (start + Nrows >= Ny) return (FALSE);
     80 
     81  Nskip = start * Nx;
     82  Nbytes = Nrows * Nx;
     83  ALLOCATE (table[0].buffer, char, MAX (Nbytes, 1));
     84
     85  fseek (f, Nskip, SEEK_CUR);
     86  Nread = fread (buffer, sizeof (char), Nbytes, f);
     87  if (Nread != Nbytes) {
     88    free (buffer);
     89    return (FALSE);
     90  }
     91
     92  /* modify structure and header to match actual read rows Ny */
     93  table[0].header[0].Naxis[1] = Nrows;
     94  gfits_modify (table[0].header, "NAXIS2",  "%d", 1, Nrows);
     95  table[0].size = gfits_data_size (table[0].header);
     96
    6597  return (TRUE);
    6698}       
  • branches/eam_branch_20071130/Ohana/src/markrock/src/markrock.c

    r15723 r15732  
    4545    exit (2);
    4646  }
    47   if (catalog.Nave_disk) {
     47  if (catalog.Naves_disk) {
    4848    dvo_catalog_unlock (&catalog);
    4949    dvo_catalog_free (&catalog);
  • branches/eam_branch_20071130/Ohana/src/markstar/src/markstar.c

    r8386 r15732  
    4848    exit (2);
    4949  }
    50   if (!catalog.Nave_disk) {
     50  if (!catalog.Naves_disk) {
    5151    dvo_catalog_unlock (&catalog);
    5252    dvo_catalog_free (&catalog);
  • branches/eam_branch_20071130/Ohana/src/mosastro/src/getptolemy.c

    r12332 r15732  
    3636    dvo_catalog_unlock (&catalog);
    3737
    38     // Nave_disk == 0 implies an empty catalog file
     38    // Naves_disk == 0 implies an empty catalog file
    3939    // for only_match, skip empty catalogs
    40     if (!catalog.Nave_disk) {
     40    if (!catalog.Naves_disk) {
    4141      dvo_catalog_free (&catalog);
    4242      continue;
  • branches/eam_branch_20071130/Ohana/src/photdbc/src/join_stars.c

    r12332 r15732  
    172172 
    173173  catalog[0].Naverage = Naves;
     174  catalog[0].Nsecf_mem = Naves*catalog[0].Nsecfilt;
    174175}
    175176
     
    181182   generates a new SecFilt table with empty values
    182183   does NOT update magnitudes
     184   output measure table is the same size as the input measure table
     185   (measures are just moved around).  thus, catalog[0].Nmeasure does not change.
    183186*/   
    184187   
  • branches/eam_branch_20071130/Ohana/src/photdbc/src/make_subcatalog.c

    r12332 r15732  
    1010
    1111  Nsecfilt = GetPhotcodeNsecfilt ();
     12  assert (catalog[0].Nsecfilt == Nsecfilt);
    1213
    1314  /* we are moving only the subset of measurements from catalog[0] to subcatalog[0] */
     
    9697  subcatalog[0].Naverage = Naverage;
    9798  subcatalog[0].Nmeasure = Nmeasure;
    98   subcatalog[0].Nsecfilt = catalog[0].Nsecfilt;
     99  subcatalog[0].Nsecfilt = Nsecfilt;
     100  subcatalog[0].Nsecf_mem = Naverage * Nsecfilt;
    99101
    100102  // XXX for now, don't copy the missing entries (these should be re-computed)
  • branches/eam_branch_20071130/Ohana/src/photdbc/src/photdbc.c

    r8701 r15732  
    3434    }
    3535    // skip empty input catalogs
    36     if (!incatalog.Nave_disk) {
     36    if (!incatalog.Naves_disk) {
    3737      dvo_catalog_unlock (&incatalog);
    3838      dvo_catalog_free (&incatalog);
  • branches/eam_branch_20071130/Ohana/src/relastro/src/bcatalog.c

    r15723 r15732  
    66  int NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm;
    77  float mag;
     8
     9  // XXX PhotNsec as a global is a bad idea; either get it from catalog
     10  // or get it from:
     11  // Nsecfilt = GetPhotcodeNsecfilt ();
     12  // assert (catalog[0].Nsecfilt == Nsecfilt);
    813
    914  /* we are moving only the subset of measurements from catalog[0] to subcatalog[0] */
     
    104109  subcatalog[0].Nmeasure = Nmeasure;
    105110  subcatalog[0].Nsecfilt = catalog[0].Nsecfilt;
     111  subcatalog[0].Nsecf_mem = Naverage * PhotNsec;
     112  assert (PhotNsec == catalog[0].Nsecfilt);
    106113
    107114  if (VERBOSE) {
  • branches/eam_branch_20071130/Ohana/src/relastro/src/load_catalogs.c

    r15723 r15732  
    2626      exit (1);
    2727    }
    28     if (VERBOSE && !pcatalog[0].Nave_disk) fprintf (stderr, "no data in %s, skipping\n", pcatalog[0].filename);
     28    if (VERBOSE && !pcatalog[0].Naves_disk) fprintf (stderr, "no data in %s, skipping\n", pcatalog[0].filename);
    2929
    3030    // select only the brighter stars
  • branches/eam_branch_20071130/Ohana/src/relastro/src/reload_catalogs.c

    r12332 r15732  
    2929      exit (1);
    3030    }
    31     if (VERBOSE && (catalog.Nave_disk == 0)) {
     31    if (VERBOSE && (catalog.Naves_disk == 0)) {
    3232        fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    3333        dvo_catalog_unlock (&catalog);
  • branches/eam_branch_20071130/Ohana/src/relphot/src/bcatalog.c

    r15634 r15732  
    66  int NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm;
    77  float mag;
     8
     9  // XXX PhotNsec as a global is a bad idea; either get it from catalog
     10  // or get it from:
     11  // Nsecfilt = GetPhotcodeNsecfilt ();
     12  // assert (catalog[0].Nsecfilt == Nsecfilt);
    813
    914  /* we are moving only the subset of measurements from catalog[0] to subcatalog[0] */
     
    105110  subcatalog[0].Nmeasure = Nmeasure;
    106111  subcatalog[0].Nsecfilt = catalog[0].Nsecfilt;
     112  subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt;
     113  assert (PhotNsec == catalog[0].Nsecfilt);
    107114
    108115  if (VERBOSE) {
  • branches/eam_branch_20071130/Ohana/src/relphot/src/load_catalogs.c

    r9633 r15732  
    2424      exit (1);
    2525    }
    26     if (VERBOSE && !tcatalog.Nave_disk) fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename);
     26    if (VERBOSE && !tcatalog.Naves_disk) fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename);
    2727
    2828    // select only the brighter stars
  • branches/eam_branch_20071130/Ohana/src/relphot/src/reload_catalogs.c

    r9633 r15732  
    3030      exit (1);
    3131    }
    32     if (VERBOSE && (catalog.Nave_disk == 0)) {
     32    if (VERBOSE && (catalog.Naves_disk == 0)) {
    3333        fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
    3434        dvo_catalog_unlock (&catalog);
  • branches/eam_branch_20071130/Ohana/src/uniphot/src/update.c

    r12332 r15732  
    5252      exit (2);
    5353    }
    54     if (!catalog.Nave_disk) {
     54    if (!catalog.Naves_disk) {
    5555      dvo_catalog_unlock (&catalog);
    5656      dvo_catalog_free (&catalog);
Note: See TracChangeset for help on using the changeset viewer.