IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 28, 2007, 10:59:53 AM (19 years ago)
Author:
Paul Price
Message:

Removing extraneous 'break' which caused a bug in generating the mosaicked format.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/config/pmConfigCamera.c

    r12597 r12639  
    4949    removeConcept(source, "CELL.Y0");
    5050
     51    // For the sake of the defaults, include the .DEPEND
     52    removeConcept(source, "CELL.XPARITY.DEPEND");
     53    removeConcept(source, "CELL.YPARITY.DEPEND");
     54    removeConcept(source, "CELL.X0.DEPEND");
     55    removeConcept(source, "CELL.Y0.DEPEND");
     56
    5157    return;
    5258}
     
    6571    removeConcept(source, "CHIP.X0");
    6672    removeConcept(source, "CHIP.Y0");
     73
     74    // For the sake of the defaults, include the .DEPEND
     75    removeConcept(source, "CHIP.XPARITY.DEPEND");
     76    removeConcept(source, "CHIP.YPARITY.DEPEND");
     77    removeConcept(source, "CHIP.X0.DEPEND");
     78    removeConcept(source, "CHIP.Y0.DEPEND");
    6779
    6880    return;
     
    8597    psMetadata *camera = psMetadataLookupMetadata(NULL, oldCameras, name); // The camera configuration
    8698    if (!camera) {
    87         // XXX is this an error?
     99        // XXX is this an error?
    88100        psError(PS_ERR_UNEXPECTED_NULL, false, "Can't find camera to be mosaicked in camera list.");
    89101        return false;
     
    109121    }
    110122    switch (mosaicLevel) {
    111         // For CHIP mosaic, replace the contents of each chip with a single cell
     123        // For CHIP mosaic, replace the contents of each chip with a single cell
    112124      case PM_FPA_LEVEL_CHIP: {
    113125          psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator
     
    117129                  psError(PS_ERR_UNKNOWN, true, "Element %s within FPA in camera configuration is not of type STR.",
    118130                            fpaItem->name);
    119                   psFree(new);
    120                   return false;
     131                  psFree(new);
     132                  return false;
    121133              }
    122134
     
    129141          break;
    130142      }
    131         // For FPA mosaic, replace the contents of the FPA with a single chip containing a single cell
     143        // For FPA mosaic, replace the contents of the FPA with a single chip containing a single cell
    132144      case PM_FPA_LEVEL_FPA: {
    133145          while (psListLength(fpa->list) > 0) {
     
    156168
    157169        // Add a new RULE which uniquely describes the mosaicked format.  this is needed so
    158         // that when a mosaic is written to a FITS file, it can be recognised again when read.
     170        // that when a mosaic is written to a FITS file, it can be recognised again when read.
    159171        psMetadata *rule = psMetadataLookupMetadata(NULL, format, "RULE"); // Way to identify format from PHU
    160172        if (!rule) {
    161             // a camera format without a rule is not allowed.
    162             psError(PS_ERR_UNKNOWN, false, "Camera format %s has no RULE", formatsItem->name);
    163             return false;
    164         }
    165 
    166         // the new rule is supplemented by the mosaicLevel
     173            // a camera format without a rule is not allowed.
     174            psError(PS_ERR_UNKNOWN, false, "Camera format %s has no RULE", formatsItem->name);
     175            return false;
     176        }
     177
     178        // the new rule is supplemented by the mosaicLevel
    167179        switch (mosaicLevel) {
    168180        case PM_FPA_LEVEL_CHIP:
     
    177189
    178190        // Fix the FILE information: need to fix the levels for the PHU and EXTENSIONS.
    179         // both of these elements are required in the format; we raise an error if they are not found
     191        // both of these elements are required in the format; we raise an error if they are not found
    180192        // If EXTENSIONS is NONE, then we need to change the CONTENT specifier to point to the chip name.
    181193        psMetadata *file = psMetadataLookupMetadata(NULL, format, "FILE"); // File information
    182194        if (!file) {
    183195            psError(PS_ERR_UNKNOWN, false, "Camera format %s has no FILE", formatsItem->name);
    184             return false;
     196            return false;
    185197        }
    186198        psMetadataItem *phuItem = psMetadataLookup(file, "PHU"); // PHU level
    187199        if (!phuItem || phuItem->type != PS_DATA_STRING) {
    188200            psError(PS_ERR_UNKNOWN, false, "Camera format %s is missing PHU in the FILE information", formatsItem->name);
    189             return false;
     201            return false;
    190202        }
    191203        psMetadataItem *extensionsItem = psMetadataLookup(file, "EXTENSIONS"); // Extensions level
     
    195207        }
    196208
    197         // mosaicLevel == CHIP:
    198         // Case    PHU     EXTENSIONS     Modifications
    199         // ====    ===     ==========     ===========
    200         // 1.      FPA     CHIP           NONE
    201         // 2.      FPA     CELL           EXT->CHIP
    202         // 3.      FPA     NONE           NONE
    203         // 4.      CHIP    CELL           EXT->NONE
    204         // 5.      CHIP    NONE           NONE
    205         // 6.      CELL    NONE           PHU->CHIP
    206         // possible outcomes:
    207         //         FPA     CHIP
    208         //         FPA     NONE
    209         //         CHIP    NONE
    210 
    211         // mosaicLevel == FPA:
    212         // Case    PHU     EXTENSIONS     Modifications
    213         // ====    ===     ==========     ===========
    214         // 1.      FPA     CHIP           EXT->NONE
    215         // 2.      FPA     CELL           EXT->NONE
    216         // 3.      FPA     NONE           NONE
    217         // 4.      CHIP    CELL           PHU->FPA, EXT->NONE
    218         // 5.      CHIP    NONE           PHU->FPA
    219         // 6.      CELL    NONE           PHU->FPA
    220         // possible outcomes:
    221         //         FPA     NONE
    222 
    223         // modify the values of phuItem and extensionsItem
     209        // mosaicLevel == CHIP:
     210        // Case    PHU     EXTENSIONS     Modifications
     211        // ====    ===     ==========     ===========
     212        // 1.      FPA     CHIP           NONE
     213        // 2.      FPA     CELL           EXT->CHIP
     214        // 3.      FPA     NONE           NONE
     215        // 4.      CHIP    CELL           EXT->NONE
     216        // 5.      CHIP    NONE           NONE
     217        // 6.      CELL    NONE           PHU->CHIP
     218        // possible outcomes:
     219        //         FPA     CHIP
     220        //         FPA     NONE
     221        //         CHIP    NONE
     222
     223        // mosaicLevel == FPA:
     224        // Case    PHU     EXTENSIONS     Modifications
     225        // ====    ===     ==========     ===========
     226        // 1.      FPA     CHIP           EXT->NONE
     227        // 2.      FPA     CELL           EXT->NONE
     228        // 3.      FPA     NONE           NONE
     229        // 4.      CHIP    CELL           PHU->FPA, EXT->NONE
     230        // 5.      CHIP    NONE           PHU->FPA
     231        // 6.      CELL    NONE           PHU->FPA
     232        // possible outcomes:
     233        //         FPA     NONE
     234
     235        // modify the values of phuItem and extensionsItem
    224236        switch (mosaicLevel) {
    225237          case PM_FPA_LEVEL_CHIP:
    226238            if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "CHIP")) {
    227                 break;
    228             } 
     239                break;
     240            }
    229241            if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "CELL")) {
    230242                psFree(extensionsItem->data.str);
    231243                extensionsItem->data.str = psStringCopy("CHIP");
    232                 break;
    233             } 
     244                break;
     245            }
    234246            if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "NONE")) {
    235                 break;
    236             } 
     247                break;
     248            }
    237249            if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "CELL")) {
    238250                psFree(extensionsItem->data.str);
    239251                extensionsItem->data.str = psStringCopy("NONE");
    240                 break;
    241             } 
     252                break;
     253            }
    242254            if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "NONE")) {
    243                 break;
    244             } 
     255                break;
     256            }
    245257            if (!strcasecmp(phuItem->data.str, "CELL") && !strcasecmp(extensionsItem->data.str, "NONE")) {
    246                 psFree(phuItem->data.str);
     258                psFree(phuItem->data.str);
    247259                phuItem->data.str = psStringCopy("CHIP");
    248                 break;
    249             } 
    250             psAbort ("should not reach here");
     260                break;
     261            }
     262            psAbort ("should not reach here");
    251263
    252264          case PM_FPA_LEVEL_FPA:
     
    254266                psFree(extensionsItem->data.str);
    255267                extensionsItem->data.str = psStringCopy("NONE");
    256                 break;
    257             } 
     268                break;
     269            }
    258270            if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "CELL")) {
    259271                psFree(extensionsItem->data.str);
    260272                extensionsItem->data.str = psStringCopy("NONE");
    261                 break;
    262             } 
     273                break;
     274            }
    263275            if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "NONE")) {
    264                 break;
    265             } 
     276                break;
     277            }
    266278            if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "CELL")) {
    267                 psFree(phuItem->data.str);
     279                psFree(phuItem->data.str);
    268280                phuItem->data.str = psStringCopy("FPA");
    269                 break;
    270281                psFree(extensionsItem->data.str);
    271282                extensionsItem->data.str = psStringCopy("NONE");
    272                 break;
    273             } 
     283                break;
     284            }
    274285            if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "NONE")) {
    275                 psFree(phuItem->data.str);
     286                psFree(phuItem->data.str);
    276287                phuItem->data.str = psStringCopy("FPA");
    277                 break;
    278             } 
     288                break;
     289            }
    279290            if (!strcasecmp(phuItem->data.str, "CELL") && !strcasecmp(extensionsItem->data.str, "NONE")) {
    280                 psFree(phuItem->data.str);
     291                psFree(phuItem->data.str);
    281292                phuItem->data.str = psStringCopy("FPA");
    282                 break;
    283             } 
    284             psAbort ("should not reach here");
    285 
    286           default:
     293                break;
     294            }
     295            psAbort ("should not reach here");
     296
     297          default:
    287298            psAbort("Should never get here.\n");
    288299        }
    289300
    290301#if 0
    291         // XXXX when do I need to adjust the value of CONTENT, CELL.NAME, CHIP.NAME?
    292 
    293         // Don't need a "CONTENT" to identify the content!
    294         if (psMetadataLookup(file, "CONTENT")) {
    295             psMetadataRemoveKey(file, "CONTENT");
    296         }
    297         psMetadataAddStr(file, PS_LIST_TAIL, "CONTENT", PS_META_REPLACE, "Key to CONTENTS menu",
    298                         "{CHIP.NAME}");
    299         // Don't need CELL.NAME for chip-mosaicked camera
    300         if (psMetadataLookup(file, "CELL.NAME")) {
    301             psMetadataRemoveKey(file, "CELL.NAME");
    302         }
    303         // Don't need CHIP.NAME or CELL.NAME for fpa-mosaicked camera
    304         if (psMetadataLookup(file, "CHIP.NAME")) {
    305             psMetadataRemoveKey(file, "CHIP.NAME");
    306         }
    307         if (psMetadataLookup(file, "CELL.NAME")) {
    308             psMetadataRemoveKey(file, "CELL.NAME");
    309         }
     302        // XXXX when do I need to adjust the value of CONTENT, CELL.NAME, CHIP.NAME?
     303
     304        // Don't need a "CONTENT" to identify the content!
     305        if (psMetadataLookup(file, "CONTENT")) {
     306            psMetadataRemoveKey(file, "CONTENT");
     307        }
     308        psMetadataAddStr(file, PS_LIST_TAIL, "CONTENT", PS_META_REPLACE, "Key to CONTENTS menu",
     309                        "{CHIP.NAME}");
     310        // Don't need CELL.NAME for chip-mosaicked camera
     311        if (psMetadataLookup(file, "CELL.NAME")) {
     312            psMetadataRemoveKey(file, "CELL.NAME");
     313        }
     314        // Don't need CHIP.NAME or CELL.NAME for fpa-mosaicked camera
     315        if (psMetadataLookup(file, "CHIP.NAME")) {
     316            psMetadataRemoveKey(file, "CHIP.NAME");
     317        }
     318        if (psMetadataLookup(file, "CELL.NAME")) {
     319            psMetadataRemoveKey(file, "CELL.NAME");
     320        }
    310321#endif
    311322
     
    318329          case PM_FPA_LEVEL_CHIP:
    319330            if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "CHIP")) {
    320                 // ensure the value of CONTENT in the FILE section has the right value
    321                 psMetadataAddStr(file, PS_LIST_TAIL, "CONTENT", PS_META_REPLACE, "Key to CONTENTS menu", "{CHIP.NAME}");
    322 
    323                 // List the chipName:chipType for each chip.
    324                 psMetadata *contents = psMetadataAlloc(); // List of contents, with chipName:chipType
    325 
    326                 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr
    327                 psMetadataItem *fpaItem;    // Item from iteration
    328                 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) {
    329                     assert (fpaItem->type == PS_DATA_STRING);
    330                     psString content = NULL; // Content to add
    331                     psStringAppend(&content, "%s:_mosaicChip ", fpaItem->name);
    332                     psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, content);
    333                     psFree(content);
    334                 }
    335                 psFree(fpaIter);
    336                 psMetadataAddMetadata(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE,
    337                                       "List of contents", contents);
    338                 psFree(contents);
    339 
    340                 psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType
    341                 psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL,
    342                                 "MosaickedCell:_mosaic");
    343                 psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE,
    344                                       "List of chip types", chips);
    345                 psFree(chips);
    346                 break;
    347             }
    348             if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "NONE")) {
    349                 // List the contents on a single line
    350                 psString contentsLine = NULL; // Contents of the PHU
    351                 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr
    352                 psMetadataItem *fpaItem;    // Item from iteration
    353                 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) {
    354                     assert (fpaItem->type == PS_DATA_STRING);
    355                     psStringAppend(&contentsLine, "%s:MosaickedCell:_mosaic ", fpaItem->name);
    356                 }
    357                 psFree(fpaIter);
    358                 psMetadataAddStr(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE,
    359                                 NULL, contentsLine);
    360                 psFree(contentsLine);
    361                 break;
    362             }
    363             if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "NONE")) {
    364                 // XXX recode this to match the structure above (FPA/CHIP)?
    365                 // select and remove the old contents
    366                 psMetadata *contents = psMetadataLookupMetadata(NULL, format, TABLE_OF_CONTENTS); // File contents
    367                 if (!contents) {
    368                     psError(PS_ERR_UNKNOWN, false, "Couldn't find %s in the camera format %s.\n",
    369                             TABLE_OF_CONTENTS, formatsItem->name);
    370                     return false;
    371                 }
    372                 while (psListLength(contents->list) > 0) {
    373                     psMetadataRemoveIndex(contents, PS_LIST_TAIL);
    374                 }
    375 
    376                 // update with the new contents
    377                 psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator
    378                 psMetadataItem *fpaItem;    // Item from iteration
    379                 while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) {
    380                     assert (fpaItem->type == PS_DATA_STRING);
    381                     psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, "_mosaicChip");
    382                 }
    383                 psFree(fpaIter);
    384 
    385                 psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType
    386                 psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL,
    387                                 "MosaickedCell:_mosaic");
    388                 psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE,
    389                                       "List of chip types", chips);
    390                 psFree(chips);
    391                 break;
    392             }
     331                // ensure the value of CONTENT in the FILE section has the right value
     332                psMetadataAddStr(file, PS_LIST_TAIL, "CONTENT", PS_META_REPLACE, "Key to CONTENTS menu", "{CHIP.NAME}");
     333
     334                // List the chipName:chipType for each chip.
     335                psMetadata *contents = psMetadataAlloc(); // List of contents, with chipName:chipType
     336
     337                psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr
     338                psMetadataItem *fpaItem;    // Item from iteration
     339                while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) {
     340                    assert (fpaItem->type == PS_DATA_STRING);
     341                    psString content = NULL; // Content to add
     342                    psStringAppend(&content, "%s:_mosaicChip ", fpaItem->name);
     343                    psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, content);
     344                    psFree(content);
     345                }
     346                psFree(fpaIter);
     347                psMetadataAddMetadata(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE,
     348                                      "List of contents", contents);
     349                psFree(contents);
     350
     351                psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType
     352                psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL,
     353                                "MosaickedCell:_mosaic");
     354                psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE,
     355                                      "List of chip types", chips);
     356                psFree(chips);
     357                break;
     358            }
     359            if (!strcasecmp(phuItem->data.str, "FPA") && !strcasecmp(extensionsItem->data.str, "NONE")) {
     360                // List the contents on a single line
     361                psString contentsLine = NULL; // Contents of the PHU
     362                psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iteratr
     363                psMetadataItem *fpaItem;    // Item from iteration
     364                while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) {
     365                    assert (fpaItem->type == PS_DATA_STRING);
     366                    psStringAppend(&contentsLine, "%s:MosaickedCell:_mosaic ", fpaItem->name);
     367                }
     368                psFree(fpaIter);
     369                psMetadataAddStr(format, PS_LIST_TAIL, TABLE_OF_CONTENTS, PS_META_REPLACE,
     370                                NULL, contentsLine);
     371                psFree(contentsLine);
     372                break;
     373            }
     374            if (!strcasecmp(phuItem->data.str, "CHIP") && !strcasecmp(extensionsItem->data.str, "NONE")) {
     375                // XXX recode this to match the structure above (FPA/CHIP)?
     376                // select and remove the old contents
     377                psMetadata *contents = psMetadataLookupMetadata(NULL, format, TABLE_OF_CONTENTS); // File contents
     378                if (!contents) {
     379                    psError(PS_ERR_UNKNOWN, false, "Couldn't find %s in the camera format %s.\n",
     380                            TABLE_OF_CONTENTS, formatsItem->name);
     381                    return false;
     382                }
     383                while (psListLength(contents->list) > 0) {
     384                    psMetadataRemoveIndex(contents, PS_LIST_TAIL);
     385                }
     386
     387                // update with the new contents
     388                psMetadataIterator *fpaIter = psMetadataIteratorAlloc(fpa, PS_LIST_HEAD, NULL); // Iterator
     389                psMetadataItem *fpaItem;    // Item from iteration
     390                while ((fpaItem = psMetadataGetAndIncrement(fpaIter))) {
     391                    assert (fpaItem->type == PS_DATA_STRING);
     392                    psMetadataAddStr(contents, PS_LIST_TAIL, fpaItem->name, 0, NULL, "_mosaicChip");
     393                }
     394                psFree(fpaIter);
     395
     396                psMetadata *chips = psMetadataAlloc(); // List of chip types, with cellName:cellType
     397                psMetadataAddStr(chips, PS_LIST_TAIL, "_mosaicChip", 0, NULL,
     398                                "MosaickedCell:_mosaic");
     399                psMetadataAddMetadata(format, PS_LIST_TAIL, CHIP_TYPES, PS_META_REPLACE,
     400                                      "List of chip types", chips);
     401                psFree(chips);
     402                break;
     403            }
    393404        default:
    394405            psAbort("Should never get here.\n");
     
    399410        if (!cells) {
    400411            psError(PS_ERR_UNKNOWN, false, "Couldn't find CELLS of type METADATA in the camera format %s.\n", formatsItem->name);
    401             return false;
     412            return false;
    402413        }
    403414        psMetadata *cell = psMetadataAlloc(); // Cell information
Note: See TracChangeset for help on using the changeset viewer.