IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 13, 2007, 4:03:29 PM (19 years ago)
Author:
Paul Price
Message:

Adding dark normalisation. The idea is that the dark current is not always linear with the darktime, but may be described by a polynomial function of the darktime. We introduce in the camera configuration DARK.NORM, which is a filename within the search path (or it may be a metadata, which removes the need to read a file, but clutters the configuration file). This file is read in the usual course of configuration setup. When required, DARK.NORM.KEY (which is resolved in the usual way, so try, e.g., '{CHIP.NAME}') points at a metadata within the DARK.NORM that provides the polynomial for correcting the darktime. This means that the view must be passed in to pmBiasSubtract, so that the appropriate polynomial can be identified.

File:
1 edited

Legend:

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

    r13704 r13810  
    44 *  @author EAM (IfA)
    55 *
    6  *  @version $Revision: 1.95 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2007-06-08 00:31:50 $
     6 *  @version $Revision: 1.96 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2007-06-14 02:03:29 $
    88 *
    99 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    293293}
    294294
     295// Read the calibrations for a camera
     296static bool cameraReadCalibrations(psMetadata *camera, // Camera for which to read the formats
     297                                   const char *name // Name of the camera, for error messages
     298    )
     299{
     300    assert(camera);
     301    assert(name);
     302
     303    psMetadataItem *darkNorm = psMetadataLookup(camera, "DARK.NORM"); // The dark normalisation calibration
     304    if (darkNorm) {
     305        if (darkNorm->type == PS_DATA_STRING) {
     306            const char *darkNormName = darkNorm->data.str; // The file name
     307            psTrace("config", 2, "Reading %s dark normalisation: %s\n", name, darkNormName);
     308            psMetadata *new = NULL;         // New metadata
     309            if (!pmConfigFileRead(&new, darkNormName, "Dark normalisation")) {
     310                psError(PM_ERR_CONFIG, false, "Trouble reading reading %s dark normalisation %s --- "
     311                        "ignored.\n", name, darkNormName);
     312                psFree(new);
     313                return false;
     314            }
     315
     316            // Muck around under the hood to replace the filename with the metadata;
     317            // don't try this at home, kids
     318            darkNorm->type = PS_DATA_METADATA;
     319            psFree(darkNorm->data.str);
     320            darkNorm->data.md = new;
     321        } else if (darkNorm->type != PS_DATA_METADATA) {
     322            psWarning("DARK.NORM in camera %s is not of type STR or METADATA (%x)", name, darkNorm->type);
     323        }
     324    } else {
     325        // Add a dummy entry
     326        psPolynomial1D *poly = psPolynomial1DAlloc(1, PS_POLYNOMIAL_ORD); // Dummy polynomial
     327        poly->coeff[0] = 0.0;
     328        poly->coeff[1] = 1.0;
     329        psMetadata *polyMD = psMetadataAlloc(); // Container for the polynomial
     330        (void)psPolynomial1DtoMetadata(polyMD, poly, "_DEFAULT"); // Metadata to insert
     331        psFree(poly);
     332        psMetadataAddMetadata(camera, PS_LIST_TAIL, "DARK.NORM", 0, "Dark normalisation polynomial",
     333                              polyMD);
     334        psMetadataAddStr(camera, PS_LIST_TAIL, "DARK.NORM.KEY", 0, "Key for dark normalisation", "_DEFAULT");
     335        psFree(polyMD);
     336    }
     337
     338    return true;
     339}
    295340
    296341pmConfig *pmConfigRead(int *argc, char **argv, const char *defaultRecipe)
     
    530575            }
    531576
     577            // Read in any camera-specific calibrations
     578            if (!cameraReadCalibrations(config->camera, cameraFile)) {
     579                psError(PS_ERR_UNKNOWN, false,
     580                        "Unable to read calibrations within camera configuration %s.\n",
     581                        cameraFile);
     582                psFree(config);
     583                return NULL;
     584            }
     585
    532586            psMetadataAddMetadata(cameras, PS_LIST_HEAD, cameraFile, PS_META_REPLACE,
    533587                                  "Camera specified on command line", config->camera);
Note: See TracChangeset for help on using the changeset viewer.