Changeset 18654
- Timestamp:
- Jul 21, 2008, 6:52:04 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/psModules/src/camera/pmFPACopy.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmFPACopy.c
r16861 r18654 47 47 48 48 // copy one of the psImage components of the readout 49 static void readoutCopyComponent (psImage **target, psImage *source, psImageBinning *binning, bool xFlip, bool yFlip, bool pixels) { 50 49 static void readoutCopyComponent(psImage **target, // Image to which to copy 50 const psImage *source, // Image from which to copy 51 psImageBinning *binning, // New binning 52 bool xFlip, bool yFlip, // Flip in x or y? 53 bool pixels // Copy the pixels? 54 ) 55 { 51 56 if (!source) return; 52 57 … … 66 71 return; 67 72 } 73 74 // Update the output analysis metadata, adding stuff in the input 75 // 76 // This is probably very similar to psMetadataCopy, but we want to explicitly deal with arrays (especially 77 // since astronomical sources live in them) 78 static psMetadata *updateAnalysis(psMetadata *out, psMetadata *in) 79 { 80 psAssert(in, "Require input"); 81 if (!out) { 82 out = psMetadataAlloc(); 83 } 84 85 psMetadataIterator *iter = psMetadataIteratorAlloc(in, PS_LIST_HEAD, NULL); // Iterator 86 psMetadataItem *item; // Item from iteration 87 while ((item = psMetadataGetAndIncrement(iter))) { 88 psMetadataItem *original = psMetadataLookup(in, item->name); // Checking for MULTI 89 psMetadataItem *extant = psMetadataLookup(out, item->name); // Existing item? 90 if ((original && original->type == PS_DATA_METADATA_MULTI) || 91 (extant && extant->type == PS_DATA_METADATA_MULTI)) { 92 psMetadataAddItem(out, item, PS_LIST_TAIL, PS_META_DUPLICATE_OK); 93 continue; 94 } 95 96 switch (item->type) { 97 case PS_DATA_ARRAY: { 98 // Concatenate arrays if they already exist 99 psMetadataItem *extant = psMetadataLookup(out, item->name); // Existing array? 100 if (extant && extant->type == PS_DATA_ARRAY) { 101 psArray *new = item->data.V; // New array 102 psArray *old = extant->data.V; // Old array 103 long numNew = new->n, numOld = old->n; // Number of values in each 104 extant->data.V = old = psArrayRealloc(old, old->n + numNew); 105 for (long i = 0; i < numNew; i++) { 106 old->data[numOld + i] = psMemIncrRefCounter(new->data[i]); 107 } 108 old->n = numOld + numNew; 109 } else { 110 psMetadataAddItem(out, item, PS_LIST_TAIL, PS_META_REPLACE); 111 } 112 break; 113 default: 114 // If in doubt, there's not much we can do except replace 115 psMetadataAddItem(out, item, PS_LIST_TAIL, PS_META_REPLACE); 116 break; 117 } 118 } 119 } 120 psFree(iter); 121 122 return out; 123 } 124 68 125 69 126 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 95 152 } 96 153 97 // the binning structure carries the information nohow to rebin the images if needed154 // the binning structure carries the information on how to rebin the images if needed 98 155 psImageBinning *binning = psImageBinningAlloc(); 99 156 binning->nXbin = xBin; … … 164 221 165 222 // Copy all three image components (image, mask, weight) 166 readoutCopyComponent (&targetReadout->image, sourceReadout->image, binning, xFlip, yFlip, pixels);167 readoutCopyComponent (&targetReadout->mask, sourceReadout->mask, binning, xFlip, yFlip, pixels);168 readoutCopyComponent (&targetReadout->weight, sourceReadout->weight, binning, xFlip, yFlip, pixels);223 readoutCopyComponent(&targetReadout->image, sourceReadout->image, binning, xFlip, yFlip, pixels); 224 readoutCopyComponent(&targetReadout->mask, sourceReadout->mask, binning, xFlip, yFlip, pixels); 225 readoutCopyComponent(&targetReadout->weight, sourceReadout->weight, binning, xFlip, yFlip, pixels); 169 226 170 227 // Copy bias … … 183 240 } 184 241 psFree(biasIter); 242 243 // Copy the analysis metadata 244 targetReadout->analysis = updateAnalysis(targetReadout->analysis, sourceReadout->analysis); 185 245 186 246 targetReadout->data_exists = true; … … 312 372 binItem->data.S32 *= yBin; 313 373 374 // Update the analysis metadata 375 target->analysis = updateAnalysis(target->analysis, source->analysis); 376 314 377 // Copy any headers 315 378 pmHDU *targetHDU = pmHDUFromCell(target); // The target HDU … … 376 439 } 377 440 } 441 442 // Update the analysis metadata 443 target->analysis = updateAnalysis(target->analysis, source->analysis); 378 444 379 445 // Update the concepts … … 419 485 } 420 486 487 // Update the analysis metadata 488 targetChip->analysis = updateAnalysis(targetChip->analysis, sourceChip->analysis); 489 421 490 // Update the concepts 422 491 psMetadataCopy(targetChip->concepts, sourceChip->concepts); … … 463 532 } 464 533 534 // Update the analysis metadata 535 target->analysis = updateAnalysis(target->analysis, source->analysis); 536 465 537 // Update the concepts 466 538 psMetadataCopy(target->concepts, source->concepts);
Note:
See TracChangeset
for help on using the changeset viewer.
