IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6747


Ignore:
Timestamp:
Mar 31, 2006, 3:24:14 PM (20 years ago)
Author:
Paul Price
Message:

ppImage now working again.

Location:
trunk/ppImage/src
Files:
23 edited

Legend:

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

    r6566 r6747  
    22
    33noinst_HEADERS = \
     4        ppFile.h \
    45        ppImage.h \
    56        ppImageData.h \
    67        ppImageDetrend.h \
    7         ppImageOptions.h
     8        ppImageOptions.h \
     9        ppMem.h
    810
    911ppImage_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(ppImage_CFLAGS)
    1012ppImage_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS)
    1113ppImage_SOURCES = \
     14        ppFile.c \
    1215        ppImage.c \
     16        ppImageConfig.c \
    1317        ppImageData.c \
    1418        ppImageDetrendBias.c \
     
    1923        ppImageOptions.c \
    2024        ppImageParseCamera.c \
    21         ppImageParseDetrend.c \
    22         ppImageWeights.c
     25        ppImageWeights.c \
     26        ppMem.c
    2327#       ppImageLoadPixels.c
    2428#       ppDetrendFlat.c
     
    3034ppTest_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(ppImage_CFLAGS)
    3135ppTest_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS)
    32 ppTest_SOURCES = ppTest.c
     36ppTest_SOURCES = \
     37        ppTest.c \
     38        ppMem.c
    3339
    3440
  • trunk/ppImage/src/ppFile.c

    r6260 r6747  
    1212        psFitsClose(file->fits);
    1313    }
     14    psFree(file->view);
    1415    return;
    1516}
     
    2526    file->fits = NULL;
    2627    file->phu = NULL;
     28    file->view = NULL;
    2729
    2830    return file;
     
    3032
    3133
     34bool ppFileOpen(ppFile *file, const char *name, pmConfig *config, psMetadata *camera, psMetadata *format)
     35{
     36    file->fpa = pmFPAConstruct(camera);
     37    psString filename = psMetadataLookupStr(NULL, config->arguments, name);
     38    if (strlen(filename) == 0) {
     39        return false;
     40    }
     41    file->filename = psMemIncrRefCounter(filename);
     42    file->fits = psFitsOpen(filename, "r");
     43    file->phu = psFitsReadHeader(NULL, file->fits);
     44    if (!pmConfigValidateCameraFormat(format, file->phu)) {
     45        psLogMsg(__func__, PS_LOG_WARN, "File %s doesn't match camera format --- ignored.\n", filename);
     46        psFitsClose(file->fits);
     47        return false;
     48    }
     49    file->view = pmFPAAddSource(file->fpa, file->phu, format);
     50    return true;
     51}
     52
  • trunk/ppImage/src/ppFile.h

    r6260 r6747  
    33
    44#include "pslib.h"
    5 #include "pmFPA.h"
     5#include "psmodules.h"
    66
    77// A file to process
     
    1111    psMetadata *phu;                    // The FITS header
    1212    pmFPA *fpa;                         // The FPA, with pixels and extensions
     13    pmFPAview *view;                    // The view
    1314} ppFile;
    1415
    1516
    16 // Allocators
     17// Allocator
    1718ppFile *ppFileAlloc(void);
    1819
     20bool ppFileOpen(ppFile *file, const char *name, pmConfig *config, psMetadata *camera, psMetadata *format);
    1921
    2022#endif
  • trunk/ppImage/src/ppImage.c

    r6396 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "pmConcepts.h"
     3#include "psmodules.h"
    44#include "ppImage.h"
    55#include "ppMem.h"
     
    1111    ppImageData *data = ppImageDataAlloc();
    1212    ppImageOptions *options = ppImageOptionsAlloc();
    13     ppConfig *config = ppConfigAlloc();
    1413
    1514    psTimerStart(TIMERNAME);
    1615
    1716    // Parse the configuration and arguments
    18     ppImageConfig(config, argc, argv);
     17    pmConfig *config = ppImageConfig(argc, argv);
    1918
    2019    // Open the input image, output image, output mask
     
    2625    ppImageOptionsParse(data, options, config);
    2726
     27#if 0
     28    // XXX I think we do this in ppImageParseCamera
     29
    2830    // open detrend images, load headers, optionally load pixels
    2931    ppImageParseDetrend(data, options, config);
     32#endif
    3033
    3134    // Image Arithmetic Loop
  • trunk/ppImage/src/ppImage.h

    r6260 r6747  
    33
    44#include "pslib.h"
    5 #include "pmFPA.h"
    6 #include "ppConfig.h"
    7 #include "ppFile.h"
     5#include "psmodules.h"
     6
    87#include "ppImageData.h"
    98#include "ppImageOptions.h"
    109
    11 
    12 #if 0
    13 #include <strings.h>
    14 #include "psAdditionals.h"
    15 #include "pmFPA.h"
    16 #include "pmFPAConstruct.h"
    17 #include "pmFPARead.h"
    18 #include "pmFPAWrite.h"
    19 #include "pmReadout.h"
    20 #include "pmConfig.h"
    21 #include "pmFlatField.h"
    22 #include "pmMaskBadPixels.h"
    23 #include "pmNonLinear.h"
    24 #include "pmChipMosaic.h"
    25 #include "pmSubtractBias.h"
    26 #endif
    27 
    28 
    29 #define RECIPE "PHASE2"                 // Name of the recipe to use
     10#define RECIPE_NAME "PHASE2"            // Name of the recipe to use
    3011#define TIMERNAME "ppImage"             // Name of timer
    3112
    3213// Get the configuration
    33 bool ppImageConfig(ppConfig *config, int argc, char **argv);
     14pmConfig *ppImageConfig(int argc, char **argv);
    3415
    3516// Determine what type of camera, and initialise
    3617bool ppImageParseCamera(ppImageData *data,   // The data to be processed
    37                         ppConfig *config // Configuration
     18                        pmConfig *config // Configuration
    3819                        );
    3920
    4021
    4122// Loop over the input
    42 bool ppImageLoop(ppImageData *data, ppImageOptions *options, ppConfig *config);
     23bool ppImageLoop(ppImageData *data, ppImageOptions *options, pmConfig *config);
    4324
    4425// Load the pixels for the given file
     
    4930                       );
    5031
    51 bool ppImageParseDetrend(ppImageData *data, ppImageOptions *options, ppConfig *config);
     32bool ppImageParseDetrend(ppImageData *data, ppImageOptions *options, pmConfig *config);
    5233
    5334bool ppReadoutWeights(pmReadout *readout);
     
    5637// These functions are not implemented, or not needed
    5738pmReadout* ppDetrendPedestal(pmReadout *pedestal, pmCell *input, pmReadout *bias, pmReadout *dark, float darkTime, ppImageOptions *options);
    58 bool ppImageOutput(ppImageData *data, ppConfig *config);
    59 bool ppImagePhot(ppImageData *data, ppImageOptions *options, ppConfig *config);
    60 bool ppFileOpen(ppFile *fpa, psMetadata *camera, char *name, bool doThis);
     39bool ppImageOutput(ppImageData *data, pmConfig *config);
     40bool ppImagePhot(ppImageData *data, ppImageOptions *options, pmConfig *config);
     41bool ppFileOpen(ppFile *fpa, char *name, bool doThis);
    6142#endif
    6243
  • trunk/ppImage/src/ppImageConfig.c

    r6318 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "pmConfig.h"
    4 #include "ppConfig.h"
     3#include "psmodules.h"
    54#include "ppImage.h"
    65
    7 bool ppImageConfig(ppConfig *config, int argc, char **argv)
     6pmConfig *ppImageConfig(int argc, char **argv)
    87{
    9     // XXX - this should be split into a function to parse argc,argv
    10     //       and a second to read the config files.
    11     //       all argc,argv should be interpretted before work is done.
    12     if (! pmConfigRead(&config->site, &config->camera, &config->recipe, &argc, argv, RECIPE)) {
     8    pmConfig *config = pmConfigRead(&argc, argv);
     9    if (! config) {
    1310        psErrorStackPrint(stderr, "Can't find site configuration!\n");
    1411        exit(EXIT_FAILURE);
     
    1714    // Parse other command-line arguments
    1815    config->arguments = psMetadataAlloc(); // The arguments, with default values
    19 
    2016    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-key", 0, "exposure ID", "");
    2117    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-bias", 0, "Name of the bias image", "");
     
    4339#endif
    4440
    45     return true;
     41    return config;
    4642}
  • trunk/ppImage/src/ppImageDetrend.h

    r6260 r6747  
    33
    44#include "pslib.h"
    5 #include "pmFPA.h"
    6 #include "ppConfig.h"
     5#include "psmodules.h"
    76#include "ppImageOptions.h"
    87
     
    1716
    1817
    19 bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, ppConfig *config);
     18bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config);
    2019bool ppImageDetrendMask(pmCell *cell, pmReadout *input, pmReadout *mask);
    2120bool ppImageDetrendNonLinear(pmCell *cell, pmReadout *input, ppImageOptions *options);
  • trunk/ppImage/src/ppImageDetrendBias.c

    r6260 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "pmFPA.h"
     3#include "psmodules.h"
    44#include "ppImageOptions.h"
    55#include "ppImageDetrend.h"
  • trunk/ppImage/src/ppImageDetrendCell.c

    r6260 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "pmFPA.h"
    4 #include "pmFlatField.h"
     3#include "psmodules.h"
    54#include "ppImageDetrend.h"
     5#include "ppImageOptions.h"
    66
    77// mask, bias, dark, flat are defined per Cell
     
    2222}
    2323
    24 bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, ppConfig *config)
     24bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config)
    2525{
     26#if 0
    2627    pmCellSetWeights(detrend->input);
     28#endif
    2729
    2830    pmReadout *mask = ppImageDetrendSelectFirst(detrend->mask, "mask", options->doMask);
  • trunk/ppImage/src/ppImageDetrendFlat.c

    r5858 r6747  
    1 # include "ppImage.h"
     1#include <stdio.h>
     2#include "pslib.h"
     3#include "psmodules.h"
     4#include "ppImage.h"
    25
    36// why does this use the flat pmReadout?
     
    710    psLogMsg("phase2", PS_LOG_INFO, "Performing flat field.\n");
    811
    9    
     12
    1013
    1114#ifndef PRODUCTION
    1215    psImage *dummyImage = psImageAlloc(inputReadout->image->numCols,
    13                                        inputReadout->image->numRows,
    14                                        PS_TYPE_U8);
     16                                       inputReadout->image->numRows,
     17                                       PS_TYPE_U8);
    1518    pmReadout *dummyMask = pmReadoutAlloc(NULL);
    1619    dummyMask->image = dummyImage;
  • trunk/ppImage/src/ppImageDetrendMask.c

    r6260 r6747  
    11#include <stdio.h>
    2 #include "pmFPA.h"
    3 #include "pmMaskBadPixels.h"
     2#include "psmodules.h"
    43#include "ppImageDetrend.h"
    54
  • trunk/ppImage/src/ppImageDetrendNonLinear.c

    r6260 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "pmFPA.h"
    4 #include "pmNonLinear.h"
     3#include "psmodules.h"
    54#include "ppImageDetrend.h"
    65
  • trunk/ppImage/src/ppImageDetrendPedestal.c

    r5858 r6747  
    1 # include "ppImage.h"
     1#include <stdio.h>
     2#include "pslib.h"
     3#include "psmodules.h"
     4#include "ppImage.h"
    25
    36// XXX check on image overlaps, as well as image sizes
     
    1316
    1417    if (options->doDark) {
    15         // Dark time for input image
    16         float inputTime = psMetadataLookupF32(NULL, input->concepts, "CELL.DARKTIME");
    17         if (inputTime <= 0) {
    18             psErrorStackPrint(stderr, "DARKTIME for input image (%f) is non-positive.\n",
    19                               inputTime);
    20             exit(EXIT_FAILURE);
    21         }
     18        // Dark time for input image
     19        float inputTime = psMetadataLookupF32(NULL, input->concepts, "CELL.DARKTIME");
     20        if (inputTime <= 0) {
     21            psErrorStackPrint(stderr, "DARKTIME for input image (%f) is non-positive.\n",
     22                              inputTime);
     23            exit(EXIT_FAILURE);
     24        }
    2225
    23         if (inputTime != lastExptime) {
    24             // this will create a new pedestal if the input one is NULL
    25             // XXX EAM : this function had darkTime * inputTime, which is wrong, yes?
    26             if (pedestal == NULL) {
    27                 pedestal = pmReadoutAlloc (NULL);
    28             }
    29             pedestal->col0    = dark->col0;
    30             pedestal->row0    = dark->row0;
    31             pedestal->colBins = dark->colBins;
    32             pedestal->rowBins = dark->rowBins;
     26        if (inputTime != lastExptime) {
     27            // this will create a new pedestal if the input one is NULL
     28            // XXX EAM : this function had darkTime * inputTime, which is wrong, yes?
     29            if (pedestal == NULL) {
     30                pedestal = pmReadoutAlloc (NULL);
     31            }
     32            pedestal->col0    = dark->col0;
     33            pedestal->row0    = dark->row0;
     34            pedestal->colBins = dark->colBins;
     35            pedestal->rowBins = dark->rowBins;
    3336
    34             pedestal->image   = (psImage *) psBinaryOp(pedestal->image, dark->image, "*", psScalarAlloc(inputTime / darkTime, PS_TYPE_F32));
    35             reusePedestal = false;
    36             lastExptime = inputTime
    37         }
     37            pedestal->image   = (psImage *) psBinaryOp(pedestal->image, dark->image, "*", psScalarAlloc(inputTime / darkTime, PS_TYPE_F32));
     38            reusePedestal = false;
     39            lastExptime = inputTime
     40        }
    3841    }
    3942
    4043    // no bias image, return dark pedestal or NULL
    4144    if (!options->doBias) {
    42         return pedestal;
     45        return pedestal;
    4346    }
    4447
    4548    // no dark image, return bias pedestal, or reuse
    4649    if (!options->doDark) {
    47         if (!pedestal) {
    48             pedestal = psMemIncrRefCounter(bias);
    49         }
    50         return pedestal;
     50        if (!pedestal) {
     51            pedestal = psMemIncrRefCounter(bias);
     52        }
     53        return pedestal;
    5154    }
    5255
    5356    if (reusePedestal) {
    54         return pedestal;
     57        return pedestal;
    5558    }
    5659
    5760    if (bias->image->numRows != dark->image->numRows ||
    58         bias->image->numCols != dark->image->numCols) {
    59         psError(PS_ERR_IO, true, "Bias and dark images have different dimensions: %dx%d vs %dx%d\n",
    60                 bias->image->numCols, bias->image->numRows,
    61                 dark->image->numCols, dark->image->numRows);
    62         exit(EXIT_FAILURE);
     61        bias->image->numCols != dark->image->numCols) {
     62        psError(PS_ERR_IO, true, "Bias and dark images have different dimensions: %dx%d vs %dx%d\n",
     63                bias->image->numCols, bias->image->numRows,
     64                dark->image->numCols, dark->image->numRows);
     65        exit(EXIT_FAILURE);
    6366    }
    6467
     
    7174
    7275// creates a new pedestal image for this readout
    73 // if the current exptime is the same as the last exptime, 
     76// if the current exptime is the same as the last exptime,
    7477// reuses the supplied pedestal
  • trunk/ppImage/src/ppImageLoadPixels.c

    r6079 r6747  
    1 // XXX PAP: Need to look this over some more
    2 
     1#include <stdio.h>
     2#include "pslib.h"
     3#include "psmodules.h"
    34#include "ppImage.h"
    45
  • trunk/ppImage/src/ppImageLoop.c

    r6396 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "pmFPA.h"
    4 #include "pmFPARead.h"
    5 #include "pmChipMosaic.h"
    6 #include "pmFPAWrite.h"
     3#include "psmodules.h"
    74#include "ppImageDetrend.h"
    85#include "ppImage.h"
     
    1310// Read the entire FPA
    1411void readFPA(ppFile *file,              // File to read
    15              ppConfig *config           // Configuration, containing the DB handle
     12             pmConfig *config           // Configuration, containing the DB handle
    1613    )
    1714{
    1815    if (file->fpa && file->fits) {
    19         if (! pmFPARead(file->fpa, file->fits, file->phu, config->database)) {
    20             psErrorStackPrint(stderr, "Unable to populate camera from input FITS file\n");
    21             exit(EXIT_FAILURE);
    22         }
     16        pmFPARead(file->fpa, file->fits, config->database);
    2317    }
    2418}
     
    2620// Read a specified chip only
    2721void readChip(ppFile *file,             // File to read
    28               ppConfig *config,         // Configuration
     22              pmConfig *config,         // Configuration
    2923              int chipNum               // Chip number to read
    3024    )
    3125{
    32     pmFPASelectChip(file->fpa, chipNum);
    33     readFPA(file, config);
     26    pmFPA *fpa = file->fpa;             // The FPA
     27    if (fpa && file->fits) {
     28        pmChip *chip = fpa->chips->data[chipNum]; // The chip
     29        pmChipRead(chip, file->fits, config->database);
     30    }
    3431}
    3532
    3633
    37 void readCell(ppFile *file, ppConfig *config, int chipNum, int cellNum)
     34void readCell(ppFile *file, pmConfig *config, int chipNum, int cellNum)
    3835{
    39     pmChip *chip = file->fpa->chips->data[chipNum];
    40     pmChipSelectCell(chip, cellNum);
    41     readFPA(file, config);
     36    pmFPA *fpa = file->fpa;             // The FPA
     37    if (fpa && file->fits) {
     38        pmChip *chip = fpa->chips->data[chipNum]; // The chip
     39        if (chip) {
     40            pmCell *cell = chip->cells->data[cellNum]; // The cell
     41            pmCellRead(cell, file->fits, config->database);
     42        }
     43    }
    4244}
    4345
    4446
    45 bool ppImageLoop(ppImageData *data, ppImageOptions *options, ppConfig *config)
     47bool ppImageLoop(ppImageData *data, ppImageOptions *options, pmConfig *config)
    4648{
    4749    ppImageDetrend detrend;
     
    108110        }
    109111
     112#if 0
    110113        int numMosaicked = pmChipMosaic(inputChip, 1, 1); // Number of cells mosaicked together
    111114        psLogMsg(__func__, PS_LOG_INFO, "%d cells mosaicked.\n", numMosaicked);
    112 
    113         // XXX EAM: Photometry goes here!
    114115
    115116        // XXX A kludge to get the write to behave w.r.t. the concepts --- we've changed the camera format, so
     
    117118        const psMetadata *camera = data->input->fpa->camera;
    118119        data->input->fpa->camera = NULL;
    119         pmFPAWrite(data->output, data->input->fpa, config->database);
     120#endif
     121
     122        // XXX Photometry goes here!
     123
     124        pmChipWrite(inputChip, data->output, config->database);
     125
     126#if 0
    120127        data->input->fpa->camera = camera;
     128#endif
    121129
    122130        // Now I can blow away the mosaic so I can then read more.
  • trunk/ppImage/src/ppImageOptions.c

    r6396 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "ppConfig.h"
     3#include "ppImage.h"
    44#include "ppImageData.h"
    55#include "ppImageOptions.h"
     
    2828// XXX EAM : this needs signficant work to choose the detrend images based on the detrend database
    2929
    30 bool ppImageOptionsParse(ppImageData *data, ppImageOptions *options, ppConfig *config)
     30bool ppImageOptionsParse(ppImageData *data, ppImageOptions *options, pmConfig *config)
    3131{
    3232
     
    5656
    5757    bool mdStatus = false;              // Result of MD lookup
    58     const char *depth = psMetadataLookupStr(&mdStatus, config->recipe, "LOAD.DEPTH");
     58    psMetadata *recipe = psMetadataLookupMD(&mdStatus, config->recipes, RECIPE_NAME);
     59    if (! mdStatus || !recipe) {
     60        psLogMsg("ppImage", PS_LOG_ERROR, "Can't find recipe %s in the RECIPES.\n", RECIPE_NAME);
     61        exit(EXIT_FAILURE);
     62    }
     63
     64    const char *depth = psMetadataLookupStr(&mdStatus, recipe, "LOAD.DEPTH");
    5965    if (! mdStatus || ! depth || strlen(depth) == 0) {
    6066        psLogMsg("ppImage", PS_LOG_ERROR, "LOAD.DEPTH not specified in recipe.");
     
    6874        options->imageLoadDepth = PP_LOAD_CELL;
    6975    } else {
    70         psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe is not FPA, CHIP or CELL.");
     76        psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe %s is not FPA, CHIP or CELL.", RECIPE_NAME);
    7177        exit(EXIT_FAILURE);
    7278    }
    7379
    7480    // Mask recipe options
    75     if (psMetadataLookupBool(NULL, config->recipe, "MASK")) {
     81    if (psMetadataLookupBool(NULL, recipe, "MASK")) {
    7682        data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask");
    7783        if (data->mask->filename && strlen(data->mask->filename) > 0) {
     
    8490
    8591    // Non-linearity recipe options
    86     if (psMetadataLookupBool(NULL, config->recipe, "NONLIN")) {
    87         psMetadataItem *dataItem = psMetadataLookup(config->recipe, "NONLIN.DATA");
     92    if (psMetadataLookupBool(NULL, recipe, "NONLIN")) {
     93        psMetadataItem *dataItem = psMetadataLookup(recipe, "NONLIN.DATA");
    8894        if (! dataItem) {
    8995            psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to "
    90                      "find NONLIN.DATA in recipe.");
     96                     "find NONLIN.DATA in recipe %s.", RECIPE_NAME);
    9197            exit(EXIT_FAILURE);
    9298        }
     
    106112            {
    107113                bool status;
    108                 options->nonLinearSource = psMetadataLookupStr(&status, config->recipe, "NONLIN.SOURCE");
     114                options->nonLinearSource = psMetadataLookupStr(&status, recipe, "NONLIN.SOURCE");
    109115                if (! status || ! options->nonLinearSource) {
    110116                    psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to "
    111                             "find NONLIN.SOURCE in recipe");
     117                            "find NONLIN.SOURCE in recipe %s.", RECIPE_NAME);
    112118                    exit(EXIT_FAILURE);
    113119                }
     
    116122          default:
    117123            psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but "
    118                     "NONLIN.DATA is of invalid type.");
     124                    "NONLIN.DATA is of invalid type in recipe %s.", RECIPE_NAME);
    119125            exit(EXIT_FAILURE);
    120126        }
     
    122128
    123129    // Bias recipe options
    124     if (psMetadataLookupBool(NULL, config->recipe, "BIAS")) {
     130    if (psMetadataLookupBool(NULL, recipe, "BIAS")) {
    125131        data->bias->filename = psMetadataLookupStr(NULL, config->arguments, "-bias");
    126132        if (data->bias->filename && strlen(data->bias->filename) > 0) {
    127133            options->doBias = true;
    128134        } else {
    129             psLogMsg(__func__, PS_LOG_WARN, "Bias subtraction is desired, but no bias was supplied --- "
    130                      "no bias subtraction will be performed.\n");
     135            psLogMsg(__func__, PS_LOG_WARN, "Bias subtraction is desired in recipe %s, but no bias was "
     136                     "supplied --- no bias subtraction will be performed.\n", RECIPE_NAME);
    131137        }
    132138    }
    133139
    134140    // Dark recipe options
    135     if (psMetadataLookupBool(NULL, config->recipe, "DARK")) {
     141    if (psMetadataLookupBool(NULL, recipe, "DARK")) {
    136142        data->dark->filename = psMetadataLookupStr(NULL, config->arguments, "-dark");
    137143        if (data->dark->filename && strlen(data->dark->filename) > 0) {
    138144            options->doDark = true;
    139145        } else {
    140             psLogMsg(__func__, PS_LOG_WARN, "Dark subtraction is desired, but no dark was supplied --- "
    141                      "no dark subtraction will be performed.\n");
     146            psLogMsg(__func__, PS_LOG_WARN, "Dark subtraction is desired in recipe %s, but no dark was "
     147                     "supplied --- no dark subtraction will be performed.\n", RECIPE_NAME);
    142148        }
    143149    }
     
    147153    // Overscan recipe options
    148154    // XXX EAM : we should abort on invalid options. default options?
    149     if (psMetadataLookupBool(NULL, config->recipe, "OVERSCAN")) {
     155    if (psMetadataLookupBool(NULL, recipe, "OVERSCAN")) {
    150156        options->doOverscan = true;
    151157
    152158        // Do the overscan as a single value?
    153         overscanSingle = psMetadataLookupBool(NULL, config->recipe, "OVERSCAN.SINGLE");
     159        overscanSingle = psMetadataLookupBool(NULL, recipe, "OVERSCAN.SINGLE");
    154160
    155161        // How do we fit it?
    156         psString fit = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.FIT");
     162        psString fit = psMetadataLookupStr(NULL, recipe, "OVERSCAN.FIT");
    157163        if (! strcasecmp(fit, "POLYNOMIAL")) {
    158164            overscanFit = PM_FIT_POLY_ORD;
    159             overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER");
     165            overscanOrder = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER");
    160166        } else if (! strcasecmp(fit, "CHEBYSHEV")) {
    161167            overscanFit = PM_FIT_POLY_CHEBY;
    162             overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER");
     168            overscanOrder = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER");
    163169        } else if (! strcasecmp(fit, "SPLINE")) {
    164170            overscanFit = PM_FIT_SPLINE;
    165171        } else if (strcasecmp(fit, "NONE")) {
    166             psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:"
    167                      " assuming NONE.\n", fit);
    168         }
    169 
    170         psString stat = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.STAT");
     172            psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) in recipe %s is not one of NONE, "
     173                     "POLYNOMIAL, or SPLINE: assuming NONE.\n", fit, RECIPE_NAME);
     174        }
     175
     176        psString stat = psMetadataLookupStr(NULL, recipe, "OVERSCAN.STAT");
    171177        if (! strcasecmp(stat, "MEAN")) {
    172178            overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
     
    174180            overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);
    175181        } else {
    176             psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) is not one of MEAN, MEDIAN: assuming MEAN\n", stat);
     182            psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) in recipe %s is not one of MEAN, MEDIAN: "
     183                              "assuming MEAN\n", stat, RECIPE_NAME);
    177184            overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);
    178185        }
     
    184191
    185192    // flat-field - recipe options
    186     if (psMetadataLookupBool(NULL, config->recipe, "FLAT")) {
     193    if (psMetadataLookupBool(NULL, recipe, "FLAT")) {
    187194        data->flat->filename = psMetadataLookupStr(NULL, config->arguments, "-flat");
    188195        if (strlen(data->flat->filename) > 0) {
    189196            options->doFlat = true;
    190197        } else {
    191             psLogMsg(__func__, PS_LOG_WARN, "Flat-fielding is desired, but no flat was supplied --- "
    192                      "no flat-fielding will be performed.\n");
     198            psLogMsg(__func__, PS_LOG_WARN, "Flat-fielding is desired in recipe %s, but no flat was "
     199                     "supplied --- no flat-fielding will be performed.\n", RECIPE_NAME);
    193200        }
    194201    }
  • trunk/ppImage/src/ppImageOptions.h

    r6260 r6747  
    33
    44#include "pslib.h"
    5 #include "pmSubtractBias.h"
     5#include "psmodules.h"
    66#include "ppImageData.h"
    77#include "ppConfig.h"
     
    3838bool ppImageOptionsParse(ppImageData *data, // The data to be processed
    3939                         ppImageOptions *options, // Processing options
    40                          ppConfig *config    // Configuration
     40                         pmConfig *config    // Configuration
    4141    );
    4242
  • trunk/ppImage/src/ppImageOutput.c

    r6114 r6747  
    1 # include "ppImage.h"
     1#include <stdio.h>
     2#include "pslib.h"
     3#include "psmodules.h"
     4#include "ppImage.h"
    25
    3 bool ppImageOutput(ppData *data, ppConfig *config)
     6bool ppImageOutput(ppData *data, pmConfig *config)
    47{
    58    const char *outname = psMetadataLookupStr(NULL, config->arguments, "-output"); // Name of output file
  • trunk/ppImage/src/ppImageParseCamera.c

    r6260 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "pmFPA.h"
    4 #include "pmFPAConstruct.h"
    5 #include "pmConfig.h"
     3#include "psmodules.h"
    64#include "ppImage.h"
    75
    8 bool ppImageParseCamera(ppImageData *data, ppConfig *config)
     6bool ppImageParseCamera(ppImageData *data, pmConfig *config)
    97{
    108    // Initialise the containers where the files will go
     
    2220    data->input->fits = psFitsOpen(data->input->filename, "r"); // File handle for FITS file
    2321    if (! data->input->fits) {
    24         // There's no point in continuing if we can't open the input
     22        // We can't open the input
    2523        psErrorStackPrint(stderr, "Can't open input image: %s\n", data->input->filename);
    2624        exit(EXIT_FAILURE);
     
    2927
    3028    // Get camera configuration from header if not already defined
     29    psMetadata *cameraFormat = NULL;    // Camera format description
    3130    if (! config->camera) {
    32         config->camera = pmConfigCameraFromHeader(config->site, data->input->phu);
     31        cameraFormat = pmConfigCameraFormatFromHeader(config, data->input->phu);
    3332        if (! config->camera) {
    3433             // There's no point in continuing if we can't recognise what we've got
     
    3635            exit(EXIT_FAILURE);
    3736        }
    38    } else if (! pmConfigValidateCamera(config->camera, data->input->phu)) {
    39        // There's no point in continuing if what we've got doesn't match what we've been told
     37    } else if (! pmConfigValidateCameraFormat(config->camera, data->input->phu)) {
     38        // What we've got doesn't match what we've been told
    4039        psError(PS_ERR_IO, true, "%s does not seem to be from the specified camera.\n",
    4140                data->input->filename);
     
    4342    }
    4443
    45     // Determine the correct recipe to use
    46     if (! config->recipe && !(config->recipe = pmConfigRecipeFromCamera(config->camera, RECIPE))) {
    47         // There's no point in continuing if we can't work out what recipe to use
    48         psErrorStackPrint(stderr, "Can't find recipe configuration!\n");
    49         exit(EXIT_FAILURE);
    50     }
     44    // Construct cameras in preparation for reading
     45    data->input->fpa  = pmFPAConstruct(config->camera);
     46    data->input->view = pmFPAAddSource(data->input->fpa, data->input->phu, cameraFormat);
    5147
    52     // Construct cameras in preparation for reading
    53     data->input->fpa   = pmFPAConstruct(config->camera);
    54     data->mask->fpa    = pmFPAConstruct(config->camera);
    55     data->bias->fpa    = pmFPAConstruct(config->camera);
    56     data->dark->fpa    = pmFPAConstruct(config->camera);
    57     data->flat->fpa    = pmFPAConstruct(config->camera);
    58     data->fringe->fpa  = pmFPAConstruct(config->camera);
     48    ppFileOpen(data->mask, "-mask", config, config->camera, cameraFormat);
     49    ppFileOpen(data->bias, "-bias", config, config->camera, cameraFormat);
     50    ppFileOpen(data->dark, "-dark", config, config->camera, cameraFormat);
     51    ppFileOpen(data->flat, "-flat", config, config->camera, cameraFormat);
     52    ppFileOpen(data->fringe, "-fringe", config, config->camera, cameraFormat);
     53
     54    psFree(cameraFormat);
    5955
    6056    // Open output file
     
    6662    }
    6763
    68     // XXX EAM : extend this to allow an array of selected chips by name
    69     // Chip selection: if we are using a single chip, select it for each FPA
    70     int chipNum = psMetadataLookupS32(NULL, config->arguments, "-chip"); // Chip number to work on
    71     if (chipNum >= 0) {
    72         if (! pmFPASelectChip(data->input->fpa, chipNum)) {
    73             psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum);
    74             exit(EXIT_FAILURE);
    75         }
    76         psLogMsg("ppImage", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);
    77     }
    7864    return true;
    7965}
    8066
    81 // XXX EAM : I dropped the pre-open of the output files; replace with a stats test of output permissions
    82 
    83 // XXX : for split data (data spread across multiple files), this step is only operating on a component
    84 //       of the FPA.  the other components should be set to 'invalid' in this case?
  • trunk/ppImage/src/ppImageParseDetrend.c

    r6260 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "pmConfig.h"
     3#include "psmodules.h"
    44#include "ppFile.h"
    55#include "ppImageData.h"
     
    1414// XXX : add fringe frame
    1515
    16 bool ppFileOpen(ppFile *file, psMetadata *camera, char *name, bool doThis) {
    17 
    18     if (!doThis) {
    19         return false;
    20     }
    21 
    22     psLogMsg("phase2", PS_LOG_INFO, "Opening %s image: %s\n", name, file->filename);
    23     file->fits = psFitsOpen(file->filename, "r"); // File handle
    24     file->phu = psFitsReadHeader(NULL, file->fits); // primary header
    25     if (! pmConfigValidateCamera(camera, file->phu)) {
    26         psError(PS_ERR_IO, true, "%s (%s) does not seem to be from the correct camera.\n", name,
    27                 file->filename);
    28         exit(EXIT_FAILURE);
    29     }
     16bool ppImageParseDetrend(ppImageData *data, ppImageOptions *options, pmConfig *config)
     17{
     18    ppFileOpen(data->mask, "mask", options->doMask);
     19    ppFileOpen(data->bias, "bias", options->doBias);
     20    ppFileOpen(data->dark, "dark", options->doDark);
     21    ppFileOpen(data->flat, "flat", options->doFlat);
    3022    return true;
    3123}
    32 
    33 bool ppImageParseDetrend(ppImageData *data, ppImageOptions *options, ppConfig *config) {
    34 
    35     ppFileOpen(data->mask, config->camera, "mask", options->doMask);
    36     ppFileOpen(data->bias, config->camera, "bias", options->doBias);
    37     ppFileOpen(data->dark, config->camera, "dark", options->doDark);
    38     ppFileOpen(data->flat, config->camera, "flat", options->doFlat);
    39     return true;
    40 }
  • trunk/ppImage/src/ppImagePhot.c

    r6114 r6747  
     1#include <stdio.h>
     2#include "pslib.h"
     3#include "psmodules.h"
    14#include "ppImage.h"
    25
    3 bool ppImagePhot(ppData *data, ppOptions *options, ppConfig *config)
     6bool ppImagePhot(ppData *data, ppOptions *options, pmConfig *config)
    47{
    58    ppFile *input = data->input;        // The input file information
  • trunk/ppImage/src/ppImageWeights.c

    r6260 r6747  
    11#include <stdio.h>
    22#include "pslib.h"
    3 #include "pmFPA.h"
     3#include "psmodules.h"
    44#include "ppImage.h"
    55
  • trunk/ppImage/src/ppTest.c

    r6624 r6747  
    33#include "pslib.h"
    44#include "psmodules.h"
     5#include "ppMem.h"
    56
    67int main(int argc, char *argv[])
     
    9697    // Read the FPA
    9798    pmFPARead(fpa, inFile, NULL);
     99    // Copy to new camera format
     100    pmFPA *newFPA = pmFPAConstruct(config->camera);
     101    psMetadata *newFormat = psMetadataConfigParse(NULL, NULL, "mcshort_splice.config", true);
     102    pmConfigConformHeader(phu, newFormat);
     103    pmFPAview *newView = pmFPAAddSource(newFPA, phu, newFormat);
     104    printf("View chip: %d\n", newView->chip);
     105    printf("View cell: %d\n", newView->cell);
     106    pmFPACopy(newFPA, fpa);
     107    pmFPAWrite(newFPA, outFile, NULL);
     108    pmFPAPrint(newFPA, false, true);
    98109
    99     // How'd we do?
    100     pmFPAPrint(fpa, true);
    101 #if 1
    102     pmChip *chip = fpa->chips->data[13];
    103     psString chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
    104     printf("CELL.NAME for chip 13: %s\n", chipName);
    105     pmCell *cell = chip->cells->data[0];
    106     psMetadataPrint(cell->concepts, 10);
    107 #endif
    108 
    109 
    110     pmFPAWrite(fpa, outFile, NULL);
    111 
     110    psFree(newView);
     111    psFree(newFormat);
     112    psFree(newFPA);
     113    psFree(view);
     114    psFree(fpa);
     115    psFree(config);
    112116    psFitsClose(inFile);
    113117    psFitsClose(outFile);
    114118    psFree(phu);
    115119    psFree(cameraFormat);
    116     psFree(fpa);
     120
     121    psTimerStop();
     122    psTraceReset();
     123    pmConceptsDone();
     124    ppMemCheck();
    117125
    118126    // Pau.
Note: See TracChangeset for help on using the changeset viewer.