IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12391


Ignore:
Timestamp:
Mar 9, 2007, 3:19:11 PM (19 years ago)
Author:
eugene
Message:

inconsistency with NSECFILT in output tables for ELIXIR and LONEOS formats

Location:
trunk/Ohana/src/libdvo/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c

    r12332 r12391  
    170170  }
    171171
    172   /* make sure header is consistent with data */
    173   gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
    174   gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure);
    175   gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
    176   gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);
    177   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
    178 
    179   f = catalog[0].f;
    180   /* rewind file pointers and truncate */
    181   fseek (f, 0, SEEK_SET);
    182   ftruncate (fileno (catalog[0].f), 0);
    183   ftable.header = &header;
    184 
    185   /* write table PHU header */
    186   if (!gfits_fwrite_header  (catalog[0].f, &catalog[0].header)) {
    187     fprintf (stderr, "can't write primary header");
    188     return (FALSE);
    189   }
    190 
    191   /* this is probably a NOP, do I have to keep it in? */
    192   gfits_create_matrix (&catalog[0].header, &matrix);
    193   if (!gfits_fwrite_matrix  (catalog[0].f, &matrix)) {
    194     fprintf (stderr, "can't write primary matrix");
    195     return (FALSE);
    196   }
    197   gfits_free_matrix (&matrix);
    198 
    199172  /* for the appropriate types, pull out the first secfilt and pass to AverageToFtable as primary */
    200173  if ((catalog[0].catformat == DVO_FORMAT_ELIXIR) || // special case for ELIXIR
     
    218191  }
    219192
     193  /* make sure header is consistent with data */
     194  gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
     195  gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure);
     196  gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
     197  gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
     198  gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
     199
     200  f = catalog[0].f;
     201  /* rewind file pointers and truncate */
     202  fseek (f, 0, SEEK_SET);
     203  ftruncate (fileno (catalog[0].f), 0);
     204  ftable.header = &header;
     205
     206  /* write table PHU header */
     207  if (!gfits_fwrite_header  (catalog[0].f, &catalog[0].header)) {
     208    fprintf (stderr, "can't write primary header");
     209    goto failure;
     210  }
     211
     212  /* this is probably a NOP, do I have to keep it in? */
     213  gfits_create_matrix (&catalog[0].header, &matrix);
     214  if (!gfits_fwrite_matrix  (catalog[0].f, &matrix)) {
     215    fprintf (stderr, "can't write primary matrix");
     216    goto failure;
     217  }
     218  gfits_free_matrix (&matrix);
     219
    220220  /* write out Average table (convert to FITS table format) */
    221221  AverageToFtable (&ftable, catalog[0].average, catalog[0].Naverage, catalog[0].catformat, primary);
    222222  if (!gfits_fwrite_Theader (catalog[0].f, &header)) {
    223223    fprintf (stderr, "can't write table header");
    224     return (FALSE);
     224    goto failure;
    225225  }
    226226  if (!gfits_fwrite_table (catalog[0].f, &ftable)) {
    227227    fprintf (stderr, "can't write table data");
    228     return (FALSE);
     228    goto failure;
    229229  }
    230230  gfits_free_table (&ftable);
     
    235235  if (!gfits_fwrite_Theader (catalog[0].f, &header)) {
    236236    fprintf (stderr, "can't write table header");
    237     return (FALSE);
     237    goto failure;
    238238  }
    239239  if (!gfits_fwrite_table (catalog[0].f, &ftable)) {
    240240    fprintf (stderr, "can't write table data");
    241     return (FALSE);
     241    goto failure;
    242242  }
    243243  gfits_free_table (&ftable);
     
    248248  if (!gfits_fwrite_Theader (catalog[0].f, &header)) {
    249249    fprintf (stderr, "can't write table header");
    250     return (FALSE);
     250    goto failure;
    251251  }
    252252  if (!gfits_fwrite_table (catalog[0].f, &ftable)) {
    253253    fprintf (stderr, "can't write table data");
    254     return (FALSE);
     254    goto failure;
    255255  }
    256256  gfits_free_table (&ftable);
     
    262262  if (!gfits_fwrite_Theader (catalog[0].f, &header)) {
    263263    fprintf (stderr, "can't write table header");
    264     return (FALSE);
     264    goto failure;
    265265  }
    266266  if (!gfits_fwrite_table (catalog[0].f, &ftable)) {
    267267    fprintf (stderr, "can't write table data");
    268     return (FALSE);
     268    goto failure;
    269269  }
    270270  gfits_free_table (&ftable);
     
    276276    free (secfilt);
    277277  }
    278 
    279278  return (TRUE);
     279
     280failure:
     281  /* free temp storage */
     282  if (primary != NULL) {
     283    free (primary);
     284    free (secfilt);
     285  }
     286  return (FALSE);
    280287}
    281288
  • trunk/Ohana/src/libdvo/src/dvo_catalog_raw.c

    r12332 r12391  
    230230  }
    231231
    232   /* make sure header is consistent with data */
    233   gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
    234   gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure);
    235   gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
    236   gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);
    237 
    238   /* specify the appropriate data format */
    239   if (catalog[0].catformat == DVO_FORMAT_INTERNAL)  gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "INTERNAL");
    240   if (catalog[0].catformat == DVO_FORMAT_LONEOS)    gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "LONEOS");
    241   if (catalog[0].catformat == DVO_FORMAT_ELIXIR)    gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "ELIXIR");
    242   if (catalog[0].catformat == DVO_FORMAT_PANSTARRS_DEV_0) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PANSTARRS_DEV_0");
    243   // if (catalog[0].catformat == DVO_FORMAT_PANSTARRS) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PANSTARRS");
    244   // if (catalog[0].catformat == DVO_FORMAT_PMTEST)    gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PMTEST");
    245 
    246   /* rewind file pointers and truncate file */
    247   f = catalog[0].f;
    248   fseek (f, 0, SEEK_SET);
    249   ftruncate (fileno (catalog[0].f), 0);
    250 
    251   /* write header data (use gfits_write_header?) */
    252   nitems = fwrite (catalog[0].header.buffer, 1, catalog[0].header.size, f);
    253   if (nitems != catalog[0].header.size) {
    254     if (VERBOSE) fprintf (stderr, "failed to write header\n");
    255     return (FALSE);
    256   }
    257 
    258232  /* for the appropriate types, pull out the first secfilt and pass to WriteRawAverage as primary */
    259233  if ((catalog[0].catformat == DVO_FORMAT_ELIXIR) || // special case for ELIXIR
     
    277251  }
    278252
     253  /* make sure header is consistent with data */
     254  gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
     255  gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure);
     256  gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
     257  gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);
     258
     259  /* specify the appropriate data format */
     260  if (catalog[0].catformat == DVO_FORMAT_INTERNAL)  gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "INTERNAL");
     261  if (catalog[0].catformat == DVO_FORMAT_LONEOS)    gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "LONEOS");
     262  if (catalog[0].catformat == DVO_FORMAT_ELIXIR)    gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "ELIXIR");
     263  if (catalog[0].catformat == DVO_FORMAT_PANSTARRS_DEV_0) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PANSTARRS_DEV_0");
     264  // if (catalog[0].catformat == DVO_FORMAT_PANSTARRS) gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PANSTARRS");
     265  // if (catalog[0].catformat == DVO_FORMAT_PMTEST)    gfits_modify (&catalog[0].header, "FORMAT", "%s", 1, "PMTEST");
     266
     267  /* rewind file pointers and truncate file */
     268  f = catalog[0].f;
     269  fseek (f, 0, SEEK_SET);
     270  ftruncate (fileno (catalog[0].f), 0);
     271
     272  /* write header data (use gfits_write_header?) */
     273  nitems = fwrite (catalog[0].header.buffer, 1, catalog[0].header.size, f);
     274  if (nitems != catalog[0].header.size) {
     275    if (VERBOSE) fprintf (stderr, "failed to write header\n");
     276    goto failure;
     277  }
     278
    279279  /* write averages and measures */
    280280  WriteRawAverage (f, catalog[0].average, catalog[0].Naverage, catalog[0].catformat, primary);
     
    287287  if (nitems != Nitems) {
    288288    if (VERBOSE) fprintf (stderr, "failed to write catalog file missing %s\n", catalog[0].filename);
    289     return (FALSE);
     289    goto failure;
    290290  }
    291291
     
    298298    free (secfilt);
    299299  }
    300 
    301300  return (TRUE);
     301
     302failure:
     303  /* free temp storage */
     304  if (primary != NULL) {
     305    free (primary);
     306    free (secfilt);
     307  }
     308  return (FALSE);
    302309}
    303310
  • trunk/Ohana/src/libdvo/src/dvo_catalog_split.c

    r12332 r12391  
    298298  }
    299299
    300   /* make sure header is consistent with data */
    301   gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
    302   gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure);
    303   gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
    304   gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);
    305   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
    306 
    307   /* rewind file pointers and truncate (file is still open) */
    308   fseek (catalog[0].f, 0, SEEK_SET);
    309 
    310   /* write table PHU header - always write this out */
    311   /* XXX EAM : check if disk file size has changed */
    312   if (!gfits_fwrite_header  (catalog[0].f, &catalog[0].header)) {
    313     fprintf (stderr, "can't write primary header");
    314     return (FALSE);
    315   }
    316 
    317   /* in split mode, we can save only part of the data */
    318 
    319300  /* for the appropriate types, pull out the first secfilt and pass to AverageToFtable as primary */
    320301  if ((catalog[0].catformat == DVO_FORMAT_ELIXIR) || // special case for ELIXIR
     
    344325  }
    345326
     327  /* make sure header is consistent with data */
     328  gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
     329  gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure);
     330  gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
     331  gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
     332  gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
     333
     334  /* rewind file pointers and truncate (file is still open) */
     335  fseek (catalog[0].f, 0, SEEK_SET);
     336
     337  /* write table PHU header - always write this out */
     338  /* XXX EAM : check if disk file size has changed */
     339  if (!gfits_fwrite_header  (catalog[0].f, &catalog[0].header)) {
     340    fprintf (stderr, "can't write primary header");
     341    goto failure;
     342  }
     343
     344  /* in split mode, we can save only part of the data */
     345
    346346  /*** Average Table ***/
    347347
     
    353353    if (!gfits_fwrite_matrix  (catalog[0].f, &matrix)) {
    354354      fprintf (stderr, "can't write primary matrix");
    355       return (FALSE);
     355      goto failure;
    356356    }
    357357    gfits_free_matrix (&matrix);
     
    361361    if (!gfits_fwrite_Theader (catalog[0].f, &header)) {
    362362      fprintf (stderr, "can't write table header");
    363       return (FALSE);
     363      goto failure;
    364364    }
    365365    if (!gfits_fwrite_table (catalog[0].f, &ftable)) {
    366366      fprintf (stderr, "can't write table data");
    367       return (FALSE);
     367      goto failure;
    368368    }
    369369    gfits_free_table (&ftable);
     
    390390    if (!gfits_fwrite_header  (catfile[0].f, &catfile[0].header)) {
    391391      fprintf (stderr, "can't write primary header");
    392       return (FALSE);
     392      goto failure;
    393393    }
    394394
     
    397397    if (!gfits_fwrite_matrix  (catfile[0].f, &matrix)) {
    398398      fprintf (stderr, "can't write primary matrix");
    399       return (FALSE);
     399      goto failure;
    400400    }
    401401    gfits_free_matrix (&matrix);
     
    405405    if (!gfits_fwrite_Theader (catfile[0].f, &header)) {
    406406      fprintf (stderr, "can't write table header");
    407       return (FALSE);
     407      goto failure;
    408408    }
    409409    if (!gfits_fwrite_table (catfile[0].f, &ftable)) {
    410410      fprintf (stderr, "can't write table data");
    411       return (FALSE);
     411      goto failure;
    412412    }
    413413    gfits_free_table (&ftable);
     
    428428    if (!gfits_fwrite_header  (catfile[0].f, &catfile[0].header)) {
    429429      fprintf (stderr, "can't write primary header");
    430       return (FALSE);
     430      goto failure;
    431431    }
    432432
     
    435435    if (!gfits_fwrite_matrix  (catfile[0].f, &matrix)) {
    436436      fprintf (stderr, "can't write primary matrix");
    437       return (FALSE);
     437      goto failure;
    438438    }
    439439    gfits_free_matrix (&matrix);
     
    443443    if (!gfits_fwrite_Theader (catfile[0].f, &header)) {
    444444      fprintf (stderr, "can't write table header");
    445       return (FALSE);
     445      goto failure;
    446446    }
    447447    if (!gfits_fwrite_table (catfile[0].f, &ftable)) {
    448448      fprintf (stderr, "can't write table data");
    449       return (FALSE);
     449      goto failure;
    450450    }
    451451    gfits_free_table (&ftable);
     
    466466    if (!gfits_fwrite_header  (catfile[0].f, &catfile[0].header)) {
    467467      fprintf (stderr, "can't write primary header");
    468       return (FALSE);
     468      goto failure;
    469469    }
    470470
     
    473473    if (!gfits_fwrite_matrix  (catfile[0].f, &matrix)) {
    474474      fprintf (stderr, "can't write primary matrix");
    475       return (FALSE);
     475      goto failure;
    476476    }
    477477    gfits_free_matrix (&matrix);
     
    482482    if (!gfits_fwrite_Theader (catfile[0].f, &header)) {
    483483      fprintf (stderr, "can't write table header");
    484       return (FALSE);
     484      goto failure;
    485485    }
    486486    if (!gfits_fwrite_table (catfile[0].f, &ftable)) {
    487487      fprintf (stderr, "can't write table data");
    488       return (FALSE);
     488      goto failure;
    489489    }
    490490    gfits_free_table (&ftable);
     
    499499
    500500  return (TRUE);
     501
     502failure:
     503  /* free temp storage */
     504  if (primary != NULL) {
     505    free (primary);
     506    free (secfilt);
     507  }
     508  return (FALSE);
    501509}
    502510
     
    524532    if (VERBOSE) fprintf (stderr, "no stars in catalog, skipping\n");
    525533    return (TRUE);
    526   }
    527 
    528   /* make sure header is consistent with data */
    529   gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
    530   gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure + catalog[0].Nmeas_off);
    531   gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
    532   gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, catalog[0].Nsecfilt);
    533   gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
    534 
    535   /* rewind file pointers and truncate (file is still open) */
    536   fseek (catalog[0].f, 0, SEEK_SET);
    537 
    538   /* write table PHU header - always write this out */
    539   /* XXX EAM : check if disk file size has changed */
    540   if (!gfits_fwrite_header  (catalog[0].f, &catalog[0].header)) {
    541     fprintf (stderr, "can't write primary header");
    542     return (FALSE);
    543534  }
    544535
     
    570561  }
    571562
     563  /* make sure header is consistent with data */
     564  gfits_modify (&catalog[0].header, "NSTARS",   "%d", 1, catalog[0].Naverage);
     565  gfits_modify (&catalog[0].header, "NMEAS",    "%d", 1, catalog[0].Nmeasure + catalog[0].Nmeas_off);
     566  gfits_modify (&catalog[0].header, "NMISS",    "%d", 1, catalog[0].Nmissing);
     567  gfits_modify (&catalog[0].header, "NSECFILT", "%d", 1, Nsecfilt);
     568  gfits_modify (&catalog[0].header, "EXTEND",   "%t", 1, TRUE);
     569
     570  /* rewind file pointers and truncate (file is still open) */
     571  fseek (catalog[0].f, 0, SEEK_SET);
     572
     573  /* write table PHU header - always write this out */
     574  /* XXX EAM : check if disk file size has changed */
     575  if (!gfits_fwrite_header  (catalog[0].f, &catalog[0].header)) {
     576    fprintf (stderr, "can't write primary header");
     577    goto failure;
     578  }
     579
    572580  /*** Average Table ***/
    573581  if (catalog[0].average != NULL) {
     
    587595    if (!gfits_fwrite_Theader (catalog[0].f, &header)) {
    588596      fprintf (stderr, "can't write table header");
    589       return (FALSE);
     597      goto failure;
    590598    }
    591599    if (!gfits_fwrite_vtable (catalog[0].f, &vtable)) {
    592600      fprintf (stderr, "can't write table data");
    593       return (FALSE);
     601      goto failure;
    594602    }
    595603    gfits_free_vtable (&vtable);
     
    637645    if (!gfits_fwrite_Theader (catfile[0].f, &header)) {
    638646      fprintf (stderr, "can't write table header");
    639       return (FALSE);
     647      goto failure;
    640648    }
    641649    if (!gfits_fwrite_vtable (catfile[0].f, &vtable)) {
    642650      fprintf (stderr, "can't write table data");
    643       return (FALSE);
     651      goto failure;
    644652    }
    645653    gfits_free_vtable (&vtable);
     
    663671    if (!gfits_fwrite_header  (catfile[0].f, &catfile[0].header)) {
    664672      fprintf (stderr, "can't write primary header");
    665       return (FALSE);
     673      goto failure;
    666674    }
    667675
     
    670678    if (!gfits_fwrite_matrix  (catfile[0].f, &matrix)) {
    671679      fprintf (stderr, "can't write primary matrix");
    672       return (FALSE);
     680      goto failure;
    673681    }
    674682    gfits_free_matrix (&matrix);
     
    678686    if (!gfits_fwrite_Theader (catfile[0].f, &header)) {
    679687      fprintf (stderr, "can't write table header");
    680       return (FALSE);
     688      goto failure;
    681689    }
    682690    if (!gfits_fwrite_table (catfile[0].f, &ftable)) {
    683691      fprintf (stderr, "can't write table data");
    684       return (FALSE);
     692      goto failure;
    685693    }
    686694    gfits_free_table (&ftable);
     
    709717    if (!gfits_fwrite_Theader (catfile[0].f, &header)) {
    710718      fprintf (stderr, "can't write table header");
    711       return (FALSE);
     719      goto failure;
    712720    }
    713721    if (!gfits_fwrite_vtable (catfile[0].f, &vtable)) {
    714722      fprintf (stderr, "can't write table data");
    715       return (FALSE);
     723      goto failure;
    716724    }
    717725    gfits_free_vtable (&vtable);
     
    727735
    728736  return (TRUE);
     737
     738failure:
     739  /* free temp storage */
     740  if (primary != NULL) {
     741    free (primary);
     742    free (secfilt);
     743  }
     744  return (FALSE);
    729745}
    730746
Note: See TracChangeset for help on using the changeset viewer.