IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12805


Ignore:
Timestamp:
Apr 11, 2007, 1:57:26 PM (19 years ago)
Author:
eugene
Message:

moved psphot library function prototypes to psphot.h, created psphotInternal.h and psphotStandAlone.h; moved file definitions into psphotDefineFiles.c

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

Legend:

Unmodified
Added
Removed
  • trunk/psphot/src/Makefile.am

    r12792 r12805  
    88psphot_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS)
    99psphot_LDADD = libpsphot.la
     10
    1011psphot_SOURCES = psphot.c       \
    1112        psphotArguments.c       \
     
    2021        psphotModelGroupInit.c  \
    2122        psphotMaskReadout.c     \
     23        psphotDefineFiles.c     \
    2224        psphotReadout.c         \
    2325        psphotImageMedian.c     \
     
    5658        psphotAddNoise.c
    5759
    58 
    5960include_HEADERS = \
    6061        psphot.h \
     
    6263
    6364noinst_HEADERS = \
    64         psphotInternal.h
     65        psphotInternal.h \
     66        psphotStandAlone.h
    6567
    6668clean-local:
  • trunk/psphot/src/psphot.c

    r12792 r12805  
    1 # include "psphotInternal.h"
     1# include "psphotStandAlone.h"
    22
    33static void usage (void) {
  • trunk/psphot/src/psphot.h

    r12792 r12805  
    1 # ifdef HAVE_CONFIG_H
    2 # include <config.h>
    3 # endif
     1/* This file defines the library functions available to external programs.  It must be included
     2 * by programs which are compiled against psphot functions.
     3 */
    44
    5 #ifndef PS_PHOT_H
    6 #define PS_PHOT_H
    7 
    8 #include <stdio.h>
    9 #include <pslib.h>
    10 #include <psmodules.h>
     5#ifndef PSPHOT_H
     6#define PSPHOT_H
    117
    128#include "psphotErrorCodes.h"
     
    1410
    1511// top-level psphot functions
    16 const char *psphotCVSName(void);
    17 psString psphotVersion(void);
    18 psString psphotVersionLong(void);
     12const char     *psphotCVSName(void);
     13psString        psphotVersion(void);
     14psString        psphotVersionLong(void);
    1915
    2016bool            psphotModelTest (pmReadout *readout, psMetadata *recipe);
    2117bool            psphotReadout (pmConfig *config, pmFPAview *view);
    2218bool            psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources);
     19bool            psphotDefineFiles (pmConfig *config, pmFPAfile *input);
     20
     21// XXX test functions
     22bool            psphotTestPSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
     23bool            pmPSFtestModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask);
     24
     25psArray        *psphotFakeSources ();
     26
     27// psphotReadout functions
     28bool            psphotImageMedian (pmConfig *config, pmFPAview *view);
     29psArray        *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, int pass);
     30psArray        *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *allpeaks);
     31bool            psphotRoughClass (psArray *sources, psMetadata *recipe);
     32bool            psphotBasicDeblend (psArray *sources, psMetadata *recipe);
     33pmPSF          *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
     34bool            psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
     35bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
     36bool            psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
     37bool            psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
     38bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
     39bool            psphotReplaceUnfit (psArray *sources);
     40bool            psphotReplaceAll (psArray *sources);
     41bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
     42bool            psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf, pmReadout *background);
     43bool            psphotSkyReplace (pmConfig *config, pmFPAview *view);
     44
     45// basic support functions
     46void            psphotModelGroupInit (void);
     47int             psphotSortBySN (const void **a, const void **b);
     48int             psphotSortByY (const void **a, const void **b);
     49bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore);
     50void            psphotTestArguments (int *argc, char **argv);
     51bool            psphotMaskReadout (pmReadout *readout, psMetadata *recipe);
     52void            psphotSourceFreePixels (psArray *sources);
     53
     54// functions to set the correct source pixels
     55bool            psphotInitRadiusPSF (const psMetadata *recipe, const pmModelType type);
     56bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model);
     57bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR);
     58bool            psphotInitRadiusEXT (psMetadata *recipe, pmModelType type);
     59bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model);
     60
     61// output functions
     62bool            psphotAddPhotcode (psMetadata *recipe, pmConfig *config, pmFPAview *view);
     63bool            psphotDumpMoments (psMetadata *recipe, psArray *sources);
     64psMetadata     *psphotDefineHeader (psMetadata *recipe);
     65bool            psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
     66int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
     67bool            psphotDumpConfig (pmConfig *config);
     68pmReadout      *psphotSelectBackground (pmConfig *config, pmFPAview *view);
     69
     70// PSF / DBL / EXT evaluation functions
     71bool            psphotEvalPSF (pmSource *source, pmModel *model);
     72bool            psphotEvalDBL (pmSource *source, pmModel *model);
     73bool            psphotEvalEXT (pmSource *source, pmModel *model);
     74
     75//  functions to support the source fitting process
     76bool            psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout);
     77bool            psphotInitLimitsEXT (psMetadata *recipe);
     78bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf);
     79bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf);
     80bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf);
     81pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source);
     82psArray        *psphotFitDBL (pmReadout *readout, pmSource *source);
     83
     84// functions to support simultaneous multi-source fitting
     85bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode);
     86
     87// plotting functions (available if libkapa is installed)
     88bool            psphotPlotMoments (pmConfig *config, pmFPAview *view, psArray *sources);
     89bool            psphotPlotPSFModel (pmConfig *config, pmFPAview *view, psArray *sources);
     90bool            psphotFitInit ();
     91bool            psphotFitSummary ();
     92bool            psphotMergeSources (psArray *oldSources, psArray *newSources);
     93bool            psphotLoadExtSources (pmConfig *config, pmFPAview *view, psArray *sources);
     94bool            psphotSetHeaderNstars (psMetadata *recipe, psArray *sources);
     95bool            psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add);
     96bool            psphotRadialPlot (int *kapa, char *filename, pmSource *source);
     97bool            psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe);
     98bool            psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY);
     99
     100bool            psphotAddWithTest (pmSource *source, bool useState);
     101bool            psphotSubWithTest (pmSource *source, bool useState);
     102bool            psphotSetState (pmSource *source, bool curState);
     103bool            psphotDeblendSatstars (psArray *sources, psMetadata *recipe);
    23104
    24105#endif
  • trunk/psphot/src/psphotArguments.c

    r12792 r12805  
    1 # include "psphotInternal.h"
     1# include "psphotStandAlone.h"
    22
    33pmConfig *psphotArguments(int argc, char **argv) {
  • trunk/psphot/src/psphotCleanup.c

    r12792 r12805  
    1 # include "psphotInternal.h"
     1# include "psphotStandAlone.h"
    22
    33void psphotCleanup (pmConfig *config) {
  • trunk/psphot/src/psphotImageLoop.c

    r12792 r12805  
    1 # include "psphotInternal.h"
     1# include "psphotStandAlone.h"
    22
    33bool psphotImageLoop (pmConfig *config) {
  • trunk/psphot/src/psphotInternal.h

    r12792 r12805  
     1/* this file is included by the internal, library functions. */
     2
    13#ifdef HAVE_CONFIG_H
    24#include <config.h>
    35#endif
    46
    5 #ifndef PS_PHOT_INTERNAL_H
    6 #define PS_PHOT_INTERNAL_H
     7#ifndef PSPHOT_INTERNAL_H
     8#define PSPHOT_INTERNAL_H
    79
    810#include <stdio.h>
     
    1113#include <pslib.h>
    1214#include <psmodules.h>
    13 
    1415#include "psphot.h"
    1516
    16 // Top level functions
    17 pmConfig       *psphotArguments (int argc, char **argv);
    18 bool            psphotParseCamera (pmConfig *config);
    19 bool            psphotImageLoop (pmConfig *config);
    20 bool            psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile);
    21 void            psphotCleanup (pmConfig *config);
    22 
    23 // XXX test functions
    24 bool psphotTestPSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
    25 bool pmPSFtestModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask);
    26 
    27 psArray        *psphotFakeSources ();
    28 
    29 // psphotReadout functions
    30 bool            psphotImageMedian (pmConfig *config, pmFPAview *view);
    31 psArray        *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, int pass);
    32 psArray        *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *allpeaks);
    33 bool            psphotRoughClass (psArray *sources, psMetadata *recipe);
    34 bool            psphotBasicDeblend (psArray *sources, psMetadata *recipe);
    35 pmPSF          *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
    36 bool            psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
    37 bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
    38 bool            psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
    39 bool            psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
    40 bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
    41 bool            psphotReplaceUnfit (psArray *sources);
    42 bool            psphotReplaceAll (psArray *sources);
    43 bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
    44 bool            psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf, pmReadout *background);
    45 bool            psphotSkyReplace (pmConfig *config, pmFPAview *view);
    46 
    47 // basic support functions
    48 void            psphotModelGroupInit (void);
    49 int             psphotSortBySN (const void **a, const void **b);
    50 int             psphotSortByY (const void **a, const void **b);
    51 bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore);
    52 void            psphotTestArguments (int *argc, char **argv);
    53 bool            psphotMaskReadout (pmReadout *readout, psMetadata *recipe);
    54 void            psphotSourceFreePixels (psArray *sources);
    55 
    56 // functions to set the correct source pixels
    57 bool            psphotInitRadiusPSF (const psMetadata *recipe, const pmModelType type);
    58 bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model);
    59 bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR);
    60 bool            psphotInitRadiusEXT (psMetadata *recipe, pmModelType type);
    61 bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model);
    62 
    63 // output functions
    64 bool            psphotAddPhotcode (psMetadata *recipe, pmConfig *config, pmFPAview *view);
    65 bool            psphotDumpMoments (psMetadata *recipe, psArray *sources);
    66 psMetadata     *psphotDefineHeader (psMetadata *recipe);
    67 bool            psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
    68 int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
    69 bool psphotDumpConfig (pmConfig *config);
    70 pmReadout *psphotSelectBackground (pmConfig *config, pmFPAview *view);
    71 
    72 // PSF / DBL / EXT evaluation functions
    73 bool            psphotEvalPSF (pmSource *source, pmModel *model);
    74 bool            psphotEvalDBL (pmSource *source, pmModel *model);
    75 bool            psphotEvalEXT (pmSource *source, pmModel *model);
    76 
    77 //  functions to support the source fitting process
    78 bool            psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout);
    79 bool            psphotInitLimitsEXT (psMetadata *recipe);
    80 bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf);
    81 bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf);
    82 bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf);
    83 pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source);
    84 psArray        *psphotFitDBL (pmReadout *readout, pmSource *source);
    85 
    86 // functions to support simultaneous multi-source fitting
    87 bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode);
    88 
    89 // plotting functions (available if libkapa is installed)
    90 bool psphotPlotMoments (pmConfig *config, pmFPAview *view, psArray *sources);
    91 bool psphotPlotPSFModel (pmConfig *config, pmFPAview *view, psArray *sources);
    92 
    93 bool psphotFitInit ();
    94 bool psphotFitSummary ();
    95 bool psphotMergeSources (psArray *oldSources, psArray *newSources);
    96 bool psphotLoadExtSources (pmConfig *config, pmFPAview *view, psArray *sources);
    97 psExit psphotGetExitStatus ();
    98 bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources);
    99 bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add);
    100 bool psphotRadialPlot (int *kapa, char *filename, pmSource *source);
    101 bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe);
    102 bool psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY);
    103 
    104 bool psphotAddWithTest (pmSource *source, bool useState);
    105 bool psphotSubWithTest (pmSource *source, bool useState);
    106 bool psphotSetState (pmSource *source, bool curState);
    107 bool psphotDeblendSatstars (psArray *sources, psMetadata *recipe);
    108 
    109 
    11017#endif
  • trunk/psphot/src/psphotParseCamera.c

    r12792 r12805  
    1 # include "psphotInternal.h"
     1# include "psphotStandAlone.h"
    22
    33// define the needed / desired I/O files
     
    1515    load->dataLevel = PM_FPA_LEVEL_CHIP; // force load at the CHIP level
    1616
     17    // if MASK or WEIGHT was supplied on command line, bind files to 'load'
     18    // the mask and weight will be mosaicked with the image
     19    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.MASK",   "MASK");
     20    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.WEIGHT", "WEIGHT");
     21
    1722    // the psphot analysis is performed on chips
    1823    pmFPAfile *input = pmFPAfileDefineChipMosaic(config, load->fpa, "PSPHOT.INPUT");
     
    2227    }
    2328
    24     // if we have requested PSPHOT.SRC, attempt to resolve it
    25     // this is a list of input sources, stored in a psphot output format file
    26 # if (0)   
    27     if (psMetadataLookupPtr(NULL, config->arguments, "SRC")) {
    28         pmFPAfileDefineFromArgs (&status, config, "PSPHOT.SRC", "SRC");
    29         if (!status) {
    30             psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.SRC");
    31             return status;
    32         }
     29    // define the additional input/output files associated with psphot
     30    if (!psphotDefineFiles (config, input)) {
     31        psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files");
     32        return false;
    3333    }
    34 # endif
    35 
    36     // select recipe options supplied on command line
    37     psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
    38 
    39     // these values are used below to define the background subtraction images.
    40 
    41     // if MASK or WEIGHT was supplied on command line, bind files to input fpa
    42     // XXX these do not quite yet work: pmFPAAddSourceFromHeader is not appropriate
    43     // the mask and weight will be mosaic'ed with the image
    44     pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.MASK",   "MASK");
    45     pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.WEIGHT", "WEIGHT");
    46 
    47     // optionally load the PSF Model and/or fixed stars
    48     // XXX bind this to the input or the load file?
    49     // if the readout->analysis entries are copied, we can bind to the load file
    50     // XXX add this back in later
    51     // pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF");
    52 
    53     // XXX we need to be able to distinguish several cases:
    54     // 1) the particular output data was not requested
    55     // 2) the particular output data was requested but was not generated (skipped)
    56     // 3) the particular output data was requested but was not generated (for valid failure)
    57     // 4) the particular output data was requested but was not generated (surprising failure)
    58 
    59     // the output sources are carried on the input->fpa structures
    60     if (psMetadataLookupBool (NULL, recipe, "SAVE.OUTPUT")) {
    61         if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT")) {
    62             psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.OUTPUT");
    63             return false;
    64         }
    65     }
    66     // optionally save the residual image
    67     if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) {
    68         if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.RESID")) {
    69             psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
    70             return false;
    71         }
    72     }
    73     // optionally save the background model (small FITS image)
    74     if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
    75         int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
    76         int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
    77         if (!pmFPAfileDefineFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL")) {
    78             psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
    79             return false;
    80         }
    81     }
    82     // optionally save the full background image
    83     if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) {
    84         if (!pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKGND")) {
    85             psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKGND");
    86             return false;
    87         }
    88     }
    89     // optionally save the background-subtracted image
    90     if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) {
    91         if (!pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKSUB")) {
    92             psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.");
    93             return false;
    94         }
    95     }
    96     // optionally save the PSF Model
    97     if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) {
    98         if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.PSF.SAVE")) {
    99             psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.PSF.SAVE");
    100             return false;
    101         }
    102     }
    103 
    104     // optionally save output plots
    105     if (psMetadataLookupBool(NULL, recipe, "SAVE.PLOTS")) {
    106         if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.MOMENTS")) {
    107             psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.MOMENTS");
    108         }
    109         if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.PSFMODEL")) {
    110             psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.PSFMODEL");
    111         }
    112     }
    113 
    114     // XXX add in example PSF image thumbnails
    115     // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE");
    11634
    11735    // Chip selection: turn on only the chips specified (pass status to suppress missing-key log msg)
  • trunk/psphot/src/psphotVersion.c

    r12792 r12805  
    1 #include "psphotInternal.h"
     1# include "psphotInternal.h"
    22
    33# if (HAVE_KAPA)
Note: See TracChangeset for help on using the changeset viewer.