Changeset 40791
- Timestamp:
- Jun 12, 2019, 3:49:14 PM (7 years ago)
- Location:
- branches/eam_branches/ohana.20190329/src/opihi
- Files:
-
- 10 edited
-
cmd.data/write_vectors.c (modified) (3 diffs)
-
dvo/avextract.c (modified) (1 diff)
-
dvo/avmatch.c (modified) (2 diffs)
-
dvo/avperiodomatch.c (modified) (1 diff)
-
dvo/avselect.c (modified) (2 diffs)
-
dvo/dvo_host_utils.c (modified) (1 diff)
-
dvo/mextract.c (modified) (1 diff)
-
dvo/mmatch.c (modified) (2 diffs)
-
include/dvomath.h (modified) (1 diff)
-
lib.shell/VectorIO.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20190329/src/opihi/cmd.data/write_vectors.c
r40574 r40791 32 32 } 33 33 34 /* option generate a FITS output table */ 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 35 37 char *FITS = NULL; 38 Header *fitsheader = NULL; 39 Buffer *headbuffer = NULL; 36 40 if ((N = get_argument (argc, argv, "-fits"))) { 37 41 remove_argument (N, &argc, argv); 38 42 FITS = strcreate (argv[N]); 39 43 remove_argument (N, &argc, argv); 40 } 41 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 42 53 /* option generate a FITS output table */ 43 54 int CSV = FALSE; … … 124 135 125 136 if (FITS) { 126 int status = WriteVectorTableFITS (argv[1], FITS, vec, Nvec, append, compress, format, Ntile);137 int status = WriteVectorTableFITS (argv[1], FITS, fitsheader, vec, Nvec, append, compress, format, Ntile); 127 138 free (vec); 128 139 return status; … … 260 271 gprint (GP_ERR, " -append : write to the end of the existing file\n"); 261 272 gprint (GP_ERR, " -fits NAME : write a fits table (extention name is NAME, column names match vector names)\n"); 273 gprint (GP_ERR, " in FITS output context, -header takes an additional argument which is interpretted\n"); 274 gprint (GP_ERR, " as a buffer containing header keywords to supplement the FITS table header\n"); 262 275 gprint (GP_ERR, " -csv : write a comma-separated values file (eg, to read in excel)\n"); 263 276 gprint (GP_ERR, " -f \"format\" : provide formatting codes for output:\n"); -
branches/eam_branches/ohana.20190329/src/opihi/dvo/avextract.c
r40574 r40791 272 272 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 273 273 if (RESULT_FILE && !SKIP_RESULTS) { 274 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, FALSE, NULL, 0);274 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", NULL, vec, Nreturn, FALSE, FALSE, NULL, 0); 275 275 if (!status) { 276 276 goto escape; -
branches/eam_branches/ohana.20190329/src/opihi/dvo/avmatch.c
r40523 r40791 114 114 115 115 CoordsFile = abspath("coords.fits", 1024); 116 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, FALSE, NULL, 0);116 int status = WriteVectorTableFITS (CoordsFile, "COORDS", NULL, vec, 2, FALSE, FALSE, NULL, 0); 117 117 if (!status) goto escape; 118 118 } … … 301 301 vec[i][0].Nelements = Nfound; 302 302 } 303 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields + 1, FALSE, FALSE, NULL, 0);303 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", NULL, vec, Nfields + 1, FALSE, FALSE, NULL, 0); 304 304 free (vec[Nfields]->elements.Int); 305 305 free (vec[Nfields]); -
branches/eam_branches/ohana.20190329/src/opihi/dvo/avperiodomatch.c
r40523 r40791 99 99 100 100 CoordsFile = abspath("coords.fits", 1024); 101 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, FALSE, NULL, 0);101 int status = WriteVectorTableFITS (CoordsFile, "COORDS", NULL, vec, 2, FALSE, FALSE, NULL, 0); 102 102 if (!status) goto escape; 103 103 free (vec); -
branches/eam_branches/ohana.20190329/src/opihi/dvo/avselect.c
r40575 r40791 132 132 133 133 CoordsFile = abspath("coords.fits", 1024); 134 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, FALSE, NULL, 0);134 int status = WriteVectorTableFITS (CoordsFile, "COORDS", NULL, vec, 2, FALSE, FALSE, NULL, 0); 135 135 if (!status) goto escape; 136 136 } … … 327 327 vec[NfieldsOut-1] = RADvec; 328 328 } 329 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, NfieldsOut, FALSE, FALSE, NULL, 0);329 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", NULL, vec, NfieldsOut, FALSE, FALSE, NULL, 0); 330 330 if (!status) goto escape; 331 331 } -
branches/eam_branches/ohana.20190329/src/opihi/dvo/dvo_host_utils.c
r40549 r40791 233 233 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 234 234 if (ResultFile) { 235 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, FALSE, NULL, 0);235 int status = WriteVectorTableFITS (ResultFile, "RESULT", NULL, vec, Nvec, FALSE, FALSE, NULL, 0); 236 236 if (!status) { 237 237 gprint (GP_ERR, "failed to write result file %s\n", ResultFile); -
branches/eam_branches/ohana.20190329/src/opihi/dvo/mextract.c
r40574 r40791 352 352 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 353 353 if (RESULT_FILE && !SKIP_RESULTS) { 354 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, FALSE, NULL, 0);354 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", NULL, vec, Nreturn, FALSE, FALSE, NULL, 0); 355 355 if (!status) goto escape; 356 356 } -
branches/eam_branches/ohana.20190329/src/opihi/dvo/mmatch.c
r40523 r40791 148 148 // XXX this is now set for both cases... 149 149 CoordsFile = abspath("coords.fits", 1024); 150 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, FALSE, NULL, 0);150 int status = WriteVectorTableFITS (CoordsFile, "COORDS", NULL, vec, 2, FALSE, FALSE, NULL, 0); 151 151 if (!status) goto escape; 152 152 } … … 349 349 vec[Nfields-1] = IDXvec; 350 350 } 351 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields, FALSE, FALSE, NULL, 0);351 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", NULL, vec, Nfields, FALSE, FALSE, NULL, 0); 352 352 if (!status) goto escape; 353 353 } -
branches/eam_branches/ohana.20190329/src/opihi/include/dvomath.h
r39640 r40791 169 169 170 170 /* vector IO functions */ 171 int WriteVectorTableFITS PROTO((char *filename, char *extname, Vector **vec, int Nvec, int append, char *compress, char *format, int Ntile));171 int WriteVectorTableFITS PROTO((char *filename, char *extname, Header *extraheader, Vector **vec, int Nvec, int append, char *compress, char *format, int Ntile)); 172 172 Vector **ReadVectorTableFITS PROTO((char *filename, char *extname, int *Nvec)); 173 173 -
branches/eam_branches/ohana.20190329/src/opihi/lib.shell/VectorIO.c
r40291 r40791 110 110 } 111 111 112 // insert a new header line, return end pointer 113 char *gfits_insert_header_line (Header *header, char *endptr, char *newline) { 114 115 if (0) { 116 char temp1[32], temp2[32]; 117 memset (temp1, 0, 32); 118 memset (temp2, 0, 32); 119 120 if (endptr) { 121 memcpy (temp1, endptr, 8); 122 } 123 memcpy (temp2, newline, 8); 124 fprintf (stderr, "insert: %s : %s\n", temp1, temp2); 125 } 126 127 /* find the END of the header, if not supplied */ 128 if (!endptr) { 129 endptr = gfits_header_field (header, "END", 1); 130 if (endptr == NULL) return NULL; 131 } 132 133 /* is there enough space for 1 more line? */ 134 if (header[0].datasize - (endptr - (header[0].buffer)) < 2*FT_LINE_LENGTH) { 135 // no, so expand by a full header block (FT_RECORD_SIZE = 32*80 = 2880) 136 header[0].datasize += FT_RECORD_SIZE; 137 REALLOCATE (header[0].buffer, char, header[0].datasize); 138 // re-find the "END" marker, in case new memory block is used 139 endptr = gfits_header_field (header, "END", 1); 140 if (endptr == NULL) return NULL; 141 memset (endptr + FT_LINE_LENGTH, ' ', FT_RECORD_SIZE); 142 } 143 144 /* push END line back 1 */ 145 memmove ((endptr + FT_LINE_LENGTH), endptr, FT_LINE_LENGTH); 146 memset (endptr, ' ', FT_LINE_LENGTH); 147 148 strncpy (endptr, newline, 80); 149 endptr += FT_LINE_LENGTH; 150 151 return endptr; 152 } 153 154 static char *rawkeywords[] = {"SIMPLE", "BITPIX", "NAXIS", "PCOUNT", "GCOUNT", "EXTEND", "EXTNAME", "BSCALE", "BZERO", "TFIELDS", "TFORM", "TZERO", "TSCAL", " ", NULL}; 155 112 156 // write a set of vectors to a FITS file (vectors names become fits column names) 113 int WriteVectorTableFITS (char *filename, char *extname, Vector **vec, int Nvec, int append, char *compress, char *format, int Ntile) {157 int WriteVectorTableFITS (char *filename, char *extname, Header *extraheader, Vector **vec, int Nvec, int append, char *compress, char *format, int Ntile) { 114 158 115 159 Header rawheader; … … 139 183 rawtable.header = &rawheader; 140 184 if (!WriteVectorTable (&rawtable, extname, vec, Nvec, format, (compress != NULL))) goto escape; 141 // NOTE : for compression, the table is constructed in native by order185 // NOTE : for compression, the table is constructed in native byte order 142 186 143 187 FTable *outtable = &rawtable; … … 163 207 164 208 if (!append) { 209 // generate a blank PHU header 165 210 Header header; 166 211 Matrix matrix; … … 176 221 } 177 222 223 if (extraheader) { 224 // copy keywords which are not the standard or table keywords 225 char *buf = extraheader->buffer; 226 char *endptr = NULL; 227 for (int i = 0; i < extraheader->datasize; i+= FT_LINE_LENGTH, buf += FT_LINE_LENGTH) { 228 229 if (0) { 230 char temp1[32]; 231 memset (temp1, 0, 32); 232 memcpy (temp1, buf, 8); 233 fprintf (stderr, "buffer: %s\n", temp1); 234 } 235 236 for (int j = 0; rawkeywords[j] != NULL; j++) { 237 if (!strncmp (buf, rawkeywords[j], strlen(rawkeywords[j]))) goto skip_insert; 238 } 239 endptr = gfits_insert_header_line (outheader, endptr, buf); 240 if (!endptr) { 241 gprint (GP_ERR, "failed to update FITS header with extra keywords\n"); 242 return (FALSE); 243 } 244 skip_insert: 245 continue; 246 } 247 } 248 178 249 // write the actual table data 179 250 gfits_fwrite_Theader (f, outheader);
Note:
See TracChangeset
for help on using the changeset viewer.
