IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 1, 2021, 1:58:44 PM (5 years ago)
Author:
eugene
Message:

fix FITS ASCII column reading

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libfits/table/F_get_column.c

    r41474 r41676  
    310310   C - complex float
    311311   M - complex double
    312    P - var lenght array descrpt (64 bit)
     312   P - var length array descrpt (64 bit)
    313313   
    314314   all can be preceeded by integer N which specified number
     
    341341
    342342  if (!gfits_table_format (format, type, Nval, &Nbytes)) return (FALSE);
    343   *Nval = 1;
    344343
    345344  return (TRUE);
     
    379378  gfits_scan (header, "NAXIS2",  OFF_T_FMT, 1,  &Ny);
    380379
    381   /* scan columns to find insert point */
    382   Nstart = 0;
    383   for (i = 1; i < N; i++) {
    384     snprintf (field, 256, "TFORM%d", i);
    385     gfits_scan (header, field, "%s", 1, format);
    386     gfits_table_format (format, tmp, &Nv, &Nb);
    387     Nstart += Nv*Nb;
     380  // find the starting byte for this column
     381  // FITS ASCII table is supposed to have TBCOLn to specify the starting point
     382  // but if it is missing, we can try to find by counting
     383  snprintf (field, 256, "TBCOL%d", N);
     384  int status = gfits_scan (header, field, "%d", 1, &Nstart);
     385  if (!status) {
     386    /* scan columns to find insert point */
     387    Nstart = 0;
     388    for (i = 1; i < N; i++) {
     389      snprintf (field, 256, "TFORM%d", i);
     390      gfits_scan (header, field, "%s", 1, format);
     391      gfits_table_format (format, tmp, &Nv, &Nb);
     392      Nstart += Nv*Nb;
     393    }
     394  } else {
     395    Nstart --;
    388396  }
    389397
    390398  /* allocate temporary line, init pointers */
    391   ALLOCATE (line, char, Nval+1);
    392   bzero (line, Nval+1);
     399  ALLOCATE (line, char, Nval*Nbytes+1);
     400  bzero (line, Nval*Nbytes+1);
    393401  Pin  = table[0].buffer + Nstart;
    394402
Note: See TracChangeset for help on using the changeset viewer.