Changeset 6815
- Timestamp:
- Apr 7, 2006, 5:05:28 PM (20 years ago)
- Location:
- branches/rel10_ifa/psModules/src/astrom
- Files:
-
- 6 edited
-
pmConcepts.c (modified) (1 diff)
-
pmConceptsStandard.c (modified) (2 diffs)
-
pmConceptsStandard.h (modified) (1 diff)
-
pmConceptsWrite.c (modified) (5 diffs)
-
pmFPAConstruct.c (modified) (1 diff)
-
pmHDU.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/astrom/pmConcepts.c
r6804 r6815 434 434 psFree(trimsec); 435 435 pmConceptRegister(cellTrimsec, (pmConceptParseFunc)pmConceptParse_CELL_TRIMSEC, 436 #if 0 437 (pmConceptFormatFunc)pmConceptFormat_CELL_TRIMSEC, 438 #else 439 NULL, 440 #endif 441 PM_CONCEPT_LEVEL_CELL); 436 (pmConceptFormatFunc)pmConceptFormat_CELL_TRIMSEC, PM_CONCEPT_LEVEL_CELL); 442 437 psFree(cellTrimsec); 443 438 } -
branches/rel10_ifa/psModules/src/astrom/pmConceptsStandard.c
r6743 r6815 434 434 435 435 436 #if 0437 436 psMetadataItem *pmConceptFormat_CELL_TRIMSEC(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell) 438 437 { … … 446 445 return formatted; 447 446 } 448 #endif449 447 450 448 psMetadataItem *pmConceptFormat_CELL_BIASSEC(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell) -
branches/rel10_ifa/psModules/src/astrom/pmConceptsStandard.h
r6734 r6815 14 14 psMetadataItem *pmConceptParse_CELL_TIME(psMetadataItem *concept, psMetadataItem *pattern, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell); 15 15 psMetadataItem *pmConceptParse_CELL_Positions(psMetadataItem *concept, psMetadataItem *pattern, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell); 16 #if 017 16 psMetadataItem *pmConceptFormat_CELL_TRIMSEC(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell); 18 #endif19 17 psMetadataItem *pmConceptFormat_CELL_BIASSEC(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell); 20 18 psMetadataItem *pmConceptFormat_CELL_XBIN(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell); -
branches/rel10_ifa/psModules/src/astrom/pmConceptsWrite.c
r6804 r6815 14 14 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 15 15 16 static bool compareConcepts(psMetadataItem * item1, // First item to compare17 psMetadataItem * item2 // Second item to compare16 static bool compareConcepts(psMetadataItem *compare, // Item to compare 17 psMetadataItem *standard // Standard for comparison 18 18 ) 19 19 { 20 20 // First order checks 21 if (! item1 || ! item2) {22 return false; 23 } 24 if (strcasecmp( item1->name, item2->name) != 0) {21 if (! compare || ! standard) { 22 return false; 23 } 24 if (strcasecmp(compare->name, standard->name) != 0) { 25 25 return false; 26 26 } 27 27 28 28 // Check the more boring types 29 switch ( item1->type) {29 switch (compare->type) { 30 30 case PS_TYPE_S32: 31 switch ( item2->type) {31 switch (standard->type) { 32 32 case PS_TYPE_S32: 33 psTrace(__func__, 10, "Comparing %d and %d...\n", item1->data.S32, item2->data.S32);34 return ( item1->data.S32 == item2->data.S32) ? true : false;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 35 case PS_TYPE_F32: 36 psTrace(__func__, 10, "Comparing %d and %d...\n", item1->data.S32, (int)item2->data.F32);37 return ( item1->data.S32 == (int)item2->data.F32) ? true : false;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 38 case PS_TYPE_F64: 39 psTrace(__func__, 10, "Comparing %d and %d...\n", item1->data.S32, (int)item2->data.F64);40 return ( item1->data.S32 == (int)item2->data.F64) ? true : false;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; 41 41 default: 42 42 return false; 43 43 } 44 44 case PS_TYPE_F32: 45 switch ( item2->type) {45 switch (standard->type) { 46 46 case PS_TYPE_S32: 47 psTrace(__func__, 10, "Comparing %f and %f...\n", item1->data.F32, (float)item2->data.S32);48 return ( item1->data.F32 == (float)item2->data.S32) ? true : false;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 49 case PS_TYPE_F32: 50 psTrace(__func__, 10, "Comparing %f and %f...\n", item1->data.F32, item2->data.F32);51 return ( item1->data.F32 == item2->data.F32) ? true : false;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 52 case PS_TYPE_F64: 53 psTrace(__func__, 10, "Comparing %f and %f...\n", item1->data.F32, (float)item2->data.F64);54 return ( item1->data.F32 == (float)item2->data.F64) ? true : false;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 55 default: 56 56 return false; 57 57 } 58 58 case PS_TYPE_F64: 59 switch ( item2->type) {59 switch (standard->type) { 60 60 case PS_TYPE_S32: 61 psTrace(__func__, 10, "Comparing %f and %f...\n", item1->data.F32, (double)item2->data.S32);62 return ( item1->data.F64 == (double)item2->data.S32) ? true : false;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 63 case PS_TYPE_F32: 64 psTrace(__func__, 10, "Comparing %f and %f...\n", item1->data.F32, (double)item2->data.F32);65 return ( item1->data.F64 == (double)item2->data.F32) ? true : false;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 66 case PS_TYPE_F64: 67 psTrace(__func__, 10, "Comparing %f and %f...\n", item1->data.F32, item2->data.F64);68 return ( item1->data.F64 == item2->data.F64) ? true : false;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 69 default: 70 70 return false; 71 71 } 72 return ( item1->data.F64 == item2->data.F64) ? true : false;72 return (compare->data.F64 == standard->data.F64) ? true : false; 73 73 case PS_DATA_STRING: 74 if ( item2->type != PS_DATA_STRING) {74 if (standard->type != PS_DATA_STRING) { 75 75 return false; 76 76 } 77 psTrace(__func__, 10, "Comparing '%s' and '%s'\n", item1->data.V, item2->data.V); 78 return (strcasecmp(item1->data.V, item2->data.V) == 0) ? true : false; 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) { 95 psFree(sList); 96 return false; 97 } 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 } 79 145 default: 80 146 return false; … … 82 148 psAbort(__func__, "Should never get here.\n"); 83 149 } 150 84 151 85 152 // Format a single concept … … 216 283 } else if (strcasecmp(source, "VALUE") == 0) { 217 284 psTrace(__func__, 8, "Checking %s against camera format.\n", name); 218 if (! compareConcepts( cameraItem, formatted)) {285 if (! compareConcepts(formatted, cameraItem)) { 219 286 psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by value in the camera " 220 287 "format, but the values don't match.\n", name); … … 224 291 "write\n", nameSource); 225 292 } 226 } else if (! compareConcepts( cameraItem, formatted)) {293 } else if (! compareConcepts(formatted, cameraItem)) { 227 294 // Assume it's specified by value 228 295 psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by value in the camera " … … 290 357 continue; 291 358 } 292 if (! compareConcepts( defaultItem, formatted)) {359 if (! compareConcepts(formatted, defaultItem)) { 293 360 psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by the DEFAULTS in the camera " 294 361 "format, but the values don't match.\n", name); -
branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.c
r6813 r6815 579 579 psTrace(__func__, 2, "---> NO PIXELS read in for extension %s\n", fpa->hdu->extname); 580 580 } 581 if (fpa->hdu->header && header) { 582 psTrace(__func__, 2, "---> Header:\n"); 583 psMetadataPrint(fpa->hdu->header, 8); 584 } 581 585 } 582 586 if (concepts) { -
branches/rel10_ifa/psModules/src/astrom/pmHDU.c
r6734 r6815 145 145 } 146 146 147 if (!hdu->images && !psFitsWriteHeader(hdu->header, fits)) { 148 psError(PS_ERR_IO, false, "Unable to write header for extension %s\n", extname); 147 // Only a header 148 if (!hdu->images && !hdu->table) { 149 // Tell CFITSIO there's nothing there 150 psMetadataItem *naxis = psMetadataLookup(hdu->header, "NAXIS"); 151 naxis->data.S32 = 0; 152 153 if (!psFitsWriteHeader(hdu->header, fits)) { 154 psError(PS_ERR_IO, false, "Unable to write header for extension %s\n", extname); 155 } 149 156 } 150 157
Note:
See TracChangeset
for help on using the changeset viewer.
