Changeset 21268 for branches/eam_branch_20081230/pswarp/src/pswarpLoop.c
- Timestamp:
- Feb 2, 2009, 11:57:10 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branch_20081230/pswarp/src/pswarpLoop.c
r21090 r21268 1 /** @file pswarpLoop.c 2 * 3 * @brief 4 * 5 * @ingroup pswarp 6 * 7 * @author IfA 8 * @version $Revision: 1.32.8.2 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2009-02-02 21:57:10 $ 10 * Copyright 2009 Institute for Astronomy, University of Hawaii 11 */ 12 1 13 #include "pswarp.h" 2 14 #include <ppStats.h> 3 15 4 #define WCS_NONLIN_TOL 0.001 // Non-linear tolerance for header WCS 5 #define PSPHOT_FIND_PSF 0 // Use psphot's findPSF function? 6 //#define TESTING 1 // Testing output? 7 8 // Lists of file rules for the detectors and skycells, and an independent list of everything else 9 // Lists must end with a NULL 10 static char *detectorFiles[] = { "PSWARP.INPUT", "PSWARP.MASK", "PSWARP.WEIGHT", NULL }; 11 static char *skycellFiles[] = { "PSWARP.OUTPUT", "PSWARP.OUTPUT.MASK", "PSWARP.OUTPUT.WEIGHT", NULL }; 12 static char *photFiles[] = { "PSPHOT.INPUT", "PSPHOT.OUTPUT", 13 #if PSPHOT_FIND_PSF 14 "PSPHOT.INPUT.CMF", 15 #endif 16 "PSPHOT.RESID", 17 "PSPHOT.BACKMDL", "PSPHOT.BACKMDL.STDEV", "PSPHOT.BACKGND", "PSPHOT.BACKSUB", 18 "PSPHOT.PSF.SAVE", "SOURCE.PLOT.MOMENTS", "SOURCE.PLOT.PSFMODEL", 19 "SOURCE.PLOT.APRESID", NULL }; 20 static char *independentFiles[] = { "PSWARP.ASTROM", // Read independently from the input pixels 21 "PSWARP.SKYCELL", // Don't care about the skycell once we have its WCS 22 "PSWARP.OUTPUT.SOURCES", // Save these independently so we can do the PSF 23 NULL }; 24 25 // Activate a list of files 26 static void fileActivation(pmConfig *config, // Configuration 27 char **files, // Files to turn on/off 28 bool state // Activation state 16 #define WCS_NONLIN_TOL 0.001 ///< Non-linear tolerance for header WCS 17 #define PSPHOT_FIND_PSF 1 ///< Use psphot's findPSF function? 18 #define TESTING 0 ///< Testing output? 19 20 #include "pswarpFileNames.h" ///< Lists of file rules used at different stages 21 22 /** 23 * XXX these are generic functions which should be moved to psModules 24 * Activate a list of files 25 */ 26 static void fileActivation(pmConfig *config, ///< Configuration 27 char **files, ///< Files to turn on/off 28 bool state ///< Activation state 29 29 ) 30 30 { … … 35 35 } 36 36 37 // Run down the FPA hierarchy, checking files 38 static bool ioChecksBefore(pmConfig *config // Configuration 37 /** 38 * Run down the FPA hierarchy, checking files 39 */ 40 static bool ioChecksBefore(pmConfig *config ///< Configuration 39 41 ) 40 42 { 41 pmFPAview *view = pmFPAviewAlloc(0); // View for checking42 bool status = true; // Status of checks43 pmFPAview *view = pmFPAviewAlloc(0); ///< View for checking 44 bool status = true; ///< Status of checks 43 45 status &= pmFPAfileIOChecks(config, view, PM_FPA_BEFORE); 44 46 view->chip = 0; … … 50 52 } 51 53 52 // Run up the FPA hierarchy, checking files 53 static bool ioChecksAfter(pmConfig *config // Configuration 54 /** 55 * Run up the FPA hierarchy, checking files 56 */ 57 static bool ioChecksAfter(pmConfig *config ///< Configuration 54 58 ) 55 59 { 56 pmFPAview *view = pmFPAviewAlloc(0); // View for checking60 pmFPAview *view = pmFPAviewAlloc(0); ///< View for checking 57 61 view->chip = view->cell = 0; 58 bool status = true; // Status of checks62 bool status = true; ///< Status of checks 59 63 status &= pmFPAfileIOChecks(config, view, PM_FPA_AFTER); 60 64 view->cell = -1; … … 67 71 68 72 69 // Loop over the inputs, warp them to the output skycell and then write out the output. 73 /** 74 * Loop over the inputs, warp them to the output skycell and then write out the output. 75 */ 70 76 bool pswarpLoop(pmConfig *config) 71 77 { … … 113 119 psFree (view); 114 120 115 bool mdok; // Status of MD lookup116 const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics117 psMetadata *stats = NULL; // Container for statistics118 FILE *statsFile = NULL; // File stream for statistics121 bool mdok; ///< Status of MD lookup 122 const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); ///< Filename for statistics 123 psMetadata *stats = NULL; ///< Container for statistics 124 FILE *statsFile = NULL; ///< File stream for statistics 119 125 if (mdok && statsName && strlen(statsName) > 0) { 120 126 psString resolved = pmConfigConvertFilename(statsName, config, true, true); … … 141 147 142 148 // Read the input astrometry 149 // XXX rather than use the activations here, this should just explicitly loop over the desired filerule 143 150 { 144 151 pmFPAfileActivate(config->files, true, "PSWARP.ASTROM"); … … 257 264 } 258 265 259 pmCell *outCell = output->parent; // Output cell260 pmChip *outChip = outCell->parent; // Output chip261 pmFPA *outFPA = outChip->parent; // Output FP266 pmCell *outCell = output->parent; ///< Output cell 267 pmChip *outChip = outCell->parent; ///< Output chip 268 pmFPA *outFPA = outChip->parent; ///< Output FP 262 269 263 270 if (!pswarpPixelFraction(output, stats, config)) { … … 277 284 varFactor /= goodPix; 278 285 279 psMetadataItem *vfItem = psMetadataLookup(outCell->concepts, "CELL.VARFACTOR"); // Item to update286 psMetadataItem *vfItem = psMetadataLookup(outCell->concepts, "CELL.VARFACTOR"); ///< Item to update 280 287 psAssert(vfItem && vfItem->type == PS_TYPE_F32, "Concept should be as specified."); 281 288 if (!isfinite(vfItem->data.F32)) { … … 295 302 psFree(cells); 296 303 297 psRegion *trimsec = psMetadataLookupPtr(NULL, outCell->concepts, "CELL.TRIMSEC"); // Trim section298 trimsec->x0 = trimsec->x1 = trimsec->y0 = trimsec->y1 = 0; // All pixels304 psRegion *trimsec = psMetadataLookupPtr(NULL, outCell->concepts, "CELL.TRIMSEC"); ///< Trim section 305 trimsec->x0 = trimsec->x1 = trimsec->y0 = trimsec->y1 = 0; ///< All pixels 299 306 300 307 if (!psMetadataCopy(outFPA->concepts, input->fpa->concepts)) { … … 305 312 } 306 313 307 pmHDU *hdu = outFPA->hdu; // HDU for the output warped image314 pmHDU *hdu = outFPA->hdu; ///< HDU for the output warped image 308 315 309 316 // Copy header from target 310 317 { 311 pmFPAview *skyView = pmFPAviewAlloc(0); // View into skycell318 pmFPAview *skyView = pmFPAviewAlloc(0); ///< View into skycell 312 319 skyView->chip = skyView->cell = 0; 313 320 pmCell *cell = pmFPAfileThisCell(config->files, skyView, "PSWARP.SKYCELL"); // Skycell cell 314 321 psFree(skyView); 315 pmHDU *skyHDU = pmHDUFromCell(cell); // HDU322 pmHDU *skyHDU = pmHDUFromCell(cell); ///< HDU 316 323 if (!skyHDU) { 317 324 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find skycell HDU."); … … 364 371 pmFPACopy(photFile->fpa, outFPA); 365 372 366 pmFPAview *view = pmFPAviewAlloc(0); // View into skycell373 pmFPAview *view = pmFPAviewAlloc(0); ///< View into skycell 367 374 view->chip = view->cell = view->readout = 0; 368 375 … … 372 379 // We can adjust the weight directly since this is a deep copy 373 380 pmReadout *photRO = pmFPAviewThisReadout(view, photFile->fpa); 374 float vf = psMetadataLookupF32(NULL, photRO->parent->concepts, "CELL.VARFACTOR"); // Variance factor381 float vf = psMetadataLookupF32(NULL, photRO->parent->concepts, "CELL.VARFACTOR"); ///< Variance factor 375 382 psBinaryOp(photRO->weight, photRO->weight, "*", psScalarAlloc(vf, PS_TYPE_F32)); 376 383 … … 386 393 #endif 387 394 388 #if def TESTING395 #if (TESTING) 389 396 { 390 #define PSF_SIZE 20 // Half-size of PSF391 #define PSF_FLUX 10000 // Central flux for PSF397 #define PSF_SIZE 20 ///< Half-size of PSF 398 #define PSF_FLUX 10000 ///< Central flux for PSF 392 399 pmChip *photChip = pmFPAviewThisChip(view, photFile->fpa); 393 400 pmPSF *psf = psMetadataLookupPtr(NULL, photChip->analysis, "PSPHOT.PSF"); … … 419 426 const char *chipName = psMetadataLookupStr(NULL, output->parent->parent->concepts, "CHIP.NAME"); 420 427 const char *cellName = psMetadataLookupStr(NULL, output->parent->concepts, "CELL.NAME"); 421 psString headerName = NULL; // Header name for MD5428 psString headerName = NULL; ///< Header name for MD5 422 429 psStringAppend(&headerName, "MD5_%s_%s_%d", chipName, cellName, view->readout); 423 psVector *md5 = psImageMD5(output->image); // md5 hash424 psString md5string = psMD5toString(md5); // String430 psVector *md5 = psImageMD5(output->image); ///< md5 hash 431 psString md5string = psMD5toString(md5); ///< String 425 432 psFree(md5); 426 433 psMetadataAddStr(hdu->header, PS_LIST_TAIL, headerName, PS_META_REPLACE,
Note:
See TracChangeset
for help on using the changeset viewer.
