Changeset 36359
- Timestamp:
- Dec 6, 2013, 2:58:40 PM (13 years ago)
- Location:
- tags/ipp-20130712/ppSkycell/src
- Files:
-
- 6 edited
-
. (modified) (1 prop)
-
ppSkycell.h (modified) (2 diffs)
-
ppSkycellArguments.c (modified) (3 diffs)
-
ppSkycellCamera.c (modified) (6 diffs)
-
ppSkycellData.c (modified) (3 diffs)
-
ppSkycellLoop.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-20130712/ppSkycell/src
- Property svn:mergeinfo changed
/trunk/ppSkycell/src merged: 36356-36357
- Property svn:mergeinfo changed
-
tags/ipp-20130712/ppSkycell/src/ppSkycell.h
r35855 r36359 10 10 typedef struct { 11 11 psString imagesName; // Filename with images 12 psString masksName; // Filename with masks13 12 psString wcsrefName; // Filename with WCS references 14 13 psString outRoot; // Output root name … … 17 16 int bin1, bin2; // Binning factors 18 17 pmConfig *config; // Configuration 19 bool doFits; // hold whether to do fits as well. 18 bool doFits; // hold whether to do fits as well. 19 int exptimeOrder; // Order of exptime scaling. 20 20 } ppSkycellData; 21 21 -
tags/ipp-20130712/ppSkycell/src/ppSkycellArguments.c
r35855 r36359 29 29 { 30 30 fprintf(stderr, "\nPan-STARRS skycell JPEGifier\n\n"); 31 fprintf(stderr, "Usage: %s -images INPUT.list [-masks MASK.list]OUTPUT_ROOT\n\n",31 fprintf(stderr, "Usage: %s -images INPUT.list OUTPUT_ROOT\n\n", 32 32 program); 33 33 fprintf(stderr, "\n"); … … 50 50 psMetadata *arguments = psMetadataAlloc(); // Command-line arguments 51 51 psMetadataAddStr(arguments, PS_LIST_TAIL, "-images", 0, "Filename with input images", NULL); 52 psMetadataAddStr(arguments, PS_LIST_TAIL, "-masks", 0, "Filename with input masks", NULL);53 52 psMetadataAddStr(arguments, PS_LIST_TAIL, "-wcsref", 0, "Filename with WCS references", NULL); 53 psMetadataAddS16(arguments, PS_LIST_TAIL, "-exptimeOrder", 0, "Order of exptime scaling", 0); 54 54 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) { 55 55 usage(argv[0], arguments, data); … … 57 57 58 58 data->imagesName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-images")); 59 data->masksName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-masks"));60 59 data->wcsrefName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-wcsref")); 60 data->exptimeOrder = psMetadataLookupS16(NULL,arguments,"-exptimeOrder"); 61 61 62 62 data->outRoot = psStringCopy(argv[1]); -
tags/ipp-20130712/ppSkycell/src/ppSkycellCamera.c
r35855 r36359 56 56 data->numInputs = images->n; 57 57 58 psArray *masks = NULL; // Mask names59 if (data->masksName) {60 masks = fileList(data->masksName);61 if (!masks) {62 psError(psErrorCodeLast(), false, "No masks provided.");63 psFree(images);64 return false;65 }66 if (masks->n != data->numInputs) {67 psError(PS_ERR_BAD_PARAMETER_SIZE, true, "Number of images (%ld) and masks (%ld) do not match",68 images->n, masks->n);69 psFree(images);70 psFree(masks);71 return false;72 }73 }74 75 58 psArray *wcsref = NULL; // Names of WCS reference images 76 59 if (data->wcsrefName) { … … 79 62 psError(psErrorCodeLast(), false, "No WCSrefs provided."); 80 63 psFree(images); 81 psFree(masks);82 64 return(false); 83 65 } … … 86 68 images->n, wcsref->n); 87 69 psFree(images); 88 psFree(masks);89 70 psFree(wcsref); 90 71 return(false); … … 104 85 } 105 86 106 if (data->masksName) {107 fileArguments("MASK", masks->data[i], "Name of the mask", data->config);108 if (!pmFPAfileBindFromArgs(&status, image, data->config, "PPSKYCELL.MASK", "MASK") || !status) {109 psError(PS_ERR_IO, false, "Failed to build file from PPSKYCELL.MASK");110 // XXX Cleanup111 return false;112 }113 }114 115 87 if (data->wcsrefName) { 116 88 fileArguments("WCSREF", wcsref->data[i], "Name of the WCS reference", data->config); … … 120 92 return(false); 121 93 } 122 /* if (!pmFPAfileBindFromArgs(&status, image, data->config, "PPSKYCELL.WCSREF", "WCSREF") || !status) { */123 /* psError(PS_ERR_IO, false, "Failed to build file from PPSKYCELL.WCSREF"); */124 /* return false; */125 /* } */126 94 } 127 128 95 } 129 96 … … 145 112 psError(psErrorCodeLast(), false, "Unable to define output."); 146 113 return false; 147 }148 if (data->masksName) {149 pmFPAfile *mask1 = pmFPAfileDefineOutput(data->config, bin1->fpa , "PPSKYCELL.BIN1.MASK");150 if (!mask1) {151 psError(psErrorCodeLast(), false, "Unable to define output.");152 return false;153 }154 mask1->save = true;155 pmFPAfile *mask2 = pmFPAfileDefineOutput(data->config, bin2->fpa , "PPSKYCELL.BIN2.MASK");156 if (!mask2) {157 psError(psErrorCodeLast(), false, "Unable to define output.");158 return false;159 }160 mask2->save = true;161 114 } 162 115 -
tags/ipp-20130712/ppSkycell/src/ppSkycellData.c
r35855 r36359 14 14 { 15 15 psFree(data->imagesName); 16 psFree(data->masksName);17 16 psFree(data->wcsrefName); 18 17 psFree(data->outRoot); … … 28 27 29 28 data->imagesName = NULL; 30 data->masksName = NULL;31 29 data->wcsrefName = NULL; 32 30 data->outRoot = NULL; … … 36 34 data->bin2 = 0; 37 35 data->config = NULL; 38 36 data->exptimeOrder = 0; 39 37 return data; 40 38 } -
tags/ipp-20130712/ppSkycell/src/ppSkycellLoop.c
r35855 r36359 11 11 #define BUFFER 16 // Size of buffer for projections 12 12 13 #if (0)14 // This is all junk that is basically useless, because it calculates things we already know.15 16 static void regionMinMax(psRegion *base,// Base region; modified17 const psRegion *compare // Comparison region18 )19 {20 base->x0 = PS_MAX(base->x0, compare->x0);21 base->x1 = PS_MIN(base->x1, compare->x1);22 base->y0 = PS_MIN(base->y0, compare->y0);23 base->y1 = PS_MAX(base->y1, compare->y1);24 return;25 }26 27 28 static psRegion *skycellRegion(pmAstromWCS *wcs, // World Coordinate System29 int numCols, int numRows // Size of image30 )31 {32 psPlane *fromCoords = psPlaneAlloc(), *toCoords = psPlaneAlloc(); // Coordinates for transforms33 psRegion *region = psRegionAlloc(-INFINITY, INFINITY, INFINITY, -INFINITY); // Region for skycell34 35 // Limit the region using the nominated point (X,Y)36 #define REGION_RANGE(X,Y) \37 fromCoords->x = (X); \38 fromCoords->y = (Y); \39 psPlaneTransformApply(toCoords, wcs->trans, fromCoords); \40 printf("%f %f %f %f\n",toCoords->x,toCoords->y,fromCoords->x,fromCoords->y); \41 toCoords->x /= wcs->cdelt1; \42 toCoords->y /= wcs->cdelt2; \43 toCoords->x -= wcs->crpix1; \44 toCoords->y += wcs->crpix2; \45 region->x0 = PS_MAX(region->x0, toCoords->x); \46 region->x1 = PS_MIN(region->x1, toCoords->x); \47 region->y0 = PS_MIN(region->y0, toCoords->y); \48 region->y1 = PS_MAX(region->y1, toCoords->y);49 //50 REGION_RANGE(0, 0); // Lower left51 psTrace("ppSkycell", 9, "Start: %.0f %.0f", toCoords->x, toCoords->y);52 REGION_RANGE(0, numRows); // Upper left53 REGION_RANGE(numCols, 0); // Lower right54 REGION_RANGE(numCols, numRows); // Upper right55 psTrace("ppSkycell", 9, "Stop: %.0f %.0f\n", toCoords->x, toCoords->y);56 psTrace("ppSkycell", 7, "%g %g %g %g\n",wcs->cdelt1,wcs->cdelt2,wcs->crpix1,wcs->crpix2);57 return region;58 }59 #endif60 13 61 14 // Activate/deactivate a single element for a list … … 139 92 psArray *imageRegions = psArrayAlloc(data->numInputs); // Region for image 140 93 psArray *regionHDUs = psArrayAlloc(data->numInputs); 94 95 psVector *exptimes = psVectorAlloc(data->numInputs, PS_TYPE_F64); 96 141 97 // Determine which projection cells we have to deal with. 142 98 for (int i = 0; i < data->numInputs; i++) { 143 99 pmFPAfile *file = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.IMAGE", i); // File to examine 144 100 // Header in the FPA should have been read as a part of defining the file... 145 #if 0146 bool pmFPAReadHeaderSet(pmFPA *fpa, // FPA to read into147 psFits *fits, // FITS file from which to read148 pmConfig *config // Configuration149 );150 #endif151 101 pmHDU *hdu = file->fpa->hdu; // Header of interest 152 102 … … 187 137 } 188 138 } 189 190 if (!found) { 139 140 if (!found) { // Add new projection cell if we didn't find one. 191 141 psVectorAppend(crval1, wcs->crval1); 192 142 psVectorAppend(crval2, wcs->crval2); 193 143 psVectorAppend(cdelt1, wcs->cdelt1); 194 144 psVectorAppend(cdelt2, wcs->cdelt2); 145 195 146 psRegion *projRegion = psRegionAlloc(region->x0, region->x1, region->y0, region->y1); 196 147 psArrayAdd(projRegions, projRegions->n, projRegion); … … 200 151 psArrayAdd(regionHDUs,1,hdu); 201 152 numProj++; 153 202 154 } 203 } 204 155 156 // Save exptime 157 exptimes->data.F64[i] = psMetadataLookupF64(NULL, hdu->header, "EXPTIME"); 158 } 159 160 psStats *stats = psStatsAlloc(PS_STAT_ROBUST_MEDIAN); 161 psVectorStats(stats,exptimes,NULL, NULL, 0); 162 205 163 pmFPAfileActivate(data->config->files, false, NULL); 206 164 // Loop over projections 207 165 for (int i = 0; i < numProj; i++) { 208 166 psRegion *projRegion = projRegions->data[i]; // Region for skycell projection 209 // projRegion->x0 += 5760;210 //projRegion->x1 += 5760;211 // projRegion->x0 +=212 // projRegion->x1 +=213 167 psTrace("ppSkycell", 2, "Projection %d: [%.0f:%.0f,%.0f:%.0f]\n", 214 168 i, projRegion->x0, projRegion->x1, projRegion->y0, projRegion->y1); 215 int xSize = projRegion->x1 - projRegion->x0 + 1; // Size of unbinned image 216 int ySize = projRegion->y1 - projRegion->y0 + 1; // Size of unbinned image 217 // Size of binned image 1 169 170 // Size of unbinned image 171 int xSize = projRegion->x1 - projRegion->x0 + 1; 172 int ySize = projRegion->y1 - projRegion->y0 + 1; 173 174 // Size of binned images 218 175 int numCols1 = xSize / (float)data->bin1 + 1.5, numRows1 = ySize / (float)data->bin1 + 1.5; 219 // Size of binned image 2220 176 int numCols2 = numCols1 / (float)data->bin2 + 1.5, numRows2 = numRows1 / (float)data->bin2 + 1.5; 221 177 222 psImage *image1 = psImageAlloc(numCols1, numRows1, PS_TYPE_F32); // Binned image 223 psImage *image2 = psImageAlloc(numCols2, numRows2, PS_TYPE_F32); // Binned image 178 // Binned image containers 179 psImage *image1 = psImageAlloc(numCols1, numRows1, PS_TYPE_F32); 180 psImage *image2 = psImageAlloc(numCols2, numRows2, PS_TYPE_F32); 224 181 psImageInit(image1,NAN); 225 182 psImageInit(image2,NAN); 183 184 // Binned image radius values. Used to determine primacy. 185 psImage *radius1 = psImageAlloc(numCols1, numRows1, PS_TYPE_F32); 186 psImage *radius2 = psImageAlloc(numCols2, numRows2, PS_TYPE_F32); 187 psImageInit(radius1,pow(numCols1 + numRows1,2)); // These values can be anything, just need to be larger than a binned radius. 188 psImageInit(radius2,pow(numCols1 + numRows1,2)); 226 189 227 psImage *mask1 = NULL, *mask2 = NULL; // Binned masks228 if (data->masksName) {229 mask1 = psImageAlloc(numCols1, numRows1, PS_TYPE_IMAGE_MASK);230 mask2 = psImageAlloc(numCols2, numRows2, PS_TYPE_IMAGE_MASK);231 psImageInit(mask1, 0xFF);232 psImageInit(mask2, 0xFF);233 }234 190 // HDU containing the WCS we plan on using 235 191 pmHDU *projhdu = NULL; … … 249 205 } 250 206 pmFPAfileActivateSingle(data->config->files, true, "PPSKYCELL.IMAGE", j); 251 if (data->masksName) {252 pmFPAfileActivateSingle(data->config->files, true, "PPSKYCELL.MASK", j);253 }254 207 255 208 pmFPAview *view = filesIterateDown(data->config); // View to readout … … 304 257 } 305 258 306 #if (0) 307 psRegion *imageRegion = imageRegions->data[j]; // Region for image 308 fprintf(stderr,"%d IM %f %f %f %f PR %f %f %f %f\n", 309 j, 310 imageRegion->x0,imageRegion->x1, 311 imageRegion->y0,imageRegion->y1, 312 projRegion->x0,projRegion->x1, 313 projRegion->y0,projRegion->y1); 314 #endif 259 // Scale by exposure time 260 double exptime_factor = pow(exptimes->data.F64[j]/stats->robustMedian,data->exptimeOrder); 261 if ((isfinite(exptime_factor))&&(exptime_factor != 0.0)) { 262 psBinaryOp(bin1RO->image,bin1RO->image,"/", 263 psScalarAlloc(exptime_factor, PS_TYPE_F32)); 264 psBinaryOp(bin2RO->image,bin2RO->image,"/", 265 psScalarAlloc(exptime_factor, PS_TYPE_F32)); 266 } 267 // End scaling 268 315 269 // Offsets for image on this projection cell are just differences in CRPIX positions. 316 270 int xOffset1 = (-1 * wcs->crpix1 - projRegion->x0) / (float)(data->bin1); 317 271 int yOffset1 = (-1 * wcs->crpix2 - projRegion->y0) / (float)(data->bin1); 318 272 319 int xOffset2 = xOffset1 / (float)data->bin2, yOffset2 = yOffset1 / (float)data->bin2; 273 int xOffset2 = xOffset1 / (float)data->bin2; 274 int yOffset2 = yOffset1 / (float)data->bin2; 320 275 psTrace("ppSkycell",5,"Offsets: %d %d : %d %d", 321 276 xOffset1,yOffset1,xOffset2,yOffset2); 322 277 278 // Check each pixel for primacy. A pixel is primary 279 // if it is closer to the central pixel of its skycell 280 // than any other pixel is to theirs. 281 282 // Let's just do the overlay here, instead of doing math, then handing it 283 // off to another function. That seems silly. 284 285 int u,v,x,y; 286 287 double u0 = xOffset1 + (bin1RO->image->numCols) / 2.0; 288 double v0 = yOffset1 + (bin1RO->image->numRows) / 2.0; 289 for (x = 0; x < bin1RO->image->numCols; x++) { 290 for (y = 0; y < bin1RO->image->numRows; y++) { 291 if (!isfinite(bin1RO->image->data.F32[y][x])) { 292 continue; 293 } 294 u = x + xOffset1; 295 v = y + yOffset1; 296 double R2 = pow(u - u0,2) + pow(v - v0,2); 297 298 if (R2 < radius1->data.F32[v][u]) { 299 radius1->data.F32[v][u] = R2; 300 image1->data.F32[v][u] = bin1RO->image->data.F32[y][x]; 301 } 302 } 303 } 304 305 u0 = xOffset2 + (bin2RO->image->numCols) / 2.0; 306 v0 = yOffset2 + (bin2RO->image->numRows) / 2.0; 307 for (x = 0; x < bin2RO->image->numCols; x++) { 308 for (y = 0; y < bin2RO->image->numRows; y++) { 309 if (!isfinite(bin2RO->image->data.F32[y][x])) { 310 continue; 311 } 312 u = x + xOffset2; 313 v = y + yOffset2; 314 double R2 = pow(u - u0,2) + pow(v - v0,2); 315 if (R2 < radius2->data.F32[v][u]) { 316 radius2->data.F32[v][u] = R2; 317 image2->data.F32[v][u] = bin2RO->image->data.F32[y][x]; 318 } 319 } 320 } 321 322 323 324 323 325 // Overlay the data onto the appropriate pixels in the final outputs 324 326 // XXX Completely neglecting rotations 325 327 // The skycells are divided up neatly with them all having the same orientation 326 psImageOverlaySection(image1, bin1RO->image, xOffset1, yOffset1, "E"); 327 psImageOverlaySection(image2, bin2RO->image, xOffset2, yOffset2, "E"); 328 if (data->masksName) { 329 psImageOverlaySection(mask1, bin1RO->mask, xOffset1, yOffset1, "M"); 330 psImageOverlaySection(mask2, bin2RO->mask, xOffset2, yOffset2, "M"); 331 } 328 // psImageOverlaySection(image1, bin1RO->image, xOffset1, yOffset1, "E"); 329 // psImageOverlaySection(image2, bin2RO->image, xOffset2, yOffset2, "E"); 332 330 333 331 // Cleanup on input loop. … … 337 335 psFree(file->fpa); 338 336 file->fpa = NULL; 339 if (data->masksName) {340 pmFPAfile *file = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.MASK", j);341 psFree(file->fpa);342 file->fpa = NULL;343 }344 337 pmFPAfileActivate(data->config->files, false, NULL); 345 338 } … … 350 343 pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN1"); 351 344 pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN2"); 352 if (data->masksName) {353 pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN1.MASK");354 pmFPAfileActivate(data->config->files, true, "PPSKYCELL.BIN2.MASK");355 }356 345 } 357 346 … … 366 355 ro1->image = image1; 367 356 ro2->image = image2; 368 ro1->mask = mask1;369 ro2->mask = mask2;370 357 371 358 ro1->data_exists = cell1->data_exists = cell1->parent->data_exists = true; … … 386 373 fits1->fpa->hdu->header = psMetadataAlloc(); 387 374 psMetadataCopy(fits1->fpa->hdu->header,projhdu->header); 388 375 389 376 // Change wcs here 390 #define WCS_DEBUG 0391 377 if (modify_wcs1) { 392 378 pmAstromWCS *WCS = pmAstromWCSfromHeader(fits1->fpa->hdu->header); 393 379 double cd1f = 1.0 * data->bin1; 394 380 double cd2f = 1.0 * data->bin1; 395 #if WCS_DEBUG 396 fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g)\n",data->bin1,data->bin2, 397 cd1f,cd2f,WCS->cdelt1,WCS->cdelt2, 398 WCS->crpix1,WCS->crpix2 399 ); 400 #endif 381 401 382 WCS->cdelt1 *= cd1f; 402 383 WCS->cdelt2 *= cd2f; … … 414 395 WCS->crpix2 = WCS->crpix2 / cd2f; 415 396 } 416 #if WCS_DEBUG 417 fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g) %d %d %d %d\n",data->bin1,data->bin2, 418 cd1f,cd2f,WCS->cdelt1,WCS->cdelt2, 419 WCS->crpix1,WCS->crpix2, 420 WCS->trans->x->nX, WCS->trans->x->nY, 421 WCS->trans->y->nX, WCS->trans->y->nY 422 ); 423 #endif 397 424 398 for (int q = 0; q <= WCS->trans->x->nX; q++) { 425 399 for (int r = 0; r <= WCS->trans->x->nY; r++) { 426 400 WCS->trans->x->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r); 427 #if WCS_DEBUG428 fprintf(stderr,"PC: %d %d %g %g\n",429 q,r,pow(cd1f,q) * pow(cd2f,r),430 WCS->trans->x->coeff[q][r]);431 #endif432 401 } 433 402 } … … 435 404 for (int r = 0; r <= WCS->trans->y->nY; r++) { 436 405 WCS->trans->y->coeff[q][r] *= pow(cd1f,q) * pow(cd2f,r); 437 #if WCS_DEBUG438 fprintf(stderr,"PC: %d %d %g %g\n",439 q,r,pow(cd1f,q) * pow(cd2f,r),440 WCS->trans->y->coeff[q][r]);441 #endif442 406 } 443 407 } 444 408 pmAstromWCStoHeader (fits1->fpa->hdu->header,WCS); 445 #if WCS_DEBUG446 WCS = pmAstromWCSfromHeader(fits1->fpa->hdu->header);447 fprintf(stderr,">>> %d %d (%g %g) (%g %g) (%g %g)\n",data->bin1,data->bin2,448 cd1f,cd2f,WCS->cdelt1,WCS->cdelt2,449 WCS->crpix1,WCS->crpix2450 );451 #endif452 409 modify_wcs1 = 0; 453 410 } … … 459 416 460 417 pmCell *Fcell1 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN1"); // Rebinned cell 1 461 /* // This is a hack to get a functioning header created so the fits images can be written out. */ 418 // This is a hack to get a functioning header created so the fits images can be written out. 462 419 psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.XPARITY", PS_META_REPLACE,"",1); 463 420 psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1); 464 421 psMetadataAddS32(Fcell1->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1); 465 422 423 // I am baffled that this is the way to get the exposure time updated correctly. 424 psMetadataItem *item1; 425 item1 = psMetadataLookup(Fcell1->concepts,"CELL.EXPOSURE"); 426 item1->data.F32 = stats->robustMedian; 427 466 428 pmReadout *Fro1 = pmReadoutAlloc(Fcell1); 467 429 Fro1->image = image1; 468 Fro1->mask = mask1;469 430 Fro1->data_exists = Fcell1->data_exists = Fcell1->parent->data_exists = true; 470 431 … … 472 433 fits1->fileIndex = i; 473 434 474 // Do the mask if we need to475 if (data->masksName) {476 /* pmFPAfile *Mask1 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN1.MASK", 0); */477 /* // Mask1->fpa->hdu = pmHDUAlloc(NULL); */478 /* // Mask1->fpa->hdu->header = psMetadataAlloc(); */479 /* // psMetadataCopy(Mask1->fpa->hdu->header,fits1->fpa->hdu->header); */480 /* pmChip *Mchip1 = pmFPAfileThisChip(data->config->files, view, "PPSKYCELL.BIN1.MASK"); */481 /* psMetadataAddS32(Mchip1->concepts,PS_LIST_TAIL,"CHIP.XPARITY", PS_META_REPLACE,"",1); */482 /* psMetadataAddS32(Mchip1->concepts,PS_LIST_TAIL,"CHIP.YPARITY", PS_META_REPLACE,"",1); */483 484 /* pmCell *Mcell1 = pmFPAfileThisCell(data->config->files, view, "PPSKYCELL.BIN1.MASK"); // Rebinned cell 1 */485 /* /\* // This is a hack to get a functioning header created so the fits images can be written out. *\/ */486 /* psMetadataAddS32(Mcell1->concepts,PS_LIST_TAIL,"CELL.XPARITY", PS_META_REPLACE,"",1); */487 /* psMetadataAddS32(Mcell1->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1); */488 /* psMetadataAddS32(Mcell1->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1); */489 490 /* pmReadout *Mro1 = pmReadoutAlloc(Mcell1); */491 /* Mro1->image = image1; */492 /* Mro1->mask = mask1; */493 /* Mro1->data_exists = Mcell1->data_exists = Mcell1->parent->data_exists = true; */494 495 /* Mask1->save = true; */496 /* Mask1->fileIndex = i; */497 }498 499 500 501 435 // Repeat with second binned image 502 436 pmFPAfile *fits2 = pmFPAfileSelectSingle(data->config->files, "PPSKYCELL.BIN2", 0); … … 504 438 fits2->fpa->hdu->header = psMetadataAlloc(); 505 439 psMetadataCopy(fits2->fpa->hdu->header,projhdu->header); 506 440 507 441 if (modify_wcs2) { 508 442 pmAstromWCS *WCS = pmAstromWCSfromHeader(fits2->fpa->hdu->header); … … 538 472 psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.YPARITY", PS_META_REPLACE,"",1); 539 473 psMetadataAddS32(Fcell2->concepts,PS_LIST_TAIL,"CELL.READDIR", PS_META_REPLACE,"",1); 474 475 psMetadataItem *item2 = psMetadataLookup(Fcell2->concepts,"CELL.EXPOSURE"); 476 item2->data.F32 = stats->robustMedian; 540 477 541 478 pmReadout *Fro2 = pmReadoutAlloc(Fcell2); 542 479 Fro2->image = image2; 543 Fro2->mask = mask2;544 480 Fro2->data_exists = Fcell2->data_exists = Fcell2->parent->data_exists = true; 545 481 … … 551 487 552 488 psFree(view); 553 #if 0554 {555 psString filename = NULL; // Filename for image556 psStringAppend(&filename, "skycell_%d_1.fits", i);557 psFits *fits = psFitsOpen(filename, "w");558 psFree(filename);559 psFitsWriteImage(fits, NULL, image1, 0, NULL);560 psFitsClose(fits);561 }562 563 {564 psString filename = NULL; // Filename for image565 psStringAppend(&filename, "skycell_%d_2.fits", i);566 psFits *fits = psFitsOpen(filename, "w");567 psFree(filename);568 psFitsWriteImage(fits, NULL, image2, 0, NULL);569 psFitsClose(fits);570 }571 #endif572 489 573 490 filesIterateUp(data->config);
Note:
See TracChangeset
for help on using the changeset viewer.
