IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 27667


Ignore:
Timestamp:
Apr 12, 2010, 2:18:52 PM (16 years ago)
Author:
Paul Price
Message:

Add ability to get inputs from text file. Don't use PSF residuals ever, since they seem to cause bad results whenever they're used.

Location:
trunk/ppViz/src/ppVizPSF
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppViz/src/ppVizPSF/ppVizPSF.h

    r26405 r27667  
    1111    psString psfName;                   // Filename with PSF
    1212    psString sourcesName;               // Filename with sources
    13     int fakeNum;                        // Number of fake sources
     13    int fakeNum;                        // Number of fake sources
    1414    float fakeMag;                      // Magnitude of fake sources
    1515    psString outRoot;                   // Output root name
     
    1717    int size;                           // Size of PSF image
    1818    float x, y;                         // Position of fake source
     19    psArray *input;                     // Input positions and magnitudes
    1920    pmConfig *config;                   // Configuration
    2021} ppVizPSFData;
  • trunk/ppViz/src/ppVizPSF/ppVizPSFArguments.c

    r26405 r27667  
    5050    psMetadataAddStr(arguments, PS_LIST_TAIL, "-psf", 0, "Filename of PSF", NULL);
    5151    psMetadataAddStr(arguments, PS_LIST_TAIL, "-sources", 0, "Filename of CMF sources", NULL);
     52    psMetadataAddStr(arguments, PS_LIST_TAIL, "-input", 0, "Filename with x,y,mag", NULL);
    5253    psMetadataAddS32(arguments, PS_LIST_TAIL, "-fake-num", 0, "Number of fake sources", 0);
    5354    psMetadataAddF32(arguments, PS_LIST_TAIL, "-fake-mag", 0, "Magnitude of fake sources", NAN);
     
    6869    psMetadataAddStr(data->config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Output root name", data->outRoot);
    6970
     71    const char *inputName = psMetadataLookupStr(NULL, arguments, "-input"); // Name of input file
     72    if (inputName) {
     73        data->input = psVectorsReadFromFile(inputName, "%f %f %f");
     74        if (!data->input) {
     75            psError(psErrorCodeLast(), false, "Unable to read input file %s", inputName);
     76            return false;
     77        }
     78    }
     79
    7080    psTrace("ppVizPSF", 1, "Done reading command-line arguments\n");
    7181    psFree(arguments);
  • trunk/ppViz/src/ppVizPSF/ppVizPSFData.c

    r26405 r27667  
    1616    psFree(data->sourcesName);
    1717    psFree(data->outRoot);
     18    psFree(data->input);
    1819    psFree(data->config);
    1920    return;
     
    3637    data->x = NAN;
    3738    data->y = NAN;
     39    data->input = NULL;
    3840
    3941    return data;
  • trunk/ppViz/src/ppVizPSF/ppVizPSFLoop.c

    r27666 r27667  
    7575                psVector *xOffset = NULL, *yOffset = NULL; // Offset from source to true position
    7676
    77                 if (sources || (data->fakeNum > 0 && isfinite(data->fakeMag))) {
     77                if (sources || data->input || (data->fakeNum > 0 && isfinite(data->fakeMag))) {
    7878                    numCols = psf->fieldNx;
    7979                    numRows = psf->fieldNy;
     
    8282                if (sources) {
    8383                    psMemIncrRefCounter(sources);
    84                     psLogMsg("ppVizPSF", PS_LOG_INFO, "Using %ld input sources", sources->n);
    85                 }
     84                    psLogMsg("ppVizPSF", PS_LOG_INFO, "Using %ld input sources from CMF file", sources->n);
     85                } else if (data->input) {
     86                    psVector *x = data->input->data[0]; // x coordinates
     87                    psLogMsg("ppVizPSF", PS_LOG_INFO, "Using %ld input sources from text file", x->n);
     88                }
     89
    8690                if (data->fakeNum > 0 && isfinite(data->fakeMag)) {
    8791                    long numOld = 0; // Old number of sources
     
    113117                    }
    114118                }
    115                 if (!sources) {
     119                if (!sources && !data->input) {
    116120                    // Generate fake image with only a single realisation of the PSF
    117121                    sources = psArrayAlloc(1);
     
    137141                    psRegion *trimsec = psMetadataLookupPtr(NULL, cell->concepts, "CELL.TRIMSEC");
    138142                    *trimsec = psRegionSet(0, numCols, 0, numRows);
    139 
    140                     // We have trouble with PSF residuals in this case, so don't use them
    141                     psFree(psf->residuals);
    142                     psf->residuals = NULL;
    143143                }
    144144
     
    148148                }
    149149
    150                 if (!pmReadoutFakeFromSources(readout, numCols, numRows, sources, 0, xOffset, yOffset, psf,
    151                                               data->minFlux, 0, false, true)) {
    152                     psError(PS_ERR_UNKNOWN, false, "Unable to generate fake readout.");
    153                     return false;
     150                // We have trouble with PSF residuals, so don't use them
     151                psFree(psf->residuals);
     152                psf->residuals = NULL;
     153
     154                if (sources) {
     155                    if (!pmReadoutFakeFromSources(readout, numCols, numRows, sources, 0, xOffset, yOffset,
     156                                                  psf, data->minFlux, 0, false, true)) {
     157                        psError(PS_ERR_UNKNOWN, false, "Unable to generate fake readout.");
     158                        return false;
     159                    }
     160                } else if (data->input) {
     161                    psVector *x = data->input->data[0]; // x coordinates
     162                    psVector *y = data->input->data[1]; // y coordinates
     163                    psVector *mag = data->input->data[2]; // Magnitudes
     164                    if (!pmReadoutFakeFromVectors(readout, numCols, numRows, x, y, mag, xOffset, yOffset,
     165                                                  psf, data->minFlux, 0, false, true)) {
     166                        psError(PS_ERR_UNKNOWN, false, "Unable to generate fake readout.");
     167                        return false;
     168                    }
    154169                }
    155170
Note: See TracChangeset for help on using the changeset viewer.