IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 30, 2006, 2:14:20 PM (20 years ago)
Author:
Paul Price
Message:

Adding processing metadata to header.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/detrend/pmBias.c

    r10302 r10326  
    88
    99#include "pmFPA.h"
     10#include "pmHDUUtils.h"
    1011#include "pmBias.h"
    11 
    1212
    1313static void overscanOptionsFree(pmOverscanOptions *options)
     
    212212    }
    213213
    214     //    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now, used for reporting
     214    pmHDU *hdu = pmHDUFromReadout(in);  // HDU of interest
    215215
    216216    psImage *image = in->image;         // The input image
     
    235235        }
    236236        psStats *stats = psStatsAlloc(statistic); // A new psStats, to avoid clobbering original
     237
     238        psString comment = NULL;    // Comment to add
     239        psStringAppend(&comment, "Subtracting overscan (stat %x; type %x; order %d)",
     240                       statistic, overscanOpts->fitType, overscanOpts->order);
     241        psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK,
     242                         comment, "");
     243        psFree(comment);
    237244
    238245        // Reduce all overscan pixels to a single value
     
    245252                pixels = psVectorRealloc(pixels, pixels->n + overscan->numRows * overscan->numCols);
    246253                pixels->n += overscan->numRows * overscan->numCols;
    247                 // XXX Reimplement with memcpy
    248254                for (int i = 0; i < overscan->numRows; i++) {
    249                     for (int j = 0; j < overscan->numCols; j++) {
    250                         pixels->data.F32[index++] = overscan->data.F32[i][j];
    251                     }
    252                 }
    253 
     255                    memcpy(&pixels->data.F32[index], overscan->data.F32[i],
     256                           overscan->numCols * sizeof(psF32));
     257                    index += overscan->numCols;
     258                }
    254259            }
    255260            psFree(iter);
     
    260265            (void)psBinaryOp(image, image, "-", psScalarAlloc((float)reduced, PS_TYPE_F32));
    261266        } else {
    262 
    263267            // We do the regular overscan subtraction
    264 
    265268            bool readRows = psMetadataLookupBool(NULL, in->parent->concepts, "CELL.READDIR");// Read direction
    266269
     
    357360    // Bias frame subtraction
    358361    if (bias) {
    359         if (!subtractFrame(in, bias, 1.0))
     362        psVector *md5 = psImageMD5(bias->image); // md5 hash
     363        psString md5string = psMD5toString(md5); // String
     364        psFree(md5);
     365        psStringPrepend(&md5string, "BIAS image MD5: ");
     366        psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK,
     367                         md5string, "");
     368        psFree(md5string);
     369
     370        if (!subtractFrame(in, bias, 1.0)) {
    360371            return false;
     372        }
    361373    }
    362374
     
    365377        float inTime = psMetadataLookupF32(NULL, in->parent->concepts, "CELL.DARKTIME");
    366378        float darkTime = psMetadataLookupF32(NULL, dark->parent->concepts, "CELL.DARKTIME");
    367         if (!subtractFrame(in, dark, inTime/darkTime))
     379
     380        psVector *md5 = psImageMD5(dark->image); // md5 hash
     381        psString md5string = psMD5toString(md5); // String
     382        psFree(md5);
     383        psStringPrepend(&md5string, "DARK image (scale %.3f) MD5: ", inTime/darkTime);
     384        psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK,
     385                         md5string, "");
     386        psFree(md5string);
     387
     388        if (!subtractFrame(in, dark, inTime/darkTime)) {
    368389            return false;
    369     }
     390        }
     391    }
     392
     393    psTime *time = psTimeGetNow(PS_TIME_TAI); // The time now, used for reporting
     394    psString timeString = psTimeToISO(time); // String with time
     395    psFree(time);
     396    psStringPrepend(&timeString, "Bias processing completed at ");
     397    psMetadataAddStr(hdu->header, PS_LIST_TAIL, "HISTORY", PS_META_DUPLICATE_OK,
     398                     timeString, "");
     399    psFree(timeString);
     400
    370401
    371402    return true;
Note: See TracChangeset for help on using the changeset viewer.