IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 16, 2020, 1:54:47 PM (6 years ago)
Author:
tdeboer
Message:

revert to working Ohana build

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/cmd.data/write_vectors.c

    r41269 r41340  
    3232  }
    3333
    34   // option generate a FITS output table (FITS holds the filename)
    35   // in FITS output context, -header is interpretted as a buffer containing
    36   // header keywords to supplement the FITS table header
     34  /* option generate a FITS output table */
    3735  char *FITS = NULL;
    38   Header *fitsheader = NULL;
    39   Buffer *headbuffer = NULL;
    4036  if ((N = get_argument (argc, argv, "-fits"))) {
    4137    remove_argument (N, &argc, argv);
    4238    FITS = strcreate (argv[N]);
    4339    remove_argument (N, &argc, argv);
    44 
    45     if ((N = get_argument (argc, argv, "-header"))) {
    46       remove_argument (N, &argc, argv);
    47       if ((headbuffer = SelectBuffer (argv[N], OLDBUFFER, TRUE)) == NULL) return (FALSE);
    48       fitsheader = &headbuffer->header;
    49       remove_argument (N, &argc, argv);
    50     }
    51   }
    52  
     40  }
     41
    5342  /* option generate a FITS output table */
    5443  int CSV = FALSE;
     
    135124
    136125  if (FITS) {
    137     int status = WriteVectorTableFITS (argv[1], FITS, fitsheader, vec, Nvec, append, compress, format, Ntile);
     126    int status = WriteVectorTableFITS (argv[1], FITS, vec, Nvec, append, compress, format, Ntile);
    138127    free (vec);
    139128    return status;
     
    154143  if (ADD_HEADER) {
    155144    for (j = 0; j < Nvec; j++) {
    156       if (j == 0) fprintf (f, "# ");
    157145      if (CSV) {
    158146        fprintf (f, "%s,", vec[j][0].name);
    159147      } else {
     148        if (j == 0) fprintf (f, "# ");
    160149        fprintf (f, "%s ", vec[j][0].name);
    161150      }
     
    166155  /* default output format */
    167156  if (format == (char *) NULL) {
    168     char padChar = CSV ? ',' : ' ';
    169157    for (i = 0; i < vec[0][0].Nelements; i++) {
    170158      for (j = 0; j < Nvec; j++) {
    171         switch (vec[j][0].type) {
    172           case OPIHI_FLT:
    173             fprintf (f, "%.12g%c", vec[j][0].elements.Flt[i], padChar);
    174             break;
    175           case OPIHI_INT:
    176             fprintf (f, OPIHI_INT_FMT"%c", vec[j][0].elements.Int[i], padChar);
    177             break;
    178           case OPIHI_STR:
    179             fprintf (f, "%s%c", vec[j][0].elements.Str[i], padChar);
    180             break;
     159        if (vec[j][0].type == OPIHI_FLT) {
     160          if (CSV) {
     161            fprintf (f, "%.12g,", vec[j][0].elements.Flt[i]);
     162          } else {
     163            fprintf (f, "%.12g ", vec[j][0].elements.Flt[i]);
     164          }
     165        } else {
     166          if (CSV) {
     167            fprintf (f, OPIHI_INT_FMT",", vec[j][0].elements.Int[i]);
     168          } else {
     169            fprintf (f, OPIHI_INT_FMT" ", vec[j][0].elements.Int[i]);
     170          }
    181171        }
    182172      }
     
    225215        fmttype[j] = 'd';
    226216        break;
    227       case 's':
    228         fmttype[j] = 's';
    229         break;
    230217      default:
    231         gprint (GP_ERR, "syntax error in format (only e,f,d,c,x,s allowed)\n");
     218        gprint (GP_ERR, "syntax error in format (only e,f,d,c,x allowed)\n");
    232219        return (FALSE);
    233220    }
     
    236223  strcat (fmtlist[Nvec-1], p0);
    237224 
    238   // check format types against vector types:
    239   for (j = 0; j < Nvec; j++) {
    240     switch (vec[j][0].type) {
    241       case OPIHI_FLT:
    242       case OPIHI_INT:
    243         if (fmttype[j] == 's') {
    244           gprint (GP_ERR, "mismatch between string format and numerical vector for %s\n", vec[j][0].name);
    245           return FALSE;
    246         }
    247         break;
    248       case OPIHI_STR:
    249         if (fmttype[j] != 's') {
    250           gprint (GP_ERR, "mismatch between numerical format and string vector for %s\n", vec[j][0].name);
    251           return FALSE;
    252         }
    253         break;
    254     }
    255   }
    256 
    257225  for (i = 0; i < vec[0][0].Nelements; i++) {
    258226    for (j = 0; j < Nvec; j++) {
     
    271239        }
    272240      }
    273       if (fmttype[j] == 's') {
    274         fprintf (f, fmtlist[j], vec[j][0].elements.Str[i]);
    275       }
    276241    }
    277242    fprintf (f, "\n");
     
    295260    gprint (GP_ERR, "  -append : write to the end of the existing file\n");
    296261    gprint (GP_ERR, "  -fits NAME : write a fits table (extention name is NAME, column names match vector names)\n");
    297     gprint (GP_ERR, "     in FITS output context, -header takes an additional argument which is interpretted\n");
    298     gprint (GP_ERR, "     as a buffer containing header keywords to supplement the FITS table header\n");
    299262    gprint (GP_ERR, "  -csv : write a comma-separated values file (eg, to read in excel)\n");
    300263    gprint (GP_ERR, "  -f \"format\" : provide formatting codes for output:\n");
Note: See TracChangeset for help on using the changeset viewer.