IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18924


Ignore:
Timestamp:
Aug 5, 2008, 2:39:59 PM (18 years ago)
Author:
Paul Price
Message:

Adding configuration dumping. Required reorganisation of how recipe values get into the program. Formerly, the command-line and recipe values were parsed and the result was put on config->arguments. Now, we want whatever was altered by the command-line to be reflected in the recipe (which is dumped), so using the recipe as the storage. Not yet tested, but will do so soon.

Location:
trunk/pswarp/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/pswarp/src/pswarp.c

    r17781 r18924  
    22
    33static void usage (void) {
    4     fprintf (stderr, "USAGE: pswarp [-file image(s)] [-list imagelist] [options] (output) (skycell)\n");
    5     fprintf (stderr, "  options:\n");
    6     fprintf (stderr, "    [-astrom astrom.cmp] : provide an alternative astrometry calibration\n");
    7     fprintf (stderr, "    [-mask mask.fits] : provide a corresponding mask image\n");
    8     fprintf (stderr, "    [-weight weight.fits] : provide a corresponding weight image (pixel varience)\n");
     4    fprintf(stderr, "USAGE: pswarp [-file image(s)] [-list imagelist] [options] (output) (skycell)\n");
     5    fprintf(stderr, "  options:\n");
     6    fprintf(stderr, "    [-astrom astrom.cmp] : provide an alternative astrometry calibration\n");
     7    fprintf(stderr, "    [-mask mask.fits] : provide a corresponding mask image\n");
     8    fprintf(stderr, "    [-weight weight.fits] : provide a corresponding weight image (pixel varience)\n");
    99    psErrorStackPrint(stderr, "\n");
    1010    exit (2);
     
    2424    if (!config) usage();
    2525
    26     if (!pswarpOptions(config)) {
    27         psErrorStackPrint(stderr, "error parsing options\n");
    28         exit(1);
    29     }
    30 
    3126    // load identify the data sources
    3227    if (!pswarpParseCamera(config)) {
    3328        psErrorStackPrint(stderr, "error setting up the camera\n");
    34         exit (1);
     29        exit(PS_EXIT_CONFIG_ERROR);
     30    }
     31
     32    if (!pswarpOptions(config)) {
     33        psErrorStackPrint(stderr, "error parsing options\n");
     34        exit(PS_EXIT_SYS_ERROR);
    3535    }
    3636
     
    3838    if (!pswarpDefine(config)) {
    3939        psErrorStackPrint(stderr, "error loading output definition\n");
    40         exit (1);
     40        exit(PS_EXIT_CONFIG_ERROR);
    4141    }
    4242
     
    4444    if (!pswarpLoop(config)) {
    4545        psErrorStackPrint(stderr, "error warping data\n");
    46         exit (1);
     46        exit(PS_EXIT_DATA_ERROR);
    4747    }
    4848
     
    5050    pswarpCleanup(config);
    5151    psLibFinalize();
    52     exit(EXIT_SUCCESS);
     52    exit(PS_EXIT_SUCCESS);
    5353}
  • trunk/pswarp/src/pswarpArguments.c

    r18839 r18924  
    4444    if ((N = psArgumentGet(argc, argv, "-threads"))) {
    4545        psArgumentRemove(N, &argc, argv);
    46         int nThreads = atoi(argv[N]);
     46        int nThreads = atoi(argv[N]);
    4747        psMetadataAddS32(config->arguments, PS_LIST_TAIL, "NTHREADS", 0, "number of warp threads", nThreads);
    4848        psArgumentRemove(N, &argc, argv);
    4949
    50         // create the thread pool with number of desired threads, supplying our thread launcher function
    51         // XXX need to determine the number of threads from the config data
    52         psThreadPoolInit (nThreads);
     50        // create the thread pool with number of desired threads, supplying our thread launcher function
     51        // XXX need to determine the number of threads from the config data
     52        psThreadPoolInit (nThreads);
    5353    }
    5454    pswarpSetThreads ();
     
    9494{
    9595    // Select the appropriate recipe
    96     psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE);
     96    psMetadata *recipe  = psMetadataLookupPtr(NULL, config->recipes, PSWARP_RECIPE);
    9797    if (!recipe) {
    9898        psError(PSWARP_ERR_CONFIG, true, "Can't find %s recipe!\n", PSWARP_RECIPE);
     
    102102    // Get grid size
    103103    bool status;                        // Status of MD lookup
    104     int nGridX = psMetadataLookupS32 (&status, recipe, "GRID.NX");
    105     if (!status) nGridX = 128;
    106     int nGridY = psMetadataLookupS32 (&status, recipe, "GRID.NY");
    107     if (!status) nGridY = 128;
     104    int nGridX = psMetadataLookupS32(&status, recipe, "GRID.NX");
     105    if (!status || nGridX <= 0) {
     106        nGridX = 128;
     107        psWarning("GRID.NX is not set in the recipe --- defaulting to %d", nGridX);
     108    }
     109    int nGridY = psMetadataLookupS32(&status, recipe, "GRID.NY");
     110    if (!status) {
     111        nGridY = 128;
     112        psWarning("GRID.NY is not set in the recipe --- defaulting to %d", nGridY);
     113    }
    108114
    109115    // Get interpolation mode
    110     psImageInterpolateMode interpolationMode; // Mode for interpolation
    111116    const char *name = psMetadataLookupStr (&status, recipe, "INTERPOLATION.MODE"); // Name of interp mode
    112117    if (!name) {
     118        name = "BILINEAR";
     119        psLogMsg("pswarp", 3, "defaulting to %s interpolation", name);
     120    }
     121    psImageInterpolateMode interpolationMode = psImageInterpolateModeFromString(name); // Mode for interp.
     122    if (interpolationMode == PS_INTERPOLATE_NONE) {
    113123        interpolationMode = PS_INTERPOLATE_BILINEAR;
    114         psLogMsg ("pswarp", 3, "defaulting to bilinear interpolation\n");
    115     } else {
    116         interpolationMode = psImageInterpolateModeFromString (name);
    117         if (interpolationMode == PS_INTERPOLATE_NONE) {
    118             interpolationMode = PS_INTERPOLATE_BILINEAR;
    119             psLogMsg ("pswarp", 3,
    120                       "Unknown interpolation mode %s, defaulting to bilinear interpolation\n", name);
    121         }
     124        psLogMsg ("pswarp", 3,
     125                  "Unknown interpolation mode %s, defaulting to bilinear interpolation\n", name);
     126        name = "BILINEAR";
    122127    }
    123128
     
    134139    }
    135140
     141    // Set recipe values in the recipe (since we've possibly altered some)
     142    psMetadataAddS32(recipe, PS_LIST_TAIL, "GRID.NX", PS_META_REPLACE,
     143                     "Iso-astrom grid spacing in x", nGridX);
     144    psMetadataAddS32(recipe, PS_LIST_TAIL, "GRID.NY", PS_META_REPLACE,
     145                     "Iso-astrom grid spacing in y", nGridY);
     146    psMetadataAddStr(recipe, PS_LIST_TAIL, "INTERPOLATION.MODE", PS_META_REPLACE,
     147                     "Interpolation mode", name);
     148    psMetadataAddF32(recipe, PS_LIST_TAIL, "POOR.FRAC", PS_META_REPLACE,
     149                     "Fraction of bad flux for a pixel to be marked as poor", poorFrac);
     150    psMetadataAddF32(recipe, PS_LIST_TAIL, "ACCEPT.FRAC", PS_META_REPLACE,
     151                     "Minimum fraction of good pixels for result to be accepted", acceptFrac);
     152
    136153    // Set recipe values in the arguments
    137154    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "GRID.NX", 0,
     
    147164
    148165    psTrace("pswarp", 1, "Done with pswarpArguments...\n");
     166
     167    // Dump configuration, now that's it's settled
     168    {
     169        pmConfigCamerasCull(config);
     170        pmConfigRecipesCull(config, "PSWARP,PPSTATS,PSPHOT,MASKS");
     171
     172        const char *outroot = psMetadataLookupStr(NULL, config->arguments, "OUTPUT"); // Output root name
     173        psAssert(outroot, "Should be there, we put it there!");
     174
     175        pmFPAfile *input = psMetadataLookupPtr(NULL, config->files, "PSWARP.INPUT"); // Input file
     176        pmConfigDump(config, input->fpa, outroot);
     177    }
     178
    149179    return (config);
    150180}
  • trunk/pswarp/src/pswarpLoop.c

    r18839 r18924  
    6464bool pswarpLoop(pmConfig *config)
    6565{
    66     bool status; 
     66    bool status;
    6767
    6868    // load the recipe
     
    7474
    7575    // output mask bits
    76     psMaskType maskValue = psMetadataLookupU8(&status, recipe, "MASK.OUTPUT"); 
     76    psMaskType maskValue = psMetadataLookupU8(&status, recipe, "MASK.OUTPUT");
    7777    psAssert (status, "MASK.OUTPUT was not defined");
    7878
  • trunk/pswarp/src/pswarpParseCamera.c

    r18558 r18924  
    11# include "pswarp.h"
    22
    3 bool pswarpParseCamera (pmConfig *config) {
    4 
     3bool pswarpParseCamera(pmConfig *config)
     4{
    55    bool status;
    66    bool mdok;                          // Status of MD lookup
     
    3838        psLogMsg ("pswarp", 3, "no mask supplied\n");
    3939    }
    40    
     40
    4141    // loading the mask here should have invoked pmConfigMaskReadHeader()
    4242    if (!pswarpSetMaskBits (config)) {
Note: See TracChangeset for help on using the changeset viewer.