IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 18, 2005, 4:19:41 PM (21 years ago)
Author:
Paul Price
Message:

Current state before I go on holiday. Not sure if it works or not. Not current for pslib8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/archive/scripts/src/phase2/papPhase2.c

    r5104 r5371  
    4545static psMemId memPrintAlloc(const psMemBlock *mb)
    4646{
    47     printf("Allocated memory block %lld (%lld):\n"
     47    printf("Allocated memory block %ld (%ld):\n"
    4848           "\tFile %s, line %d, size %d\n"
    4949           "\tPosts: %x %x %x\n",
     
    5454static psMemId memPrintFree(const psMemBlock *mb)
    5555{
    56     printf("Freed memory block %lld (%lld):\n"
     56    printf("Freed memory block %ld (%ld):\n"
    5757           "\tFile %s, line %d, size %d\n"
    5858           "\tPosts: %x %x %x\n",
     
    6464{
    6565    psMemBlock *mb = ((psMemBlock*)ptr) - 1;
    66     printf("Memory block %lld (%lld):\n"
     66    printf("Memory block %ld (%ld):\n"
    6767           "\tFile %s, line %d, size %d\n"
    6868           "\tPosts: %x %x %x\n",
     
    7575#if 0
    7676    // Hunting memory leaks
    77     psMemAllocateCallbackSetID(23289);
    78     psMemFreeCallbackSetID(23289);
    79     psMemAllocateCallbackSet(memPrintAlloc);
     77    psMemAllocCallbackSetID(22367);
     78    psMemFreeCallbackSetID(22367);
     79    psMemAllocCallbackSet(memPrintAlloc);
    8080    psMemFreeCallbackSet(memPrintFree);
    8181#endif
     
    198198    bool doAstrom = false;              // Astrometry
    199199    pmOverscanAxis overscanMode = PM_OVERSCAN_NONE; // Axis for overscan
    200     pmFit overscanFit = PM_FIT_NONE;    // Fit type for overscan
     200    pmFit overscanFitType = PM_FIT_NONE; // Fit type for overscan
    201201    int overscanBins = 1;               // Number of pixels per bin for overscan
    202202    psStats *overscanStats = NULL;      // Statistics for overscan
     203    void *overscanFit = NULL;           // Overscan fit (polynomial or spline)
    203204
    204205    if (psMetadataLookupBool(NULL, recipe, "MASK")) {
     
    243244        psString fit = psMetadataLookupString(NULL, recipe, "OVERSCAN.FIT");
    244245        if (strcasecmp(fit, "POLYNOMIAL") == 0) {
    245             overscanFit = PM_FIT_POLYNOMIAL;
     246            overscanFitType = PM_FIT_POLYNOMIAL;
     247            int order = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER"); // Order of polynomial fit
     248            overscanFit = psPolynomial1DAlloc(order, PS_POLYNOMIAL_ORD);
    246249        } else if (strcasecmp(fit, "SPLINE") == 0) {
    247             overscanFit = PM_FIT_SPLINE;
     250            overscanFitType = PM_FIT_SPLINE;
     251            int order = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER"); // Order of polynomial fit
     252//          overscanFit = psSpline1DAlloc(order, PS_POLYNOMIAL_ORD);
    248253        } else if (strcasecmp(fit, "NONE") != 0) {
    249254            psLogMsg("phase2", PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:"
     
    297302#endif
    298303
    299     pmFPAPrint(input);
     304    //pmFPAPrint(input);
    300305
    301306    // Load the calibration frames, if required
     
    475480                pmReadout *inputReadout = inputReadouts->data[k]; // Readout of interest in input image
    476481                psImage *inputImage = inputReadout->image; // The actual image
    477                 psList *inputOverscans = inputReadout->overscans; // List of overscan bias regions
    478482
    479483                // Mask bad pixels
     
    656660                }
    657661
    658                 printf("mode: %d\n", overscanMode);
    659 
    660662                if (doBias || doOverscan || doDark) {
    661                     void *overscanResult = NULL; // Result of overscan fit
    662 #ifdef PRODUCTION
    663                     (void)pmSubtractBias(inputReadout, overscanResult, inputOverscans, overscanMode,
    664                                          overscanStats, overscanBins, overscanFit, pedestal);
    665 #else
    666                     (void)pmSubtractBias(inputReadout, overscanResult, inputOverscans, overscanMode,
    667                                          overscanStats, overscanBins, overscanFit, biasReadout);
    668 #endif
    669                    
     663                    psList *inputOverscans = pmReadoutGetBias(inputReadout); // List of overscan bias regions
     664#ifdef PRODUCTION
     665                    (void)pmSubtractBias(inputReadout, overscanFit, inputOverscans, overscanMode,
     666                                         overscanStats, overscanBins, overscanFitType, pedestal);
     667#else
     668                    (void)pmSubtractBias(inputReadout, overscanFit, inputOverscans, overscanMode,
     669                                         overscanStats, overscanBins, overscanFitType, biasReadout);
     670#endif
     671                    psFree(inputOverscans);
     672
    670673                    // Output overscan fit results, if required
    671674                    if (doOverscan) {
    672                         switch (overscanFit) {
     675                        switch (overscanFitType) {
    673676                          case PM_FIT_POLYNOMIAL:
    674677                            {
    675                                 psPolynomial1D *poly = (psPolynomial1D*)overscanResult; // The polynomial
     678                                psPolynomial1D *poly = (psPolynomial1D*)overscanFit;    // The polynomial
    676679                                psString coeffs = NULL; // String containing the coefficients
    677680                                for (int i = 0; i < poly->n; i++) {
    678                                     psStringAppend(&coeffs, "%.2f ", poly->coeff[i]);
     681                                    psStringAppend(&coeffs, "%e ", poly->coeff[i]);
    679682                                }
    680683                                psLogMsg("phase2", PS_LOG_INFO, "Overscan polynomial coefficients:\n%s\n",
     
    685688                          case PM_FIT_SPLINE:
    686689                            {
    687                                 psSpline1D *spline = (psSpline1D*)overscanResult; // The spline
     690                                psSpline1D *spline = (psSpline1D*)overscanFit; // The spline
    688691                                psString coeffs = NULL; // String containing the coefficients
    689692                                for (int i = 0; i < spline->n; i++) {
     
    691694                                    psStringAppend(&coeffs, "%d: ", i);
    692695                                    for (int j = 0; j < poly->n; j++) {
    693                                         psStringAppend(&coeffs, "%.2f ", poly->coeff[i]);
     696                                        psStringAppend(&coeffs, "%e ", poly->coeff[i]);
    694697                                    }
    695698                                    psStringAppend(&coeffs, "\n");
     
    755758    psFree(dark);
    756759    psFree(flat);
     760    psFree(overscanFit);
    757761    psFree(overscanStats);
    758762
     
    764768#if 1
    765769    for (int i = 0; i < nLeaks; i++) {
    766         printf("Memory leak detection: memBlock %lld (%lld)\n"
    767                "\tFile %s, line %d, size %d\n",
    768                leaks[i]->id, leaks[i]->refCounter, leaks[i]->file, leaks[i]->lineno,
    769                leaks[i]->userMemorySize);
     770        psMemBlock *mb = leaks[i];
     771        printf("Memory leak %ld (%ld):\n"
     772               "\tFile %s, line %d, size %d\n"
     773               "\tPosts: %x %x %x\n",
     774               mb->id, mb->refCounter, mb->file, mb->lineno, mb->userMemorySize, mb->startblock, mb->endblock,
     775               *(void**)((int8_t *)(mb + 1) + mb->userMemorySize));
    770776    }
    771777#endif
Note: See TracChangeset for help on using the changeset viewer.