Changeset 38330
- Timestamp:
- May 28, 2015, 8:28:24 PM (11 years ago)
- Location:
- branches/eam_branches/ohana.20150429/src/opihi
- Files:
-
- 9 edited
-
cmd.data/wd.c (modified) (3 diffs)
-
cmd.data/write_vectors.c (modified) (4 diffs)
-
dvo/avextract.c (modified) (1 diff)
-
dvo/avmatch.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) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/wd.c
r38062 r38330 3 3 int wd (int argc, char **argv) { 4 4 5 int N, Extend ;5 int N, Extend, Compress; 6 6 int newUnsign, newBitpix, newScale, newZero; 7 7 int outUnsign, outBitpix; … … 16 16 remove_argument (N, &argc, argv); 17 17 Extend = TRUE; 18 } 19 20 Compress = FALSE; 21 if ((N = get_argument (argc, argv, "-compress"))) { 22 remove_argument (N, &argc, argv); 23 Compress = TRUE; 18 24 } 19 25 … … 162 168 } 163 169 170 // not compatible with extend 171 if (Compress) { 172 Header myHeader; 173 Matrix myMatrix; 174 175 FILE *f = fopen (argv[2], "w"); 176 if (!f) { 177 fprintf (stderr, "ERROR: cannot open image subset file for output %s\n", argv[2]); 178 return FALSE; 179 } 180 181 gfits_init_header (&myHeader); 182 myHeader.extend = TRUE; 183 gfits_create_header (&myHeader); 184 gfits_create_matrix (&myHeader, &myMatrix); 185 gfits_fwrite_header (f, &myHeader); 186 gfits_fwrite_matrix (f, &myMatrix); 187 gfits_free_header (&myHeader); 188 gfits_free_matrix (&myMatrix); 189 190 FTable ftable; 191 Header theader; 192 193 ftable.header = &theader; 194 195 gfits_compress_image (&temp_header, &temp_matrix, &ftable, NULL, "GZIP_1"); 196 gfits_byteswap_varlength_column (&ftable, 1); 197 198 gfits_fwrite_Theader (f, &theader); 199 gfits_fwrite_table (f, &ftable); 200 fclose (f); 201 202 gfits_free_header (&theader); 203 gfits_free_table (&ftable); 204 return (TRUE); 205 } 206 164 207 /* the actual write-to-disk goes here */ 165 208 if (!gfits_write_header (argv[2], &temp_header)) { -
branches/eam_branches/ohana.20150429/src/opihi/cmd.data/write_vectors.c
r35109 r38330 3 3 int write_vectors (int argc, char **argv) { 4 4 5 int append;6 5 int i, j, Nvec, Ne, N; 7 6 FILE *f; 8 7 char **fmtlist, *fmttype; 9 char *p0, *p1, *p2, *format , *FITS;8 char *p0, *p1, *p2, *format; 10 9 Vector **vec; 11 10 … … 34 33 35 34 /* option generate a FITS output table */ 36 FITS = NULL;35 char *FITS = NULL; 37 36 if ((N = get_argument (argc, argv, "-fits"))) { 38 37 remove_argument (N, &argc, argv); … … 58 57 } 59 58 60 append = FALSE;59 int append = FALSE; 61 60 if ((N = get_argument (argc, argv, "-append"))) { 62 61 remove_argument (N, &argc, argv); 63 62 append = TRUE; 63 } 64 65 int compress = FALSE; 66 if ((N = get_argument (argc, argv, "-compress"))) { 67 remove_argument (N, &argc, argv); 68 compress = TRUE; 69 if (!FITS) { 70 fprintf (stderr, "NOTE: write_vectors -compress has no effect on non-FITS\n"); 71 } 64 72 } 65 73 … … 105 113 106 114 if (FITS) { 107 int status = WriteVectorTableFITS (argv[1], FITS, vec, Nvec, append, format);115 int status = WriteVectorTableFITS (argv[1], FITS, vec, Nvec, append, compress, format); 108 116 free (vec); 109 117 return status; -
branches/eam_branches/ohana.20150429/src/opihi/dvo/avextract.c
r38062 r38330 256 256 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 257 257 if (RESULT_FILE && !SKIP_RESULTS) { 258 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL);258 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, FALSE, NULL); 259 259 if (!status) { 260 260 goto escape; -
branches/eam_branches/ohana.20150429/src/opihi/dvo/avmatch.c
r37807 r38330 115 115 116 116 CoordsFile = abspath("coords.fits", 1024); 117 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);117 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, FALSE, NULL); 118 118 if (!status) goto escape; 119 119 } … … 302 302 vec[i][0].Nelements = Nfound; 303 303 } 304 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields + 1, FALSE, NULL);304 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields + 1, FALSE, FALSE, NULL); 305 305 free (vec[Nfields]->elements.Int); 306 306 free (vec[Nfields]); -
branches/eam_branches/ohana.20150429/src/opihi/dvo/dvo_host_utils.c
r37807 r38330 230 230 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 231 231 if (ResultFile) { 232 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, NULL);232 int status = WriteVectorTableFITS (ResultFile, "RESULT", vec, Nvec, FALSE, FALSE, NULL); 233 233 if (!status) { 234 234 gprint (GP_ERR, "failed to write result file %s\n", ResultFile); -
branches/eam_branches/ohana.20150429/src/opihi/dvo/mextract.c
r37807 r38330 317 317 // write vectors to a table (this is used by parallel dvo operations, but can be used elsewhere) 318 318 if (RESULT_FILE && !SKIP_RESULTS) { 319 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, NULL);319 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nreturn, FALSE, FALSE, NULL); 320 320 if (!status) goto escape; 321 321 } -
branches/eam_branches/ohana.20150429/src/opihi/dvo/mmatch.c
r37807 r38330 150 150 // XXX this is now set for both cases... 151 151 CoordsFile = abspath("coords.fits", 1024); 152 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, NULL);152 int status = WriteVectorTableFITS (CoordsFile, "COORDS", vec, 2, FALSE, FALSE, NULL); 153 153 if (!status) goto escape; 154 154 } … … 349 349 vec[Nfields-1] = IDXvec; 350 350 } 351 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields, FALSE, NULL);351 int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields, FALSE, FALSE, NULL); 352 352 if (!status) goto escape; 353 353 } -
branches/eam_branches/ohana.20150429/src/opihi/include/dvomath.h
r38062 r38330 167 167 168 168 /* vector IO functions */ 169 int WriteVectorTableFITS PROTO((char *filename, char *extname, Vector **vec, int Nvec, int append, char *format));169 int WriteVectorTableFITS PROTO((char *filename, char *extname, Vector **vec, int Nvec, int append, int compress, char *format)); 170 170 Vector **ReadVectorTableFITS PROTO((char *filename, char *extname, int *Nvec)); 171 171 -
branches/eam_branches/ohana.20150429/src/opihi/lib.shell/VectorIO.c
r37049 r38330 1 1 # include "opihi.h" 2 2 3 // write a set of vectors to a FITS file (vectors names become fits column names)4 int WriteVectorTable (Header *theader,FTable *ftable, char *extname, Vector **vec, int Nvec, char *format) {3 // write a set of vectors to a FITS FTable structure (vectors names become fits column names) 4 static int WriteVectorTable (FTable *ftable, char *extname, Vector **vec, int Nvec, char *format) { 5 5 6 6 int j; … … 8 8 char *tformat = NULL; 9 9 10 Header *theader = ftable->header; 10 11 gfits_create_table_header (theader, "BINTABLE", extname); 11 12 … … 71 72 72 73 // write a set of vectors to a FITS file (vectors names become fits column names) 73 int WriteVectorTableFITS (char *filename, char *extname, Vector **vec, int Nvec, int append, char *format) {74 75 Header header;76 Matrix matrix;77 Header theader;78 FTable ftable;74 int WriteVectorTableFITS (char *filename, char *extname, Vector **vec, int Nvec, int append, int compress, char *format) { 75 76 Header rawheader; 77 Header cmpheader; 78 FTable rawtable; 79 FTable cmptable; 79 80 80 81 FILE *f = NULL; … … 91 92 } 92 93 93 if (!WriteVectorTable (&theader, &ftable, extname, vec, Nvec, format)) goto escape; 94 // init so free below does not fail if table is not created 95 gfits_init_header (&rawheader); 96 gfits_init_header (&cmpheader); 97 gfits_init_table (&rawtable); 98 gfits_init_table (&cmptable); 99 100 rawtable.header = &rawheader; 101 if (!WriteVectorTable (&rawtable, extname, vec, Nvec, format)) goto escape; 102 103 FTable *outtable = &rawtable; 104 Header *outheader = &rawheader; 105 106 if (compress) { 107 cmptable.header = &cmpheader; 108 if (!gfits_compress_table (&rawtable, &cmptable, 10, "GZIP_1")) goto escape; 109 outtable = &cmptable; 110 outheader = &cmpheader; 111 } 94 112 95 113 if (!append) { 114 Header header; 115 Matrix matrix; 96 116 gfits_init_header (&header); 117 gfits_init_matrix (&matrix); 97 118 header.extend = TRUE; 98 119 gfits_create_header (&header); … … 103 124 gfits_free_matrix (&matrix); 104 125 } 105 gfits_fwrite_Theader (f, &theader); 106 gfits_fwrite_table (f, &ftable); 107 108 gfits_free_header (&theader); 109 gfits_free_table (&ftable); 126 127 // write the actual table data 128 gfits_fwrite_Theader (f, outheader); 129 gfits_fwrite_table (f, outtable); 130 131 gfits_free_header (&rawheader); 132 gfits_free_table (&rawtable); 133 134 if (compress) { 135 gfits_free_header (&cmpheader); 136 gfits_free_table (&cmptable); 137 } 110 138 111 139 fclose (f); … … 114 142 115 143 escape: 116 if (!append) { 117 gfits_free_header (&header); 118 gfits_free_matrix (&matrix); 119 } 120 gfits_free_header (&theader); 121 gfits_free_table (&ftable); 144 gfits_free_header (&rawheader); 145 gfits_free_table (&rawtable); 146 147 if (compress) { 148 gfits_free_header (&cmpheader); 149 gfits_free_table (&cmptable); 150 } 122 151 123 152 fclose (f);
Note:
See TracChangeset
for help on using the changeset viewer.
