IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6815


Ignore:
Timestamp:
Apr 7, 2006, 5:05:28 PM (20 years ago)
Author:
Paul Price
Message:

Working on pmFPACopy for lris blue

Location:
branches/rel10_ifa/psModules/src/astrom
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/rel10_ifa/psModules/src/astrom/pmConcepts.c

    r6804 r6815  
    434434            psFree(trimsec);
    435435            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);
    442437            psFree(cellTrimsec);
    443438        }
  • branches/rel10_ifa/psModules/src/astrom/pmConceptsStandard.c

    r6743 r6815  
    434434
    435435
    436 #if 0
    437436psMetadataItem *pmConceptFormat_CELL_TRIMSEC(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell)
    438437{
     
    446445    return formatted;
    447446}
    448 #endif
    449447
    450448psMetadataItem *pmConceptFormat_CELL_BIASSEC(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell)
  • branches/rel10_ifa/psModules/src/astrom/pmConceptsStandard.h

    r6734 r6815  
    1414psMetadataItem *pmConceptParse_CELL_TIME(psMetadataItem *concept, psMetadataItem *pattern, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell);
    1515psMetadataItem *pmConceptParse_CELL_Positions(psMetadataItem *concept, psMetadataItem *pattern, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell);
    16 #if 0
    1716psMetadataItem *pmConceptFormat_CELL_TRIMSEC(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell);
    18 #endif
    1917psMetadataItem *pmConceptFormat_CELL_BIASSEC(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell);
    2018psMetadataItem *pmConceptFormat_CELL_XBIN(psMetadataItem *concept, psMetadata *cameraFormat, pmFPA *fpa, pmChip *chip, pmCell *cell);
  • branches/rel10_ifa/psModules/src/astrom/pmConceptsWrite.c

    r6804 r6815  
    1414//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    1515
    16 static bool compareConcepts(psMetadataItem *item1, // First item to compare
    17                             psMetadataItem *item2 // Second item to compare
     16static bool compareConcepts(psMetadataItem *compare, // Item to compare
     17                            psMetadataItem *standard // Standard for comparison
    1818                           )
    1919{
    2020    // 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) {
    2525        return false;
    2626    }
    2727
    2828    // Check the more boring types
    29     switch (item1->type) {
     29    switch (compare->type) {
    3030    case PS_TYPE_S32:
    31         switch (item2->type) {
     31        switch (standard->type) {
    3232        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;
    3535        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;
    3838        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;
    4141        default:
    4242            return false;
    4343        }
    4444    case PS_TYPE_F32:
    45         switch (item2->type) {
     45        switch (standard->type) {
    4646        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;
    4949        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;
    5252        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;
    5555        default:
    5656            return false;
    5757        }
    5858    case PS_TYPE_F64:
    59         switch (item2->type) {
     59        switch (standard->type) {
    6060        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;
    6363        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;
    6666        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;
    6969        default:
    7070            return false;
    7171        }
    72         return (item1->data.F64 == item2->data.F64) ? true : false;
     72        return (compare->data.F64 == standard->data.F64) ? true : false;
    7373    case PS_DATA_STRING:
    74         if (item2->type != PS_DATA_STRING) {
     74        if (standard->type != PS_DATA_STRING) {
    7575            return false;
    7676        }
    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        }
    79145    default:
    80146        return false;
     
    82148    psAbort(__func__, "Should never get here.\n");
    83149}
     150
    84151
    85152// Format a single concept
     
    216283                    } else if (strcasecmp(source, "VALUE") == 0) {
    217284                        psTrace(__func__, 8, "Checking %s against camera format.\n", name);
    218                         if (! compareConcepts(cameraItem, formatted)) {
     285                        if (! compareConcepts(formatted, cameraItem)) {
    219286                            psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by value in the camera "
    220287                                     "format, but the values don't match.\n", name);
     
    224291                                 "write\n", nameSource);
    225292                    }
    226                 } else if (! compareConcepts(cameraItem, formatted)) {
     293                } else if (! compareConcepts(formatted, cameraItem)) {
    227294                    // Assume it's specified by value
    228295                    psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by value in the camera "
     
    290357                    continue;
    291358                }
    292                 if (! compareConcepts(defaultItem, formatted)) {
     359                if (! compareConcepts(formatted, defaultItem)) {
    293360                    psLogMsg(__func__, PS_LOG_WARN, "Concept %s is specified by the DEFAULTS in the camera "
    294361                             "format, but the values don't match.\n", name);
  • branches/rel10_ifa/psModules/src/astrom/pmFPAConstruct.c

    r6813 r6815  
    579579            psTrace(__func__, 2, "---> NO PIXELS read in for extension %s\n", fpa->hdu->extname);
    580580        }
     581        if (fpa->hdu->header && header) {
     582            psTrace(__func__, 2, "---> Header:\n");
     583            psMetadataPrint(fpa->hdu->header, 8);
     584        }
    581585    }
    582586    if (concepts) {
  • branches/rel10_ifa/psModules/src/astrom/pmHDU.c

    r6734 r6815  
    145145    }
    146146
    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        }
    149156    }
    150157
Note: See TracChangeset for help on using the changeset viewer.