IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 23753 for trunk/ppSub/src


Ignore:
Timestamp:
Apr 8, 2009, 2:33:59 PM (17 years ago)
Author:
Paul Price
Message:

Put statistics files in RUN metadata. Removed unnecessary argument from pmConfigDump. Reorganised ppSub so configuration is carried by the ppSubData, which means that the configuration can be dumped when we free the ppSubData (similar operation as for writing statistics).

Location:
trunk/ppSub/src
Files:
3 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSub/src/Makefile.am

    r23740 r23753  
    3232        ppSubReadoutStats.c             \
    3333        ppSubReadoutSubtract.c          \
    34         ppSubSetMasks.c                 \
    35         ppSubReadoutRenorm.c            \
    36         ppSubVarianceFactors.c
     34        ppSubSetMasks.c
    3735
    3836ppSubKernel_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PPSUB_CFLAGS)
  • trunk/ppSub/src/ppSub.c

    r23740 r23753  
    4141        psErrorStackPrint(stderr, "Error initialising model classes.\n");
    4242        exitValue = PS_EXIT_PROG_ERROR;
     43        psFree(config);
    4344        goto die;
    4445    }
     
    4748        psErrorStackPrint(stderr, "Error initialising psphot.\n");
    4849        exitValue = PS_EXIT_PROG_ERROR;
     50        psFree(config);
    4951        goto die;
    5052    }
    5153
    52     data = ppSubDataAlloc(); // Processing data
     54    data = ppSubDataAlloc(config);
    5355
    54     if (!ppSubArguments(argc, argv, config, data)) {
     56    if (!ppSubArguments(argc, argv, data)) {
    5557        psErrorStackPrint(stderr, "Error reading arguments.\n");
    5658        exitValue = PS_EXIT_CONFIG_ERROR;
     
    5860    }
    5961
    60     if (!ppSubCamera(config, data)) {
     62    if (!ppSubCamera(data)) {
    6163        psErrorStackPrint(stderr, "Error setting up camera.\n");
    6264        exitValue = PS_EXIT_CONFIG_ERROR;
     
    6466    }
    6567
    66     if (!ppSubLoop(config, data)) {
     68    if (!ppSubLoop(data)) {
    6769        psErrorStackPrint(stderr, "Error performing subtraction.\n");
    6870        exitValue = PS_EXIT_SYS_ERROR;
     
    7577
    7678    psFree(data);
    77     psFree(config);
    7879
    7980    pmVisualClose(); //close plot windows, if -visual is set
  • trunk/ppSub/src/ppSub.h

    r23740 r23753  
    4040/// Data for processing
    4141typedef struct {
     42    pmConfig *config;                   // Configuration
    4243    psErrorCode quality;                // Quality code; 0 for no problem
    4344    bool photometry;                    // Perform photometry?
     
    4546    psString stamps;                    // Stamps file
    4647    pmPSF *psf;                         // Point Spread Function
     48    psString statsName;                 // Name of statistics file
    4749    FILE *statsFile;                    // Statistics file
    4850    psMetadata *stats;                  // Statistics
     
    5052
    5153/// Constructor
    52 ppSubData *ppSubDataAlloc(void);
     54ppSubData *ppSubDataAlloc(pmConfig *config ///< Configuration
     55    );
    5356
    5457/// Setup the arguments parsing
    5558bool ppSubArguments(int argc, char *argv[], ///< Command-line arguments
    56                     pmConfig *config, ///< Configuration
    5759                    ppSubData *data ///< Processing data
    5860    );
    5961
    6062/// Parse the camera input
    61 bool ppSubCamera(pmConfig *config,      ///< Configuration
    62                  ppSubData *data        ///< Processing data
     63bool ppSubCamera(ppSubData *data        ///< Processing data
    6364    );
    6465
    6566/// Loop over the FPA hierarchy
    66 bool ppSubLoop(pmConfig *config,        ///< Configuration
    67                ppSubData *data          ///< Processing data
    68     );
    69 
    70 /// Perform PSF-matched image subtraction on the readout
    71 bool ppSubReadout(pmConfig *config,     ///< Configuration
    72                   ppSubData *data       ///< Processing data
     67bool ppSubLoop(ppSubData *data          ///< Processing data
    7368    );
    7469
     
    7974/// Generate the PSF-matching kernel and convolve the images as needed.  Most of this function involves
    8075/// looking up the parameters in the recipe and supplying them to the function pmSubtractionMatch()
    81 bool ppSubMatchPSFs(pmConfig *config,   ///< Configuration
    82                     ppSubData *data     ///< Processing data
     76bool ppSubMatchPSFs(ppSubData *data     ///< Processing data
    8377    );
    8478
     
    8983
    9084/// Photometry stage 1: measure the PSF from the minuend image
    91 bool ppSubMakePSF(pmConfig *config,     ///< Configuration
    92                   ppSubData *data       ///< Processing data
     85bool ppSubMakePSF(ppSubData *data       ///< Processing data
    9386    );
    9487
     
    10093/// Photometry stage 2: find and measure sources on the subtracted image
    10194bool ppSubReadoutPhotometry(const char *name, ///< Name of file to photometer
    102                             pmConfig *config, ///< Configuration
    10395                            ppSubData *data ///< Processing data
    104     );
    105 
    106 /// Renormalize, update headers and generate JPEGs
    107 bool ppSubReadoutUpdate(pmConfig *config, ///< Configuration
    108                         ppSubData *data ///< Processing data
    10996    );
    11097
     
    121108
    122109/// Mark the data quality as bad and prepare to suspend processing
    123 void ppSubDataQuality(pmConfig *config, ///< Configuration
    124                       ppSubData *data,  ///< Processing data
     110void ppSubDataQuality(ppSubData *data,  ///< Processing data
    125111                      psErrorCode error,///< Error code
    126112                      ppSubFiles files  ///< Files to deactivate
     
    150136
    151137/// Collect statistics
    152 bool ppSubReadoutStats(pmConfig *config,// Configuration
    153                        ppSubData *data  // Processing data
     138bool ppSubReadoutStats(ppSubData *data  // Processing data
    154139    );
    155140
  • trunk/ppSub/src/ppSubArguments.c

    r23740 r23753  
    5757}
    5858
    59 bool ppSubArguments(int argc, char *argv[], pmConfig *config, ppSubData *data)
     59bool ppSubArguments(int argc, char *argv[], ppSubData *data)
    6060{
     61    assert(data);
     62    pmConfig *config = data->config;
    6163    assert(config);
    6264
     
    127129    data->stamps = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-stamps"));
    128130
    129     const char *statsName = psMetadataLookupStr(NULL, arguments, "-stats"); // Filename for statistics
    130     if (statsName && strlen(statsName) > 0) {
    131         psString resolved = pmConfigConvertFilename(statsName, config, true, true); // Resolved filename
     131    data->statsName = psMetadataLookupStr(NULL, arguments, "-stats"); // Filename for statistics
     132    if (data->statsName && strlen(data->statsName) > 0) {
     133        psString resolved = pmConfigConvertFilename(data->statsName, config, true, true); // Resolved filename
    132134        data->statsFile = fopen(resolved, "w");
    133135        if (!data->statsFile) {
  • trunk/ppSub/src/ppSubCamera.c

    r23740 r23753  
    134134
    135135
    136 bool ppSubCamera(pmConfig *config, ppSubData *data)
     136bool ppSubCamera(ppSubData *data)
    137137{
     138    psAssert(data, "Require processing data");
     139    pmConfig *config = data->config;
    138140    psAssert(config, "Require configuration");
    139141
  • trunk/ppSub/src/ppSubData.c

    r23740 r23753  
    2222        psFree(stats);
    2323        fclose(data->statsFile);
     24        pmConfigRunFilenameAddWrite(data->config, "STATS", data->statsName);
    2425    }
     26    psFree(data->statsName);
    2527    psFree(data->stamps);
    2628    psFree(data->psf);
    2729    psFree(data->stats);
     30
     31    psString dump_file = psMetadataLookupStr(NULL, data->config->arguments, "-dumpconfig");
     32    if (dump_file) {
     33        pmConfigDump(data->config, dump_file);
     34    }
     35    psFree(data->config);
     36
    2837    return;
    2938}
    3039
    31 ppSubData *ppSubDataAlloc(void)
     40ppSubData *ppSubDataAlloc(pmConfig *config)
    3241{
    3342    ppSubData *data = psAlloc(sizeof(ppSubData)); // Processing data, to return
    3443    psMemSetDeallocator(data, (psFreeFunc)subDataFree);
    3544
     45    data->config = config;
    3646    data->quality = 0;
    3747    data->photometry = false;
     
    3949    data->stamps = NULL;
    4050    data->psf = NULL;
     51    data->statsName = NULL;
    4152    data->statsFile = NULL;
    4253    data->stats = psMetadataAlloc();
     
    4758
    4859
    49 void ppSubDataQuality(pmConfig *config, ppSubData *data, psErrorCode error, ppSubFiles files)
     60void ppSubDataQuality(ppSubData *data, psErrorCode error, ppSubFiles files)
    5061{
    51     psAssert(config, "Require configuration");
    5262    psAssert(data, "Require processing data");
    5363
     
    5767    }
    5868
    59     ppSubFilesActivate(config, files, false);
     69    ppSubFilesActivate(data->config, files, false);
    6070
    6171    psErrorClear();
  • trunk/ppSub/src/ppSubLoop.c

    r23740 r23753  
    2020#include "ppSub.h"
    2121
    22 bool ppSubLoop(pmConfig *config, ppSubData *data)
     22bool ppSubLoop(ppSubData *data)
    2323{
     24    psAssert(data, "Require processing data");
     25    pmConfig *config = data->config;    // Configuration
    2426    psAssert(config, "Require configuration.");
    2527
     
    4547    }
    4648
    47     if (!ppSubMatchPSFs(config, data)) {
     49    if (!ppSubMatchPSFs(data)) {
    4850        psError(PS_ERR_UNKNOWN, false, "Unable to match PSFs.");
    4951        return false;
     
    7476    }
    7577
    76     if (!data->quality && !ppSubMakePSF(config, data)) {
     78    if (!data->quality && !ppSubMakePSF(data)) {
    7779        psError(PS_ERR_UNKNOWN, false, "Unable to generate PSF.");
    7880        return false;
     
    101103    }
    102104
    103     if (!data->quality && !ppSubReadoutPhotometry("PPSUB.OUTPUT", config, data)) {
     105    if (!data->quality && !ppSubReadoutPhotometry("PPSUB.OUTPUT", data)) {
    104106        psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry.");
    105107        return false;
     
    112114
    113115    // Perform statistics on the cell
    114     if (!ppSubReadoutStats(config, data)) {
     116    if (!ppSubReadoutStats(data)) {
    115117        psError(PS_ERR_UNKNOWN, false, "Unable to collect statistics");
    116118        return false;
     
    150152        }
    151153
    152         if (!data->quality && !ppSubReadoutPhotometry("PPSUB.INVERSE", config, data)) {
     154        if (!data->quality && !ppSubReadoutPhotometry("PPSUB.INVERSE", data)) {
    153155            psError(PS_ERR_UNKNOWN, false, "Unable to perform photometry.");
    154156            return false;
     
    168170    }
    169171
    170     psString dump_file = psMetadataLookupStr(NULL, config->arguments, "-dumpconfig");
    171     if (dump_file) {
    172         pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PPSUB.INPUT"); // Input file
    173         pmConfigDump(config, input->fpa, dump_file);
    174     }
    175 
    176172    return true;
    177173}
  • trunk/ppSub/src/ppSubMakePSF.c

    r23740 r23753  
    2222#include "ppSub.h"
    2323
    24 bool ppSubMakePSF(pmConfig *config, ppSubData *data)
     24bool ppSubMakePSF(ppSubData *data)
    2525{
     26    psAssert(data, "Require processing data");
     27    pmConfig *config = data->config;    // Configuration
    2628    psAssert(config, "Require configuration");
    2729
     
    105107        psErrorStackPrint(stderr, "Unable to determine PSF");
    106108        psWarning("Unable to determine PSF --- suspect bad data quality.");
    107         ppSubDataQuality(config, data, PSPHOT_ERR_PSF, PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
     109        ppSubDataQuality(data, PSPHOT_ERR_PSF, PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
    108110        psFree(view);
    109111        return true;
  • trunk/ppSub/src/ppSubMatchPSFs.c

    r23740 r23753  
    2222#include "ppSub.h"
    2323
    24 bool ppSubMatchPSFs(pmConfig *config, ppSubData *data)
     24bool ppSubMatchPSFs(ppSubData *data)
    2525{
     26    psAssert(data, "Require processing data");
     27    pmConfig *config = data->config;    // Configuration
    2628    psAssert(config, "Require configuration");
    2729
     
    161163            psErrorStackPrint(stderr, "Unable to find stamps");
    162164            psWarning("Unable to find stamps --- suspect bad data quality.");
    163             ppSubDataQuality(config, data, error, PPSUB_FILES_ALL);
     165            ppSubDataQuality(data, error, PPSUB_FILES_ALL);
    164166            return true;
    165167        } else {
  • trunk/ppSub/src/ppSubReadout.c

    r23740 r23753  
    2121#include "ppSub.h"
    2222
    23 bool ppSubReadout(const char *name, bool reverse, pmConfig *config, ppSubData *data, const pmFPAview *view)
     23bool ppSubReadout(const char *name, bool reverse, ppSubData *data, const pmFPAview *view)
    2424{
     25    psAssert(data, "Require processing data");
     26    pmConfig *config = data->config;    // Configuration
     27    psAssert(config, "Require configuration");
     28
    2529    psAssert(name, "Require name");
    26     psAssert(config, "Require configuration");
    27     psAssert(data, "Require data");
    2830    psAssert(view, "Require view");
    2931
  • trunk/ppSub/src/ppSubReadoutPhotometry.c

    r23740 r23753  
    2222#include "ppSub.h"
    2323
    24 bool ppSubReadoutPhotometry(const char *name, pmConfig *config, ppSubData *data)
     24bool ppSubReadoutPhotometry(const char *name, ppSubData *data)
    2525{
     26    psAssert(data, "Require processing data");
     27    pmConfig *config = data->config;    // Configuration
    2628    psAssert(config, "Require configuration");
    2729
     
    5153        psErrorStackPrint(stderr, "No PSF available");
    5254        psWarning("No PSF available --- suspect bad data quality.");
    53         ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
     55        ppSubDataQuality(data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
    5456        return true;
    5557    }
     
    9496        psErrorStackPrint(stderr, "Unable to perform photometry on image");
    9597        psWarning("Unable to perform photometry on image --- suspect bad data quality.");
    96         ppSubDataQuality(config, data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
     98        ppSubDataQuality(data, psErrorCodeLast(), PPSUB_FILES_PHOT_SUB | PPSUB_FILES_PHOT_INV);
    9799    }
    98100
  • trunk/ppSub/src/ppSubReadoutStats.c

    r23740 r23753  
    1010
    1111
    12 bool ppSubReadoutStats(pmConfig *config, ppSubData *data)
     12bool ppSubReadoutStats(ppSubData *data)
    1313{
     14    psAssert(data, "Require processing data");
     15    pmConfig *config = data->config;    // Configuration
    1416    psAssert(config, "Require configuration");
    15     psAssert(data, "Require data");
    1617
    1718    if (!data->statsFile) {
Note: See TracChangeset for help on using the changeset viewer.