IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14000


Ignore:
Timestamp:
Jul 3, 2007, 10:01:23 AM (19 years ago)
Author:
eugene
Message:

consolidating includes in ppImage.h; adding ppImageMetadataStats and ppImagePixelStats

Location:
trunk/ppImage/src
Files:
3 added
4 deleted
9 edited

Legend:

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

    r13970 r14000  
    44
    55noinst_HEADERS = \
    6         ppImage.h \
    7         ppImageOptions.h \
    8         ppImageDetrendFringe.h \
    9         ppImageVersion.h
     6        ppImage.h
    107
    118ppImage_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(ppImage_CFLAGS)
     
    2724        ppImageAddstar.c \
    2825        ppImageStats.c \
     26        ppImageStatsOutput.c \
     27        ppImagePixelStats.c \
     28        ppImageMetadataStats.c \
    2929        ppImageDefineFile.c \
     30        ppImageFileCheck.c \
    3031        ppImageVersion.c
    3132
     
    5051        ppImageAddstar.c \
    5152        ppImageStats.c \
     53        ppImageStatsOutput.c \
     54        ppImagePixelStats.c \
     55        ppImageMetadataStats.c \
    5256        ppImageDefineFile.c \
     57        ppImageFileCheck.c \
    5358        ppImageVersion.c
    5459
  • trunk/ppImage/src/ppImage.c

    r13901 r14000  
    4545    return PS_EXIT_SUCCESS;
    4646}
    47 
    48 void ppImageFileCheck (pmConfig *config) {
    49 
    50     // add the output names to the output-type files
    51     psMetadataItem *item = NULL;
    52     psMetadataIterator *iter = psMetadataIteratorAlloc (config->files, PS_LIST_HEAD, NULL);
    53     while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
    54         pmFPAfile *file = item->data.V;
    55         pmFPA *fpa = file->fpa;
    56         fprintf (stderr, "file %s\n", file->name);
    57         if (!fpa) {
    58             fprintf (stderr, "  has no FPA\n");
    59             continue;
    60         }
    61         if (fpa->hdu) {
    62             if (fpa->hdu->images) fprintf (stderr, "  (%d,%d) images\n", -1, -1);
    63             if (fpa->hdu->weights) fprintf (stderr, "  (%d,%d) weights\n", -1, -1);
    64             if (fpa->hdu->masks) fprintf (stderr, "  (%d,%d) masks\n", -1, -1);
    65             if (fpa->hdu->header) fprintf (stderr, "  (%d,%d) header\n", -1, -1);
    66         } else {
    67             // fprintf (stderr, "  has no fpa data (%d,%d)\n", -1, -1);
    68         }
    69         for (int i = 0; i < fpa->chips->n; i++) {
    70             pmChip *chip = fpa->chips->data[i];
    71             if (chip->hdu) {
    72                 if (chip->hdu->images) fprintf (stderr, "  (%d,%d) images\n", i, -1);
    73                 if (chip->hdu->weights) fprintf (stderr, "  (%d,%d) weights\n", i, -1);
    74                 if (chip->hdu->masks) fprintf (stderr, "  (%d,%d) masks\n", i, -1);
    75                 if (chip->hdu->header) fprintf (stderr, "  (%d,%d) header\n", i, -1);
    76             } else {
    77                 // fprintf (stderr, "  has no chip data (%d,%d)\n", i, -1);
    78             }
    79             for (int j = 0; j < chip->cells->n; j++) {
    80                 pmCell *cell = chip->cells->data[j];
    81                 if (cell->hdu) {
    82                     if (cell->hdu->images) fprintf (stderr, "  (%d,%d) images\n", i, j);
    83                     if (cell->hdu->weights) fprintf (stderr, "  (%d,%d) weights\n", i, j);
    84                     if (cell->hdu->masks) fprintf (stderr, "  (%d,%d) masks\n", i, j);
    85                     if (cell->hdu->header) fprintf (stderr, "  (%d,%d) header\n", i, j);
    86                 } else {
    87                     // fprintf (stderr, "  has no cell data (%d,%d)\n", i, j);
    88                 }
    89                 for (int k = 0; k < cell->readouts->n; k++) {
    90                     pmReadout *readout = cell->readouts->data[k];
    91                     if (readout) {
    92                         if (readout->image) fprintf (stderr, "  (%d,%d,%d) image\n", i, j, k);
    93                         if (readout->weight) fprintf (stderr, "  (%d,%d,%d) weight\n", i, j, k);
    94                         if (readout->mask) fprintf (stderr, "  (%d,%d,%d) masks\n", i, j, k);
    95                     }
    96                 }
    97             }
    98         }
    99     }
    100     psFree (iter);
    101 }
  • trunk/ppImage/src/ppImage.h

    r13970 r14000  
    1414#include "psphot.h"
    1515#include "psastro.h"
    16 #include "ppImageOptions.h"
     16#include "ppStats.h"
    1717
    1818#define RECIPE_NAME "PPIMAGE"           // Name of the recipe to use
    1919#define TIMERNAME "ppImage"             // Name of timer
     20
     21// Options for ppImage processing
     22typedef struct {
     23    bool doMask;                        // Mask bad pixels
     24    psMaskType maskValue;               // apply this bit-mask to choose masked bits
     25    psMaskType satMask;                 // Mask value to give saturated pixels
     26    psMaskType badMask;                 // Mask value to give bad pixels
     27    psMaskType flatMask;                // Mask value to give bad flat pixels
     28    psMaskType blankMask;               // Mask value to give blank pixels
     29
     30    bool doBias;                        // Bias subtraction
     31    bool doDark;                        // Dark subtraction
     32    bool doShutter;                     // Shutter correction
     33    bool doFlat;                        // Flat-field normalisation
     34    bool doFringe;                      // Fringe subtraction
     35    bool doPhotom;                      // Source identification and photometry
     36    bool doAstromChip;                  // per-chip Astrometry
     37    bool doAstromMosaic;                // full-mosaic Astrometry
     38    bool doAddstar;                     // add results to object database?
     39
     40    bool doOverscan;                    // Overscan subtraction
     41    pmOverscanOptions *overscan;        // Overscan options
     42
     43    bool doNonLin;                      // Non-linearity correction
     44    psDataType nonLinearType;
     45    psMetadataItem *nonLinearData;
     46    void *nonLinearSource;
     47
     48    bool doStats;
     49
     50    bool BaseFITS;
     51    bool ChipFITS;
     52    bool FPA1FITS;
     53    bool FPA2FITS;
     54
     55    bool Bin1FITS;
     56    bool Bin1JPEG;
     57    int xBin1, yBin1;
     58
     59    bool Bin2FITS;
     60    bool Bin2JPEG;
     61    int xBin2, yBin2;
     62
     63    float fringeRej;                    // Fringe rejection limit
     64    int fringeIter;                     // Fringe iterations
     65    float fringeKeep;                   // Fringe keep fraction
     66} ppImageOptions;
     67
     68// Cells to be used in the detrend
     69typedef struct {
     70    pmCell *input;                      // The input cell, to be operated upon
     71    pmCell *mask;                       // The bad pixel mask
     72    pmCell *bias;                       // The bias correction
     73    pmCell *dark;                       // The dark correction
     74    pmCell *flat;                       // The flat-field correction
     75} ppImageDetrend;
     76
     77ppImageOptions *ppImageOptionsAlloc(void);
     78
     79// Determine the processing options
     80ppImageOptions *ppImageOptionsParse(pmConfig *config);
    2081
    2182// Get the configuration
     
    3596
    3697bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options);
    37 bool ppImageDetrendMask(pmReadout *input, pmReadout *mask);
    3898
    3999bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options);
    40100bool ppImageDetrendNonLinearLookup(pmReadout *input, psMetadataItem *dataItem);
    41101bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem);
     102
     103bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config);
     104bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options);
     105pmReadout* ppImageDetrendSelectFirst(pmCell *cell, char *name, bool doThis);
    42106
    43107bool ppImageRebinChip (pmConfig *config, pmFPAview *view, char *outName);
     
    69133
    70134// write stats to output file
    71 bool ppImageStatsOutput (pmConfig *config, pmFPA *fpa, const ppImageOptions *options);
     135bool ppImageStatsOutput (pmConfig *config, const ppImageOptions *options);
     136
     137
     138// Measure fringes
     139bool ppImageDetrendFringeMeasure(pmReadout *readout, // Readout to measure
     140                                 pmCell *fringe, // Fringe cell (each readout is a different component)
     141                                 const bool isResidual,
     142                                 const ppImageOptions *options // Options
     143    );
     144
     145// Solve the fringe system
     146bool ppImageDetrendFringeSolve(pmChip *scienceChip, // Chip with science
     147                               const pmChip *refChip, // Chip with reference fringes
     148                               const bool isResidual,
     149                               const ppImageOptions *options // Options
     150    );
     151
     152// Generate fringe frame
     153bool ppImageDetrendFringeGenerate(pmCell *science, // Science cell
     154                                  pmCell *fringes, // Fringe cell, one readout per fringe component
     155                                  const ppImageOptions *options // Options
     156    );
     157
     158
     159bool ppImageDetrendFringeApply (pmConfig *config, // config
     160                                pmChip *chip, // science chip
     161                                const pmFPAview *inputView, // current view
     162                                const ppImageOptions *options // options
     163    );
     164
     165/// Return short version information
     166psString ppImageVersion(void);
     167
     168/// Return long version information
     169psString ppImageVersionLong(void);
     170
     171/// Update the metadata with version information for all dependencies
     172void ppImageVersionMetadata(psMetadata *metadata ///< Metadata to update with version information
     173    );
     174
     175
     176// calculate stats, including MD5
     177bool ppImagePixelStats (pmConfig *config, const ppImageOptions *options, const pmFPAview *inputView);
     178
     179// calculate stats from headers and concepts
     180bool ppImageMetadataStats (pmConfig *config, const ppImageOptions *options);
     181
     182void ppImageFileCheck (pmConfig *config);
    72183
    73184#endif
  • trunk/ppImage/src/ppImageArguments.c

    r13750 r14000  
    44
    55#include "ppImage.h"
    6 #include "ppImageVersion.h"
    7 #include "ppStatsVersion.h"
    86
    97static void usage (void) {
  • trunk/ppImage/src/ppImageDetrendFringe.c

    r13970 r14000  
    33#endif
    44
    5 #include <stdio.h>
    6 #include <pslib.h>
    7 #include <psmodules.h>
    8 
    9 #include "ppImageOptions.h"
    10 #include "ppImageDetrendFringe.h"
     5#include "ppImage.h"
    116
    127bool ppImageDetrendFringeMeasure(pmReadout *readout, pmCell *fringe, const bool isResidual, const ppImageOptions *options)
  • trunk/ppImage/src/ppImageDetrendReadout.c

    r13970 r14000  
    44
    55#include "ppImage.h"
    6 #include "ppImageDetrendFringe.h"
    76
    87bool ppImageDetrendReadout(pmConfig *config, ppImageOptions *options, pmFPAview *view)
  • trunk/ppImage/src/ppImageLoop.c

    r13970 r14000  
    44
    55#include "ppImage.h"
    6 #include "ppImageDetrendFringe.h"
    7 #include "ppImageVersion.h"
    86
    97bool ppImageLoop (pmConfig *config, ppImageOptions *options) {
     
    8886       
    8987        // measure various statistics for this image
    90         if (!ppImageStats (config, chip, view, options)) {
     88        if (!ppImagePixelStats (config, options, view)) {
    9189            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to measures stats for image");
    9290            psFree (view);
     
    119117        }
    120118
    121         // Close cells
     119        // Close cells (XXX shouldn't pmFPAfileClose iterate down as needed?)
    122120        view->cell = -1;
    123121        while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
     
    139137    }
    140138
    141     // Write out summary statistics
    142     if (!ppImageStatsOutput (config, input->fpa, options)) {
    143         psError(PS_ERR_UNKNOWN, false, "Unable to write statistics file.\n");
    144         psFree (view);
    145         return false;
    146     }
    147 
    148139    // XXX an optional full-scale FPA mosaic could happen here
    149140    // it would require us to NOT free PPIMAGE.CHIP until here
     
    161152    }
    162153
     154    ppImageFileCheck (config);
     155
     156    // Write out summary statistics
     157    if (!ppImageMetadataStats (config, options)) {
     158        psError(PS_ERR_UNKNOWN, false, "Unable to write statistics file.\n");
     159        psFree (view);
     160        return false;
     161    }
     162
     163
     164    // Write out summary statistics
     165    if (!ppImageStatsOutput (config, options)) {
     166        psError(PS_ERR_UNKNOWN, false, "Unable to write statistics file.\n");
     167        psFree (view);
     168        return false;
     169    }
     170
    163171    // Close FPA
    164172    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
  • trunk/ppImage/src/ppImageStats.c

    r13970 r14000  
    33#endif
    44
    5 #include <stdio.h>
    6 #include <pslib.h>
    7 #include <psmodules.h>
    8 
    95#include "ppImage.h"
    10 #include "ppStats.h"
    116
    127// calculate stats, including MD5
     
    4237        if (options->doStats) {
    4338
    44             pmFPAfile *output = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.OUTPUT");
    45             if (!mdok || !output) {
    46                 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find file PPIMAGE.OUTPUT.");
     39            pmFPAfile *outImage = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.OUTPUT");
     40            pmFPAfile *outPhotom = psMetadataLookupPtr(&mdok, config->files, "PSPHOT.OUTPUT");
     41            pmFPAfile *outAstrom = psMetadataLookupPtr(&mdok, config->files, "PSASTRO.OUTPUT");
     42
     43            if (!outImage && !outPhotom && !outAstrom) {
     44                psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find any output file (PPIMAGE.OUTPUT, PSPHOT.OUTPUT, PSASTRO.OUTPUT).");
    4745                psFree (view);
    4846                psFree(stats);
     
    5048            }
    5149
    52             if (!ppStats(stats, output->fpa, view,
     50            // get the latest output product available
     51            pmFPAfile *output = outAstrom;
     52            if (!output) {
     53                output = outPhotom;
     54            }
     55            if (!output) {
     56                output = outImage;
     57            }
     58
     59            if (!ppStatsFPA(stats, output->fpa, view,
    5360                         options->satMask | options->badMask | options->maskValue,
    5461                         config)) {
     
    98105    return true;
    99106}
    100 
    101 // write stats to output file
    102 bool ppImageStatsOutput (pmConfig *config, pmFPA *fpa, const ppImageOptions *options) {
    103 
    104     bool mdok;
    105 
    106     // measure statistics, or ignore?
    107     if (!options->doStats) return true;
    108        
    109     // get the output stats filename
    110     const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics
    111     if (!statsName && !strlen(statsName)) {
    112         psError (PS_ERR_UNEXPECTED_NULL, false, "missing STATS entry in arguments list.");
    113         return false;
    114     }
    115 
    116     // convert to a real UNIX filename
    117     psString resolved = pmConfigConvertFilename(statsName, config, true); // Resolved filename
    118     FILE *statsFile = fopen (resolved, "w");
    119     if (!statsFile) {
    120         psError(PS_ERR_IO, true, "Unable to open statistics file %s for writing.\n", resolved);
    121         psFree(resolved);
    122         return false;
    123     }
    124     psFree(resolved);
    125 
    126     // select the fpa-level analysis stats metadata:
    127     psMetadata *stats = psMetadataLookupPtr (&mdok, fpa->analysis, "PPIMAGE.STATS");
    128     if (!stats) {
    129         psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find PPIMAGE.STATS entry in fpa analysis.\n");
    130         return false;
    131     }
    132 
    133     // convert the stats MDC to a string
    134     char *statsMDC = psMetadataConfigFormat(stats);
    135     if (!statsMDC || strlen(statsMDC) == 0) {
    136         psError(PS_ERR_IO, false, "Unable to serialize stats metadata.\n");
    137         return false;
    138     }
    139 
    140     // write the stats MDC to a file
    141     // XXX why does this not call psMetadataConfigPrint?
    142     fprintf(statsFile, "%s", statsMDC);
    143 
    144     psFree(statsMDC);
    145     fclose(statsFile);
    146     return true;
    147 }
  • trunk/ppImage/src/ppImageVersion.c

    r10294 r14000  
    33#endif
    44
    5 #include <stdio.h>
    6 #include <pslib.h>
    7 #include <psmodules.h>
    8 #include <psphot.h>
    9 #include <psastro.h>
    10 #include <ppStats.h>
    11 
    12 #include "ppImageVersion.h"
     5#include "ppImage.h"
    136
    147static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
Note: See TracChangeset for help on using the changeset viewer.