Changeset 37966
- Timestamp:
- Mar 11, 2015, 7:38:53 PM (11 years ago)
- Location:
- trunk/ppSub/src
- Files:
-
- 3 edited
-
ppSubCamera.c (modified) (17 diffs)
-
ppSubDefineOutput.c (modified) (6 diffs)
-
ppSubReadoutPhotometry.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSub/src/ppSubCamera.c
r29954 r37966 22 22 #include "ppSub.h" 23 23 24 bool checkFileruleFileSave (pmFPAfile *file, pmConfig *config) { 25 26 bool status; 27 28 psMetadata *filerule = pmConfigFileRule(config, file->camera, file->name); // File rule 29 if (!filerule) return false; 30 31 char *myString = psMetadataLookupStr(&status, filerule, "FILE.SAVE"); 32 if (!myString) return false; 33 34 // do not change the value from the default unless TRUE or FALSE are found 35 if (!strcasecmp(myString, "TRUE")) { 36 file->save = true; 37 return true; 38 } 39 if (!strcasecmp(myString, "FALSE")) { 40 file->save = false; 41 return true; 42 } 43 44 return false; 45 } 46 24 47 // Define an input file 25 48 static pmFPAfile *defineInputFile(bool *success, … … 131 154 } 132 155 if (file) { 133 // It's an output 134 file->save = true; 156 // It's an output (respect filerules) 157 checkFileruleFileSave(file, config); 135 158 } 136 159 } … … 244 267 return false; 245 268 } 269 // these ->save values below are set by command-line arguments (in ppSubArguments.c) : -save-inconv, -save-refconv 246 270 inConvImage->save = data->saveInConv; 247 271 inConvMask->save = data->saveInConv; … … 283 307 return false; 284 308 } 285 output->save = true;286 outMask->save = true;309 checkFileruleFileSave (output, config); 310 checkFileruleFileSave (outMask, config); 287 311 if (inVar && refVar) { 288 312 pmFPAfile *outVar = defineOutputFile(config, output, false, "PPSUB.OUTPUT.VARIANCE", … … 292 316 return false; 293 317 } 294 outVar->save = true;318 checkFileruleFileSave (outVar, config); 295 319 } 296 320 … … 305 329 return false; 306 330 } 307 inverse->save = true;308 invMask->save = true;331 checkFileruleFileSave (inverse, config); 332 checkFileruleFileSave (invMask, config); 309 333 if (inVar && refVar) { 310 334 pmFPAfile *invVar = defineOutputFile(config, inverse, false, "PPSUB.INVERSE.VARIANCE", … … 314 338 return false; 315 339 } 316 invVar->save = true;340 checkFileruleFileSave(invVar, config); 317 341 } 318 342 } … … 329 353 return false; 330 354 } 331 jpeg1->save = true;355 checkFileruleFileSave(jpeg1, config); 332 356 pmFPAfile *jpeg2 = pmFPAfileDefineOutput(config, NULL, "PPSUB.OUTPUT.JPEG2"); 333 357 if (!jpeg2) { … … 339 363 return false; 340 364 } 341 jpeg2->save = true;365 checkFileruleFileSave(jpeg2, config); 342 366 343 367 // Output residual JPEG … … 351 375 return false; 352 376 } 353 jpeg3->save = true;377 checkFileruleFileSave(jpeg3, config); 354 378 355 379 // Output subtraction kernel … … 395 419 // Deactivate psphot output sources --- we want to define output source files of our own 396 420 pmFPAfile *psphotOutput = pmFPAfileSelectSingle(config->files, "PSPHOT.OUTPUT", 0); 397 psphotOutput->save = false; 421 psphotOutput->save = false; // this one should NOT be set 398 422 399 423 pmFPAfile *outSources = defineOutputFile(config, output, false, "PPSUB.OUTPUT.SOURCES", … … 403 427 return false; 404 428 } 405 outSources->save = true;429 checkFileruleFileSave(outSources, config); 406 430 407 431 if (data->inverse) { … … 412 436 return false; 413 437 } 414 invSources->save = true;438 checkFileruleFileSave(invSources, config); 415 439 } 416 440 … … 423 447 return false; 424 448 } 425 posSources1->save = true;449 checkFileruleFileSave(posSources1, config); 426 450 427 451 // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #1 … … 431 455 return false; 432 456 } 433 frcSources1->save = true;457 checkFileruleFileSave(frcSources1, config); 434 458 } 435 459 … … 441 465 return false; 442 466 } 443 posSources2->save = true;467 checkFileruleFileSave(posSources2, config); 444 468 445 469 // this pmFPAfile is used to carry sources detected in the diff image @ the positions from positive image #2 … … 449 473 return false; 450 474 } 451 frcSources2->save = true;475 checkFileruleFileSave(frcSources2, config); 452 476 } 453 477 } -
trunk/ppSub/src/ppSubDefineOutput.c
r31435 r37966 22 22 #include "ppSub.h" 23 23 24 bool ppSubCopyWarpToChip (psMetadata *tgtHeader, psMetadata *srcHeader); 25 24 26 bool ppSubDefineOutput(const char *name, pmConfig *config) 25 27 { 26 28 psAssert(name, "Require name"); 27 29 psAssert(config, "Require configuration"); 30 31 bool status = false; 28 32 29 33 pmFPAview *view = ppSubViewReadout(); // View to readout … … 44 48 45 49 // Convolved input images 46 psMetadata *recipe = psMetadataLookupPtr(NULL, config->recipes, PPSUB_RECIPE); 47 bool noConvolve = psMetadataLookupBool(NULL, recipe, "NOCONVOLVE"); // Do not use convolved images. 50 psMetadata *recipe = psMetadataLookupPtr(&status, config->recipes, PPSUB_RECIPE); 51 bool noConvolve = psMetadataLookupBool(&status, recipe, "NOCONVOLVE"); // Do not use convolved images. 52 bool reverse = psMetadataLookupBool(&status, config->arguments, "REVERSE"); // Reverse sense of subtraction? 53 bool mapFromPositive = psMetadataLookupBool(&status, config->arguments, "CHIP.MAP.FROM.POSITIVE"); 54 // mapFromPositive = true means "always grab the warp->chip map from the positive image (eg, A for A - B, B for B - A) 55 // mapFromPositive = false means "always grab the warp->chip map from the first image (eg, PPSUB.INPUT if not 'reverse') 48 56 49 57 pmReadout *inConv; 50 58 if (noConvolve) { 51 59 inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT"); // Input readout 52 } 53 else { 60 } else { 54 61 inConv = pmFPAfileThisReadout(config->files, view, "PPSUB.INPUT.CONV"); // Input readout 55 62 } … … 57 64 if (noConvolve) { 58 65 refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF"); // Reference readout 59 } 60 else { 66 } else { 61 67 refConv = pmFPAfileThisReadout(config->files, view, "PPSUB.REF.CONV"); // Reference readout 62 68 } 63 psFree(view);64 69 65 70 // Add kernel descrption to header. … … 78 83 psError(PPSUB_ERR_UNKNOWN, true, "Unable to find SUBTRACTION.KERNEL"); 79 84 psFree(outRO); 85 psFree(view); 80 86 return false; 81 87 } … … 85 91 } 86 92 outHDU->header = psMetadataCopy(outHDU->header, hdu->header); 93 94 // in warp-stack mode, we should always use the warp 95 // in warp-warp mode, we should use the positive warp for the positive subtraction 96 97 bool normalDiff = true; 98 if (!strcmp (name, "PPSUB.INVERSE")) { 99 normalDiff = false; 100 } 101 102 if (reverse) { 103 // normal = PPSUB.REF - PPSUB.INPUT 104 // inverse = PPSUB.INPUT - PPSUB.REF 105 if (mapFromPositive) { 106 pmCell *cell_Pos = normalDiff ? pmFPAfileThisCell(config->files, view, "PPSUB.REF") : pmFPAfileThisCell(config->files, view, "PPSUB.INPUT"); 107 pmHDU *hdu_Pos = pmHDUFromCell(cell_Pos); 108 ppSubCopyWarpToChip (outHDU->header, hdu_Pos->header); 109 } else { 110 pmCell *cell_Pos = pmFPAfileThisCell(config->files, view, "PPSUB.REF"); 111 pmHDU *hdu_Pos = pmHDUFromCell(cell_Pos); 112 ppSubCopyWarpToChip (outHDU->header, hdu_Pos->header); 113 } 114 } else { 115 // normal = PPSUB.INPUT - PPSUB.REF 116 // inverse = PPSUB.REF - PPSUB.INPUT 117 if (mapFromPositive) { 118 pmCell *cell_Pos = normalDiff ? pmFPAfileThisCell(config->files, view, "PPSUB.INPUT") : pmFPAfileThisCell(config->files, view, "PPSUB.REF"); 119 pmHDU *hdu_Pos = pmHDUFromCell(cell_Pos); 120 ppSubCopyWarpToChip (outHDU->header, hdu_Pos->header); 121 } else { 122 pmCell *cell_Pos = pmFPAfileThisCell(config->files, view, "PPSUB.INPUT"); 123 pmHDU *hdu_Pos = pmHDUFromCell(cell_Pos); 124 ppSubCopyWarpToChip (outHDU->header, hdu_Pos->header); 125 } 126 } 87 127 88 128 // Add additional data to the header … … 104 144 105 145 psFree(outRO); 146 psFree(view); 106 147 107 148 return true; 108 149 } 150 151 // we have 4 sets of header keywords to copy: 152 // SRC_nnnn, SEC_nnnn, MPX_nnnn, MPY_nnnn 153 154 bool ppSubCopyWarpToChip (psMetadata *tgtHeader, psMetadata *srcHeader) { 155 156 char keyword[80]; 157 158 bool status = false; 159 160 int Nchip = 0; 161 while (true) { 162 snprintf (keyword, 80, "SRC_%04d", Nchip); 163 char *string = psMetadataLookupStr (&status, srcHeader, keyword); 164 if (!status) { 165 break; 166 } 167 psMetadataAddStr(tgtHeader, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", string); 168 Nchip ++; 169 } 170 171 for (int i = 0; i < Nchip; i++) { 172 snprintf (keyword, 80, "SEC_%04d", i); 173 char *string = psMetadataLookupStr (&status, srcHeader, keyword); 174 if (!status) { 175 psWarning ("cannot find keyword %s\n", keyword); 176 continue; 177 } 178 psMetadataAddStr(tgtHeader, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", string); 179 } 180 181 for (int i = 0; i < Nchip; i++) { 182 snprintf (keyword, 80, "MPX_%04d", i); 183 char *string = psMetadataLookupStr (&status, srcHeader, keyword); 184 if (!status) { 185 psWarning ("cannot find keyword %s\n", keyword); 186 continue; 187 } 188 psMetadataAddStr(tgtHeader, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", string); 189 } 190 191 for (int i = 0; i < Nchip; i++) { 192 snprintf (keyword, 80, "MPY_%04d", i); 193 char *string = psMetadataLookupStr (&status, srcHeader, keyword); 194 if (!status) { 195 psWarning ("cannot find keyword %s\n", keyword); 196 continue; 197 } 198 psMetadataAddStr(tgtHeader, PS_LIST_TAIL, keyword, PS_META_REPLACE, "input image", string); 199 } 200 return true; 201 } 202 203 bool ppSubCopyWarpToChip_Alt (psMetadata *tgtHeader, psMetadata *srcHeader, bool isPositive) { 204 205 char srcKeyword[80], tgtKeyword[80]; 206 207 bool status = false; 208 209 int Nchip = 0; 210 while (true) { 211 snprintf (srcKeyword, 80, "SRC_%04d", Nchip); 212 if (isPositive) { 213 snprintf (tgtKeyword, 80, "SRCP_%03d", Nchip); 214 } else { 215 snprintf (tgtKeyword, 80, "SRCM_%03d", Nchip); 216 } 217 218 char *string = psMetadataLookupStr (&status, srcHeader, srcKeyword); 219 if (!status) { 220 break; 221 } 222 psMetadataAddStr(tgtHeader, PS_LIST_TAIL, srcKeyword, PS_META_REPLACE, "input image", string); 223 Nchip ++; 224 } 225 226 for (int i = 0; i < Nchip; i++) { 227 snprintf (srcKeyword, 80, "SEC_%04d", i); 228 if (isPositive) { 229 snprintf (tgtKeyword, 80, "SECP_%03d", Nchip); 230 } else { 231 snprintf (tgtKeyword, 80, "SECM_%03d", Nchip); 232 } 233 234 char *string = psMetadataLookupStr (&status, srcHeader, srcKeyword); 235 if (!status) { 236 psWarning ("cannot find keyword %s\n", srcKeyword); 237 continue; 238 } 239 psMetadataAddStr(tgtHeader, PS_LIST_TAIL, srcKeyword, PS_META_REPLACE, "input image", string); 240 } 241 242 for (int i = 0; i < Nchip; i++) { 243 snprintf (srcKeyword, 80, "MPX_%04d", i); 244 if (isPositive) { 245 snprintf (tgtKeyword, 80, "MPXP_%03d", Nchip); 246 } else { 247 snprintf (tgtKeyword, 80, "MPXM_%03d", Nchip); 248 } 249 250 char *string = psMetadataLookupStr (&status, srcHeader, srcKeyword); 251 if (!status) { 252 psWarning ("cannot find keyword %s\n", srcKeyword); 253 continue; 254 } 255 psMetadataAddStr(tgtHeader, PS_LIST_TAIL, srcKeyword, PS_META_REPLACE, "input image", string); 256 } 257 258 for (int i = 0; i < Nchip; i++) { 259 snprintf (srcKeyword, 80, "MPY_%04d", i); 260 if (isPositive) { 261 snprintf (tgtKeyword, 80, "MPYP_%03d", Nchip); 262 } else { 263 snprintf (tgtKeyword, 80, "MPYM_%03d", Nchip); 264 } 265 266 char *string = psMetadataLookupStr (&status, srcHeader, srcKeyword); 267 if (!status) { 268 psWarning ("cannot find keyword %s\n", srcKeyword); 269 continue; 270 } 271 psMetadataAddStr(tgtHeader, PS_LIST_TAIL, srcKeyword, PS_META_REPLACE, "input image", string); 272 } 273 return true; 274 } 275 -
trunk/ppSub/src/ppSubReadoutPhotometry.c
r32822 r37966 46 46 psFree(view); 47 47 return false; 48 } 49 50 // psphot may need the PHU header 51 if (!photFile->fpa->hdu) { 52 photFile->fpa->hdu = psMemIncrRefCounter (inFile->fpa->hdu); 48 53 } 49 54
Note:
See TracChangeset
for help on using the changeset viewer.
