Changeset 37807 for trunk/Ohana/src/relastro/src/ImagePosIO.c
- Timestamp:
- Jan 11, 2015, 2:14:39 PM (12 years ago)
- Location:
- trunk/Ohana
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
src/relastro/src/ImagePosIO.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana
- Property svn:mergeinfo changed
-
trunk/Ohana/src/relastro/src/ImagePosIO.c
r36630 r37807 70 70 GET_COLUMN (polyterms, "POLYTERMS", float); // verify that we got 14 columns? 71 71 GET_COLUMN (ctype, "CTYPE", char); // verify that we got 15 columns? 72 GET_COLUMN (Npolyterms, "NPOLYTERMS", char);72 GET_COLUMN (Npolyterms, "NPOLYTERMS", byte); 73 73 GET_COLUMN (dXpixSys, "XPIX_SYS_ERR", float); 74 74 GET_COLUMN (dYpixSys, "YPIX_SYS_ERR", float); 75 GET_COLUMN (refColorBlue, "REF_COLOR_BLUE", float); 76 GET_COLUMN (refColorRed, "REF_COLOR_RED", float); 75 77 GET_COLUMN (imageID, "ID", int); 76 78 GET_COLUMN (nFitAstrom, "NFIT", int); … … 85 87 ALLOCATE (image_pos, ImagePos, Nrow); 86 88 for (i = 0; i < Nrow; i++) { 87 image_pos[i].coords.crval1 = crval1 [i]; 88 image_pos[i].coords.crval2 = crval2 [i]; 89 image_pos[i].coords.crpix1 = crpix1 [i]; 90 image_pos[i].coords.crpix2 = crpix2 [i]; 91 image_pos[i].coords.cdelt1 = cdelt1 [i]; 92 image_pos[i].coords.cdelt2 = cdelt2 [i]; 93 image_pos[i].coords.pc1_1 = pc1_1 [i]; 94 image_pos[i].coords.pc1_2 = pc1_2 [i]; 95 image_pos[i].coords.pc2_1 = pc2_1 [i]; 96 image_pos[i].coords.pc2_2 = pc2_2 [i]; 97 image_pos[i].coords.Npolyterms = Npolyterms[i]; 98 image_pos[i].dXpixSys = dXpixSys [i]; 99 image_pos[i].dYpixSys = dYpixSys [i]; 100 image_pos[i].imageID = imageID [i]; 101 image_pos[i].nFitAstrom = nFitAstrom[i]; 102 image_pos[i].flags = flags [i]; 89 InitCoords(&image_pos[i].coords, NULL); 90 image_pos[i].coords.crval1 = crval1 [i]; 91 image_pos[i].coords.crval2 = crval2 [i]; 92 image_pos[i].coords.crpix1 = crpix1 [i]; 93 image_pos[i].coords.crpix2 = crpix2 [i]; 94 image_pos[i].coords.cdelt1 = cdelt1 [i]; 95 image_pos[i].coords.cdelt2 = cdelt2 [i]; 96 image_pos[i].coords.pc1_1 = pc1_1 [i]; 97 image_pos[i].coords.pc1_2 = pc1_2 [i]; 98 image_pos[i].coords.pc2_1 = pc2_1 [i]; 99 image_pos[i].coords.pc2_2 = pc2_2 [i]; 100 image_pos[i].coords.Npolyterms = Npolyterms [i]; 101 image_pos[i].dXpixSys = dXpixSys [i]; 102 image_pos[i].dYpixSys = dYpixSys [i]; 103 image_pos[i].refColorBlue = refColorBlue[i]; 104 image_pos[i].refColorRed = refColorRed [i]; 105 image_pos[i].imageID = imageID [i]; 106 image_pos[i].nFitAstrom = nFitAstrom [i]; 107 image_pos[i].flags = flags [i]; 103 108 104 109 // polyterms and ctype are a bit different … … 108 113 fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow); 109 114 110 free (crval1 ); 111 free (crval2 ); 112 free (crpix1 ); 113 free (crpix2 ); 114 free (cdelt1 ); 115 free (cdelt2 ); 116 free (pc1_1 ); 117 free (pc1_2 ); 118 free (pc2_1 ); 119 free (pc2_2 ); 120 free (polyterms ); 121 free (ctype ); 122 free (Npolyterms); 123 free (dXpixSys ); 124 free (dYpixSys ); 125 free (imageID ); 126 free (nFitAstrom); 127 free (flags ); 115 free (crval1 ); 116 free (crval2 ); 117 free (crpix1 ); 118 free (crpix2 ); 119 free (cdelt1 ); 120 free (cdelt2 ); 121 free (pc1_1 ); 122 free (pc1_2 ); 123 free (pc2_1 ); 124 free (pc2_2 ); 125 free (polyterms ); 126 free (ctype ); 127 free (Npolyterms ); 128 free (dXpixSys ); 129 free (dYpixSys ); 130 free (refColorBlue); 131 free (refColorRed ); 132 free (imageID ); 133 free (nFitAstrom ); 134 free (flags ); 128 135 129 136 *nimage_pos = Nrow; … … 153 160 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_POS"); 154 161 155 gfits_define_bintable_column (&theader, "D", "CRVAL1", "word", "unit", 1.0, 0.0); 156 gfits_define_bintable_column (&theader, "D", "CRVAL2", "word", "unit", 1.0, 0.0); 157 gfits_define_bintable_column (&theader, "E", "CRPIX1", "word", "unit", 1.0, 0.0); 158 gfits_define_bintable_column (&theader, "E", "CRPIX2", "word", "unit", 1.0, 0.0); 159 gfits_define_bintable_column (&theader, "E", "CDELT1", "word", "unit", 1.0, 0.0); 160 gfits_define_bintable_column (&theader, "E", "CDELT2", "word", "unit", 1.0, 0.0); 161 gfits_define_bintable_column (&theader, "E", "PC1_1", "word", "unit", 1.0, 0.0); 162 gfits_define_bintable_column (&theader, "E", "PC1_2", "word", "unit", 1.0, 0.0); 163 gfits_define_bintable_column (&theader, "E", "PC2_1", "word", "unit", 1.0, 0.0); 164 gfits_define_bintable_column (&theader, "E", "PC2_2", "word", "unit", 1.0, 0.0); 165 gfits_define_bintable_column (&theader, "14E", "POLYTERMS", "word", "unit", 1.0, 0.0); 166 gfits_define_bintable_column (&theader, "15A", "CTYPE", "word", "unit", 1.0, 0.0); 167 gfits_define_bintable_column (&theader, "L", "NPOLYTERMS", "word", "unit", 1.0, 0.0); 168 gfits_define_bintable_column (&theader, "E", "XPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 169 gfits_define_bintable_column (&theader, "E", "YPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 170 gfits_define_bintable_column (&theader, "J", "ID", "image ID", "unitless", 1.0, 0.0); 171 gfits_define_bintable_column (&theader, "J", "NFIT", "number of fitted stars", "unitless", 1.0, 0.0); 172 gfits_define_bintable_column (&theader, "J", "FLAGS", "analysis flags", "unitless", 1.0, 0.0); 162 gfits_define_bintable_column (&theader, "D", "CRVAL1", "word", "unit", 1.0, 0.0); 163 gfits_define_bintable_column (&theader, "D", "CRVAL2", "word", "unit", 1.0, 0.0); 164 gfits_define_bintable_column (&theader, "E", "CRPIX1", "word", "unit", 1.0, 0.0); 165 gfits_define_bintable_column (&theader, "E", "CRPIX2", "word", "unit", 1.0, 0.0); 166 gfits_define_bintable_column (&theader, "E", "CDELT1", "word", "unit", 1.0, 0.0); 167 gfits_define_bintable_column (&theader, "E", "CDELT2", "word", "unit", 1.0, 0.0); 168 gfits_define_bintable_column (&theader, "E", "PC1_1", "word", "unit", 1.0, 0.0); 169 gfits_define_bintable_column (&theader, "E", "PC1_2", "word", "unit", 1.0, 0.0); 170 gfits_define_bintable_column (&theader, "E", "PC2_1", "word", "unit", 1.0, 0.0); 171 gfits_define_bintable_column (&theader, "E", "PC2_2", "word", "unit", 1.0, 0.0); 172 gfits_define_bintable_column (&theader, "14E", "POLYTERMS", "word", "unit", 1.0, 0.0); 173 gfits_define_bintable_column (&theader, "15A", "CTYPE", "word", "unit", 1.0, 0.0); 174 gfits_define_bintable_column (&theader, "L", "NPOLYTERMS", "word", "unit", 1.0, 0.0); 175 gfits_define_bintable_column (&theader, "E", "XPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 176 gfits_define_bintable_column (&theader, "E", "YPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 177 gfits_define_bintable_column (&theader, "E", "REF_COLOR_BLUE", "word", "unit", 1.0, 0.0); 178 gfits_define_bintable_column (&theader, "E", "REF_COLOR_RED", "word", "unit", 1.0, 0.0); 179 gfits_define_bintable_column (&theader, "J", "ID", "image ID", "unitless", 1.0, 0.0); 180 gfits_define_bintable_column (&theader, "J", "NFIT", "number of fitted stars", "unitless", 1.0, 0.0); 181 gfits_define_bintable_column (&theader, "J", "FLAGS", "analysis flags", "unitless", 1.0, 0.0); 173 182 174 183 // generate the output array that carries the data 175 184 gfits_create_table (&theader, &ftable); 176 185 177 double *crval1 ; 178 double *crval2 ; 179 float *crpix1 ; 180 float *crpix2 ; 181 float *cdelt1 ; 182 float *cdelt2 ; 183 float *pc1_1 ; 184 float *pc1_2 ; 185 float *pc2_1 ; 186 float *pc2_2 ; 187 float *polyterms ; 188 char *ctype ; 189 char *Npolyterms; 190 float *dXpixSys ; 191 float *dYpixSys ; 192 int *imageID ; 193 int *nFitAstrom; 194 int *flags ; 186 double *crval1 ; 187 double *crval2 ; 188 float *crpix1 ; 189 float *crpix2 ; 190 float *cdelt1 ; 191 float *cdelt2 ; 192 float *pc1_1 ; 193 float *pc1_2 ; 194 float *pc2_1 ; 195 float *pc2_2 ; 196 float *polyterms ; 197 char *ctype ; 198 char *Npolyterms ; 199 float *dXpixSys ; 200 float *dYpixSys ; 201 float *refColorBlue; 202 float *refColorRed ; 203 int *imageID ; 204 int *nFitAstrom ; 205 int *flags ; 195 206 196 207 // create intermediate storage arrays … … 210 221 ALLOCATE (dXpixSys , float , Nimage_pos); 211 222 ALLOCATE (dYpixSys , float , Nimage_pos); 223 ALLOCATE (refColorBlue, float , Nimage_pos); 224 ALLOCATE (refColorRed , float , Nimage_pos); 212 225 ALLOCATE (imageID , int , Nimage_pos); 213 226 ALLOCATE (nFitAstrom, int , Nimage_pos); … … 216 229 // assign the storage arrays 217 230 for (i = 0; i < Nimage_pos; i++) { 218 crval1 [i] = image_pos[i].coords.crval1 ; 219 crval2 [i] = image_pos[i].coords.crval2 ; 220 crpix1 [i] = image_pos[i].coords.crpix1 ; 221 crpix2 [i] = image_pos[i].coords.crpix2 ; 222 cdelt1 [i] = image_pos[i].coords.cdelt1 ; 223 cdelt2 [i] = image_pos[i].coords.cdelt2 ; 224 pc1_1 [i] = image_pos[i].coords.pc1_1 ; 225 pc1_2 [i] = image_pos[i].coords.pc1_2 ; 226 pc2_1 [i] = image_pos[i].coords.pc2_1 ; 227 pc2_2 [i] = image_pos[i].coords.pc2_2 ; 228 Npolyterms[i] = image_pos[i].coords.Npolyterms; 229 dXpixSys [i] = image_pos[i].dXpixSys ; 230 dYpixSys [i] = image_pos[i].dYpixSys ; 231 imageID [i] = image_pos[i].imageID ; 232 nFitAstrom[i] = image_pos[i].nFitAstrom ; 233 flags [i] = image_pos[i].flags ; 231 crval1 [i] = image_pos[i].coords.crval1 ; 232 crval2 [i] = image_pos[i].coords.crval2 ; 233 crpix1 [i] = image_pos[i].coords.crpix1 ; 234 crpix2 [i] = image_pos[i].coords.crpix2 ; 235 cdelt1 [i] = image_pos[i].coords.cdelt1 ; 236 cdelt2 [i] = image_pos[i].coords.cdelt2 ; 237 pc1_1 [i] = image_pos[i].coords.pc1_1 ; 238 pc1_2 [i] = image_pos[i].coords.pc1_2 ; 239 pc2_1 [i] = image_pos[i].coords.pc2_1 ; 240 pc2_2 [i] = image_pos[i].coords.pc2_2 ; 241 Npolyterms [i] = image_pos[i].coords.Npolyterms; 242 dXpixSys [i] = image_pos[i].dXpixSys ; 243 dYpixSys [i] = image_pos[i].dYpixSys ; 244 refColorBlue[i] = image_pos[i].refColorBlue ; 245 refColorRed [i] = image_pos[i].refColorRed ; 246 imageID [i] = image_pos[i].imageID ; 247 nFitAstrom [i] = image_pos[i].nFitAstrom ; 248 flags [i] = image_pos[i].flags ; 234 249 235 250 // polyterms and ctype are a bit different … … 239 254 240 255 // add the columns to the output array 241 gfits_set_bintable_column (&theader, &ftable, "CRVAL1", crval1 , Nimage_pos); 242 gfits_set_bintable_column (&theader, &ftable, "CRVAL2", crval2 , Nimage_pos); 243 gfits_set_bintable_column (&theader, &ftable, "CRPIX1", crpix1 , Nimage_pos); 244 gfits_set_bintable_column (&theader, &ftable, "CRPIX2", crpix2 , Nimage_pos); 245 gfits_set_bintable_column (&theader, &ftable, "CDELT1", cdelt1 , Nimage_pos); 246 gfits_set_bintable_column (&theader, &ftable, "CDELT2", cdelt2 , Nimage_pos); 247 gfits_set_bintable_column (&theader, &ftable, "PC1_1", pc1_1 , Nimage_pos); 248 gfits_set_bintable_column (&theader, &ftable, "PC1_2", pc1_2 , Nimage_pos); 249 gfits_set_bintable_column (&theader, &ftable, "PC2_1", pc2_1 , Nimage_pos); 250 gfits_set_bintable_column (&theader, &ftable, "PC2_2", pc2_2 , Nimage_pos); 251 gfits_set_bintable_column (&theader, &ftable, "POLYTERMS", polyterms , Nimage_pos); 252 gfits_set_bintable_column (&theader, &ftable, "CTYPE", ctype , Nimage_pos); 253 gfits_set_bintable_column (&theader, &ftable, "NPOLYTERMS", Npolyterms, Nimage_pos); 254 gfits_set_bintable_column (&theader, &ftable, "XPIX_SYS_ERR",dXpixSys , Nimage_pos); 255 gfits_set_bintable_column (&theader, &ftable, "YPIX_SYS_ERR",dYpixSys , Nimage_pos); 256 gfits_set_bintable_column (&theader, &ftable, "ID", imageID , Nimage_pos); 257 gfits_set_bintable_column (&theader, &ftable, "NFIT", nFitAstrom, Nimage_pos); 258 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nimage_pos); 259 260 free (crval1 ); 261 free (crval2 ); 262 free (crpix1 ); 263 free (crpix2 ); 264 free (cdelt1 ); 265 free (cdelt2 ); 266 free (pc1_1 ); 267 free (pc1_2 ); 268 free (pc2_1 ); 269 free (pc2_2 ); 270 free (polyterms ); 271 free (ctype ); 272 free (Npolyterms); 273 free (dXpixSys ); 274 free (dYpixSys ); 275 free (imageID ); 276 free (nFitAstrom); 277 free (flags ); 256 gfits_set_bintable_column (&theader, &ftable, "CRVAL1", crval1 , Nimage_pos); 257 gfits_set_bintable_column (&theader, &ftable, "CRVAL2", crval2 , Nimage_pos); 258 gfits_set_bintable_column (&theader, &ftable, "CRPIX1", crpix1 , Nimage_pos); 259 gfits_set_bintable_column (&theader, &ftable, "CRPIX2", crpix2 , Nimage_pos); 260 gfits_set_bintable_column (&theader, &ftable, "CDELT1", cdelt1 , Nimage_pos); 261 gfits_set_bintable_column (&theader, &ftable, "CDELT2", cdelt2 , Nimage_pos); 262 gfits_set_bintable_column (&theader, &ftable, "PC1_1", pc1_1 , Nimage_pos); 263 gfits_set_bintable_column (&theader, &ftable, "PC1_2", pc1_2 , Nimage_pos); 264 gfits_set_bintable_column (&theader, &ftable, "PC2_1", pc2_1 , Nimage_pos); 265 gfits_set_bintable_column (&theader, &ftable, "PC2_2", pc2_2 , Nimage_pos); 266 gfits_set_bintable_column (&theader, &ftable, "POLYTERMS", polyterms , Nimage_pos); 267 gfits_set_bintable_column (&theader, &ftable, "CTYPE", ctype , Nimage_pos); 268 gfits_set_bintable_column (&theader, &ftable, "NPOLYTERMS", Npolyterms, Nimage_pos); 269 gfits_set_bintable_column (&theader, &ftable, "XPIX_SYS_ERR", dXpixSys , Nimage_pos); 270 gfits_set_bintable_column (&theader, &ftable, "YPIX_SYS_ERR", dYpixSys , Nimage_pos); 271 gfits_set_bintable_column (&theader, &ftable, "REF_COLOR_BLUE", refColorBlue, Nimage_pos); 272 gfits_set_bintable_column (&theader, &ftable, "REF_COLOR_RED", refColorRed , Nimage_pos); 273 gfits_set_bintable_column (&theader, &ftable, "ID", imageID , Nimage_pos); 274 gfits_set_bintable_column (&theader, &ftable, "NFIT", nFitAstrom, Nimage_pos); 275 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nimage_pos); 276 277 free (crval1 ); 278 free (crval2 ); 279 free (crpix1 ); 280 free (crpix2 ); 281 free (cdelt1 ); 282 free (cdelt2 ); 283 free (pc1_1 ); 284 free (pc1_2 ); 285 free (pc2_1 ); 286 free (pc2_2 ); 287 free (polyterms ); 288 free (ctype ); 289 free (Npolyterms ); 290 free (dXpixSys ); 291 free (dYpixSys ); 292 free (refColorBlue); 293 free (refColorRed ); 294 free (imageID ); 295 free (nFitAstrom ); 296 free (flags ); 278 297 279 298 FILE *f = fopen (filename, "w");
Note:
See TracChangeset
for help on using the changeset viewer.
