IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6624


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

Now both reading and writing

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppImage/src/ppTest.c

    r6566 r6624  
    33#include "pslib.h"
    44#include "psmodules.h"
    5 
    6 #define RECIPE "PHASE2"
    75
    86int main(int argc, char *argv[])
     
    1210// ppImageConfig.c
    1311//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    14     pmConfig *config = pmConfigRead(&argc, argv, RECIPE);
     12    pmConfig *config = pmConfigRead(&argc, argv);
    1513    if (! config) {
    1614        psErrorStackPrint(stderr, "Can't find site configuration!\n");
     
    4947//////////////////////////////////////////////////////////////////////////////////////////////////////////////
    5048
    51     const char *filename = psMetadataLookupStr(NULL, config->arguments, "-input");
    52     psLogMsg("ppImage", PS_LOG_INFO, "Opening input image: %s\n", filename);
    53     psFits *fits = psFitsOpen(filename, "r"); // File handle for FITS file
    54     if (! fits) {
     49    const char *inName = psMetadataLookupStr(NULL, config->arguments, "-input");
     50    psLogMsg("ppImage", PS_LOG_INFO, "Opening input image: %s\n", inName);
     51    psFits *inFile = psFitsOpen(inName, "r"); // File handle for FITS file
     52    if (! inFile) {
    5553        // There's no point in continuing if we can't open the input
    56         psErrorStackPrint(stderr, "Can't open input image: %s\n", filename);
     54        psErrorStackPrint(stderr, "Can't open input image: %s\n", inName);
    5755        exit(EXIT_FAILURE);
    5856    }
    59     psMetadata *phu = psFitsReadHeader(NULL, fits); // FITS primary header
     57    psMetadata *phu = psFitsReadHeader(NULL, inFile); // FITS primary header
    6058
    6159    psMetadata *cameraFormat = pmConfigCameraFormatFromHeader(config, phu);
     
    6967    }
    7068    // Determine the correct recipe to use
    71     if (! config->recipe && !pmConfigRecipeFromCamera(config, RECIPE)) {
    72         // There's no point in continuing if we can't work out what recipe to use
     69    if (! config->recipes && !pmConfigReadRecipes(config)) {
     70        // There's no point in continuing if we can't work out what recipes to use
    7371        psErrorStackPrint(stderr, "Can't find recipe configuration!\n");
     72        exit(EXIT_FAILURE);
     73    }
     74
     75    const char *outName = psMetadataLookupStr(NULL, config->arguments, "-output");
     76    psLogMsg("ppImage", PS_LOG_INFO, "Opening output image: %s\n", outName);
     77    psFits *outFile = psFitsOpen(outName, "w");
     78    if (!outFile) {
     79        // There's no point in continuing if we can't open the output
     80        psErrorStackPrint(stderr, "Can't open output image: %s\n", outName);
    7481        exit(EXIT_FAILURE);
    7582    }
     
    8390
    8491    // Add in a source file
    85     pmFPAAddSource(fpa, NULL, NULL, phu, cameraFormat);
     92    pmFPAview *view = pmFPAAddSource(fpa, phu, cameraFormat);
     93    printf("View chip: %d\n", view->chip);
     94    printf("View cell: %d\n", view->cell);
    8695
    8796    // Read the FPA
    88 //    pmFPARead(fpa, fits, NULL);
     97    pmFPARead(fpa, inFile, NULL);
    8998
    9099    // How'd we do?
    91     pmFPAPrint(fpa, false);
     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
    92108
    93     psFitsClose(fits);
     109
     110    pmFPAWrite(fpa, outFile, NULL);
     111
     112    psFitsClose(inFile);
     113    psFitsClose(outFile);
    94114    psFree(phu);
    95115    psFree(cameraFormat);
Note: See TracChangeset for help on using the changeset viewer.