Changeset 5976 for trunk/ppImage/src/ppImageDetrendNonLinear.c
- Timestamp:
- Jan 13, 2006, 5:14:07 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImageDetrendNonLinear.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageDetrendNonLinear.c
r5858 r5976 6 6 psVector *coeff = dataItem->data.V; // The coefficient vector 7 7 if (coeff->type.type != PS_TYPE_F64) { 8 psVector *temp = psVectorCopy(NULL, coeff, PS_TYPE_F64); // F64 version9 psFree (coeff);10 coeff = temp;8 psVector *temp = psVectorCopy(NULL, coeff, PS_TYPE_F64); // F64 version 9 psFree (coeff); 10 coeff = temp; 11 11 } 12 12 psPolynomial1D *correction = psPolynomial1DAlloc(coeff->n - 1, PS_POLYNOMIAL_ORD); … … 17 17 psFree(correction); 18 18 return true; 19 } 19 } 20 20 21 21 bool ppDetrendNonLinearLookup (pmReadout *input, psMetadataItem *dataItem) { … … 25 25 psLookupTable *table = psLookupTableAlloc(name, "%f %f", 0); 26 26 if (psLookupTableRead(table) <= 0) { 27 psErrorStackPrint(stderr, "Unable to read non-linearity correction file "28 "%s --- ignored\n", name);29 return false;30 } 27 psErrorStackPrint(stderr, "Unable to read non-linearity correction file " 28 "%s --- ignored\n", name); 29 return false; 30 } 31 31 #ifdef PRODUCTION 32 32 pmNonLinearityLookup(input, table); … … 38 38 psFree(table); 39 39 return true; 40 } 40 } 41 41 42 42 bool ppDetrendNonLinear (pmCell *cell, pmReadout *input, ppOptions *options) { … … 46 46 switch (options->nonLinearType) { 47 47 case PS_DATA_VECTOR: 48 ppDetrendNonLinearPolynomial (input, options->nonLinearData);49 return true;48 ppDetrendNonLinearPolynomial (input, options->nonLinearData); 49 return true; 50 50 51 51 case PS_DATA_STRING: 52 ppDetrendNonLinearLookup (input, options->nonLinearData);53 return true;52 ppDetrendNonLinearLookup (input, options->nonLinearData); 53 return true; 54 54 55 55 case PS_DATA_METADATA: 56 // XXX this is somewhat confusing : let's wrap in a function when i understand it 57 concept = pmCellGetConcept(cell, options->nonLinearSource); 58 if (! concept) { 59 psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s " 60 "for non-linearity correction --- ignored.\n", options->nonLinearSource); 61 return false; 62 } 63 if (concept->type != PS_DATA_STRING) { 64 psLogMsg("phase2", PS_LOG_WARN, "Type for concept %s isn't STRING, as" 65 " expected for non-linearity correction --- ignored.\n", 66 concept); 67 return false; 68 } 56 // XXX EAM: this is somewhat confusing : let's wrap in a function when i understand it 69 57 70 // Get the value of the concept 71 psString conceptValue = concept->data.V; 72 psMetadata *folder = (psMetadata *)options->nonLinearData->data.V; 73 psMetadataItem *optionItem = psMetadataLookup(folder, conceptValue); 74 if (!optionItem) { 75 psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA" 76 " --- ignored.\n", conceptValue); 77 return false; 78 } 58 // Go looking for the value in the hierarchy 59 concept = psMetadataLookup(cell->concepts, options->nonLinearSource); 60 if (! concept) { 61 pmChip *chip = cell->parent;// Parent chip 62 concept = psMetadataLookup(chip->concepts, options->nonLinearSource); 63 if (! concept) { 64 pmFPA *fpa = chip->parent; // Parent FPA 65 concept = psMetadataLookup(fpa->concepts, options->nonLinearSource); 66 if (! concept) { 67 psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s " 68 "for non-linearity correction --- ignored.\n", options->nonLinearSource); 69 return false; 70 } 71 } 72 } 79 73 80 switch (optionItem->type) { 81 case PS_DATA_VECTOR: 82 ppDetrendNonLinearPolynomial (input, optionItem); 83 return true; 84 case PS_DATA_STRING: 85 ppDetrendNonLinearLookup (input, optionItem); 86 return true; 87 default: 88 psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction " 89 "desired but unable to interpret NONLIN.DATA for %s" 90 " --- ignored\n", conceptValue); 91 return false; 92 } 74 if (concept->type != PS_DATA_STRING) { 75 psLogMsg("phase2", PS_LOG_WARN, "Type for concept %s isn't STRING, as" 76 " expected for non-linearity correction --- ignored.\n", 77 concept); 78 return false; 79 } 80 81 // Get the value of the concept 82 psString conceptValue = concept->data.V; 83 psMetadata *folder = (psMetadata *)options->nonLinearData->data.V; 84 psMetadataItem *optionItem = psMetadataLookup(folder, conceptValue); 85 if (!optionItem) { 86 psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA" 87 " --- ignored.\n", conceptValue); 88 return false; 89 } 90 91 switch (optionItem->type) { 92 case PS_DATA_VECTOR: 93 ppDetrendNonLinearPolynomial (input, optionItem); 94 return true; 95 case PS_DATA_STRING: 96 ppDetrendNonLinearLookup (input, optionItem); 97 return true; 98 default: 99 psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction " 100 "desired but unable to interpret NONLIN.DATA for %s" 101 " --- ignored\n", conceptValue); 102 return false; 103 } 93 104 default: 94 psAbort("phase2", "Invalid options->nonLinearType");105 psAbort("phase2", "Invalid options->nonLinearType"); 95 106 } 96 107 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
