Changeset 6888
- Timestamp:
- Apr 18, 2006, 12:37:01 PM (20 years ago)
- Location:
- trunk/psModules/src/astrom
- Files:
-
- 4 edited
-
pmConceptsWrite.c (modified) (2 diffs)
-
pmFPAConstruct.c (modified) (2 diffs)
-
pmFPACopy.c (modified) (1 diff)
-
pmFPARead.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmConceptsWrite.c
r6872 r6888 9 9 #include "pmConceptsRead.h" 10 10 #include "psAdditionals.h" 11 #include "psMetadataItemCompare.h" 11 12 12 13 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// … … 26 27 } 27 28 28 // Check the more boring types 29 switch (compare->type) { 30 case PS_TYPE_S32: 29 // Special case: list 30 if (compare->type == PS_DATA_LIST) { 31 // "compare" contains a list of psMetadataItems 32 // "standard" likely contains just a string (but it might possibly be a list of strings) 33 psList *cList = compare->data.V; // The list from comparison item 34 psList *sList = NULL; // The list from standard item 31 35 switch (standard->type) { 32 case PS_TYPE_S32: 33 psTrace(__func__, 10, "Comparing %d and %d...\n", compare->data.S32, standard->data.S32); 34 return (compare->data.S32 == standard->data.S32) ? true : false; 35 case PS_TYPE_F32: 36 psTrace(__func__, 10, "Comparing %d and %d...\n", compare->data.S32, (int)standard->data.F32); 37 return (compare->data.S32 == (int)standard->data.F32) ? true : false; 38 case PS_TYPE_F64: 39 psTrace(__func__, 10, "Comparing %d and %d...\n", compare->data.S32, (int)standard->data.F64); 40 return (compare->data.S32 == (int)standard->data.F64) ? true : false; 36 case PS_DATA_STRING: 37 sList = psStringSplit(standard->data.V, " ;"); 38 break; 39 case PS_DATA_LIST: 40 sList = psMemIncrRefCounter(standard->data.V); 41 break; 41 42 default: 42 43 return false; 43 44 } 44 case PS_TYPE_F32: 45 switch (standard->type) { 46 case PS_TYPE_S32: 47 psTrace(__func__, 10, "Comparing %f and %f...\n", compare->data.F32, (float)standard->data.S32); 48 return (compare->data.F32 == (float)standard->data.S32) ? true : false; 49 case PS_TYPE_F32: 50 psTrace(__func__, 10, "Comparing %f and %f...\n", compare->data.F32, standard->data.F32); 51 return (compare->data.F32 == standard->data.F32) ? true : false; 52 case PS_TYPE_F64: 53 psTrace(__func__, 10, "Comparing %f and %f...\n", compare->data.F32, (float)standard->data.F64); 54 return (compare->data.F32 == (float)standard->data.F64) ? true : false; 55 default: 45 if (cList->n != sList->n) { 46 psFree(sList); 56 47 return false; 57 48 } 58 case PS_TYPE_F64: 59 switch (standard->type) { 60 case PS_TYPE_S32: 61 psTrace(__func__, 10, "Comparing %f and %f...\n", compare->data.F32, (double)standard->data.S32); 62 return (compare->data.F64 == (double)standard->data.S32) ? true : false; 63 case PS_TYPE_F32: 64 psTrace(__func__, 10, "Comparing %f and %f...\n", compare->data.F32, (double)standard->data.F32); 65 return (compare->data.F64 == (double)standard->data.F32) ? true : false; 66 case PS_TYPE_F64: 67 psTrace(__func__, 10, "Comparing %f and %f...\n", compare->data.F32, standard->data.F64); 68 return (compare->data.F64 == standard->data.F64) ? true : false; 69 default: 70 return false; 71 } 72 return (compare->data.F64 == standard->data.F64) ? true : false; 73 case PS_DATA_STRING: 74 if (standard->type != PS_DATA_STRING) { 75 return false; 76 } 77 psTrace(__func__, 10, "Comparing '%s' and '%s'\n", compare->data.V, standard->data.V); 78 return (strcasecmp(compare->data.V, standard->data.V) == 0) ? true : false; 79 case PS_DATA_LIST: { // A list of strings 80 // "compare" contains a list of psMetadataItems 81 // "standard" likely contains just a string (but it might possibly be a list of strings) 82 psList *cList = compare->data.V; // The list from comparison item 83 psList *sList = NULL; // The list from standard item 84 switch (standard->type) { 85 case PS_DATA_STRING: 86 sList = psStringSplit(standard->data.V, " ;"); 87 break; 88 case PS_DATA_LIST: 89 sList = psMemIncrRefCounter(standard->data.V); 90 break; 91 default: 92 return false; 93 } 94 if (cList->n != sList->n) { 49 psVector *match = psVectorAlloc(cList->n, PS_TYPE_U8); // Array indicating which values match 50 match->n = cList->n; 51 psVectorInit(match, 0); 52 psListIterator *cIter = psListIteratorAlloc(cList, PS_LIST_HEAD, false); // compare iterator 53 psListIterator *sIter = psListIteratorAlloc(sList, PS_LIST_HEAD, false); // standard iterator 54 psMetadataItem *cItem = NULL; // Item from compare list 55 while ((cItem = psListGetAndIncrement(cIter))) { 56 if (cItem->type != PS_DATA_STRING) { 57 psLogMsg(__func__, PS_LOG_WARN, "psMetadataItem from list is of type %x instead of " 58 "%x (PS_DATA_STRING) --- can't interpret.\n", cItem->type, PS_DATA_STRING); 59 psFree(cIter); 60 psFree(sIter); 61 psFree(match); 95 62 psFree(sList); 96 63 return false; 97 64 } 98 psVector *match = psVectorAlloc(cList->n, PS_TYPE_U8); // Array indicating which values match 99 psVectorInit(match, 0); 100 psListIterator *cIter = psListIteratorAlloc(cList, PS_LIST_HEAD, false); // compare iterator 101 psListIterator *sIter = psListIteratorAlloc(sList, PS_LIST_HEAD, false); // standard iterator 102 psMetadataItem *cItem = NULL; // Item from compare list 103 while ((cItem = psListGetAndIncrement(cIter))) { 104 if (cItem->type != PS_DATA_STRING) { 105 psLogMsg(__func__, PS_LOG_WARN, "psMetadataItem from list is of type %x instead of " 106 "%x (PS_DATA_STRING) --- can't interpret.\n", cItem->type, PS_DATA_STRING); 107 psFree(cIter); 108 psFree(sIter); 109 psFree(match); 110 psFree(sList); 111 return false; 112 } 113 psString cString = cItem->data.V; // String from compare list 114 psListIteratorSet(sIter, PS_LIST_HEAD); 115 int index = 0; // Index for list 116 bool found = false; // Found a match? 117 for (psString sString = NULL; (sString = psListGetAndIncrement(sIter)) && !found; index++) { 118 if (strcasecmp(cString, sString) == 0) { 119 match->data.U8[index]++; 120 found = true; 121 } 122 } 123 if (! found) { 124 // Can give up immediately 125 psFree(cIter); 126 psFree(sIter); 127 psFree(match); 128 psFree(sList); 129 return false; 130 } 131 } 132 // Make sure we got 100% matches in both directions 133 bool allMatch = true; // Did all of them match? 134 for (int i = 0; i < match->n && allMatch; i++) { 135 if (!match->data.U8[i]) { 136 allMatch = false; 137 } 138 } 139 psFree(cIter); 140 psFree(sIter); 141 psFree(sList); 142 psFree(match); 143 return allMatch; 144 } 145 default: 146 return false; 147 } 148 psAbort(__func__, "Should never get here.\n"); 65 psString cString = cItem->data.V; // String from compare list 66 psListIteratorSet(sIter, PS_LIST_HEAD); 67 int index = 0; // Index for list 68 bool found = false; // Found a match? 69 for (psString sString = NULL; (sString = psListGetAndIncrement(sIter)) && !found; index++) { 70 if (strcasecmp(cString, sString) == 0) { 71 match->data.U8[index]++; 72 found = true; 73 } 74 } 75 if (! found) { 76 // Can give up immediately 77 psFree(cIter); 78 psFree(sIter); 79 psFree(match); 80 psFree(sList); 81 return false; 82 } 83 } 84 // Make sure we got 100% matches in both directions 85 bool allMatch = true; // Did all of them match? 86 for (int i = 0; i < match->n && allMatch; i++) { 87 if (!match->data.U8[i]) { 88 allMatch = false; 89 } 90 } 91 psFree(cIter); 92 psFree(sIter); 93 psFree(sList); 94 psFree(match); 95 return allMatch; 96 } 97 98 return psMetadataItemCompare(compare, standard); 99 149 100 } 150 101 -
trunk/psModules/src/astrom/pmFPAConstruct.c
r6874 r6888 47 47 *second = psArrayAlloc(values->n); 48 48 *third = psArrayAlloc(values->n); 49 (*first)->n = (*second)->n = (*third)->n = values->n; 49 50 int num = 0; 50 51 psListIterator *valuesIter = psListIteratorAlloc(values, PS_LIST_HEAD, false); // Iterator for values … … 104 105 return NULL; 105 106 } 106 // XXX EAM test107 fprintf (stderr, "phu name: %s == %s\n", keyword, name);108 107 return psMetadataItemParseString(resultItem); 109 108 } -
trunk/psModules/src/astrom/pmFPACopy.c
r6872 r6888 320 320 321 321 hdu->images = psArrayAlloc(numReadouts); 322 hdu->images->n = numReadouts; 322 323 for (int i = 0; i < numReadouts; i++) { 323 324 psImage *image = psImageAlloc(xSize, ySize, PS_TYPE_F32); -
trunk/psModules/src/astrom/pmFPARead.c
r6872 r6888 142 142 hdu->images = psArrayAlloc(naxis3); 143 143 } 144 if (hdu->images->n != naxis3) {144 if (hdu->images->nalloc != naxis3) { 145 145 hdu->images = psArrayRealloc(hdu->images, naxis3); 146 hdu->images->n = naxis3; 146 147 } 147 148 if (hdu->images->data[z]) {
Note:
See TracChangeset
for help on using the changeset viewer.
