- Timestamp:
- May 8, 2013, 4:41:42 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130419/pswarp/src/pswarpArguments.c
r35527 r35535 12 12 13 13 # include "pswarp.h" 14 # include <glob.h>15 16 14 17 15 static 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"); 19 17 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"); 20 20 fprintf(stderr, " [-astrom astrom.cmp] : provide an alternative astrometry calibration\n"); 21 21 fprintf(stderr, " [-mask mask.fits] : provide a corresponding mask image\n"); … … 24 24 exit(PS_EXIT_CONFIG_ERROR); 25 25 } 26 27 26 28 27 pmConfig *pswarpArguments (int argc, char **argv) { … … 55 54 } 56 55 56 // XXX move to the single group below? 57 57 pmConfigFileSetsMD(config->arguments, &argc, argv, "ASTROM", "-astrom", "-astromlist"); 58 58 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); 65 63 } 66 64 … … 143 141 return config; 144 142 } 145 146 /**147 * Parse the recipe and format into the arguments148 */149 bool pswarpOptions(pmConfig *config)150 {151 // Select the appropriate recipe152 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 size159 bool status; ///< Status of MD lookup160 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 mode172 const char *name = psMetadataLookupStr (&status, recipe, "INTERPOLATION.MODE"); ///< Name of interp mode173 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 model209 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 model214 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 arguments232 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.
