Changeset 6064
- Timestamp:
- Jan 19, 2006, 4:58:42 PM (20 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 1 added
- 7 edited
-
Makefile.am (modified) (1 diff)
-
ppImage.c (modified) (1 diff)
-
ppImage.h (modified) (5 diffs)
-
ppImageDetrendBias.c (modified) (1 diff)
-
ppImageDetrendCell.c (modified) (2 diffs)
-
ppImageOptions.c (modified) (3 diffs)
-
ppImageOutput.c (modified) (1 diff)
-
ppImagePhot.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/Makefile.am
r5976 r6064 17 17 ppImageParseCamera.c \ 18 18 ppImageParseDetrend.c \ 19 ppImageWeights.c 19 ppImageWeights.c \ 20 ppImageOutput.c \ 21 ppImagePhot.c 20 22 # ppDetrendFlat.c 21 23 # ppImageOutput.c -
trunk/ppImage/src/ppImage.c
r5976 r6064 27 27 ppImageLoop(&data, &options, &config); 28 28 29 // output options 30 // ppImageOutput(&data, &options, &config); 29 // Output image 30 ppImageOutput(&data, &config); 31 32 // Do photometry 33 ppImagePhot(&data, &options, &config); 31 34 32 35 exit(EXIT_SUCCESS); -
trunk/ppImage/src/ppImage.h
r5976 r6064 9 9 #include "psAdditionals.h" 10 10 11 #include "pmAstrometry.h" 11 #include "pmFPA.h" 12 #include "pmFPAConstruct.h" 13 #include "pmFPARead.h" 14 #include "pmFPAWrite.h" 12 15 #include "pmReadout.h" 13 16 #include "pmConfig.h" 14 #include "pmFPAConstruct.h"15 #include "pmFPARead.h"16 #include "pmFPAConceptsGet.h"17 #include "pmFPAWrite.h"18 17 19 18 #include "pmFlatField.h" … … 23 22 #include "pmChipMosaic.h" 24 23 //#include "pmFPAMorph.h" 24 #include "pmSubtractBias.h" 25 25 26 26 #define RECIPE "PHASE2" // Name of the recipe to use … … 53 53 bool doSource; // Source identification and photometry 54 54 bool doAstrom; // Astrometry 55 56 55 bool doOverscan; // Overscan subtraction 57 int overscanBins; // Number of pixels per bin for overscan 58 psStats *overscanStats; // Statistics for overscan 59 void *overscanFit; // Overscan fit (polynomial or spline) 60 pmFit overscanFitType; // Fit type for overscan 61 pmOverscanAxis overscanMode; // Axis for overscan 62 56 pmOverscanOptions *overscan; // Overscan options 63 57 bool doNonLin; // Non-linearity correction 64 58 psDataType nonLinearType; 65 59 psMetadataItem *nonLinearData; 66 60 void *nonLinearSource; 67 68 61 ppImageLoadDepth imageLoadDepth; // How much of the FPA to load at once 69 62 } ppOptions; … … 142 135 bool ppDetrendNonLinearLookup(pmReadout *input, psMetadataItem *dataItem); 143 136 bool ppDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem); 144 bool ppDetrendBias(pmCell *inputCell, pmReadout *inputReadout, pmReadout *pedestal, ppOptions *options); 137 bool ppDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppOptions *options); 138 #if 0 145 139 pmReadout* ppDetrendPedestal(pmReadout *pedestal, pmCell *input, pmReadout *bias, pmReadout *dark, float darkTime, ppOptions *options); 140 #endif 146 141 pmReadout* ppDetrendSelectFirst(pmCell *cell, char *name, bool doThis); 147 142 … … 150 145 #endif 151 146 147 bool ppImageOutput(ppData *data, ppConfig *config); 148 bool ppImagePhot(ppData *data, ppOptions *options, ppConfig *config); 152 149 153 150 #endif // Pau. -
trunk/ppImage/src/ppImageDetrendBias.c
r5858 r6064 1 # include "ppImage.h"1 #include "ppImage.h" 2 2 3 bool ppDetrendBias (pmCell *inputCell, pmReadout *inputReadout, pmReadout *pedestal, ppOptions *options) {3 bool ppDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppOptions *options) { 4 4 5 psPolynomial1D *poly;6 psSpline1D *spline;7 psString coeffs;8 5 9 // XXX EAM : renamed the general edge overscan concept 10 if (options->overscanMode == PM_OVERSCAN_EDGE) { 11 // Need to get the read direction 12 int readdir = psMetadataLookupS32(NULL, inputCell->concepts, "CELL.READDIR"); 13 if (readdir == 1) { 14 options->overscanMode = PM_OVERSCAN_ROWS; 15 } else if (readdir == 2) { 16 options->overscanMode = PM_OVERSCAN_COLUMNS; 17 } else { 18 psAbort("phase2", "CELL.READDIR (%d) is not 1 or 2", readdir); 19 } 6 // psMetadataPrint(inputCell->concepts, 7); 7 8 pmSubtractBias(inputReadout, options->overscan, bias, dark); 9 10 // Output overscan fit results, if required 11 if (! options->doOverscan || ! options->overscan) { 12 return true; 20 13 } 21 14 22 // XXX : should this be a psArray? 23 psList *inputOverscans = NULL; 24 if (options->doOverscan) { 25 inputOverscans = pmReadoutGetBias(inputReadout); // List of overscan bias regions 15 if (!options->overscan->poly && !options->overscan->spline) { 16 psLogMsg("ppImage", PS_LOG_WARN, "No fit generated!\n"); 17 return true; 26 18 } 27 19 28 // supplies the fit result in 'overscanFit' 29 pmSubtractBias(inputReadout, 30 options->overscanFit, 31 inputOverscans, 32 options->overscanMode, 33 options->overscanStats, 34 options->overscanBins, 35 options->overscanFitType, 36 pedestal); 37 psFree(inputOverscans); 38 39 // Output overscan fit results, if required 40 if (! options->doOverscan) { 41 return true; 20 switch (options->overscan->fitType) { 21 case PM_FIT_POLY_ORD: 22 case PM_FIT_POLY_CHEBY: 23 { 24 psPolynomial1D *poly = options->overscan->poly; // The polynomial 25 psString coeffs = NULL; // String containing the coefficients 26 for (int i = 0; i < poly->nX; i++) { 27 psStringAppend(&coeffs, "%e ", poly->coeff[i]); 28 } 29 psLogMsg("phase2", PS_LOG_INFO, "Overscan polynomial coefficients:\n%s\n", coeffs); 30 psFree(coeffs); 31 break; 32 } 33 case PM_FIT_SPLINE: 34 { 35 psSpline1D *spline = options->overscan->spline; // The spline 36 psString coeffs = NULL; // String containing the coefficients 37 for (int i = 0; i < spline->n; i++) { 38 psPolynomial1D *poly = spline->spline[i]; // i-th polynomial 39 psStringAppend(&coeffs, "%d: ", i); 40 for (int j = 0; j < poly->nX; j++) { 41 psStringAppend(&coeffs, "%e ", poly->coeff[i]); 42 } 43 psStringAppend(&coeffs, "\n"); 44 } 45 psLogMsg("phase2", PS_LOG_INFO, "Overscan spline coefficients:\n%s\n", coeffs); 46 psFree(coeffs); 47 break; 48 } 49 case PM_FIT_NONE: 50 break; 51 default: 52 psAbort(__func__, "Should never get here!!!\n"); 42 53 } 43 54 44 if (! options->overscanFit) {45 psLogMsg("phase2", PS_LOG_WARN, "No fit generated!\n");46 return true;47 }48 49 switch (options->overscanFitType) {50 case PM_FIT_POLYNOMIAL:51 poly = (psPolynomial1D *) options->overscanFit; // The polynomial52 coeffs = NULL; // String containing the coefficients53 for (int i = 0; i < poly->nX; i++) {54 psStringAppend(&coeffs, "%e ", poly->coeff[i]);55 }56 psLogMsg("phase2", PS_LOG_INFO, "Overscan polynomial coefficients:\n%s\n",57 coeffs);58 psFree(coeffs);59 break;60 61 case PM_FIT_SPLINE:62 spline = (psSpline1D *) options->overscanFit; // The spline63 coeffs = NULL; // String containing the coefficients64 for (int i = 0; i < spline->n; i++) {65 psPolynomial1D *poly = spline->spline[i]; // i-th polynomial66 psStringAppend(&coeffs, "%d: ", i);67 for (int j = 0; j < poly->nX; j++) {68 psStringAppend(&coeffs, "%e ", poly->coeff[i]);69 }70 psStringAppend(&coeffs, "\n");71 }72 psLogMsg("phase2", PS_LOG_INFO, "Overscan spline coefficients:\n%s\n",73 coeffs);74 psFree(coeffs);75 break;76 77 case PM_FIT_NONE:78 break;79 80 default:81 psAbort(__func__, "Should never get here!!!\n");82 }83 55 return true; 84 56 } -
trunk/ppImage/src/ppImageDetrendCell.c
r5858 r6064 1 1 # include "ppImage.h" 2 #include "pmFPA.h" 2 3 3 4 // mask, bias, dark, flat are defined per Cell 4 5 // pedestal is constructed for each readout, which may have different exposure times 5 6 6 pmReadout *ppDetrendSelectFirst (pmCell *cell, char *name, bool doThis) { 7 pmReadout *ppDetrendSelectFirst(pmCell *cell, char *name, bool doThis) 8 { 7 9 8 10 if (!doThis) { 9 return NULL;11 return NULL; 10 12 } 11 13 12 14 if (cell->readouts->n > 1) { 13 psLogMsg("phase2", PS_LOG_WARN, "%s contains multiple readouts: only the first will be used.", name);15 psLogMsg("phase2", PS_LOG_WARN, "%s contains multiple readouts: only the first will be used.", name); 14 16 } 15 17 … … 19 21 } 20 22 21 bool ppDetrendCell (ppDetrend *detrend, ppOptions *options, ppConfig *config) { 23 bool ppDetrendCell(ppDetrend *detrend, ppOptions *options, ppConfig *config) 24 { 22 25 23 pmReadout *mask = ppDetrendSelectFirst (detrend->mask, "mask", options->doMask); 24 pmReadout *bias = ppDetrendSelectFirst (detrend->bias, "bias", options->doBias); 25 pmReadout *dark = ppDetrendSelectFirst (detrend->dark, "dark", options->doDark); 26 // pmReadout *flat = ppDetrendSelectFirst (detrend->flat, "flat", options->doFlat); 26 pmCellSetWeights(detrend->input); 27 28 pmReadout *mask = ppDetrendSelectFirst(detrend->mask, "mask", options->doMask); 29 pmReadout *bias = ppDetrendSelectFirst(detrend->bias, "bias", options->doBias); 30 pmReadout *dark = ppDetrendSelectFirst(detrend->dark, "dark", options->doDark); 31 pmReadout *flat = ppDetrendSelectFirst(detrend->flat, "flat", options->doFlat); 27 32 28 33 // Dark time for dark image 29 float darkTime = 1.0; 34 float darkTime = 1.0; 30 35 if (options->doDark) { 31 darkTime = psMetadataLookupF32(NULL, detrend->dark->concepts, "CELL.DARKTIME");32 if (darkTime <= 0.0) {33 psErrorStackPrint(stderr, "DARKTIME for dark image (%f) is non-positive.\n", darkTime);34 exit(EXIT_FAILURE);35 }36 darkTime = psMetadataLookupF32(NULL, detrend->dark->concepts, "CELL.DARKTIME"); 37 if (darkTime <= 0.0) { 38 psErrorStackPrint(stderr, "DARKTIME for dark image (%f) is non-positive.\n", darkTime); 39 exit(EXIT_FAILURE); 40 } 36 41 } 37 38 // the pedestal combines the bias and dark contributions for a single readout39 pmReadout *pedestal = NULL;40 42 41 43 for (int k = 0; k < detrend->input->readouts->n; k++) { 42 44 43 pmReadout *input = detrend->input->readouts->data[k]; // Readout of interest in input image45 pmReadout *input = detrend->input->readouts->data[k]; // Readout of interest in input image 44 46 45 // Mask bad pixels46 if (options->doMask) {47 ppDetrendMask (detrend->input, input, mask);48 }47 // Mask bad pixels 48 if (options->doMask) { 49 ppDetrendMask (detrend->input, input, mask); 50 } 49 51 50 // Non-linearity correction51 if (options->doNonLin) {52 ppDetrendNonLinear (detrend->input, input, options);53 }52 // Non-linearity correction 53 if (options->doNonLin) { 54 ppDetrendNonLinear (detrend->input, input, options); 55 } 54 56 55 // generate the pedestal image (passes through the old pedestal if current exptime == last exptime) 56 pedestal = ppDetrendPedestal (pedestal, detrend->input, bias, dark, darkTime, options);57 // Bias, dark and overscan subtraction are all merged. 58 ppDetrendBias(input, bias, dark, options); 57 59 58 // Bias, dark and overscan subtraction are all merged. 59 ppDetrendBias (detrend->input, input, pedestal, options); 60 61 // Flat-field correction (no options used?) 62 if (options->doFlat) { 63 psLogMsg("phase2", PS_LOG_INFO, "flat field disabled.\n"); 64 // pmFlatField (input, flat); 65 } 60 // Flat-field correction (no options used?) 61 if (options->doFlat) { 62 #if 0 63 psLogMsg("phase2", PS_LOG_INFO, "flat field disabled.\n"); 64 #endif 65 pmFlatField(input, flat); 66 } 66 67 } 67 68 return true; -
trunk/ppImage/src/ppImageOptions.c
r5976 r6064 17 17 options->doAstrom = false; // Astrometry 18 18 // Overscan options 19 options->overscan Bins = 1; // Number of pixels per bin for overscan20 options->overscanStats = NULL; // Statistics for overscan21 options->overscanFit = NULL; // Overscan fit (polynomial or spline)22 options->overscanFitType = PM_FIT_NONE; // Fit type for overscan23 options->overscanMode = PM_OVERSCAN_NONE; // Axis for overscan19 options->overscan = NULL; // Overscan options 20 bool overscanSingle = false; // A single value for entire overscan? 21 pmFit overscanFit = PM_FIT_NONE; // Fit type for overscan 22 int overscanOrder = 0; // Order for overscan fit 23 psStats *overscanStats = NULL; // Statistics for overscan 24 24 // Non-linearity options 25 25 options->nonLinearType = 0; // Type of non-linearity data (vector, string or metadata) … … 28 28 // Various others 29 29 options->imageLoadDepth = PP_LOAD_NONE; // No load depth specified yet 30 30 31 31 32 bool mdStatus = false; // Result of MD lookup … … 122 123 // XXX EAM : we should abort on invalid options. default options? 123 124 if (psMetadataLookupBool(NULL, config->recipe, "OVERSCAN")) { 124 // XXX EAM : does 'overscanMode = NONE' mean doOverscan = false?125 125 options->doOverscan = true; 126 psString mode = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.MODE"); 127 if (! strcasecmp(mode, "INDIVIDUAL")) { 128 options->overscanMode = PM_OVERSCAN_EDGE; 129 } else if (! strcasecmp(mode, "ALL")) { 130 options->overscanMode = PM_OVERSCAN_ALL; 131 } else if (strcasecmp(mode, "NONE")) { 132 psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.MODE (%s) is not one of NONE, INDIVIDUAL, or ALL:" 133 " assuming NONE.\n", mode); 134 } 126 127 // Do the overscan as a single value? 128 overscanSingle = psMetadataLookupBool(NULL, config->recipe, "OVERSCAN.SINGLE"); 129 130 // How do we fit it? 135 131 psString fit = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.FIT"); 136 132 if (! strcasecmp(fit, "POLYNOMIAL")) { 137 options->overscanFitType = PM_FIT_POLYNOMIAL; 138 int order = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER"); // Order of polynomial fit 139 options->overscanFit = psPolynomial1DAlloc(order, PS_POLYNOMIAL_ORD); 133 overscanFit = PM_FIT_POLY_ORD; 134 overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER"); 135 } else if (! strcasecmp(fit, "CHEBYSHEV")) { 136 overscanFit = PM_FIT_POLY_CHEBY; 137 overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER"); 140 138 } else if (! strcasecmp(fit, "SPLINE")) { 141 options->overscanFit = NULL; 142 options->overscanFitType = PM_FIT_SPLINE; 143 // int order = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER"); // Order of polynomial fit 144 // XXX : not in psLib yet : options->overscanFit = psSpline1DAlloc(); 139 overscanFit = PM_FIT_SPLINE; 145 140 } else if (strcasecmp(fit, "NONE")) { 146 141 psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) is not one of NONE, POLYNOMIAL, or SPLINE:" 147 142 " assuming NONE.\n", fit); 148 143 } 149 options->overscanBins = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.BIN"); 150 if (options->overscanBins <= 0) { 151 psErrorStackPrint(stderr, "OVERSCAN.BIN (%d) is non-positive --- assuming 1.\n", options->overscanBins); 152 options->overscanBins = 1; 153 } 144 154 145 psString stat = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.STAT"); 155 146 if (! strcasecmp(stat, "MEAN")) { 156 o ptions->overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);147 overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 157 148 } else if (! strcasecmp(stat, "MEDIAN")) { 158 o ptions->overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN);149 overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 159 150 } else { 160 151 psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) is not one of MEAN, MEDIAN: assuming MEAN\n", stat); 161 o ptions->overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN);152 overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 162 153 } 154 155 // Fill in the options 156 options->overscan = pmOverscanOptionsAlloc(overscanSingle, overscanFit, overscanOrder, overscanStats); 163 157 } 164 158 -
trunk/ppImage/src/ppImageOutput.c
r5857 r6064 1 1 # include "ppImage.h" 2 2 3 bool ppImageLoop (ppData *data, ppRecipe *options, ppConfig *config) { 3 bool ppImageOutput(ppData *data, ppConfig *config) 4 { 5 const char *outname = psMetadataLookupStr(NULL, config->arguments, "-output"); // Name of output file 6 psFits *outFile = psFitsOpen(outname, "w"); // File for writing 4 7 5 8 // Write the output 6 pmFPAWrite(outputFile, input, database); 9 pmFPAWrite(outFile, data->input->fpa, config->database); 10 #if 0 7 11 pmFPAWriteMask(input, outputFile); 8 12 pmFPAWriteWeight(input, outputFile); 13 #endif 9 14 10 psLogMsg("phase2", PS_LOG_INFO, "Output completed after %f sec.\n", psTimerMark("phase2")); 15 psFitsClose(outFile); 16 psLogMsg("ppImage", PS_LOG_INFO, "Output completed after %f sec.\n", psTimerMark("ppImage")); 11 17 12 psFitsClose(outputFile);13 14 psFree(arguments);15 psFree(site);16 psFree(header);17 psFree(camera);18 psFree(recipe);19 psFree(input);20 psFree(mask);21 psFree(bias);22 psFree(dark);23 psFree(flat);24 psFree(overscanFit);25 psFree(overscanStats);26 27 psLogMsg("phase2", PS_LOG_INFO, "Output completed after %f sec.\n", psTimerMark("phase2"));28 18 return true; 29 19 }
Note:
See TracChangeset
for help on using the changeset viewer.
