IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jan 13, 2006, 5:14:07 PM (21 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/ppImageParseCamera.c

    r5860 r5976  
    1 # include "ppImage.h"
     1#include "ppImage.h"
    22
    3 static void ppFPA_Free (ppFPA *fpa) {
    4     return;
    5 }
     3bool ppImageParseCamera(ppData *data, ppConfig *config)
     4{
     5    // Initialise the containers where the files will go
     6    data->input   = ppFileAlloc();
     7    data->mask    = ppFileAlloc();
     8    data->bias    = ppFileAlloc();
     9    data->dark    = ppFileAlloc();
     10    data->flat    = ppFileAlloc();
     11    data->fringe  = ppFileAlloc();
     12#if 0
     13    data->process = ppFileAlloc();
     14#endif
    615
    7 ppFPA *ppFPA_Alloc (void) {
    8 
    9     ppFPA *fpa = psAlloc (sizeof(ppFPA));
    10     psMemSetDeallocator(fpa, (psFreeFunc) ppFPA_Free);
    11 
    12     fpa->filename = NULL;
    13     fpa->fpa = NULL;
    14     fpa->fits = NULL;
    15     fpa->header = NULL;
    16 
    17     return fpa;
    18 }
    19 
    20 bool ppImageParseCamera (ppData *data, ppConfig *config) {
    21    
    22     bool status;
    23 
    24     data->input   = ppFPA_Alloc ();
    25     data->mask    = ppFPA_Alloc ();
    26     data->bias    = ppFPA_Alloc ();
    27     data->dark    = ppFPA_Alloc ();
    28     data->flat    = ppFPA_Alloc ();
    29     data->fringe  = ppFPA_Alloc ();
    30     data->process = ppFPA_Alloc ();
    31    
    32     data->input->filename = psMetadataLookupPtr (NULL, config->arguments, "-input");
     16    data->input->filename = psMemIncrRefCounter(psMetadataLookupStr(NULL, config->arguments, "-input"));
    3317
    3418    // Open the input image
    35     psLogMsg("phase2", PS_LOG_INFO, "Opening input image: %s\n", data->input->filename);
     19    psLogMsg("ppImage", PS_LOG_INFO, "Opening input image: %s\n", data->input->filename);
    3620    data->input->fits = psFitsOpen(data->input->filename, "r"); // File handle for FITS file
    3721    if (! data->input->fits) {
     22        // There's no point in continuing if we can't open the input
    3823        psErrorStackPrint(stderr, "Can't open input image: %s\n", data->input->filename);
    3924        exit(EXIT_FAILURE);
    4025    }
    41     data->input->header = psFitsReadHeader(NULL, data->input->fits); // FITS header
     26    data->input->phu = psFitsReadHeader(NULL, data->input->fits); // FITS header
    4227
    4328    // Get camera configuration from header if not already defined
    4429    if (! config->camera) {
    45         config->camera = pmConfigCameraFromHeader(config->site, data->input->header);
     30        config->camera = pmConfigCameraFromHeader(config->site, data->input->phu);
    4631        if (! config->camera) {
     32             // There's no point in continuing if we can't recognise what we've got
    4733            psErrorStackPrint(stderr, "Can't find camera configuration!\n");
    4834            exit(EXIT_FAILURE);
    4935        }
    50    } else if (! pmConfigValidateCamera(config->camera, data->input->header)) {
    51         psError(PS_ERR_IO, true, "%s does not seem to be from the camera.\n", data->input->filename);
     36   } else if (! pmConfigValidateCamera(config->camera, data->input->phu)) {
     37       // There's no point in continuing if what we've got doesn't match what we've been told
     38        psError(PS_ERR_IO, true, "%s does not seem to be from the specified camera.\n",
     39                data->input->filename);
    5240        exit(EXIT_FAILURE);
    5341    }
    5442
    55     // determine the correct recipe to use
     43    // Determine the correct recipe to use
    5644    if (! config->recipe && !(config->recipe = pmConfigRecipeFromCamera(config->camera, RECIPE))) {
     45        // There's no point in continuing if we can't work out what recipe to use
    5746        psErrorStackPrint(stderr, "Can't find recipe configuration!\n");
    5847        exit(EXIT_FAILURE);
    5948    }
    6049
    61     // Construct camera in preparation for reading
     50    // Construct cameras in preparation for reading
    6251    data->input->fpa   = pmFPAConstruct(config->camera);
    6352    data->mask->fpa    = pmFPAConstruct(config->camera);
     
    6655    data->flat->fpa    = pmFPAConstruct(config->camera);
    6756    data->fringe->fpa  = pmFPAConstruct(config->camera);
     57#if 0
    6858    data->process->fpa = pmFPAConstruct(config->camera);
     59#endif
    6960
    7061    // XXX EAM : extend this to allow an array of selected chips by name
    7162    // Chip selection: if we are using a single chip, select it for each FPA
    72     // data->process acts as a process mask for the full FPA
    73     int chipNum = psMetadataLookupS32(&status, config->arguments, "-chip"); // Chip number to work on
     63    int chipNum = psMetadataLookupS32(NULL, config->arguments, "-chip"); // Chip number to work on
    7464    if (chipNum >= 0) {
    75         if (! pmFPASelectChip(data->process->fpa, chipNum)) {
     65        if (! pmFPASelectChip(data->input->fpa, chipNum)) {
    7666            psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum);
    7767            exit(EXIT_FAILURE);
    7868        }
    79         psLogMsg("phase2", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);
     69        psLogMsg("ppImage", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);
    8070    }
    8171    return true;
     
    8474// XXX EAM : I dropped the pre-open of the output files; replace with a stats test of output permissions
    8575
    86 // XXX : for split data (data spread across multiple files), this step is only operating on a component 
     76// XXX : for split data (data spread across multiple files), this step is only operating on a component
    8777//       of the FPA.  the other components should be set to 'invalid' in this case?
Note: See TracChangeset for help on using the changeset viewer.