IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 8, 2013, 4:41:42 PM (13 years ago)
Author:
eugene
Message:

warping of background model appears to work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpArguments.c

    r35527 r35535  
    1212
    1313# include "pswarp.h"
    14 # include <glob.h>
    15 
    1614
    1715static void usage (void) {
    18     fprintf(stderr, "USAGE: pswarp [-file image(s)] [-list imagelist] [options] (output) (skycell)\n");
     16    fprintf(stderr, "USAGE: pswarp [-input input.mdc] [-file image(s)] [-list imagelist] [options] (output) (skycell)\n");
    1917    fprintf(stderr, "  options:\n");
     18    fprintf(stderr, "    [-input input.mdc] : input image information in a metadata file\n");
     19    fprintf(stderr, "    [-file input.fits[,input.fits]] : input image to be warped\n");
    2020    fprintf(stderr, "    [-astrom astrom.cmp] : provide an alternative astrometry calibration\n");
    2121    fprintf(stderr, "    [-mask mask.fits] : provide a corresponding mask image\n");
     
    2424    exit(PS_EXIT_CONFIG_ERROR);
    2525}
    26 
    2726
    2827pmConfig *pswarpArguments (int argc, char **argv) {
     
    5554    }
    5655
     56    // XXX move to the single group below?
    5757    pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM",   "-astrom", "-astromlist");
    5858
    59     {
    60         int arg;                        ///< Argument Number
    61         if ((arg = psArgumentGet(argc, argv, "-psphot-visual"))) {
    62             psArgumentRemove(arg, &argc, argv);
    63             pmVisualSetVisual(true);
    64         }
     59    // turn on psphot visualization
     60    if ((N = psArgumentGet(argc, argv, "-psphot-visual"))) {
     61        psArgumentRemove(N, &argc, argv);
     62        pmVisualSetVisual(true);
    6563    }
    6664
     
    143141    return config;
    144142}
    145 
    146 /**
    147  * Parse the recipe and format into the arguments
    148  */
    149 bool pswarpOptions(pmConfig *config)
    150 {
    151     // Select the appropriate recipe
    152     psMetadata *recipe  = psMetadataLookupPtr(NULL, config->recipes, PSWARP_RECIPE);
    153     if (!recipe) {
    154         psError(PSWARP_ERR_CONFIG, true, "Can't find %s recipe!\n", PSWARP_RECIPE);
    155         return false;
    156     }
    157 
    158     // Get grid size
    159     bool status;                        ///< Status of MD lookup
    160     int nGridX = psMetadataLookupS32(&status, recipe, "GRID.NX");
    161     if (!status || nGridX <= 0) {
    162         nGridX = 128;
    163         psWarning("GRID.NX is not set in the recipe --- defaulting to %d", nGridX);
    164     }
    165     int nGridY = psMetadataLookupS32(&status, recipe, "GRID.NY");
    166     if (!status) {
    167         nGridY = 128;
    168         psWarning("GRID.NY is not set in the recipe --- defaulting to %d", nGridY);
    169     }
    170 
    171     // Get interpolation mode
    172     const char *name = psMetadataLookupStr (&status, recipe, "INTERPOLATION.MODE"); ///< Name of interp mode
    173     if (!name) {
    174         name = "BILINEAR";
    175         psLogMsg("pswarp", 3, "defaulting to %s interpolation", name);
    176     }
    177     psImageInterpolateMode interpolationMode = psImageInterpolateModeFromString(name); ///< Mode for interp.
    178     if (interpolationMode == PS_INTERPOLATE_NONE) {
    179         interpolationMode = PS_INTERPOLATE_BILINEAR;
    180         psLogMsg ("pswarp", 3,
    181                   "Unknown interpolation mode %s, defaulting to bilinear interpolation\n", name);
    182         name = "BILINEAR";
    183     }
    184 
    185     int numKernels = psMetadataLookupS32(&status, recipe, "INTERPOLATION.NUM");
    186     if (!status) {
    187         numKernels = 0;
    188         psWarning("INTERPOLATION.NUM is not set in the recipe --- defaulting to %d", numKernels);
    189     }
    190 
    191     float poorFrac = psMetadataLookupF32(&status, recipe, "POOR.FRAC"); ///< Frac of bad flux for a "poor"
    192     if (!status) {
    193         poorFrac = 0.0;
    194         psWarning("POOR.FRAC is not set in the %s recipe --- defaulting to %f.", PSWARP_RECIPE, poorFrac);
    195     }
    196 
    197     bool PSF = psMetadataLookupBool(&status, recipe, "PSF"); ///< Generate a PSF model?
    198     if (!status) {
    199         PSF = true;
    200         psWarning("PSF is not set in the %s recipe --- defaulting to TRUE.", PSWARP_RECIPE);
    201     }
    202 
    203     bool doBKG = psMetadataLookupBool(&status,recipe, "BACKGROUND.MODEL"); ///< Generate the warped background model?
    204     if (!status) {
    205       doBKG = false;
    206       psWarning("BACKGROUND.MODEL is not set in the %s recipe -- defaulting to FALSE.", PSWARP_RECIPE);
    207     }
    208     int bkgXgrid = psMetadataLookupS32(&status,recipe, "BKG.XGRID"); ///< Xsize of background model
    209     if (!status) {
    210       bkgXgrid = 10;
    211       psWarning("BKG.XGRID is not set in the %s recipe -- defaultint to %d.",PSWARP_RECIPE,bkgXgrid);
    212     }
    213     int bkgYgrid = psMetadataLookupS32(&status,recipe, "BKG.YGRID"); ///< Xsize of background model
    214     if (!status) {
    215       bkgYgrid = 10;
    216       psWarning("BKG.YGRID is not set in the %s recipe -- defaultint to %d.",PSWARP_RECIPE,bkgYgrid);
    217     }
    218 
    219    
    220     // Set recipe values in the recipe (since we've possibly altered some)
    221     psMetadataAddS32(recipe, PS_LIST_TAIL, "GRID.NX", PS_META_REPLACE, "Iso-astrom grid spacing in x", nGridX);
    222     psMetadataAddS32(recipe, PS_LIST_TAIL, "GRID.NY", PS_META_REPLACE, "Iso-astrom grid spacing in y", nGridY);
    223     psMetadataAddStr(recipe, PS_LIST_TAIL, "INTERPOLATION.MODE", PS_META_REPLACE, "Interpolation mode", name);
    224     psMetadataAddS32(recipe, PS_LIST_TAIL, "INTERPOLATION.NUM", PS_META_REPLACE, "Interpolation pre-calculated kernels", numKernels);
    225     psMetadataAddF32(recipe, PS_LIST_TAIL, "POOR.FRAC", PS_META_REPLACE, "Fraction of bad flux for a pixel to be marked as poor", poorFrac);
    226     psMetadataAddBool(recipe, PS_LIST_TAIL, "PSF", PS_META_REPLACE, "Generate a PSF Model?", PSF);
    227     psMetadataAddBool(recipe, PS_LIST_TAIL, "BACKGROUND.MODEL", PS_META_REPLACE, "Generate the warped background model?", doBKG);
    228     psMetadataAddS32(recipe, PS_LIST_TAIL, "BKG.XGRID", PS_META_REPLACE, "Xsize of background model", bkgXgrid);
    229     psMetadataAddS32(recipe, PS_LIST_TAIL, "BKG.YGRID", PS_META_REPLACE, "Ysize of background model", bkgYgrid);
    230    
    231     // Set recipe values in the arguments
    232     psMetadataAddS32(config->arguments, PS_LIST_TAIL, "GRID.NX", 0, "Iso-astrom grid spacing in x", nGridX);
    233     psMetadataAddS32(config->arguments, PS_LIST_TAIL, "GRID.NY", 0, "Iso-astrom grid spacing in y", nGridY);
    234     psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INTERPOLATION.MODE", 0, "Interpolation mode", interpolationMode);
    235     psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INTERPOLATION.NUM", 0, "Interpolation pre-calculated kernels", numKernels);
    236     psMetadataAddF32(config->arguments, PS_LIST_TAIL, "POOR.FRAC", 0, "Fraction of bad flux for a pixel to be marked as poor", poorFrac);
    237     psMetadataAddBool(config->arguments, PS_LIST_TAIL, "PSF", PS_META_REPLACE, "Generate a PSF Model?", PSF);
    238     psMetadataAddBool(config->arguments, PS_LIST_TAIL, "BACKGROUND.MODEL", PS_META_REPLACE, "Generate the warped background model?", doBKG);
    239     psMetadataAddS32(config->arguments, PS_LIST_TAIL, "BKG.XGRID", PS_META_REPLACE, "Xsize of background model", bkgXgrid);
    240     psMetadataAddS32(config->arguments, PS_LIST_TAIL, "BKG.YGRID", PS_META_REPLACE, "Ysize of background model", bkgYgrid);
    241 
    242     psTrace("pswarp", 1, "Done with pswarpOptions...\n");
    243 
    244     return (config);
    245 }
Note: See TracChangeset for help on using the changeset viewer.