Changeset 14000
- Timestamp:
- Jul 3, 2007, 10:01:23 AM (19 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 3 added
- 4 deleted
- 9 edited
-
Makefile.am (modified) (3 diffs)
-
ppImage.c (modified) (1 diff)
-
ppImage.h (modified) (3 diffs)
-
ppImageArguments.c (modified) (1 diff)
-
ppImageDetrend.h (deleted)
-
ppImageDetrendFringe.c (modified) (1 diff)
-
ppImageDetrendFringe.h (deleted)
-
ppImageDetrendReadout.c (modified) (1 diff)
-
ppImageLoop.c (modified) (5 diffs)
-
ppImageMetadataStats.c (added)
-
ppImageOptions.h (deleted)
-
ppImagePixelStats.c (added)
-
ppImageStats.c (modified) (4 diffs)
-
ppImageStatsOutput.c (added)
-
ppImageVersion.c (modified) (1 diff)
-
ppImageVersion.h (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/Makefile.am
r13970 r14000 4 4 5 5 noinst_HEADERS = \ 6 ppImage.h \ 7 ppImageOptions.h \ 8 ppImageDetrendFringe.h \ 9 ppImageVersion.h 6 ppImage.h 10 7 11 8 ppImage_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(PSPHOT_CFLAGS) $(PSASTRO_CFLAGS) $(PPSTATS_CFLAGS) $(ppImage_CFLAGS) … … 27 24 ppImageAddstar.c \ 28 25 ppImageStats.c \ 26 ppImageStatsOutput.c \ 27 ppImagePixelStats.c \ 28 ppImageMetadataStats.c \ 29 29 ppImageDefineFile.c \ 30 ppImageFileCheck.c \ 30 31 ppImageVersion.c 31 32 … … 50 51 ppImageAddstar.c \ 51 52 ppImageStats.c \ 53 ppImageStatsOutput.c \ 54 ppImagePixelStats.c \ 55 ppImageMetadataStats.c \ 52 56 ppImageDefineFile.c \ 57 ppImageFileCheck.c \ 53 58 ppImageVersion.c 54 59 -
trunk/ppImage/src/ppImage.c
r13901 r14000 45 45 return PS_EXIT_SUCCESS; 46 46 } 47 48 void ppImageFileCheck (pmConfig *config) {49 50 // add the output names to the output-type files51 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 14 14 #include "psphot.h" 15 15 #include "psastro.h" 16 #include "pp ImageOptions.h"16 #include "ppStats.h" 17 17 18 18 #define RECIPE_NAME "PPIMAGE" // Name of the recipe to use 19 19 #define TIMERNAME "ppImage" // Name of timer 20 21 // Options for ppImage processing 22 typedef 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 69 typedef 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 77 ppImageOptions *ppImageOptionsAlloc(void); 78 79 // Determine the processing options 80 ppImageOptions *ppImageOptionsParse(pmConfig *config); 20 81 21 82 // Get the configuration … … 35 96 36 97 bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options); 37 bool ppImageDetrendMask(pmReadout *input, pmReadout *mask);38 98 39 99 bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options); 40 100 bool ppImageDetrendNonLinearLookup(pmReadout *input, psMetadataItem *dataItem); 41 101 bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem); 102 103 bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config); 104 bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options); 105 pmReadout* ppImageDetrendSelectFirst(pmCell *cell, char *name, bool doThis); 42 106 43 107 bool ppImageRebinChip (pmConfig *config, pmFPAview *view, char *outName); … … 69 133 70 134 // write stats to output file 71 bool ppImageStatsOutput (pmConfig *config, pmFPA *fpa, const ppImageOptions *options); 135 bool ppImageStatsOutput (pmConfig *config, const ppImageOptions *options); 136 137 138 // Measure fringes 139 bool 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 146 bool 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 153 bool ppImageDetrendFringeGenerate(pmCell *science, // Science cell 154 pmCell *fringes, // Fringe cell, one readout per fringe component 155 const ppImageOptions *options // Options 156 ); 157 158 159 bool 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 166 psString ppImageVersion(void); 167 168 /// Return long version information 169 psString ppImageVersionLong(void); 170 171 /// Update the metadata with version information for all dependencies 172 void ppImageVersionMetadata(psMetadata *metadata ///< Metadata to update with version information 173 ); 174 175 176 // calculate stats, including MD5 177 bool ppImagePixelStats (pmConfig *config, const ppImageOptions *options, const pmFPAview *inputView); 178 179 // calculate stats from headers and concepts 180 bool ppImageMetadataStats (pmConfig *config, const ppImageOptions *options); 181 182 void ppImageFileCheck (pmConfig *config); 72 183 73 184 #endif -
trunk/ppImage/src/ppImageArguments.c
r13750 r14000 4 4 5 5 #include "ppImage.h" 6 #include "ppImageVersion.h"7 #include "ppStatsVersion.h"8 6 9 7 static void usage (void) { -
trunk/ppImage/src/ppImageDetrendFringe.c
r13970 r14000 3 3 #endif 4 4 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" 11 6 12 7 bool ppImageDetrendFringeMeasure(pmReadout *readout, pmCell *fringe, const bool isResidual, const ppImageOptions *options) -
trunk/ppImage/src/ppImageDetrendReadout.c
r13970 r14000 4 4 5 5 #include "ppImage.h" 6 #include "ppImageDetrendFringe.h"7 6 8 7 bool ppImageDetrendReadout(pmConfig *config, ppImageOptions *options, pmFPAview *view) -
trunk/ppImage/src/ppImageLoop.c
r13970 r14000 4 4 5 5 #include "ppImage.h" 6 #include "ppImageDetrendFringe.h"7 #include "ppImageVersion.h"8 6 9 7 bool ppImageLoop (pmConfig *config, ppImageOptions *options) { … … 88 86 89 87 // measure various statistics for this image 90 if (!ppImage Stats (config, chip, view, options)) {88 if (!ppImagePixelStats (config, options, view)) { 91 89 psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to measures stats for image"); 92 90 psFree (view); … … 119 117 } 120 118 121 // Close cells 119 // Close cells (XXX shouldn't pmFPAfileClose iterate down as needed?) 122 120 view->cell = -1; 123 121 while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) { … … 139 137 } 140 138 141 // Write out summary statistics142 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 148 139 // XXX an optional full-scale FPA mosaic could happen here 149 140 // it would require us to NOT free PPIMAGE.CHIP until here … … 161 152 } 162 153 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 163 171 // Close FPA 164 172 if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) { -
trunk/ppImage/src/ppImageStats.c
r13970 r14000 3 3 #endif 4 4 5 #include <stdio.h>6 #include <pslib.h>7 #include <psmodules.h>8 9 5 #include "ppImage.h" 10 #include "ppStats.h"11 6 12 7 // calculate stats, including MD5 … … 42 37 if (options->doStats) { 43 38 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)."); 47 45 psFree (view); 48 46 psFree(stats); … … 50 48 } 51 49 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, 53 60 options->satMask | options->badMask | options->maskValue, 54 61 config)) { … … 98 105 return true; 99 106 } 100 101 // write stats to output file102 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 filename110 const char *statsName = psMetadataLookupStr(&mdok, config->arguments, "STATS"); // Filename for statistics111 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 filename117 psString resolved = pmConfigConvertFilename(statsName, config, true); // Resolved filename118 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 string134 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 file141 // 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 3 3 #endif 4 4 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" 13 6 14 7 static const char *cvsTag = "$Name: not supported by cvs2svn $";// CVS tag name
Note:
See TracChangeset
for help on using the changeset viewer.
