IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 33221


Ignore:
Timestamp:
Feb 8, 2012, 10:30:30 AM (14 years ago)
Author:
eugene
Message:

when loading a catalog (but not loading average) read the format from the header

Location:
branches/eam_branches/ipp-20111122/Ohana/src/libdvo
Files:
5 edited

Legend:

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

    r33215 r33221  
    464464int WriteRawSecFilt (FILE *f, SecFilt *secfilt, off_t Nsecfilt, char format);
    465465
     466DVOTableFormat FtableGetFormat (FTable *ftable);
     467
    466468Average *FtableToAverage (FTable *ftable, off_t *Naverage, char *format, SecFilt **primary);
    467469Measure *FtableToMeasure (FTable *ftable, off_t *Nmeasure, char *format);
  • branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/dvo_catalog.c

    r31663 r33221  
    250250
    251251  dvo_catalog_init (catalog, FALSE);
     252
     253  // reset the file pointer in case we've already read some data
     254  fseeko (catalog[0].f, 0, SEEK_SET);
    252255
    253256  // load the main catalog header, determine characteristics
  • branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/dvo_catalog_mef.c

    r33215 r33221  
    33int dvo_catalog_load_mef (Catalog *catalog, int VERBOSE) {
    44 
     5  off_t Nbytes;
     6  off_t Naverage;
     7  off_t Nmeasure;
     8  off_t Nmissing;
     9  off_t Nitems, Nexpect;
    510  int Nsecfilt;
    6   off_t Nitems, Nbytes, Nexpect, Naverage, Nmeasure, Nmissing;
    7   FILE *f;
    811
    912  Header header;
    10   Matrix matrix;
    1113  FTable ftable;
    1214
    1315  SecFilt *primary = NULL;
    1416
    15   f = catalog[0].f;
    1617  ftable.header = &header;
    1718
    18   /* move pointer past header -- must be already read (load_catalog) */
    19   fseeko (f, catalog[0].header.datasize, SEEK_SET);
    20 
    21   /* matrix should be empty */
    22   if (!gfits_fread_matrix (f, &matrix, &catalog[0].header)) {
    23     if (VERBOSE) fprintf (stderr, "can't read primary matrix");
    24     return (FALSE);
    25   }
    2619  /* get the components from the header */
    2720  if (!gfits_scan (&catalog[0].header, "NSTARS",   OFF_T_FMT, 1,  &Naverage)) return (FALSE);
     
    5851  catalog[0].secfilt = NULL;
    5952
    60   /* validate table mode */
     53  /* validate table mode ?*/
     54
     55  /*** Average Table ***/
     56
     57  /* need to read the table header to determine format (whether or not we read averages) */
     58  /* move pointer past PHU header -- must be already read (load_catalog) */
     59  Nbytes = catalog[0].header.datasize + gfits_data_size (&catalog[0].header);
     60  fseeko (catalog[0].f, Nbytes, SEEK_SET);
    6161
    6262  /* read Average table header */
    63   if (!gfits_fread_header (f, &header)) {
     63  if (!gfits_fread_header (catalog[0].f, &header)) {
    6464    if (VERBOSE) fprintf (stderr, "can't read table average header");
    6565    return (FALSE);
    6666  }
     67
    6768  /* read Average table data (or skip) */
    6869  if (catalog[0].catflags & LOAD_AVES) {
    69     if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
     70    if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) {
    7071      if (VERBOSE) fprintf (stderr, "can't read table average data");
    7172      return (FALSE);
     
    7980    catalog[0].Naves_off = 0;
    8081  } else {
     82    catalog[0].catformat = FtableGetFormat (&ftable);
    8183    Nbytes = gfits_data_size (&header);
    82     fseeko (f, Nbytes, SEEK_CUR);
     84    fseeko (catalog[0].f, Nbytes, SEEK_CUR);
    8385    ALLOCATE (catalog[0].average, Average, 1);
    8486    catalog[0].Naverage = 0;
     
    8991
    9092  /* read Measure table header */
    91   if (!gfits_fread_header (f, &header)) {
     93  if (!gfits_fread_header (catalog[0].f, &header)) {
    9294    if (VERBOSE) fprintf (stderr, "can't read table measure header");
    9395    return (FALSE);
     
    9597  /* read Measure table data */
    9698  if (catalog[0].catflags & LOAD_MEAS) {
    97     if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
     99    if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) {
    98100      if (VERBOSE) fprintf (stderr, "can't read table measure data");
    99101      return (FALSE);
     
    107109  } else {
    108110    Nbytes = gfits_data_size (&header);
    109     fseeko (f, Nbytes, SEEK_CUR);
     111    fseeko (catalog[0].f, Nbytes, SEEK_CUR);
    110112    ALLOCATE (catalog[0].measure, Measure, 1);
    111113    catalog[0].Nmeasure = 0;
     
    114116
    115117  /* read Missing table header */
    116   if (!gfits_fread_header (f, &header)) {
     118  if (!gfits_fread_header (catalog[0].f, &header)) {
    117119    if (VERBOSE) fprintf (stderr, "can't read table missing header");
    118120    return (FALSE);
     
    120122  /* read Missing table data */
    121123  if (catalog[0].catflags & LOAD_MISS) {
    122     if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
     124    if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) {
    123125      if (VERBOSE) fprintf (stderr, "can't read table missing data");
    124126      return (FALSE);
     
    137139  } else {
    138140    Nbytes = gfits_data_size (&header);
    139     fseeko (f, Nbytes, SEEK_CUR);
     141    fseeko (catalog[0].f, Nbytes, SEEK_CUR);
    140142    ALLOCATE (catalog[0].missing, Missing, 1);
    141143    catalog[0].Nmissing = 0;
     
    144146
    145147  /* read secfilt table header */
    146   if (!gfits_fread_header (f, &header)) {
     148  if (!gfits_fread_header (catalog[0].f, &header)) {
    147149    if (VERBOSE) fprintf (stderr, "can't read table secfilt header");
    148150    return (FALSE);
     
    150152  /* read secfilt table data */
    151153  if (catalog[0].catflags & LOAD_SECF) {
    152     if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
     154    if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) {
    153155      if (VERBOSE) fprintf (stderr, "can't read table secfilt data");
    154156      return (FALSE);
     
    188190    /* no real need to skip the data array here... */
    189191    Nbytes = gfits_data_size (&header);
    190     fseeko (f, Nbytes, SEEK_CUR);
     192    fseeko (catalog[0].f, Nbytes, SEEK_CUR);
    191193    if (primary != NULL) {
    192194      free (primary);
  • branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/dvo_catalog_split.c

    r31663 r33221  
    160160
    161161  off_t Nbytes;
    162   off_t Naverage, Nmeasure, Nmissing;
     162  off_t Naverage;
     163  off_t Nmeasure;
     164  off_t Nmissing;
    163165  off_t Nitems;
    164166  int status, Nsecfilt;
     
    209211
    210212  /*** Average Table ***/
     213
     214  /* need to read the table header to determine format (whether or not we read averages) */
     215  /* move pointer past PHU header -- must be already read (load_catalog) */
     216  Nbytes = catalog[0].header.datasize + gfits_data_size (&catalog[0].header);
     217  fseeko (catalog[0].f, Nbytes, SEEK_SET);
     218
     219  /* read Average table header */
     220  if (!gfits_fread_header (catalog[0].f, &header)) {
     221    if (VERBOSE) fprintf (stderr, "can't read table average header");
     222    return (FALSE);
     223  }
    211224  if (catalog[0].catflags & LOAD_AVES) {
    212     /* move pointer past header -- must be already read (load_catalog) */
    213     Nbytes = catalog[0].header.datasize + gfits_data_size (&catalog[0].header);
    214     fseeko (catalog[0].f, Nbytes, SEEK_SET);
    215     /* read Average table header */
    216     if (!gfits_fread_header (catalog[0].f, &header)) {
    217       if (VERBOSE) fprintf (stderr, "can't read table average header");
    218       return (FALSE);
    219     }
    220225    /* read Average table data : format is irrelevant here */
    221226    if (!gfits_fread_ftable_data (catalog[0].f, &ftable, FALSE)) {
     
    234239    catalog[0].Naves_off = 0;
    235240  } else {
     241    catalog[0].catformat = FtableGetFormat (&ftable);
    236242    ALLOCATE (catalog[0].average, Average, 1);
    237243    catalog[0].Naverage = 0;
  • branches/eam_branches/ipp-20111122/Ohana/src/libdvo/src/dvo_convert.c

    r29001 r33221  
    1010/** this file might be more readable if I use macros for the repetative
    1111    constructions below **/
     12
     13DVOTableFormat FtableGetFormat (FTable *ftable) {
     14
     15  DVOTableFormat format;
     16  char extname[80];
     17
     18  /* read the format of this table */
     19  if (!gfits_scan (ftable[0].header, "EXTNAME", "%s", 1, extname)) {
     20    fprintf (stderr, "EXTNAME missing for average table\n");
     21    return (DVO_FORMAT_UNDEF);
     22  }
     23
     24  if (!strcmp (extname, "DVO_AVERAGE")) {
     25    format = DVO_FORMAT_INTERNAL;
     26    return (format);
     27  }
     28# define CONVERT_FORMAT(NAME, FORMAT)           \
     29  if (!strcmp (extname, NAME)) {                \
     30    format = DVO_FORMAT_##FORMAT;               \
     31    return (format); }
     32
     33  CONVERT_FORMAT ("DVO_AVERAGE_ELIXIR",          ELIXIR);
     34  CONVERT_FORMAT ("DVO_AVERAGE_LONEOS",          LONEOS);
     35  CONVERT_FORMAT ("DVO_AVERAGE_PANSTARRS_DEV_0", PANSTARRS_DEV_0);
     36  CONVERT_FORMAT ("DVO_AVERAGE_PANSTARRS_DEV_1", PANSTARRS_DEV_1);
     37  CONVERT_FORMAT ("DVO_AVERAGE_PS1_DEV_1",       PS1_DEV_1);
     38  CONVERT_FORMAT ("DVO_AVERAGE_PS1_DEV_2",       PS1_DEV_2);
     39  CONVERT_FORMAT ("DVO_AVERAGE_PS1_V1",          PS1_V1);
     40  CONVERT_FORMAT ("DVO_AVERAGE_PS1_V2",          PS1_V2);
     41  CONVERT_FORMAT ("DVO_AVERAGE_PS1_REF",         PS1_REF);
     42# undef CONVERT_FORMAT
     43
     44  fprintf (stderr, "table format unknown: %s\n", extname);
     45  return (DVO_FORMAT_UNDEF);
     46}
    1247
    1348/*** Average / FTable conversion functions ***/
Note: See TracChangeset for help on using the changeset viewer.