IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 15604


Ignore:
Timestamp:
Nov 13, 2007, 10:50:43 AM (18 years ago)
Author:
Paul Price
Message:

Adding ACCEPT.FRAC (Minimum fraction of good pixels for result to be accepted). Reformatting.

File:
1 edited

Legend:

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

    r14874 r15604  
    7878}
    7979
    80     // Parse the recipe and format into the arguments
     80// Parse the recipe and format into the arguments
    8181bool pswarpOptions(pmConfig *config)
    8282{
    83         // Select the appropriate recipe
    84         psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE);
    85         if (!recipe) {
    86             psError(PSWARP_ERR_CONFIG, true, "Can't find %s recipe!\n", PSWARP_RECIPE);
    87             return false;
     83    // Select the appropriate recipe
     84    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, PSWARP_RECIPE);
     85    if (!recipe) {
     86        psError(PSWARP_ERR_CONFIG, true, "Can't find %s recipe!\n", PSWARP_RECIPE);
     87        return false;
     88    }
     89
     90    // Get grid size
     91    bool status;                        // Status of MD lookup
     92    int nGridX = psMetadataLookupS32 (&status, recipe, "GRID.NX");
     93    if (!status) nGridX = 128;
     94    int nGridY = psMetadataLookupS32 (&status, recipe, "GRID.NY");
     95    if (!status) nGridY = 128;
     96
     97    // Get interpolation mode
     98    psImageInterpolateMode interpolationMode; // Mode for interpolation
     99    const char *name = psMetadataLookupStr (&status, recipe, "INTERPOLATION.MODE"); // Name of interp mode
     100    if (!name) {
     101        interpolationMode = PS_INTERPOLATE_BILINEAR;
     102        psLogMsg ("pswarp", 3, "defaulting to bilinear interpolation\n");
     103    } else {
     104        interpolationMode = psImageInterpolateModeFromString (name);
     105        if (interpolationMode == PS_INTERPOLATE_NONE) {
     106            interpolationMode = PS_INTERPOLATE_BILINEAR;
     107            psLogMsg ("pswarp", 3,
     108                      "Unknown interpolation mode %s, defaulting to bilinear interpolation\n", name);
    88109        }
     110    }
    89111
    90         // Get grid size
    91         bool status;                        // Status of MD lookup
    92         int nGridX = psMetadataLookupS32 (&status, recipe, "GRID.NX");
    93         if (!status) nGridX = 128;
    94         int nGridY = psMetadataLookupS32 (&status, recipe, "GRID.NY");
    95         if (!status) nGridY = 128;
     112    // Get mask parameters
     113    psMaskType maskIn, maskPoor, maskBad; // Mask values for input, "poor" and "bad" pixels
    96114
    97         // Get interpolation mode
    98         psImageInterpolateMode interpolationMode; // Mode for interpolation
    99         const char *name = psMetadataLookupStr (&status, recipe, "INTERPOLATION.MODE"); // Name of interp mode
    100         if (!name) {
    101             interpolationMode = PS_INTERPOLATE_BILINEAR;
    102             psLogMsg ("pswarp", 3, "defaulting to bilinear interpolation\n");
    103         } else {
    104             interpolationMode = psImageInterpolateModeFromString (name);
    105             if (interpolationMode == PS_INTERPOLATE_NONE) {
    106                 interpolationMode = PS_INTERPOLATE_BILINEAR;
    107                 psLogMsg ("pswarp", 3,
    108                           "Unknown interpolation mode %s, defaulting to bilinear interpolation\n", name);
    109             }
    110         }
     115    psString maskNames = psMetadataLookupStr(&status, recipe, "MASK.IN");
     116    if (!status) {
     117        maskIn = 0x00;
     118        psWarning("MASK.IN is not set in the %s recipe --- defaulting to %x.", PSWARP_RECIPE, maskIn);
     119    }
     120    maskIn = pmConfigMask(maskNames, config); // Mask for input data
    111121
    112         // Get mask parameters
    113         psMaskType maskIn, maskPoor, maskBad; // Mask values for input, "poor" and "bad" pixels
     122    maskNames = psMetadataLookupStr(&status, recipe, "MASK.POOR");
     123    if (!status) {
     124        maskPoor = 0x00;
     125        psWarning("MASK.POOR is not set in the %s recipe --- defaulting to %x.", PSWARP_RECIPE, maskPoor);
     126    }
     127    maskPoor = pmConfigMask(maskNames, config); // Mask for "poor" warped data
    114128
    115         psString maskNames = psMetadataLookupStr(&status, recipe, "MASK.IN");
    116          if (!status) {
    117             maskIn = 0x00;
    118             psWarning("MASK.IN is not set in the %s recipe --- defaulting to %x.", PSWARP_RECIPE, maskIn);
    119         }
    120         maskIn = pmConfigMask(maskNames, config); // Mask for input data
     129    maskNames = psMetadataLookupStr(&status, recipe, "MASK.BAD");
     130    if (!status) {
     131        maskBad = 0x00;
     132        psWarning("MASK.BAD is not set in the %s recipe --- defaulting to %x.", PSWARP_RECIPE, maskBad);
     133    }
     134    maskBad = pmConfigMask(maskNames, config); // Mask for bad warped data
    121135
    122         maskNames = psMetadataLookupStr(&status, recipe, "MASK.POOR");
    123         if (!status) {
    124             maskPoor = 0x00;
    125             psWarning("MASK.POOR is not set in the %s recipe --- defaulting to %x.", PSWARP_RECIPE, maskPoor);
    126         }
    127         maskPoor = pmConfigMask(maskNames, config); // Mask for "poor" warped data
     136    float poorFrac = psMetadataLookupF32(&status, recipe, "POOR.FRAC"); // Frac of bad flux for a "poor"
     137    if (!status) {
     138        poorFrac = 0.0;
     139        psWarning("POOR.FRAC is not set in the %s recipe --- defaulting to %f.", PSWARP_RECIPE, poorFrac);
     140    }
    128141
    129         maskNames = psMetadataLookupStr(&status, recipe, "MASK.BAD");
    130         if (!status) {
    131             maskBad = 0x00;
    132             psWarning("MASK.BAD is not set in the %s recipe --- defaulting to %x.", PSWARP_RECIPE, maskBad);
    133         }
    134         maskBad = pmConfigMask(maskNames, config); // Mask for bad warped data
     142    float acceptFrac = psMetadataLookupF32(&status, recipe, "ACCEPT.FRAC"); // Min fraction of good pixels
     143    if (!status) {
     144        acceptFrac = 0.0;
     145        psWarning("ACCEPT.FRAC is not set in the %s recipe --- defaulting to %f.", PSWARP_RECIPE, poorFrac);
     146    }
    135147
    136         float poorFrac = psMetadataLookupF32(&status, recipe, "POOR.FRAC"); // Frac of bad flux for a "poor"
    137         if (!status) {
    138             poorFrac = 0.0;
    139             psWarning("POOR.FRAC is not set in the %s recipe --- defaulting to %f.", PSWARP_RECIPE, poorFrac);
    140         }
     148    // Set recipe values in the arguments
     149    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "GRID.NX", 0,
     150                     "Iso-astrom grid spacing in x", nGridX);
     151    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "GRID.NY", 0,
     152                     "Iso-astrom grid spacing in y", nGridY);
     153    psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INTERPOLATION.MODE", 0,
     154                     "Interpolation mode", interpolationMode);
     155    psMetadataAddU8(config->arguments, PS_LIST_TAIL, "MASK.IN", 0,
     156                    "Mask for input data", maskIn);
     157    psMetadataAddU8(config->arguments, PS_LIST_TAIL, "MASK.POOR", 0,
     158                    "Mask for poor warped data", maskPoor);
     159    psMetadataAddU8(config->arguments, PS_LIST_TAIL, "MASK.BAD", 0,
     160                    "Mask for bad warped data", maskBad);
     161    psMetadataAddF32(config->arguments, PS_LIST_TAIL, "POOR.FRAC", 0,
     162                     "Fraction of bad flux for a pixel to be marked as poor", poorFrac);
     163    psMetadataAddF32(config->arguments, PS_LIST_TAIL, "ACCEPT.FRAC", 0,
     164                     "Minimum fraction of good pixels for result to be accepted", acceptFrac);
    141165
    142         // Set recipe values in the arguments
    143         psMetadataAddS32(config->arguments, PS_LIST_TAIL, "GRID.NX", 0,
    144                          "Iso-astrom grid spacing in x", nGridX);
    145         psMetadataAddS32(config->arguments, PS_LIST_TAIL, "GRID.NY", 0,
    146                          "Iso-astrom grid spacing in y", nGridY);
    147         psMetadataAddS32(config->arguments, PS_LIST_TAIL, "INTERPOLATION.MODE", 0,
    148                          "Interpolation mode", interpolationMode);
    149         psMetadataAddU8(config->arguments, PS_LIST_TAIL, "MASK.IN", 0,
    150                          "Mask for input data", maskIn);
    151         psMetadataAddU8(config->arguments, PS_LIST_TAIL, "MASK.POOR", 0,
    152                          "Mask for poor warped data", maskPoor);
    153         psMetadataAddU8(config->arguments, PS_LIST_TAIL, "MASK.BAD", 0,
    154                          "Mask for bad warped data", maskBad);
    155         psMetadataAddF32(config->arguments, PS_LIST_TAIL, "POOR.FRAC", 0,
    156                          "Fraction of bad flux for a pixel to be marked as poor", poorFrac);
    157166    psTrace("pswarp", 1, "Done with pswarpArguments...\n");
    158167    return (config);
Note: See TracChangeset for help on using the changeset viewer.