Changeset 39267 for trunk/Ohana
- Timestamp:
- Dec 13, 2015, 8:56:10 AM (11 years ago)
- Location:
- trunk/Ohana/src/uniphot/src
- Files:
-
- 2 edited
-
cam_zpt_correction.c (modified) (6 diffs)
-
setphot.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/uniphot/src/cam_zpt_correction.c
r39263 r39267 87 87 88 88 while (TRUE) { 89 Header theader; 89 Header *header = NULL; 90 ALLOCATE (header, H 90 91 91 92 // load data for this header : if not found, assume we hit the end of the file … … 113 114 // assert that cam->matrix[index] is NULL? 114 115 cam->matrix[index] = matrix; 115 } 116 cam->header[index] = header; 117 } 118 return TRUE; 119 } 120 121 int save_cam_correction (char *filename) { 122 123 int i, ix, iy, dir, filter; 124 Header header; 125 126 /* open file for input */ 127 FILE *f = fopen (filename, "r"); 128 if (f == (FILE *) NULL) { 129 gprint (GP_ERR, "can't open file for read : %s\n", filename); 130 return FALSE; 131 } 132 133 gfits_init_header (&header); 134 header.extend = TRUE; 135 gfits_create_header (&header); 136 gfits_create_matrix (&header, &matrix); 137 138 gfits_modify (&header, "NSEASON", "%d", 1, camcoor->Nseason); 139 gfits_modify (&header, "NFILTER", "%d", 1, camcoor->Nfilter); 140 gfits_modify (&header, "NX", "%d", 1, camcoor->Nx); 141 gfits_modify (&header, "NY", "%d", 1, camcoor->Ny); 142 gfits_modify (&header, "DX", "%d", 1, camcoor->dX); 143 gfits_modify (&header, "DY", "%d", 1, camcoor->dY); 144 gfits_modify (&header, "NX_CHIP", "%d", 1, camcoor->NxCCD); 145 gfits_modify (&header, "NY_CHIP", "%d", 1, camcoor->NyCCD); 146 147 gfits_fwrite_header (f, &header); 148 gfits_fwrite_matrix (f, &matrix); 149 gfits_free_header (&header); 150 gfits_free_matrix (&matrix); 151 152 for (i = 0; i < camcorr->Nvalues; i++) { 153 154 // I don't need to do this, do I? 155 // if (!gfits_scan (&theader, "FILTER", "%d", 1, &filter)); 156 // if (!gfits_scan (&theader, "SEASON", "%d", 1, &season)); 157 // if (!gfits_scan (&theader, "X_CHIP", "%d", 1, &ix)); 158 // if (!gfits_scan (&theader, "Y_CHIP", "%d", 1, &iy)); 159 160 if (!cam->matrix[i]) continue; 161 162 gfits_fwrite_header (f, whatHeader); 163 gfits_fwrite_matrix (f, cam->matrix[i]); 164 } 165 116 166 return TRUE; 117 167 } … … 239 289 myAssert (flatcorrTable->IDtoSeq[ID] == i, "oops"); 240 290 291 // find the season (these are inherited from flatcorr, so they must match 241 292 int season = -1; 242 293 for (j = 0; j < newcorr->Nseason; j++) { … … 248 299 int photcode = flatcorr->image[i].photcode; 249 300 301 // find the chip and filter from photcode: 250 302 iy = flatcorr->image[i].photcode % 10; 251 303 ix = (int)(flatcorr->image[i].photcode / 10) % 10; 252 304 filter = (int)(flatcorr->image[i].photcode / 100) % 10; 253 305 306 // seq is the flatcorr entry of interest 254 307 int seq = ix + iy * newcorr->Nx + filter * newcorr->Nchips + season * camcorr->Nflat; 255 308 256 309 // we now have newcorr->matrix[seq] 257 newcorr->matrix[seq]; 310 Matrix *newDelta = newcorr->matrix[seq]; 311 312 int jx, jy; 258 313 259 314 // now loop over the newcorr pixels to get the flatcorr value: … … 261 316 for (jy = 0; jy < newcorr->NyCCD; jy++) { 262 317 263 // convert jx,jy in newcorr pixels to Jx,Jy in flatcorr pixels 264 newcorr->matrix[seq]->buffer[jx + jy*NxCCD] += flatcorr->offset[i][Jx][Jy]; 265 318 int chipX = jx * newcorr->dX; 319 int chipY = jy * newcorr->dY; 320 321 // get the flatcorr offset from this chip coordinate 322 float delta = FlatCorrectionOffset (flatcorr, flatcorr->image[i].ID, chipX, chipY); 323 324 newDelta->buffer[jx + jy*NxCCD] += flatcorr->offset[i][Jx][Jy]; 266 325 } 267 326 } … … 271 330 } 272 331 332 -
trunk/Ohana/src/uniphot/src/setphot.c
r39262 r39267 30 30 FlatCorrectionSave(&flatcorrTable, flatcorrfile); 31 31 // XXX should this program save any old copy of this file? 32 } else {33 zpts = load_zpt_table (argv[1], &Nzpts);34 }35 32 36 // if supplied, read in the camera-static flat-field correction37 if (CAM_FILE) {38 33 if (!load_cam_correction (CAM_FILE)) { 39 34 fprintf (stderr, "failed to load camera-static flat-field correction\n"); … … 41 36 } 42 37 merge_flatcorr_with_cam (flatcorrTable); 43 } else {44 convert_flatcorr_to_cam (flatcorrTable);45 }46 38 47 {48 39 char newflatfile[DVO_MAX_PATH]; 49 40 int size = snprintf (newflatfile, DVO_MAX_PATH, "%s/flatfield.fits", CATDIR); 50 41 assert (size < DVO_MAX_PATH); 51 42 save_cam_correction (newflatfile); 43 } else { 44 zpts = load_zpt_table (argv[1], &Nzpts); 52 45 } 53 46
Note:
See TracChangeset
for help on using the changeset viewer.
