IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 6, 2010, 8:02:38 PM (16 years ago)
Author:
eugene
Message:

working on psphotStack

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/psphot.20100506/src/psphotStackParseCamera.c

    r27657 r27876  
    2525        psMetadata *input = item->data.md; // The input metadata of interest
    2626
    27         // look for 'IMAGE', 'MASK', 'VARIANCE' in folder (only 'IMAGE' is required)
    28 
    29         psString image = psMetadataLookupStr(NULL, input, "IMAGE"); // Name of image
    30         if (!image || strlen(image) == 0) {
    31             psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s lacks IMAGE of type STR", item->name);
     27        pmFPAfile *rawInputFile = NULL;
     28        pmFPAfile *cnvInputFile = NULL;
     29
     30        // RAW (unconvolved) input data (RAW:IMAGE, RAW:MASK, RAW:VARIANCE, RAW:PSF)
     31        psString rawImage = psMetadataLookupStr(NULL, input, "RAW:IMAGE"); // Name of image
     32        if (rawImage && strlen(rawImage) > 0) {
     33            pmFPAfile *rawInputFile = defineFile(config, NULL, "PSPHOT.STACK.INPUT.RAW", rawImage, PM_FPA_FILE_IMAGE); // File for image
     34            if (!rawInputFile) {
     35                psError(PS_ERR_UNKNOWN, false, "Unable to define file from image %d (%s)", i, rawImage);
     36                return false;
     37            }
     38            psString mask = psMetadataLookupStr(&status, input, "RAW:MASK"); // Name of mask
     39            if (mask && strlen(mask) > 0) {
     40                if (!defineFile(config, rawInputFile, "PSPHOT.STACK.MASK.RAW", mask, PM_FPA_FILE_MASK)) {
     41                    psError(PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask);
     42                    return false;
     43                }
     44            }
     45            psString variance = psMetadataLookupStr(&status, input, "RAW:VARIANCE"); // Name of variance map
     46            if (variance && strlen(variance) > 0) {
     47                if (!defineFile(config, rawInputFile, "PSPHOT.STACK.VARIANCE.RAW", variance, PM_FPA_FILE_VARIANCE)) {
     48                    psError(PS_ERR_UNKNOWN, false, "Unable to define file from variance %d (%s)", i, variance);
     49                    return false;
     50                }
     51            }
     52            psString psf = psMetadataLookupStr(&status, input, "RAW:PSF"); // Name of mask
     53            if (psf && strlen(psf) > 0) {
     54                if (!defineFile(config, rawInputFile, "PSPHOT.STACK.PSF.RAW", psf, PM_FPA_FILE_PSF)) {
     55                    psError(PS_ERR_UNKNOWN, false, "Unable to define file from psf %d (%s)", i, psf);
     56                    return false;
     57                }
     58            }
     59        }
     60
     61        // CNV (convolved) input data (CNV:IMAGE, CNV:MASK, CNV:VARIANCE, CNV:PSF)
     62        psString cnvImage = psMetadataLookupStr(NULL, input, "CNV:IMAGE"); // Name of image
     63        if (cnvImage && strlen(cnvImage) > 0) {
     64            pmFPAfile *cnvInputFile = defineFile(config, NULL, "PSPHOT.STACK.INPUT.CNV", cnvImage, PM_FPA_FILE_IMAGE); // File for image
     65            if (!cnvInputFile) {
     66                psError(PS_ERR_UNKNOWN, false, "Unable to define file from image %d (%s)", i, cnvImage);
     67                return false;
     68            }
     69            psString mask = psMetadataLookupStr(&status, input, "CNV:MASK"); // Name of mask
     70            if (mask && strlen(mask) > 0) {
     71                if (!defineFile(config, cnvInputFile, "PSPHOT.STACK.MASK.CNV", mask, PM_FPA_FILE_MASK)) {
     72                    psError(PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask);
     73                    return false;
     74                }
     75            }
     76            psString variance = psMetadataLookupStr(&status, input, "CNV:VARIANCE"); // Name of variance map
     77            if (variance && strlen(variance) > 0) {
     78                if (!defineFile(config, cnvInputFile, "PSPHOT.STACK.VARIANCE.CNV", variance, PM_FPA_FILE_VARIANCE)) {
     79                    psError(PS_ERR_UNKNOWN, false, "Unable to define file from variance %d (%s)", i, variance);
     80                    return false;
     81                }
     82            }
     83            psString psf = psMetadataLookupStr(&status, input, "CNV:PSF"); // Name of mask
     84            if (psf && strlen(psf) > 0) {
     85                if (!defineFile(config, cnvInputFile, "PSPHOT.STACK.PSF.CNV", psf, PM_FPA_FILE_PSF)) {
     86                    psError(PS_ERR_UNKNOWN, false, "Unable to define file from psf %d (%s)", i, psf);
     87                    return false;
     88                }
     89            }
     90        }
     91
     92        if (!rawInputFile && !cnvInputFile) {
     93            psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Component %s (%d) lacks IMAGE of type STR", item->name, i);
    3294            return false;
    3395        }
    34         pmFPAfile *imageFile = defineFile(config, NULL, "PSPHOT.INPUT", image, PM_FPA_FILE_IMAGE); // File for image
    35         if (!imageFile) {
    36             psError(PS_ERR_UNKNOWN, false, "Unable to define file from image %d (%s)", i, image);
    37             return false;
    38         }
    39 
    40         psString mask = psMetadataLookupStr(&status, input, "MASK"); // Name of mask
    41         if (mask && strlen(mask) > 0) {
    42             if (!defineFile(config, imageFile, "PSPHOT.MASK", mask, PM_FPA_FILE_MASK)) {
    43                 psError(PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask);
    44                 return false;
    45             }
    46         }
    47 
    48         psString variance = psMetadataLookupStr(&status, input, "VARIANCE"); // Name of variance map
    49         if (variance && strlen(variance) > 0) {
    50             if (!defineFile(config, imageFile, "PSPHOT.VARIANCE", variance, PM_FPA_FILE_VARIANCE)) {
    51                 psError(PS_ERR_UNKNOWN, false, "Unable to define file from variance %d (%s)", i, variance);
    52                 return false;
    53             }
    54         }
    55         // the output sources are carried on the input->fpa structures
    56         pmFPAfile *outsources = pmFPAfileDefineOutputFromFile (config, imageFile, "PSPHOT.STACK.OUTPUT");
    57         if (!outsources) {
    58             psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.STACK.OUTPUT");
    59             return false;
    60         }
    61         outsources->save = true;
    62         outsources->fileID = i;         // this is used to generate output names
     96
     97        psString sources = psMetadataLookupStr(&status, input, "SOURCES"); // Name of mask
     98        pmFPAfile *srcInputFile = rawInputFile ? rawInputFile : cnvInputFile;
     99        if (sources && strlen(sources) > 0) {
     100            if (!defineFile(config, srcInputFile, "PSPHOT.STACK.SOURCES.CNV", sources, PM_FPA_FILE_CMF)) {
     101                psError(PS_ERR_UNKNOWN, false, "Unable to define file from sources %d (%s)", i, sources);
     102                return false;
     103            }
     104        }
     105
     106        // generate an pmFPAimage for the output convolved image
     107        // XXX output of these files should be optional
     108        {
     109            pmFPAfile *outputImage = pmFPAfileDefineOutput(config, NULL, "PSPHOT.STACK.OUTPUT.IMAGE");
     110            if (!outputImage) {
     111                psError(PSPHOT_ERR_CONFIG, false, "Trouble defining PSPHOT.STACK.OUTPUT.IMAGE");
     112                return false;
     113            }
     114            outputImage->save = true;
     115            outsources->fileID = i;             // this is used to generate output names
     116
     117            pmFPAfile *outputMask = pmFPAfileDefineOutput(config, outputImage->fpa, "PSPHOT.STACK.OUTPUT.MASK");
     118            if (!outputMask) {
     119                psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.STACK.OUTPUT.MASK"));
     120                return NULL;
     121            }
     122            if (outputMask->type != PM_FPA_FILE_MASK) {
     123                psError(PS_ERR_IO, true, "PSPHOT.STACK.OUTPUT.MASK is not of type MASK");
     124                return NULL;
     125            }
     126            outputMask->save = true;
     127
     128            pmFPAfile *outputVariance = pmFPAfileDefineOutput(config, outputImage->fpa, "PSPHOT.STACK.OUTPUT.VARIANCE");
     129            if (!outputVariance) {
     130                psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.STACK.OUTPUT.VARIANCE"));
     131                return NULL;
     132            }
     133            if (outputVariance->type != PM_FPA_FILE_VARIANCE) {
     134                psError(PS_ERR_IO, true, "PSPHOT.STACK.OUTPUT.VARIANCE is not of type VARIANCE");
     135                return NULL;
     136            }
     137            outputVariance->save = true;
     138
     139            // the output sources are carried on the outputImage->fpa structures
     140            pmFPAfile *outsources = pmFPAfileDefineOutputFromFile (config, outputImage, "PSPHOT.STACK.OUTPUT");
     141            if (!outsources) {
     142                psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.STACK.OUTPUT");
     143                return false;
     144            }
     145            outsources->save = true;
     146            outsources->fileID = i;             // this is used to generate output names
     147        }
    63148    }
    64149    psMetadataRemoveKey(config->arguments, "FILENAMES");
     
    71156
    72157    // generate an pmFPAimage for the chisqImage
    73     pmFPAfile *chisqImage = pmFPAfileDefineOutput(config, NULL, "PSPHOT.CHISQ.IMAGE");
    74     if (!chisqImage) {
    75         psError(PSPHOT_ERR_CONFIG, false, "Trouble defining PSPHOT.CHISQ.IMAGE");
    76         return false;
    77     }
    78     chisqImage->save = true;
    79 
    80     pmFPAfile *chisqMask = pmFPAfileDefineOutput(config, chisqImage->fpa, "PSPHOT.CHISQ.MASK");
    81     if (!chisqMask) {
    82         psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.CHISQ.MASK"));
    83         return NULL;
    84     }
    85     if (chisqMask->type != PM_FPA_FILE_MASK) {
    86         psError(PS_ERR_IO, true, "PSPHOT.CHISQ.MASK is not of type MASK");
    87         return NULL;
    88     }
    89     chisqMask->save = true;
    90 
    91     pmFPAfile *chisqVariance = pmFPAfileDefineOutput(config, chisqImage->fpa, "PSPHOT.CHISQ.VARIANCE");
    92     if (!chisqVariance) {
    93         psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.CHISQ.VARIANCE"));
    94         return NULL;
    95     }
    96     if (chisqVariance->type != PM_FPA_FILE_VARIANCE) {
    97         psError(PS_ERR_IO, true, "PSPHOT.CHISQ.VARIANCE is not of type VARIANCE");
    98         return NULL;
    99     }
    100     chisqVariance->save = true;
    101 
    102 # if (0)   
    103     // define the additional input/output files associated with psphot
    104     // XXX figure out which files are needed by psphotStack
    105     if (false && !psphotDefineFiles (config, input)) {
    106         psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files");
    107         return false;
    108     }
    109 # endif
     158    // XXX output of these files should be optional
     159    {
     160        pmFPAfile *chisqImage = pmFPAfileDefineOutput(config, NULL, "PSPHOT.CHISQ.IMAGE");
     161        if (!chisqImage) {
     162            psError(PSPHOT_ERR_CONFIG, false, "Trouble defining PSPHOT.CHISQ.IMAGE");
     163            return false;
     164        }
     165        chisqImage->save = true;
     166
     167        pmFPAfile *chisqMask = pmFPAfileDefineOutput(config, chisqImage->fpa, "PSPHOT.CHISQ.MASK");
     168        if (!chisqMask) {
     169            psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.CHISQ.MASK"));
     170            return NULL;
     171        }
     172        if (chisqMask->type != PM_FPA_FILE_MASK) {
     173            psError(PS_ERR_IO, true, "PSPHOT.CHISQ.MASK is not of type MASK");
     174            return NULL;
     175        }
     176        chisqMask->save = true;
     177
     178        pmFPAfile *chisqVariance = pmFPAfileDefineOutput(config, chisqImage->fpa, "PSPHOT.CHISQ.VARIANCE");
     179        if (!chisqVariance) {
     180            psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.CHISQ.VARIANCE"));
     181            return NULL;
     182        }
     183        if (chisqVariance->type != PM_FPA_FILE_VARIANCE) {
     184            psError(PS_ERR_IO, true, "PSPHOT.CHISQ.VARIANCE is not of type VARIANCE");
     185            return NULL;
     186        }
     187        chisqVariance->save = true;
     188    }
    110189
    111190    psTrace("psphot", 1, "Done with psphotStackParseCamera...\n");
     
    145224}
    146225
     226
     227/***
     228 *
     229 *  psphotStack :
     230
     231 *    * inputs:
     232 *      * unconvolved images
     233 *      * raw convolved images
     234 *      * psfs (unconvolved or convolved?)
     235 *      * sources
     236 
     237 * optionally convolve the unconvolved or the raw inputs
     238 * optionally perform no convolutions
     239 * optionally save the psf-matched images
     240
     241 */
     242
     243   
     244# if (0)   
     245    // define the additional input/output files associated with psphot
     246    // XXX figure out which files are needed by psphotStack
     247    if (false && !psphotDefineFiles (config, input)) {
     248        psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files");
     249        return false;
     250    }
     251# endif
     252
Note: See TracChangeset for help on using the changeset viewer.