IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 35521


Ignore:
Timestamp:
May 6, 2013, 10:32:51 AM (13 years ago)
Author:
eugene
Message:

remove superfulous ppStats.h includes; generate output psf model

Location:
branches/eam_branches/ipp-20130419/pswarp/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130419/pswarp/src/Makefile.am

    r35512 r35521  
    3939        pswarpErrorCodes.c              \
    4040        pswarpLoadAstrometry.c          \
     41        pswarpMakePSF.c                 \
    4142        pswarpMapGrid.c                 \
    4243        pswarpMaskStats.c               \
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarp.h

    r35512 r35521  
    2222#include <psmodules.h>
    2323#include <psphot.h>
     24#include <ppStats.h>
    2425
    2526#define THREADED 1
     
    198199
    199200bool pswarpTransformToTarget (pmFPA *output, pmReadout *input, pmConfig *config);
    200 bool pswarpMakePSF (pmFPA *output);
     201bool pswarpMakePSF (pmConfig *config, pmFPAfile *output, psMetadata *stats);
    201202bool pswarpUpdateStatistics (pmFPA *output, psMetadata *stats, pmFPA *input, pmFPA *astrom, pmConfig *config);
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpCleanup.c

    r35515 r35521  
    1919    // Ensure everything is written out, at every level
    2020    pswarpFileActivation(config, detectorFiles, false);
    21     pswarpFileActivation(config, photFiles, false);
    2221    pswarpFileActivation(config, independentFiles, false);
    2322
     23    pswarpFileActivation(config, photFiles, true);
    2424    pswarpFileActivation(config, skycellFiles, true);
    2525    pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.SOURCES");
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpLoop.c

    r35515 r35521  
    1111
    1212#include "pswarp.h"
    13 #include <ppStats.h>
    1413#include "pswarpFileNames.h"            // Lists of file rules used at different stages
    15 
    16 #define WCS_NONLIN_TOL 0.001            // Non-linear tolerance for header WCS
    17 #define TESTING 0                       // Testing output?
    1814
    1915// Loop over the inputs, warp them to the output skycell and then write out the output.
     
    3329    }
    3430
    35     // XXX this should probably happen elsewhere (logically it belongs to file I/O, right?)
     31    // XXX move this to pswarpParseCamera?  has to come after input mask header is read
    3632    if (!pswarpSetMaskBits(config)) {
    3733        psError(psErrorCodeLast(), false, "failed to set mask bits");
     
    7066        return false;
    7167    }
    72 
    73     // XXX NOTE : 'output' was a readout, now we need to loop over all output targets
    7468
    7569    // ensure everyone is off except what we need below
     
    7973    pswarpFileActivation(config, skycellFiles, false);
    8074   
    81     // Turn on the source output --- we need to get rid of these so that we can measure the PSF
    82     // XXX NOTE : do not tackle source issues yet...
    83     // XXX pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.SOURCES");
    84 
    8575    // the loops below load the input data
    8676    pswarpFileActivation(config, detectorFiles, true);
     
    9080
    9181    // pswarpFileActivation(config, independentFiles, true);
    92 
    9382
    9483    pmFPAview *view = pmFPAviewAlloc(0);
     
    171160    }
    172161
    173     // XXXX turn these on later .. pswarpMakePSF (output);
    174     // XXX have not yet written the output to disk
     162    if (!pswarpMakePSF (config, output, stats)) {
     163      psError(psErrorCodeLast(), false, "problem generating PSF.");
     164      goto FAIL;
     165    }
     166
    175167    psFree(view);
    176168    return true;
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpMakePSF.c

    r35511 r35521  
    1111
    1212#include "pswarp.h"
    13 #include <ppStats.h>
    14 #include "pswarpFileNames.h"            // Lists of file rules used at different stages
    1513
    1614#define WCS_NONLIN_TOL 0.001            // Non-linear tolerance for header WCS
     
    1917// We need a new PSF model for the warped frame.  It would be good to generate this analytically, but
    2018// that's going to be tricky.  We have a list of sources, so we use those to redetermine the PSF model.
    21 bool pswarpMakePSF (pmConfig *config) {
     19
     20bool pswarpMakePSF (pmConfig *config, pmFPAfile *output, psMetadata *stats) {
     21
     22    bool status = false;
    2223
    2324    // load the recipe
     
    2829    }
    2930
    30     if (psMetadataLookupBool(&mdok, recipe, "PSF")) {
    31         pswarpFileActivation(config, photFiles, true);
    32         if (!pswarpIOChecksBefore(config)) {
    33             psError(psErrorCodeLast(), false, "Unable to read files.");
    34             goto DONE;
    35         }
     31    if (!psMetadataLookupBool(&status, recipe, "PSF")) {
     32        psLogMsg("pswarp", PS_LOG_INFO, "Skipping PSF measurement");
     33        return true;
     34    }
    3635
    37         // supply the readout and fpa of interest to psphot
    38         pmFPAfile *photFile = psMetadataLookupPtr(NULL, config->files, "PSPHOT.INPUT");
    39         pmFPACopy(photFile->fpa, outFPA);
     36    // XXX What was being read here??  skip this for now
     37    if (false && !pswarpIOChecksBefore(config)) {
     38        psError(psErrorCodeLast(), false, "Unable to read files.");
     39        return false;
     40    }
    4041
    41         pmFPAview *view = pmFPAviewAlloc(0); ///< View into skycell
    42         view->chip = view->cell = view->readout = 0;
     42    // supply the readout and fpa of interest to psphot
     43    pmFPAfile *photFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.INPUT");
     44    pmFPACopy(photFile->fpa, output->fpa);
    4345
    44         // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF)
    45         psArray *sources = psphotLoadPSFSources (config, view);
    46         if (!sources) {
    47             psError(psErrorCodeLast(), false, "No sources supplied to measure PSF");
    48             goto DONE;
    49         }
     46    pmFPAview *view = pmFPAviewAlloc(0); ///< View into skycell
    5047
    51         pmModelClassSetLimits(PM_MODEL_LIMITS_STRICT);
     48    pmChip *chip;
     49    while ((chip = pmFPAviewNextChip (view, photFile->fpa, 1)) != NULL) {
     50        psTrace ("pswarpMakePSF", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     51        if (!chip->process || !chip->file_exists) { continue; }
    5252
    53         // measure the PSF using these sources
    54         if (!psphotReadoutFindPSF(config, view, "PSPHOT.INPUT", sources)) {
    55             // This is likely a data quality issue
    56             // XXX Split into multiple cases using error codes?
    57             psErrorStackPrint(stderr, "Unable to determine PSF");
    58             psWarning("Unable to determine PSF --- suspect bad data quality.");
    59             if (stats && psMetadataLookupS32(NULL, stats, "QUALITY") == 0) {
    60                 psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE,
    61                                  "Unable to determine PSF", psErrorCodeLast());
    62             }
    63             psErrorClear();
    64             psphotFilesActivate(config, false);
    65         }
     53        pmCell *cell;
     54        while ((cell = pmFPAviewNextCell (view, photFile->fpa, 1)) != NULL) {
     55            psTrace ("pswarpMakePSF", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     56            if (!cell->process || !cell->file_exists) { continue; }
    6657
    67         // Ensure seeing is carried over
    68         pmChip *photChip = pmFPAviewThisChip(view, photFile->fpa);                 // Chip with seeing
    69         psMetadataItem *item = psMetadataLookup(outChip->concepts, "CHIP.SEEING"); // Concept with seeing
    70         item->data.F32 = psMetadataLookupF32(NULL, photChip->concepts, "CHIP.SEEING");
     58            // process each of the readouts
     59            pmReadout *readout;
     60            while ((readout = pmFPAviewNextReadout(view, photFile->fpa, 1)) != NULL) {
     61                if (!readout->data_exists) {
     62                    continue;
     63                }
    7164
    72 // XXX EAM : put this in a visualization function
    73 #if (TESTING)
    74         {
    75             #define PSF_SIZE 20         ///< Half-size of PSF
    76             #define PSF_FLUX 10000      ///< Central flux for PSF
    77             pmChip *photChip = pmFPAviewThisChip(view, photFile->fpa);
    78             pmPSF *psf = psMetadataLookupPtr(NULL, photChip->analysis, "PSPHOT.PSF");
    79             psImage *image = psImageAlloc(2 * PSF_SIZE + 1, 2 * PSF_SIZE + 1, PS_TYPE_F32);
    80             psImageInit(image, 0);
    81             pmModel *model = pmModelFromPSFforXY(psf, PSF_SIZE, PSF_SIZE, PSF_FLUX);
    82             pmModelAdd(image, NULL, model, PM_MODEL_OP_FULL, 0);
    83             psFree(model);
    84             psFits *fits = psFitsOpen("psf.fits", "w");
    85             psFitsWriteImage(fits, NULL, image, 0, NULL);
    86             psFitsClose(fits);
    87             psFree(image);
    88         }
    89 #endif
     65                // grab the sources of interest from the storage location (pmFPAfile PSPHOT.INPUT.CMF)
     66                psArray *sources = psphotLoadPSFSources (config, view);
     67                if (!sources) {
     68                    // psError(psErrorCodeLast(), false, "No sources supplied to measure PSF");
     69                    psLogMsg ("psphot", 3, "no psf sources for this readout (%d %d %d)", view->chip, view->cell, view->readout);
     70                    continue;
     71                }
    9072
    91         psFree(view);
     73                // XXX move above the loop
     74                pmModelClassSetLimits(PM_MODEL_LIMITS_STRICT);
     75               
     76                // measure the PSF using these sources
     77                if (!psphotReadoutFindPSF(config, view, "PSPHOT.INPUT", sources)) {
     78                    // A failure is likely a data quality issue.  raise a quality flag, but do not skip other readouts
     79                    // XXX Split into multiple cases using error codes?
     80                    psErrorStackPrint(stderr, "Unable to determine PSF for readout (%d %d %d)", view->chip, view->cell, view->readout);
     81                    psWarning("Unable to determine PSF --- suspect bad data quality : readout (%d %d %d)", view->chip, view->cell, view->readout);
     82                    if (stats) {
     83                        int currentQuality = psMetadataLookupS32(&status, stats, "QUALITY");
     84                        if (currentQuality == 0) {
     85                            psMetadataAddS32(stats, PS_LIST_TAIL, "QUALITY", PS_META_REPLACE, "Unable to determine PSF", psErrorCodeLast());
     86                        }
     87                    }
     88                    psErrorClear();
     89                }
     90            }
     91        }
     92
     93        // Ensure seeing is carried over from the PSPHOT.INPUT chip to the output chip
     94        pmChip *outChip = pmFPAviewThisChip(view, output->fpa); // Chip with seeing
     95        psMetadataItem *item = psMetadataLookup(outChip->concepts, "CHIP.SEEING"); // Concept with seeing
     96        item->data.F32 = psMetadataLookupF32(&status, chip->concepts, "CHIP.SEEING");
    9297    }
     98
     99    // XXX test function found below
     100    // pswarpMakePSF_test ();
     101
     102    psFree(view);
     103    return true;
     104}
     105
     106# if (0)
     107bool pswarpMakePSF_test () {
     108
     109#define PSF_SIZE 20         ///< Half-size of PSF
     110#define PSF_FLUX 10000      ///< Central flux for PSF
     111    pmChip *photChip = pmFPAviewThisChip(view, photFile->fpa);
     112    pmPSF *psf = psMetadataLookupPtr(NULL, photChip->analysis, "PSPHOT.PSF");
     113    psImage *image = psImageAlloc(2 * PSF_SIZE + 1, 2 * PSF_SIZE + 1, PS_TYPE_F32);
     114    psImageInit(image, 0);
     115    pmModel *model = pmModelFromPSFforXY(psf, PSF_SIZE, PSF_SIZE, PSF_FLUX);
     116    pmModelAdd(image, NULL, model, PM_MODEL_OP_FULL, 0);
     117    psFree(model);
     118    psFits *fits = psFitsOpen("psf.fits", "w");
     119    psFitsWriteImage(fits, NULL, image, 0, NULL);
     120    psFitsClose(fits);
     121    psFree(image);
    93122    return true;
    94123}
    95124# endif
    96 
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpMaskStats.c

    r35512 r35521  
    11#include "pswarp.h"
    2 #include <ppStats.h>
    32
    43bool pswarpMaskStats(const pmReadout *readout, psMetadata *stats, const pmConfig *config)
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpParseCamera.c

    r35514 r35521  
    179179    }
    180180   
    181     /// XXX re-enable after sources work
    182     if (false && psMetadataLookupBool(&mdok, recipe, "PSF")) {
     181    if (psMetadataLookupBool(&mdok, recipe, "PSF")) {
    183182        // This file, PSPHOT.INPUT, is just used as a carrier; output files (eg, PSPHOT.RESID) are defined by
    184183        // psphotDefineFiles
    185         pmFPAfile *psphotInput = pmFPAfileDefineSkycell(config, NULL, "PSPHOT.INPUT");
     184        // XXX old : pmFPAfile *psphotInput = pmFPAfileDefineSkycell(config, NULL, "PSPHOT.INPUT");
     185        pmFPAfile *psphotInput = pmFPAfileDefineOutputForFormat(config, NULL, "PSPHOT.INPUT", skycell->cameraName, skycell->formatName);
    186186        if (!psphotInput) {
    187187            psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT"));
     
    189189        }
    190190        psphotInput->src = psMemIncrRefCounter(output->fpa);
    191         // specify the number of psphot input images
     191
     192        // specify the number of psphot input images (psphotReadout loops over all input images)
    192193        psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
    193194
    194         pmFPAfile *psphotInSources = pmFPAfileDefineSkycell(config, output->fpa, "PSPHOT.INPUT.CMF");
     195        // the input sources (read from the input astrometry file) are transformed (in pswarpLoop) to the readout->analysis
     196        // entries of the output file PSWARP.OUTPUT.SOURCES, associated with the main output pmFPAfile PSWARP.OUTPUT
     197
     198        // the PSPHOT.INPUT.CMF is used to supply those sources to psphot (specifically psphotLoadPSFSources). 
     199
     200        // pmFPAfile *psphotInSources = pmFPAfileDefineSkycell(config, output->fpa, "PSPHOT.INPUT.CMF");
     201        pmFPAfile *psphotInSources = pmFPAfileDefineOutputForFormat(config, output->fpa, "PSPHOT.INPUT.CMF", skycell->cameraName, skycell->formatName);
    195202        if (!psphotInSources) {
    196203            psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT.CMF"));
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpUpdateStatistics.c

    r35511 r35521  
    1111
    1212#include "pswarp.h"
    13 #include <ppStats.h>
    1413
    1514// once the output fpa elements have been built, loop over the fpa and generate stats
  • branches/eam_branches/ipp-20130419/pswarp/src/pswarpVersion.c

    r28043 r35521  
    1313#include <config.h>
    1414#endif
    15 
    16 #include <stdio.h>
    17 #include <pslib.h>
    18 #include <psmodules.h>
    19 #include <psphot.h>
    20 #include <ppStats.h>
    2115
    2216#include "pswarp.h"
Note: See TracChangeset for help on using the changeset viewer.