IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7073 for trunk/ppMerge/src


Ignore:
Timestamp:
May 4, 2006, 5:37:16 PM (20 years ago)
Author:
Paul Price
Message:

Moving format back into options --- we need to know the camera configuration in order to get the recipe

Location:
trunk/ppMerge/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppMerge/src/ppMergeCheckInputs.c

    r7067 r7073  
    4949        // FPAview from the specified camera format configuration, and use pmFPAAddSourceFromView), but for
    5050        // now it's less hassle just to limit the output format to be the input format.
    51         if (!data->format) {
    52             data->format = pmConfigCameraFormatFromHeader(config, header);
     51        if (!options->format) {
     52            options->format = pmConfigCameraFormatFromHeader(config, header);
    5353            psFree(header);
    54             if (!data->format) {
     54            if (!options->format) {
    5555                psLogMsg(__func__, PS_LOG_WARN, "Unable to identify camera format for input file %s --- "
    5656                             "ignored.\n", name);
     
    6060                continue;
    6161            }
    62         } else if (!pmConfigValidateCameraFormat(data->format, header)) {
     62        } else if (!pmConfigValidateCameraFormat(options->format, header)) {
    6363            psLogMsg(__func__, PS_LOG_WARN, "Input file %s doesn't match camera format --- ignored.\n", name);
    6464            // Kick it out
     
    6969
    7070        data->in->data[i] = pmFPAConstruct(config->camera);
    71         pmFPAview *view = pmFPAAddSourceFromHeader(data->in->data[i], header, data->format);
     71        pmFPAview *view = pmFPAAddSourceFromHeader(data->in->data[i], header, options->format);
    7272        psFree(view);
    7373
     
    7575        if (!data->out) {
    7676            data->out = pmFPAConstruct(config->camera);
    77             pmFPAview *view = pmFPAAddSourceFromHeader(data->out, header, data->format);
     77            pmFPAview *view = pmFPAAddSourceFromHeader(data->out, header, options->format);
    7878            psFree(view);
    7979        }
  • trunk/ppMerge/src/ppMergeConfig.c

    r7067 r7073  
    77
    88// Output usage information
    9 static void usage(const char *programName // Name of the program
     9static void usage(const char *programName, // Name of the program
     10                  pmConfig *config      // Configuration (contains the arguments list)
    1011    )
    1112{
    1213    printf("Merge multiple calibration frames into a master frame by stacking.\n\n"
    1314           "Usage:\n"
    14            "\t%s OUTPUT.fits [-files FILES] [-list FILE_LIST]\n\n"
    15            "where:\n"
    16            "FILES       is a glob to be interpreted by the program.\n"
    17            "FILE_LIST   is a list of files (including a glob interpreted by the shell).\n"
     15           "\t%s OUTPUT.fits INPUT1.fits INPUT2.fits ...\n"
    1816           "\n", programName);
     17    psArgumentHelp(config->arguments);
    1918    exit(EXIT_FAILURE);
    2019}
     
    2221pmConfig *ppMergeConfig(int *argc, char **argv)
    2322{
    24     if (*argc == 1) {
    25         usage(argv[0]);
     23    pmConfig *config = pmConfigRead(argc, argv);
     24    // Load the site-wide configuration information
     25    if (! config) {
     26        psErrorStackPrint(stderr, "Can't find site configuration!\n");
     27        exit(EXIT_FAILURE);
    2628    }
    2729
    28     // Load the site-wide configuration information
    29     pmConfig *config = pmConfigRead(argc, argv);
    30     if (! config) {
    31         psErrorStackPrint(stderr, "Can't find site configuration!\n");
    32         usage(argv[0]);
    33     }
    34 
    35     // Parse other command-line arguments, save for future use
     30    // Command-line arguments
    3631    config->arguments = psMetadataAlloc(); // The arguments, with default values
    3732    psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-type", 0, "Type of calibration frame", "");
     
    4136    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-onoff", 0, "Number of on/off pairs", 0);
    4237
     38    if (*argc == 1) {
     39        usage(argv[0], config);
     40    }
     41
    4342    // Parse the arguments
    44     if (! psArgumentParse(config->arguments, argc, argv) || *argc != 2) {
    45         usage(argv[0]);
     43    if (! psArgumentParse(config->arguments, argc, argv) || *argc < 3) {
     44        usage(argv[0], config);
    4645    }
    4746
     
    5655    psArray *files = psArrayAlloc(*argc - 2);
    5756    for (int i = 2; i < *argc; i++) {
    58         files->data[i] = psStringCopy(argv[i]);
     57        files->data[i - 2] = psStringCopy(argv[i]);
    5958    }
     59    files->n = *argc - 2;
    6060    psMetadataAddPtr(config->arguments, PS_LIST_TAIL, "INPUT", PS_DATA_ARRAY,
    6161                     "Array of inputs images", files);
  • trunk/ppMerge/src/ppMergeData.c

    r7067 r7073  
    99    )
    1010{
    11     psFree(data->format);
    1211    psFree(data->in);
    1312    psFree(data->out);
     
    2322    psMemSetDeallocator(data, (psFreeFunc)mergeDataFree);
    2423
    25     data->format = NULL;
    2624    data->numCells = 0;
    2725    data->in = NULL;
  • trunk/ppMerge/src/ppMergeData.h

    r7064 r7073  
    77// Container for the data
    88typedef struct {
    9     psMetadata *format;                 // The camera format for the input and output
    109    int numCells;                       // Number of (valid) cells in the FPA
    1110    psArray *in;                        // Input FPA structures
  • trunk/ppMerge/src/ppMergeOptions.c

    r7067 r7073  
    1414    )
    1515{
     16    psFree(options->format);
    1617    psFree(options->combine);
    1718}
     
    2324    psMemSetDeallocator(options, (psFreeFunc)mergeOptionsFree);
    2425
     26    options->format = NULL;
    2527    options->rows = 0;
    2628    options->minElectrons = NAN;
     
    9193    ppMergeOptions *options = ppMergeOptionsAlloc(); // The merge options
    9294
     95    // We need to work out the camera before we can get the recipe.  Take the first input and inspect it.
     96    if (!config->camera) {
     97        psArray *filenames = psMetadataLookupPtr(NULL, config->arguments, "INPUT"); // The input file names
     98        psFits *inFile = psFitsOpen(filenames->data[0], "r"); // The FITS file to read
     99        if (!inFile) {
     100            psError(PS_ERR_IO, false, "Unable to open input file %s to determine camera.\n",
     101                    filenames->data[0]);
     102            exit(EXIT_FAILURE);
     103        }
     104        psMetadata *header = psFitsReadHeader(NULL, inFile); // The FITS (primary) header
     105        psFitsClose(inFile);
     106
     107        options->format = pmConfigCameraFormatFromHeader(config, header);
     108        psFree(header);
     109        if (!options->format) {
     110            psLogMsg(__func__, PS_LOG_WARN, "Unable to identify camera format for input file %s\n",
     111                     filenames->data[0]);
     112            exit(EXIT_FAILURE);
     113        }
     114    }
     115
     116    // Get the recipes
     117    if (!config->recipes && !pmConfigReadRecipes(config)) {
     118        psError(PS_ERR_IO, false, "Unable to read recipes.\n");
     119        exit(EXIT_FAILURE);
     120    }
     121
     122    // Now we can read the recipe
    93123    bool mdok = true;                   // Status of MD lookup
    94124    psMetadata *recipe = psMetadataLookupMD(&mdok, config->recipes, RECIPENAME); // Recipe information
  • trunk/ppMerge/src/ppMergeOptions.h

    r7067 r7073  
    1616// Options for ppMerge
    1717typedef struct {
     18    psMetadata *format;                 // Camera format configuration
    1819    unsigned int rows;                  // Number of rows to read at once
    1920    float minElectrons;                 // Minimum number of electrons for useful signal
Note: See TracChangeset for help on using the changeset viewer.