- Timestamp:
- Dec 5, 2014, 4:17:32 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImagePosIO.c
r37699 r37720 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); … … 86 88 for (i = 0; i < Nrow; i++) { 87 89 InitCoords(&image_pos[i].coords, NULL); 88 image_pos[i].coords.crval1 = crval1 [i]; 89 image_pos[i].coords.crval2 = crval2 [i]; 90 image_pos[i].coords.crpix1 = crpix1 [i]; 91 image_pos[i].coords.crpix2 = crpix2 [i]; 92 image_pos[i].coords.cdelt1 = cdelt1 [i]; 93 image_pos[i].coords.cdelt2 = cdelt2 [i]; 94 image_pos[i].coords.pc1_1 = pc1_1 [i]; 95 image_pos[i].coords.pc1_2 = pc1_2 [i]; 96 image_pos[i].coords.pc2_1 = pc2_1 [i]; 97 image_pos[i].coords.pc2_2 = pc2_2 [i]; 98 image_pos[i].coords.Npolyterms = Npolyterms[i]; 99 image_pos[i].dXpixSys = dXpixSys [i]; 100 image_pos[i].dYpixSys = dYpixSys [i]; 101 image_pos[i].imageID = imageID [i]; 102 image_pos[i].nFitAstrom = nFitAstrom[i]; 103 image_pos[i].flags = flags [i]; 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]; 104 108 105 109 // polyterms and ctype are a bit different … … 109 113 fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow); 110 114 111 free (crval1 ); 112 free (crval2 ); 113 free (crpix1 ); 114 free (crpix2 ); 115 free (cdelt1 ); 116 free (cdelt2 ); 117 free (pc1_1 ); 118 free (pc1_2 ); 119 free (pc2_1 ); 120 free (pc2_2 ); 121 free (polyterms ); 122 free (ctype ); 123 free (Npolyterms); 124 free (dXpixSys ); 125 free (dYpixSys ); 126 free (imageID ); 127 free (nFitAstrom); 128 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 ); 129 135 130 136 *nimage_pos = Nrow; … … 154 160 gfits_create_table_header (&theader, "BINTABLE", "IMAGE_POS"); 155 161 156 gfits_define_bintable_column (&theader, "D", "CRVAL1", "word", "unit", 1.0, 0.0); 157 gfits_define_bintable_column (&theader, "D", "CRVAL2", "word", "unit", 1.0, 0.0); 158 gfits_define_bintable_column (&theader, "E", "CRPIX1", "word", "unit", 1.0, 0.0); 159 gfits_define_bintable_column (&theader, "E", "CRPIX2", "word", "unit", 1.0, 0.0); 160 gfits_define_bintable_column (&theader, "E", "CDELT1", "word", "unit", 1.0, 0.0); 161 gfits_define_bintable_column (&theader, "E", "CDELT2", "word", "unit", 1.0, 0.0); 162 gfits_define_bintable_column (&theader, "E", "PC1_1", "word", "unit", 1.0, 0.0); 163 gfits_define_bintable_column (&theader, "E", "PC1_2", "word", "unit", 1.0, 0.0); 164 gfits_define_bintable_column (&theader, "E", "PC2_1", "word", "unit", 1.0, 0.0); 165 gfits_define_bintable_column (&theader, "E", "PC2_2", "word", "unit", 1.0, 0.0); 166 gfits_define_bintable_column (&theader, "14E", "POLYTERMS", "word", "unit", 1.0, 0.0); 167 gfits_define_bintable_column (&theader, "15A", "CTYPE", "word", "unit", 1.0, 0.0); 168 gfits_define_bintable_column (&theader, "L", "NPOLYTERMS", "word", "unit", 1.0, 0.0); 169 gfits_define_bintable_column (&theader, "E", "XPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 170 gfits_define_bintable_column (&theader, "E", "YPIX_SYS_ERR", "word", "unit", 1.0, 0.0); 171 gfits_define_bintable_column (&theader, "J", "ID", "image ID", "unitless", 1.0, 0.0); 172 gfits_define_bintable_column (&theader, "J", "NFIT", "number of fitted stars", "unitless", 1.0, 0.0); 173 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); 174 182 175 183 // generate the output array that carries the data 176 184 gfits_create_table (&theader, &ftable); 177 185 178 double *crval1 ; 179 double *crval2 ; 180 float *crpix1 ; 181 float *crpix2 ; 182 float *cdelt1 ; 183 float *cdelt2 ; 184 float *pc1_1 ; 185 float *pc1_2 ; 186 float *pc2_1 ; 187 float *pc2_2 ; 188 float *polyterms ; 189 char *ctype ; 190 char *Npolyterms; 191 float *dXpixSys ; 192 float *dYpixSys ; 193 int *imageID ; 194 int *nFitAstrom; 195 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 ; 196 206 197 207 // create intermediate storage arrays … … 211 221 ALLOCATE (dXpixSys , float , Nimage_pos); 212 222 ALLOCATE (dYpixSys , float , Nimage_pos); 223 ALLOCATE (refColorBlue, float , Nimage_pos); 224 ALLOCATE (refColorRed , float , Nimage_pos); 213 225 ALLOCATE (imageID , int , Nimage_pos); 214 226 ALLOCATE (nFitAstrom, int , Nimage_pos); … … 217 229 // assign the storage arrays 218 230 for (i = 0; i < Nimage_pos; i++) { 219 crval1 [i] = image_pos[i].coords.crval1 ; 220 crval2 [i] = image_pos[i].coords.crval2 ; 221 crpix1 [i] = image_pos[i].coords.crpix1 ; 222 crpix2 [i] = image_pos[i].coords.crpix2 ; 223 cdelt1 [i] = image_pos[i].coords.cdelt1 ; 224 cdelt2 [i] = image_pos[i].coords.cdelt2 ; 225 pc1_1 [i] = image_pos[i].coords.pc1_1 ; 226 pc1_2 [i] = image_pos[i].coords.pc1_2 ; 227 pc2_1 [i] = image_pos[i].coords.pc2_1 ; 228 pc2_2 [i] = image_pos[i].coords.pc2_2 ; 229 Npolyterms[i] = image_pos[i].coords.Npolyterms; 230 dXpixSys [i] = image_pos[i].dXpixSys ; 231 dYpixSys [i] = image_pos[i].dYpixSys ; 232 imageID [i] = image_pos[i].imageID ; 233 nFitAstrom[i] = image_pos[i].nFitAstrom ; 234 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 ; 235 249 236 250 // polyterms and ctype are a bit different … … 240 254 241 255 // add the columns to the output array 242 gfits_set_bintable_column (&theader, &ftable, "CRVAL1", crval1 , Nimage_pos); 243 gfits_set_bintable_column (&theader, &ftable, "CRVAL2", crval2 , Nimage_pos); 244 gfits_set_bintable_column (&theader, &ftable, "CRPIX1", crpix1 , Nimage_pos); 245 gfits_set_bintable_column (&theader, &ftable, "CRPIX2", crpix2 , Nimage_pos); 246 gfits_set_bintable_column (&theader, &ftable, "CDELT1", cdelt1 , Nimage_pos); 247 gfits_set_bintable_column (&theader, &ftable, "CDELT2", cdelt2 , Nimage_pos); 248 gfits_set_bintable_column (&theader, &ftable, "PC1_1", pc1_1 , Nimage_pos); 249 gfits_set_bintable_column (&theader, &ftable, "PC1_2", pc1_2 , Nimage_pos); 250 gfits_set_bintable_column (&theader, &ftable, "PC2_1", pc2_1 , Nimage_pos); 251 gfits_set_bintable_column (&theader, &ftable, "PC2_2", pc2_2 , Nimage_pos); 252 gfits_set_bintable_column (&theader, &ftable, "POLYTERMS", polyterms , Nimage_pos); 253 gfits_set_bintable_column (&theader, &ftable, "CTYPE", ctype , Nimage_pos); 254 gfits_set_bintable_column (&theader, &ftable, "NPOLYTERMS", Npolyterms, Nimage_pos); 255 gfits_set_bintable_column (&theader, &ftable, "XPIX_SYS_ERR",dXpixSys , Nimage_pos); 256 gfits_set_bintable_column (&theader, &ftable, "YPIX_SYS_ERR",dYpixSys , Nimage_pos); 257 gfits_set_bintable_column (&theader, &ftable, "ID", imageID , Nimage_pos); 258 gfits_set_bintable_column (&theader, &ftable, "NFIT", nFitAstrom, Nimage_pos); 259 gfits_set_bintable_column (&theader, &ftable, "FLAGS", flags , Nimage_pos); 260 261 free (crval1 ); 262 free (crval2 ); 263 free (crpix1 ); 264 free (crpix2 ); 265 free (cdelt1 ); 266 free (cdelt2 ); 267 free (pc1_1 ); 268 free (pc1_2 ); 269 free (pc2_1 ); 270 free (pc2_2 ); 271 free (polyterms ); 272 free (ctype ); 273 free (Npolyterms); 274 free (dXpixSys ); 275 free (dYpixSys ); 276 free (imageID ); 277 free (nFitAstrom); 278 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 ); 279 297 280 298 FILE *f = fopen (filename, "w");
Note:
See TracChangeset
for help on using the changeset viewer.
