Changeset 23576
- Timestamp:
- Mar 27, 2009, 1:26:55 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 9 edited
-
ppStack/src/Makefile.am (modified) (1 diff)
-
ppStack/src/ppStackCamera.c (modified) (5 diffs)
-
ppStack/src/ppStackCombineInitial.c (modified) (1 diff)
-
ppStack/src/ppStackCombinePrepare.c (added)
-
ppStack/src/ppStackLoop.c (modified) (1 diff)
-
ppStack/src/ppStackLoop.h (modified) (1 diff)
-
ppStack/src/ppStackReadout.c (modified) (3 diffs)
-
ppStack/src/ppStackSetup.c (modified) (3 diffs)
-
psModules/src/camera/pmFPAfileIO.c (modified) (2 diffs)
-
psModules/src/camera/pmFPAfileIO.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppStack/src/Makefile.am
r23341 r23576 29 29 ppStackPrepare.c \ 30 30 ppStackConvolve.c \ 31 ppStackCombinePrepare.c \ 31 32 ppStackCombineInitial.c \ 32 33 ppStackReject.c \ -
trunk/ppStack/src/ppStackCamera.c
r23371 r23576 51 51 bool status = false; // Status of file definition 52 52 53 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim 54 if (!recipe) { 55 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE); 56 return false; 57 } 58 bool convolve = psMetadataLookupBool(NULL, recipe, "CONVOLVE"); // Convolve images before stack? 59 53 60 psArray *runImages = pmFPAfileDefineMultipleFromRun(&status, NULL, config, 54 61 "PPSTACK.INPUT"); // Input images from previous run … … 98 105 } 99 106 if (!runSrc) { 100 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metad ta.");107 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define input sources from RUN metadata."); 101 108 psFree(runImages); 102 109 return false; … … 104 111 psFree(runSrc); 105 112 106 psArray *runKernel = pmFPAfileDefineMultipleFromRun(&status, runImages, config, 107 "PPSTACK.CONV.KERNEL"); // Convolution kernels 108 if (!status) { 109 psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata."); 110 psFree(runImages); 111 return false; 112 } 113 if (!runSrc) { 114 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define convolution kernels from RUN metadta."); 115 psFree(runImages); 116 return false; 117 } 118 psFree(runKernel); 113 if (convolve) { 114 psArray *runKernel = pmFPAfileDefineMultipleFromRun(&status, runImages, config, 115 "PPSTACK.CONV.KERNEL"); // Convolution kernels 116 if (!status) { 117 psError(PS_ERR_UNKNOWN, false, "Unable to define convolution kernels from RUN metadata."); 118 psFree(runImages); 119 return false; 120 } 121 if (!runKernel) { 122 psError(PS_ERR_UNEXPECTED_NULL, true, 123 "Unable to define convolution kernels from RUN metadata."); 124 psFree(runImages); 125 return false; 126 } 127 psFree(runKernel); 128 } 119 129 120 130 psFree(runImages); … … 200 210 } 201 211 202 pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL"); 203 if (!kernel) { 204 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL")); 205 return false; 206 } 207 kernel->save = true; 212 if (convolve) { 213 pmFPAfile *kernel = pmFPAfileDefineOutput(config, imageFile->fpa, "PPSTACK.CONV.KERNEL"); 214 if (!kernel) { 215 psError(PS_ERR_IO, false, _("Unable to generate output file from PPSTACK.CONV.KERNEL")); 216 return false; 217 } 218 kernel->save = true; 219 } 208 220 209 221 i++; … … 300 312 } 301 313 jpeg2->save = true; 302 303 304 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // Recipe for ppSim305 if (!recipe) {306 psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find recipe %s", PPSTACK_RECIPE);307 return false;308 }309 314 310 315 // For photometry, we operate on the chip-mosaicked image -
trunk/ppStack/src/ppStackCombineInitial.c
r23573 r23576 23 23 psTimerStart("PPSTACK_INITIAL"); 24 24 25 psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe26 psAssert(recipe, "We've thrown an error on this before.");27 28 25 psMetadata *ppsub = psMetadataLookupMetadata(NULL, config->recipes, "PPSUB"); // PPSUB recipe 29 26 int overlap = 2 * psMetadataLookupS32(NULL, ppsub, 30 27 "KERNEL.SIZE"); // Overlap by kernel size between consecutive scans 31 28 32 pmFPAview *view = NULL; // View to readout33 34 int row0, col0; // Offset for readout35 int numCols, numRows; // Size of readout36 ppStackThread *thread = stack->threads->data[0]; // Representative thread37 if (!pmReadoutStackSetOutputSize(&col0, &row0, &numCols, &numRows, thread->readouts)) {38 psError(PS_ERR_UNKNOWN, false, "problem setting output readout size.");39 return false;40 }41 42 pmFPAfileActivate(config->files, false, NULL);43 ppStackFileActivation(config, PPSTACK_FILES_COMBINE, true);44 view = ppStackFilesIterateDown(config);45 if (!view) {46 return false;47 }48 49 pmCell *outCell = pmFPAfileThisCell(config->files, view, "PPSTACK.OUTPUT"); // Output cell50 options->outRO = pmReadoutAlloc(outCell); // Output readout51 psFree(view);52 53 psString maskBadStr = psMetadataLookupStr(NULL, recipe, "MASK.BAD"); // Name of bits to mask for bad54 psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels55 if (!pmReadoutStackDefineOutput(options->outRO, col0, row0, numCols, numRows, true, true, maskBad)) {56 psError(PS_ERR_UNKNOWN, false, "Unable to prepare output.");57 return false;58 }59 60 psFree(options->cells); options->cells = NULL;61 29 62 30 bool status; // Status of read -
trunk/ppStack/src/ppStackLoop.c
r23367 r23576 59 59 if (!stack) { 60 60 psError(PS_ERR_IO, false, "Unable to initialise stack threads."); 61 psFree(options); 62 return false; 63 } 64 psFree(options->cells); options->cells = NULL; 65 66 // Prepare for combination 67 if (!ppStackCombinePrepare(stack, options, config)) { 68 psError(PS_ERR_UNKNOWN, false, "Unable to prepare for combination."); 69 psFree(stack); 61 70 psFree(options); 62 71 return false; -
trunk/ppStack/src/ppStackLoop.h
r23368 r23576 30 30 // Convolve inputs to match target PSF 31 31 bool ppStackConvolve( 32 ppStackOptions *options, // Options 33 pmConfig *config // Configuration 34 ); 35 36 // Prepare for combination 37 bool ppStackCombinePrepare( 38 ppStackThreadData *stack, // Stack 32 39 ppStackOptions *options, // Options 33 40 pmConfig *config // Configuration -
trunk/ppStack/src/ppStackReadout.c
r23346 r23576 185 185 assert(outRO); 186 186 assert(readouts); 187 assert(rejected); 188 assert(readouts->n == rejected->n); 187 assert(!rejected || readouts->n == rejected->n); 189 188 assert(mask && mask->n == readouts->n && mask->type.type == PS_TYPE_VECTOR_MASK); 190 189 assert(weightings && weightings->n == readouts->n && weightings->type.type == PS_TYPE_F32); … … 207 206 psArray *stack = psArrayAlloc(num); // Array for stacking 208 207 209 int numGood = num; // Number of good inputs: images that haven't been completely rejected208 bool entire = (rejected ? false : true); // Combine entire image? 210 209 for (int i = 0; i < num; i++) { 211 210 pmReadout *ro = readouts->data[i]; 212 if (!ro || !rejected->data[i] || mask->data.PS_TYPE_VECTOR_MASK_DATA[i]) { 213 // Image completely rejected 214 numGood--; 211 if (mask->data.U8[i] & (PPSTACK_MASK_REJECT | PPSTACK_MASK_BAD)) { 212 // Image completely rejected since previous combination 213 entire = true; 214 continue; 215 } else if (mask->data.U8[i]) { 216 // Image completely rejected before original combination 215 217 continue; 216 218 } … … 234 236 pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i], 235 237 addVariance ? addVariance->data.F32[i] : NAN); 236 data->reject = psMemIncrRefCounter(rejected->data[i]);238 data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL; 237 239 stack->data[i] = data; 238 240 } 239 241 240 242 if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskBad, 0, 0, NAN, NAN, NAN, 241 numGood != num, useVariance, false)) {243 entire, useVariance, false)) { 242 244 psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts."); 243 245 psFree(stack); -
trunk/ppStack/src/ppStackSetup.c
r23573 r23576 14 14 15 15 // Generate an array of input filenames 16 static psArray *stackNameArray(pmConfig *config, // Configuration 16 static psArray *stackNameArray(const ppStackOptions *options, // Stack options 17 pmConfig *config, // Configuration 17 18 const char *name // Name of file 18 19 ) … … 21 22 psAssert(config, "Require file name"); 22 23 23 psString regex = NULL; // Regular expression for selecting file 24 psStringAppend(®ex, "^%s$", name); 25 psMetadataIterator *iter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, regex); // Iterator 26 psFree(regex); 27 psMetadataItem *item; // Item from iteration 28 psArray *array = psArrayAlloc(BUFFER); // Array of file names 29 while ((item = psMetadataGetAndIncrement(iter))) { 30 psAssert(item->type == PS_DATA_UNKNOWN, "Should be this type"); 31 pmFPAfile *file = item->data.V; // An input file 24 psArray *array = psArrayAllocEmpty(options->num); // Array with filenames 25 pmFPAview *view = pmFPAviewAlloc(0);// View to readout 26 view->chip = view->cell = view->readout = -1; 32 27 33 psString filename = psStringCopy(file->filename); // Filename of interest 28 for (int i = 0; i < options->num; i++) { 29 pmFPAfile *file = pmFPAfileSelectSingle(config->files, name, i); // File of interest 30 31 psString filename = pmFPAfileName(file, view, config); // Filename of interest 32 psAssert(filename, "Can't determine filename"); 34 33 psArrayAdd(array, array->n, filename); 35 34 psFree(filename); // Drop reference 36 35 } 37 psFree(iter);38 36 39 37 return array; … … 114 112 psFree(outputName); 115 113 } else { 116 options->imageNames = stackNameArray( config, "PPSTACK.INPUT");117 options->maskNames = stackNameArray( config, "PPSTACK.INPUT.MASK");118 options->varianceNames = stackNameArray( config, "PPSTACK.INPUT.VARIANCE");114 options->imageNames = stackNameArray(options, config, "PPSTACK.INPUT"); 115 options->maskNames = stackNameArray(options, config, "PPSTACK.INPUT.MASK"); 116 options->varianceNames = stackNameArray(options, config, "PPSTACK.INPUT.VARIANCE"); 119 117 } 120 118 -
trunk/psModules/src/camera/pmFPAfileIO.c
r23447 r23576 635 635 } 636 636 637 psString pmFPAfileName(const pmFPAfile *file, const pmFPAview *view, pmConfig *config) 638 { 639 PS_ASSERT_PTR_NON_NULL(file, NULL); 640 PS_ASSERT_PTR_NON_NULL(view, NULL); 641 PS_ASSERT_PTR_NON_NULL(config, NULL); 642 643 psString filename = pmFPAfileNameFromRule(file->filerule, file, view); // Filename, based on rule 644 if (!filename) { 645 psError(PS_ERR_IO, true, "Cannot determine file name from rule"); 646 return false; 647 } 648 649 // indirect filenames: these come from a list on the command line or elsewhere 650 if (!strcasecmp(filename, "@FILES")) { 651 psString filesrc = pmFPAfileNameFromRule(file->filesrc, file, view); // Source of file name 652 if (!filesrc) { 653 psError(PS_ERR_IO, false, "error converting filesrc to name %s", file->filesrc); 654 return false; 655 } 656 psFree(filename); 657 filename = psMemIncrRefCounter(psMetadataLookupStr(NULL, file->names, filesrc)); 658 if (!filename) { 659 psError(PS_ERR_IO, false, "filename lookup error (@FILES) for %s : %s", file->filesrc, filesrc); 660 psFree(filesrc); 661 return false; 662 } 663 psFree(filesrc); 664 } 665 666 // get name from detrend database 667 // file->detrend->detID contains the desired -det_id detID -iteration iter string 668 if (!strcasecmp(filename, "@DETDB")) { 669 if (!file->detrend) { 670 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find information about selected detrend."); 671 return false; 672 } 673 psMetadata *menu = psMetadataLookupMetadata(NULL, file->camera, "CLASSID"); // Menu of class IDs 674 if (!menu) { 675 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 676 return false; 677 } 678 const char *rule = psMetadataLookupStr(NULL, menu, file->detrend->level); // Rule for class_id 679 if (!rule || strlen(rule) == 0) { 680 psError(PS_ERR_IO, false, "Unable to find %s in CLASSID in camera configuration", 681 file->detrend->level); 682 return false; 683 } 684 psString classId = pmFPAfileNameFromRule(rule, file, view); // The class identifier, for pmDetrendFile 685 if (!classId) { 686 psError(PS_ERR_IO, false, "error converting CLASSID rule to name: %s\n", rule); 687 return false; 688 } 689 690 psTrace("psModules.camera", 6, "looking for detrend (%s, %s)\n", file->detrend->detID, classId); 691 psFree(filename); 692 filename = pmDetrendFile(file->detrend->detID, classId, config); 693 if (!filename) { 694 psError(PS_ERR_IO, false, "failed to find a valid detrend image for detID %s : classID %s", 695 file->detrend->detID, classId); 696 psFree(classId); 697 return false; 698 } 699 700 psTrace("psModules.camera", 6, "got detrend file %s", filename); 701 psFree(classId); 702 } 703 704 return filename; 705 } 706 637 707 // open file (if not already opened). 638 708 // this function is only called only within pmFPAfileRead or pmFPAfileWrite. … … 672 742 673 743 // determine the file name, free a name allocated earlier 674 psFree (file->filename); 675 file->filename = pmFPAfileNameFromRule (file->filerule, file, view); 676 if (file->filename == NULL) { 677 psError(PS_ERR_IO, true, "Filename is NULL"); 678 return false; 679 } 680 681 // indirect filenames: these come from a list on the command line or elsewhere 682 if (!strcasecmp (file->filename, "@FILES")) { 683 char *filesrc = pmFPAfileNameFromRule (file->filesrc, file, view); 684 if (filesrc == NULL) { 685 psError(PS_ERR_IO, false, "error converting filesrc to name %s\n", file->filesrc); 686 return false; 687 } 688 689 psFree (file->filename); 690 file->filename = psMetadataLookupStr (&status, file->names, filesrc); 691 692 if (file->filename == NULL) { 693 psError(PS_ERR_IO, true, "filename lookup error (@FILES) for %s : %s\n", file->filesrc, filesrc); 694 psFree (filesrc); 695 return false; 696 } 697 // psMetadataLookupStr just returns a view, file->filename must be protected 698 psMemIncrRefCounter (file->filename); 699 psFree (filesrc); 700 } 701 702 // get name from detrend database 703 // file->detrend->detID contains the desired -det_id detID -iteration iter string 704 if (!strcasecmp (file->filename, "@DETDB")) { 705 if (!file->detrend) { 706 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find information about selected detrend."); 707 return false; 708 } 709 710 psString classId = NULL; // The class identifier, to pass to pmDetrendFile 711 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "CLASSID"); // Menu of class IDs 712 if (!status || !menu) { 713 psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration"); 714 return false; 715 } 716 const char *rule = psMetadataLookupStr(&status, menu, file->detrend->level); // Rule for class_id 717 if (!status || !rule || strlen(rule) == 0) { 718 psError(PS_ERR_IO, false, "Unable to find %s in CLASSID in camera configuration", file->detrend->level); 719 return false; 720 } 721 classId = pmFPAfileNameFromRule(rule, file, view); 722 if (!classId) { 723 psError(PS_ERR_IO, false, "error converting CLASSID rule to name: %s\n", rule); 724 return false; 725 } 726 psTrace ("psModules.camera", 6, "looking for detrend (%s, %s)\n", file->detrend->detID, classId); 727 psFree (file->filename); 728 729 file->filename = pmDetrendFile(file->detrend->detID, classId, config); 730 if (file->filename == NULL) { 731 psError(PS_ERR_IO, false, "failed to find a valid detrend image for detID %s : classID %s\n", file->detrend->detID, classId); 732 psFree (classId); 733 return false; 734 } 735 736 psTrace ("psModules.camera", 6, "got detrend file %s\n", file->filename); 737 psFree (classId); 744 psFree(file->filename); 745 file->filename = pmFPAfileName(file, view, config); 746 if (!file->filename) { 747 psError(PS_ERR_IO, true, "Unable to determine filename"); 748 return false; 738 749 } 739 750 -
trunk/psModules/src/camera/pmFPAfileIO.h
r18364 r23576 15 15 /// @addtogroup Camera Camera Layout 16 16 /// @{ 17 18 // Determine appropriate file name 19 psString pmFPAfileName(const pmFPAfile *file, const pmFPAview *view, pmConfig *config); 17 20 18 21 // open the real file corresponding to the given pmFPAfile appropriate to the current view
Note:
See TracChangeset
for help on using the changeset viewer.
