IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 14, 2006, 2:40:02 PM (19 years ago)
Author:
Paul Price
Message:

Adding functions to write masks. For this to work, had to add mask handling to pmHDUGenerate, and figured I may as well add weights as well.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/camera/pmFPAWrite.c

    r9949 r9983  
    242242
    243243
     244bool pmCellWriteMask(pmCell *cell,          // Cell to write
     245                     psFits *fits,          // FITS file to which to write
     246                     psDB *db           // Database handle for "concepts" update
     247                    )
     248{
     249    PS_ASSERT_PTR_NON_NULL(cell, false);
     250    PS_ASSERT_PTR_NON_NULL(fits, false);
     251
     252    pmHDU *hdu = cell->hdu;             // The HDU
     253    if (!hdu) {
     254        return true;                    // We wrote every HDU that exists
     255    }
     256
     257    psTrace ("pmFPAWrite", 5, "writing mask to Cell\n");
     258
     259    // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
     260    // generate the HDU, but only copies the structure.
     261    if (!hdu->blankPHU && !hdu->masks) {
     262        if (!pmHDUGenerateForCell(cell) || !hdu->masks) {
     263            psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for cell --- likely programming error.\n");
     264            return false;
     265        }
     266    }
     267
     268    pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | PM_CONCEPT_SOURCE_DEFAULTS;
     269    if (!pmConceptsWriteCell(cell, source, false, NULL)) {
     270        psError(PS_ERR_IO, false, "Unable to write concepts for cell.\n");
     271        return false;
     272    }
     273    if (!pmHDUWriteMask(hdu, fits)) {
     274        psError(PS_ERR_IO, false, "Unable to write HDU for cell.\n");
     275        return false;
     276    }
     277
     278    return true;
     279}
     280
     281
     282bool pmChipWriteMask(pmChip *chip, psFits *fits, psDB *db)
     283{
     284    PS_ASSERT_PTR_NON_NULL(chip, false);
     285    PS_ASSERT_PTR_NON_NULL(fits, false);
     286
     287    pmHDU *hdu = chip->hdu;             // The HDU
     288    if (!hdu) {
     289        return true;                    // We wrote every HDU that exists
     290    }
     291
     292    psTrace ("pmFPAWrite", 5, "writing mask to Chip\n");
     293
     294    // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
     295    // generate the HDU, but only copies the structure.
     296    if (!hdu->blankPHU && !hdu->masks) {
     297        if (!pmHDUGenerateForChip(chip) || !hdu->masks) {
     298            psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for chip --- likely programming error.\n");
     299            return false;
     300        }
     301    }
     302
     303    pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | PM_CONCEPT_SOURCE_DEFAULTS;
     304    if (!pmConceptsWriteChip(chip, source, false, true, NULL)) {
     305        psError(PS_ERR_IO, false, "Unable to write concepts for chip.\n");
     306        return false;
     307    }
     308    if (!pmHDUWriteMask(hdu, fits)) {
     309        psError(PS_ERR_IO, false, "Unable to write HDU for chip.\n");
     310        return false;
     311    }
     312
     313    return true;
     314}
     315
     316
     317
     318bool pmFPAWriteMask(pmFPA *fpa, psFits *fits, psDB *db)
     319{
     320    PS_ASSERT_PTR_NON_NULL(fpa, false);
     321    PS_ASSERT_PTR_NON_NULL(fits, false);
     322
     323    pmHDU *hdu = fpa->hdu;              // The HDU
     324    if (!hdu) {
     325        return true;                    // We wrote every HDU that exists
     326    }
     327
     328    psTrace ("pmFPAWrite", 5, "writing mask to FPA\n");
     329
     330    // Generate the HDU if needed --- this is required after a pmFPACopy, or similar, which does not
     331    // generate the HDU, but only copies the structure.
     332    if (!hdu->blankPHU && !hdu->masks) {
     333        if (!pmHDUGenerateForFPA(fpa) || !hdu->masks) {
     334            psError(PS_ERR_UNKNOWN, false, "Unable to generate HDU for chip --- likely programming error.\n");
     335            return false;
     336        }
     337    }
     338
     339    pmConceptSource source = PM_CONCEPT_SOURCE_HEADER | PM_CONCEPT_SOURCE_CELLS | PM_CONCEPT_SOURCE_DEFAULTS;
     340    if (!pmConceptsWriteFPA(fpa, source, true, NULL)) {
     341        psError(PS_ERR_IO, false, "Unable to write concepts for FPA.\n");
     342        return false;
     343    }
     344    if (!pmHDUWriteMask(hdu, fits))  {
     345        psError(PS_ERR_IO, false, "Unable to write HDU for FPA.\n");
     346        return false;
     347    }
     348
     349    return true;
     350}
     351
     352
     353
    244354int pmCellWriteTable(psFits *fits, const pmCell *cell, const char *name)
    245355{
Note: See TracChangeset for help on using the changeset viewer.