IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 25983


Ignore:
Timestamp:
Nov 1, 2009, 3:58:41 PM (17 years ago)
Author:
eugene
Message:

add functions to read text source list

Location:
trunk/psphot/src
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/psphotDefineFiles.c

    r23688 r25983  
    126126    }
    127127
     128    if (psMetadataLookupPtr(NULL, config->arguments, "SRCTEXT")) {
     129        // XXX cannot use pmFPAfileDefineFromArgs: this is explicitly a FITS-based I/O function
     130        // supply the attach the
     131        if (!psphotLoadSRCTEXT(input->fpa, config)) {
     132            psError(PSPHOT_ERR_CONFIG, false, "Failed to load PSPHOT.INPUT.TEXT");
     133            return status;
     134        }
     135    }
     136
    128137    if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
    129138        pmFPAfileBindFromArgs(&status, input, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
  • trunk/psphot/src/psphotMergeSources.c

    r21519 r25983  
    44                         PM_SOURCE_MODE_BADPSF | PM_SOURCE_MODE_DEFECT | PM_SOURCE_MODE_SATURATED | \
    55                         PM_SOURCE_MODE_CR_LIMIT | PM_SOURCE_MODE_EXT_LIMIT) // Mask to apply for PSF sources
     6
     7// merge the externally supplied sources with the existing sources.  mark them as having
     8// mode PM_SOURCE_MODE_EXTERNAL
     9bool psphotLoadExtSources (pmConfig *config, const pmFPAview *view, psArray *sources) {
     10
     11    psArray *extSourcesCMF = NULL;
     12    psArray *extSourcesTXT = NULL;
     13
     14    // load data from input CMF file:
     15    {
     16        pmReadout *readoutCMF = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT.CMF");
     17        if (!readoutCMF) goto loadTXT;
     18
     19        extSourcesCMF = psMetadataLookupPtr (NULL, readoutCMF->analysis, "PSPHOT.SOURCES");
     20        if (extSourcesCMF) {
     21            for (int i = 0; i < extSourcesCMF->n; i++) {
     22                pmSource *source = extSourcesCMF->data[i];
     23                source->mode |= PM_SOURCE_MODE_EXTERNAL;
     24
     25                // the supplied peak flux needs to be re-normalized
     26                source->peak->flux = 1.0;
     27                source->peak->value = 1.0;
     28
     29                // drop the loaded source modelPSF
     30                psFree (source->modelPSF);
     31                source->modelPSF = NULL;
     32            }
     33            psphotMergeSources (sources, extSourcesCMF);
     34        }
     35    }
     36
     37loadTXT:
     38
     39    // load data from input TXT file:
     40    {
     41        pmChip *chipTXT = pmFPAfileThisChip (config->files, view, "PSPHOT.INPUT");
     42        if (!chipTXT) goto finish;
     43
     44        extSourcesTXT = psMetadataLookupPtr (NULL, chipTXT->analysis, "PSPHOT.SOURCES.TEXT");
     45        if (extSourcesTXT) {
     46            for (int i = 0; i < extSourcesTXT->n; i++) {
     47                pmSource *source = extSourcesTXT->data[i];
     48                source->mode |= PM_SOURCE_MODE_EXTERNAL;
     49
     50                // drop the loaded source modelPSF
     51                psFree (source->modelPSF);
     52                source->modelPSF = NULL;
     53            }
     54            psphotMergeSources (sources, extSourcesTXT);
     55        }
     56    }
     57
     58finish:
     59
     60    if (!extSourcesTXT && !extSourcesTXT) {
     61        psLogMsg ("psphot", 3, "no external sources for this readout");
     62        return true;
     63    }
     64
     65    int nCMF = extSourcesCMF ? extSourcesCMF->n : 0;
     66    int nTXT = extSourcesTXT ? extSourcesTXT->n : 0;
     67
     68    psLogMsg ("psphot", 3, "%d external sources (%d cmf, %d text) merged to yield %ld total sources",
     69              nCMF + nTXT, nCMF, nTXT, sources->n);
     70    return true;
     71}
    672
    773// add newly selected sources to the existing list of sources
     
    1278        psArrayAdd (oldSources, 100, source);
    1379    }
    14     return true;
    15 }
    16 
    17 // merge the externally supplied sources with the existing sources.  mark them as having
    18 // mode PM_SOURCE_MODE_EXTERNAL
    19 bool psphotLoadExtSources (pmConfig *config, const pmFPAview *view, psArray *sources) {
    20 
    21     // find the currently selected readout
    22     pmReadout  *readout = pmFPAfileThisReadout (config->files, view, "PSPHOT.INPUT.CMF");
    23     if (!readout) {
    24         psLogMsg ("psphot", 3, "no external sources supplied");
    25         return true;
    26     }
    27 
    28     psArray *extSources = psMetadataLookupPtr (NULL, readout->analysis, "PSPHOT.SOURCES");
    29     if (!extSources) {
    30         psLogMsg ("psphot", 3, "no external sources for this readout");
    31         return true;
    32     }
    33 
    34     for (int i = 0; i < extSources->n; i++) {
    35         pmSource *source = extSources->data[i];
    36         source->mode |= PM_SOURCE_MODE_EXTERNAL;
    37         pmModel *model = source->modelPSF;
    38 
    39         float xpos = model->params->data.F32[PM_PAR_XPOS];
    40         float ypos = model->params->data.F32[PM_PAR_YPOS];
    41 
    42         source->peak = pmPeakAlloc(xpos, ypos, 1.0, PM_PEAK_LONE);
    43         source->peak->xf = xpos;
    44         source->peak->yf = ypos;
    45         source->peak->flux = 1.0;
    46 
    47         // drop the loaded source modelPSF
    48         psFree (source->modelPSF);
    49         source->modelPSF = NULL;
    50     }
    51 
    52     psphotMergeSources (sources, extSources);
    53     psLogMsg ("psphot", 3, "%ld external sources merged to yield %ld total sources", extSources->n, sources->n);
    54 
    5580    return true;
    5681}
Note: See TracChangeset for help on using the changeset viewer.