IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 13, 2006, 5:14:07 PM (20 years ago)
Author:
Paul Price
Message:

Small hacks from updating psModule code for FPAs and concepts

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppImageDetrendNonLinear.c

    r5858 r5976  
    66    psVector *coeff = dataItem->data.V; // The coefficient vector
    77    if (coeff->type.type != PS_TYPE_F64) {
    8         psVector *temp = psVectorCopy(NULL, coeff, PS_TYPE_F64); // F64 version
    9         psFree (coeff);
    10         coeff = temp;
     8        psVector *temp = psVectorCopy(NULL, coeff, PS_TYPE_F64); // F64 version
     9        psFree (coeff);
     10        coeff = temp;
    1111    }
    1212    psPolynomial1D *correction = psPolynomial1DAlloc(coeff->n - 1, PS_POLYNOMIAL_ORD);
     
    1717    psFree(correction);
    1818    return true;
    19 }   
     19}
    2020
    2121bool ppDetrendNonLinearLookup (pmReadout *input, psMetadataItem *dataItem) {
     
    2525    psLookupTable *table = psLookupTableAlloc(name, "%f %f", 0);
    2626    if (psLookupTableRead(table) <= 0) {
    27         psErrorStackPrint(stderr, "Unable to read non-linearity correction file "
    28                           "%s --- ignored\n", name);
    29         return false;
    30     } 
     27        psErrorStackPrint(stderr, "Unable to read non-linearity correction file "
     28                          "%s --- ignored\n", name);
     29        return false;
     30    }
    3131#ifdef PRODUCTION
    3232    pmNonLinearityLookup(input, table);
     
    3838    psFree(table);
    3939    return true;
    40 }   
     40}
    4141
    4242bool ppDetrendNonLinear (pmCell *cell, pmReadout *input, ppOptions *options) {
     
    4646    switch (options->nonLinearType) {
    4747      case PS_DATA_VECTOR:
    48         ppDetrendNonLinearPolynomial (input, options->nonLinearData);
    49         return true;
     48        ppDetrendNonLinearPolynomial (input, options->nonLinearData);
     49        return true;
    5050
    5151      case PS_DATA_STRING:
    52         ppDetrendNonLinearLookup (input, options->nonLinearData);
    53         return true;
     52        ppDetrendNonLinearLookup (input, options->nonLinearData);
     53        return true;
    5454
    5555      case PS_DATA_METADATA:
    56         // XXX this is somewhat confusing : let's wrap in a function when i understand it
    57         concept = pmCellGetConcept(cell, options->nonLinearSource);
    58         if (! concept) {
    59             psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s "
    60                      "for non-linearity correction --- ignored.\n", options->nonLinearSource);
    61             return false;
    62         }
    63         if (concept->type != PS_DATA_STRING) {
    64             psLogMsg("phase2", PS_LOG_WARN, "Type for concept %s isn't STRING, as"
    65                      " expected for non-linearity correction --- ignored.\n",
    66                      concept);
    67             return false;
    68         }
     56        // XXX EAM: this is somewhat confusing : let's wrap in a function when i understand it
    6957
    70         // Get the value of the concept
    71         psString conceptValue = concept->data.V;
    72         psMetadata *folder = (psMetadata *)options->nonLinearData->data.V;
    73         psMetadataItem *optionItem = psMetadataLookup(folder, conceptValue);
    74         if (!optionItem) {
    75             psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA"
    76                      " --- ignored.\n", conceptValue);
    77             return false;
    78         }
     58        // Go looking for the value in the hierarchy
     59        concept = psMetadataLookup(cell->concepts, options->nonLinearSource);
     60        if (! concept) {
     61            pmChip *chip = cell->parent;// Parent chip
     62            concept = psMetadataLookup(chip->concepts, options->nonLinearSource);
     63            if (! concept) {
     64                pmFPA *fpa = chip->parent; // Parent FPA
     65                concept = psMetadataLookup(fpa->concepts, options->nonLinearSource);
     66                if (! concept) {
     67                    psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s "
     68                             "for non-linearity correction --- ignored.\n", options->nonLinearSource);
     69                    return false;
     70                }
     71            }
     72        }
    7973
    80         switch (optionItem->type) {
    81           case PS_DATA_VECTOR:
    82             ppDetrendNonLinearPolynomial (input, optionItem);
    83             return true;
    84           case PS_DATA_STRING:
    85             ppDetrendNonLinearLookup (input, optionItem);
    86             return true;
    87           default:
    88             psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction "
    89                      "desired but unable to interpret NONLIN.DATA for %s"
    90                      " --- ignored\n", conceptValue);
    91             return false;
    92         }
     74        if (concept->type != PS_DATA_STRING) {
     75            psLogMsg("phase2", PS_LOG_WARN, "Type for concept %s isn't STRING, as"
     76                     " expected for non-linearity correction --- ignored.\n",
     77                     concept);
     78            return false;
     79        }
     80
     81        // Get the value of the concept
     82        psString conceptValue = concept->data.V;
     83        psMetadata *folder = (psMetadata *)options->nonLinearData->data.V;
     84        psMetadataItem *optionItem = psMetadataLookup(folder, conceptValue);
     85        if (!optionItem) {
     86            psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA"
     87                     " --- ignored.\n", conceptValue);
     88            return false;
     89        }
     90
     91        switch (optionItem->type) {
     92          case PS_DATA_VECTOR:
     93            ppDetrendNonLinearPolynomial (input, optionItem);
     94            return true;
     95          case PS_DATA_STRING:
     96            ppDetrendNonLinearLookup (input, optionItem);
     97            return true;
     98          default:
     99            psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction "
     100                     "desired but unable to interpret NONLIN.DATA for %s"
     101                     " --- ignored\n", conceptValue);
     102            return false;
     103        }
    93104      default:
    94         psAbort("phase2", "Invalid options->nonLinearType");
     105        psAbort("phase2", "Invalid options->nonLinearType");
    95106    }
    96107    return true;
Note: See TracChangeset for help on using the changeset viewer.