IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 13, 2008, 11:20:36 AM (18 years ago)
Author:
Paul Price
Message:

Allowing CELL.READNOISE to be specified in ADU instead of electrons. This requires updating the parsed value with the gain when it's available. Added a check at the principal (only?) place this value is used (pmReadoutSetWeight) so that errors can be trapped.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/concepts/pmConceptsStandard.c

    r19980 r20095  
    4646    return NAN;
    4747}
     48
     49
     50psMetadataItem *p_pmConceptParse_CELL_READNOISE(const psMetadataItem *concept,
     51                                                const psMetadataItem *pattern,
     52                                                pmConceptSource source,
     53                                                const psMetadata *cameraFormat,
     54                                                const pmFPA *fpa,
     55                                                const pmChip *chip,
     56                                                const pmCell *cell)
     57{
     58    assert(concept);
     59    assert(pattern);
     60    assert(cameraFormat);
     61    assert(cell);
     62
     63    float rn = psMetadataItemParseF32(concept); // Read noise
     64    if (isfinite(rn)) {
     65        bool mdok;                      // Status of MD lookup
     66        psMetadata *formats = psMetadataLookupMetadata(&mdok, cameraFormat, "FORMATS");
     67        if (mdok && formats) {
     68            psString format = psMetadataLookupStr(&mdok, formats, pattern->name);
     69            if (mdok && strlen(format) > 0) {
     70                if (strcasecmp(format, "ADU") == 0) {
     71                    float gain = psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN"); // Gain (e/ADU)
     72                    if (!isfinite(gain)) {
     73                        // Will need to update the readnoise once the gain is available
     74                        psMetadataAddBool(cell->concepts, PS_LIST_TAIL, "CELL.READNOISE.UPDATE",
     75                                          PS_META_REPLACE,
     76                                          "Need to update CELL.READNOISE when the gain is available.", true);
     77                    } else {
     78                        rn *= gain;
     79                    }
     80                } else {
     81                    psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised format for CELL.READNOISE: %s",
     82                            format);
     83                    return NULL;
     84                }
     85            }
     86        }
     87    }
     88
     89    return psMetadataItemAllocF32(pattern->name, pattern->comment, rn);
     90}
     91
     92psMetadataItem *p_pmConceptFormat_CELL_READNOISE(const psMetadataItem *concept,
     93                                                 pmConceptSource source,
     94                                                 const psMetadata *cameraFormat,
     95                                                 const pmFPA *fpa,
     96                                                 const pmChip *chip,
     97                                                 const pmCell *cell)
     98{
     99    assert(concept);
     100    assert(cell);
     101    assert(concept->type == PS_TYPE_F32);
     102
     103    float rn = concept->data.F32;       // Read noise
     104    if (isfinite(rn)) {
     105        bool mdok;                      // Status of MD lookup
     106        psMetadata *formats = psMetadataLookupMetadata(&mdok, cameraFormat, "FORMATS");
     107        if (mdok && formats) {
     108            psString format = psMetadataLookupStr(&mdok, formats, concept->name);
     109            if (mdok && strlen(format) > 0) {
     110                if (strcasecmp(format, "ADU") == 0) {
     111                    if (!psMetadataLookup(cell->concepts, "CELL.READNOISE.UPDATE")) {
     112                        // Gain correction has been applied, so we need to reverse it to format
     113                        float gain = psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN"); // Gain (e/ADU)
     114                        if (!isfinite(gain)) {
     115                            psWarning("CELL.READNOISE is supposed to be in ADU, but CELL.GAIN isn't set");
     116                        }
     117                        rn /= gain;
     118                    }
     119                } else {
     120                    psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised format for CELL.READNOISE: %s",
     121                            format);
     122                    return NULL;
     123                }
     124            }
     125        }
     126    }
     127
     128    return psMetadataItemAllocF32(concept->name, concept->comment, rn);
     129}
     130
    48131
    49132// TELTEMPS : parse a list of the form 'X1 X2 X3 X4 X5 ...' : for now use median
Note: See TracChangeset for help on using the changeset viewer.