Changeset 5858
- Timestamp:
- Dec 30, 2005, 7:05:28 AM (21 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 7 added
- 5 deleted
- 8 edited
-
ppConfigLoad.c (deleted)
-
ppDataLoadMeta.c (deleted)
-
ppDataLoadPixels.c (deleted)
-
ppImage.c (modified) (2 diffs)
-
ppImage.h (modified) (3 diffs)
-
ppImageConfig.c (added)
-
ppImageDetrendBias.c (modified) (2 diffs)
-
ppImageDetrendCell.c (added)
-
ppImageDetrendFlat.c (modified) (1 diff)
-
ppImageDetrendMask.c (modified) (1 diff)
-
ppImageDetrendNonLinear.c (modified) (3 diffs)
-
ppImageDetrendPedestal.c (modified) (2 diffs)
-
ppImageLoadPixels.c (added)
-
ppImageLoop.c (modified) (1 diff)
-
ppImageOptions.c (added)
-
ppImageParseCamera.c (added)
-
ppImageParseDetrend.c (added)
-
ppImageWeights.c (added)
-
ppReadoutDetrend.c (deleted)
-
ppReciptInit.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImage.c
r5857 r5858 5 5 ppData data; 6 6 ppConfig config; 7 pp Recipeoptions;7 ppOptions options; 8 8 9 9 psTimerStart("phase2"); 10 10 11 11 // Parse the configuration and arguments 12 pp ConfigLoad(&config, argc, argv);12 ppImageConfig (&config, argc, argv); 13 13 14 14 // Open the input image, output image, output mask 15 15 // Get camera configuration from header if not already defined 16 16 // Construct camera in preparation for reading 17 pp DataLoadMeta (&data, &config, argv);17 ppImageParseCamera (&data, &config, argv); 18 18 19 19 // Set various tasks (define optional operations) 20 pp RecipeInit (&options, &config)20 ppImageOptions (&data, &options, &config); 21 21 22 // Read in the input pixels 23 // Generate mask and weight frame 24 // Read in detrend pixels 25 ppDataLoadPixels (&data, &options, &config); 22 // open detrend images, load headers, optionally load pixels 23 ppImageParseDetrend (&data, &options, &config); 26 24 27 25 // Image Arithmetic Loop … … 29 27 30 28 // output options 31 ppImageOutput (&data, &options, &config);29 // ppImageOutput (&data, &options, &config); 32 30 33 31 exit (0); -
trunk/ppImage/src/ppImage.h
r5857 r5858 23 23 #define RECIPE "PHASE2" // Name of the recipe to use 24 24 25 typedef enum { 26 PP_LOAD_NONE, 27 PP_LOAD_FPA, 28 PP_LOAD_CHIP, 29 PP_LOAD_CELL, 30 } ppImageLoadDepth; 31 25 32 typedef struct { 26 33 psMetadata *site; … … 33 40 typedef struct { 34 41 bool doMask; // Mask bad pixles 35 bool doNonLin; // Non-linearity correction36 42 bool doBias; // Bias subtraction 37 43 bool doDark; // Dark subtraction 38 bool doOverscan; // Overscan subtraction39 44 bool doFlat; // Flat-field normalisation 40 45 bool doFringe; // Fringe subtraction 41 46 bool doSource; // Source identification and photometry 42 47 bool doAstrom; // Astrometry 48 bool preLoad; 49 50 bool doOverscan; // Overscan subtraction 43 51 int overscanBins; // Number of pixels per bin for overscan 44 52 psStats *overscanStats; // Statistics for overscan … … 47 55 pmOverscanAxis overscanMode; // Axis for overscan 48 56 49 char *maskName; 50 char *biasName; 51 char *darkName; 52 char *flatName; 53 } ppRecipe; 57 bool doNonLin; // Non-linearity correction 58 psDataType nonLinearType; 59 psMetadataItem *nonLinearData; 60 void *nonLinearSource; 61 62 ppImageLoadDepth imageLoadDepth; 63 64 } ppOptions; 54 65 55 66 typedef struct { 67 char *filename; 68 pmFPA *fpa; 69 psFits *fits; 56 70 psMetadata *header; 71 } ppFPA; 57 72 58 pmFPA *input; 59 pmFPA *weight; 60 pmFPA *mask; 61 pmFPA *bias; 62 pmFPA *dark; 63 pmFPA *flat; 64 pmFPA *fringe; 73 typedef struct { 74 ppFPA *input; 75 ppFPA *mask; 76 ppFPA *bias; 77 ppFPA *dark; 78 ppFPA *flat; 79 ppFPA *fringe; 80 ppFPA *process; 81 } ppData; 65 82 66 psFits *inputFile; 67 psFits *weightFile; 68 psFits *maskFile; 69 psFits *biasFile; 70 psFits *darkFile; 71 psFits *flatFile; 72 psFits *fringeFile; 73 } ppData; 83 typedef struct { 84 pmCell *input; 85 pmCell *mask; 86 pmCell *bias; 87 pmCell *dark; 88 pmCell *flat; 89 } ppDetrend; 90 91 bool ppImageConfig (ppConfig *config, int argc, char **argv); 92 bool ppImageLoadPixels (ppFPA *input, ppFPA *process, psDB *db, int nChip, int nCell); 93 bool ppImageLoop (ppData *data, ppOptions *options, ppConfig *config); 94 bool ppImageOptions (ppData *data, ppOptions *options, ppConfig *config); 95 bool ppImageParseCamera (ppData *data, ppConfig *config, char **argv); 96 bool ppImageParseDetrend (ppData *data, ppOptions *options, ppConfig *config); 97 98 bool ppReadoutWeights (pmReadout *readout); 99 100 bool ppDetrendCell (ppDetrend *detrend, ppOptions *options, ppConfig *config); 101 102 bool ppDetrendMask (pmCell *cell, pmReadout *input, pmReadout *mask); 103 bool ppDetrendNonLinear (pmCell *cell, pmReadout *input, ppOptions *options); 104 bool ppDetrendNonLinearLookup (pmReadout *input, psMetadataItem *dataItem); 105 bool ppDetrendNonLinearPolynomial (pmReadout *input, psMetadataItem *dataItem); 106 bool ppDetrendBias (pmCell *inputCell, pmReadout *inputReadout, pmReadout *pedestal, ppOptions *options); 107 pmReadout* ppDetrendPedestal (pmReadout *pedestal, pmCell *input, pmReadout *bias, pmReadout *dark, float darkTime, ppOptions *options); 108 pmReadout* ppDetrendSelectFirst (pmCell *cell, char *name, bool doThis); 109 110 bool ppFPAOpen (ppFPA *fpa, psMetadata *camera, char *name, bool doThis); -
trunk/ppImage/src/ppImageDetrendBias.c
r5857 r5858 1 1 # include "ppImage.h" 2 2 3 bool ppDetrendBias (pmCell *input , psImage *bias, psImage *dark, ppRecipe*options) {3 bool ppDetrendBias (pmCell *inputCell, pmReadout *inputReadout, pmReadout *pedestal, ppOptions *options) { 4 4 5 5 psPolynomial1D *poly; 6 6 psSpline1D *spline; 7 psString coeffs; 7 8 8 // XXX EAM : this is an odd trigger for this9 if (options->overscanMode == PM_OVERSCAN_ ROWS || options->overscanMode == PM_OVERSCAN_COLUMNS) {9 // XXX EAM : renamed the general edge overscan concept 10 if (options->overscanMode == PM_OVERSCAN_EDGE) { 10 11 // Need to get the read direction 11 12 int readdir = psMetadataLookupS32(NULL, inputCell->concepts, "CELL.READDIR"); 12 13 if (readdir == 1) { 13 // psmodule-0.8.0 has confused PM_OVERSCAN_ROWS and PM_OVERSCAN_COLUMNS; bug 608.14 #ifdef PRODUCTION15 14 options->overscanMode = PM_OVERSCAN_ROWS; 16 #else 15 } else if (readdir == 2) { 17 16 options->overscanMode = PM_OVERSCAN_COLUMNS; 18 #endif19 } else if (readdir == 2) {20 #ifdef PRODUCTION21 options->overscanMode = PM_OVERSCAN_COLUMNS;22 #else23 options->overscanMode = PM_OVERSCAN_ROWS;24 #endif25 17 } else { 26 psErrorStackPrint(stderr, "CELL.READDIR (%d) is not 1 or 2 --- assuming 1.\n", 27 readdir); 28 options->overscanMode = PM_OVERSCAN_ROWS; 18 psAbort("phase2", "CELL.READDIR (%d) is not 1 or 2", readdir); 29 19 } 30 20 } 31 21 32 psList *inputOverscans = pmReadoutGetBias(inputReadout); // List of overscan bias regions 33 #ifdef PRODUCTION 34 (void)pmSubtractBias(inputReadout, overscanFit, inputOverscans, overscanMode, 35 overscanStats, overscanBins, overscanFitType, pedestal); 36 #else 37 (void)pmSubtractBias(inputReadout, overscanFit, inputOverscans, overscanMode, 38 overscanStats, overscanBins, overscanFitType, biasReadout); 39 #endif 22 // XXX : should this be a psArray? 23 psList *inputOverscans = NULL; 24 if (options->doOverscan) { 25 inputOverscans = pmReadoutGetBias(inputReadout); // List of overscan bias regions 26 } 27 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); 40 37 psFree(inputOverscans); 41 38 42 39 // Output overscan fit results, if required 43 if (! doOverscan) {40 if (! options->doOverscan) { 44 41 return true; 45 42 } 46 43 47 if (! o verscanFit) {44 if (! options->overscanFit) { 48 45 psLogMsg("phase2", PS_LOG_WARN, "No fit generated!\n"); 49 46 return true; 50 47 } 51 48 52 switch (o verscanFitType) {49 switch (options->overscanFitType) { 53 50 case PM_FIT_POLYNOMIAL: 54 poly = (psPolynomial1D *)overscanFit; // The polynomial55 psStringcoeffs = NULL; // String containing the coefficients51 poly = (psPolynomial1D *) options->overscanFit; // The polynomial 52 coeffs = NULL; // String containing the coefficients 56 53 for (int i = 0; i < poly->nX; i++) { 57 54 psStringAppend(&coeffs, "%e ", poly->coeff[i]); … … 63 60 64 61 case PM_FIT_SPLINE: 65 spline = (psSpline1D *)overscanFit; // The spline66 psStringcoeffs = NULL; // String containing the coefficients62 spline = (psSpline1D *) options->overscanFit; // The spline 63 coeffs = NULL; // String containing the coefficients 67 64 for (int i = 0; i < spline->n; i++) { 68 65 psPolynomial1D *poly = spline->spline[i]; // i-th polynomial -
trunk/ppImage/src/ppImageDetrendFlat.c
r5857 r5858 1 1 # include "ppImage.h" 2 2 3 bool ppDetrendFlat () { 3 // why does this use the flat pmReadout? 4 5 bool ppDetrendFlat (pmReadout *inputReadout, pmReadout *flat, ppOptions *options) { 4 6 5 7 psLogMsg("phase2", PS_LOG_INFO, "Performing flat field.\n"); 8 9 10 6 11 #ifndef PRODUCTION 7 12 psImage *dummyImage = psImageAlloc(inputReadout->image->numCols, -
trunk/ppImage/src/ppImageDetrendMask.c
r5857 r5858 1 1 # include "ppImage.h" 2 2 3 bool ppDetrendMask (pmCell *cell, pmReadout *readout, pmImage *mask) { 3 # define MASK_MODE (PM_MASK_TRAP | PM_MASK_BADCOL | PM_MASK_SAT) 4 5 // XXX pass 'concepts' not 'cell' to this function? 6 7 bool ppDetrendMask (pmCell *cell, pmReadout *input, pmReadout *mask) { 4 8 5 9 float saturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION"); 6 10 7 11 // Need to change this later to grow the mask by the size of the convolution kernel 8 (void)pmMaskBadPixels(readout, mask,9 PM_MASK_TRAP | PM_MASK_BADCOL | PM_MASK_SAT, saturation, 10 PM_MASK_TRAP, 0);12 // XXX does this function respect the mask / image cell region information? 13 // XXX should probably take pmRegion *mask 14 pmMaskBadPixels(input, mask->image, MASK_MODE, saturation, PM_MASK_TRAP, 0); 11 15 12 16 return true; 13 17 } 14 -
trunk/ppImage/src/ppImageDetrendNonLinear.c
r5857 r5858 1 1 # include "ppImage.h" 2 2 3 bool ppDetrendNonLinear (pmCell *cell, pmReadout *readout, psMetadata *recipe) {3 bool ppDetrendNonLinearPolynomial (pmReadout *input, psMetadataItem *dataItem) { 4 4 5 psString name; 6 psVector *coeff; 7 psMetadata *options; 5 // These are the polynomial coefficients 6 psVector *coeff = dataItem->data.V; // The coefficient vector 7 if (coeff->type.type != PS_TYPE_F64) { 8 psVector *temp = psVectorCopy(NULL, coeff, PS_TYPE_F64); // F64 version 9 psFree (coeff); 10 coeff = temp; 11 } 12 psPolynomial1D *correction = psPolynomial1DAlloc(coeff->n - 1, PS_POLYNOMIAL_ORD); 13 psFree(correction->coeff); 14 correction->coeff = psMemIncrRefCounter(coeff->data.F64); 15 pmNonLinearityPolynomial(input, correction); 16 psFree(coeff); 17 psFree(correction); 18 return true; 19 } 8 20 9 psMetadataItem *dataItem = psMetadataLookup(recipe, "NONLIN.DATA"); 10 if (! dataItem) { 11 psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction desired, but unable to " 12 "find NONLIN.DATA in recipe --- ignored.\n"); 21 bool ppDetrendNonLinearLookup (pmReadout *input, psMetadataItem *dataItem) { 22 23 // This is a filename: lookup table 24 char *name = dataItem->data.V; // Filename 25 psLookupTable *table = psLookupTableAlloc(name, "%f %f", 0); 26 if (psLookupTableRead(table) <= 0) { 27 psErrorStackPrint(stderr, "Unable to read non-linearity correction file " 28 "%s --- ignored\n", name); 13 29 return false; 14 30 } 31 #ifdef PRODUCTION 32 pmNonLinearityLookup(input, table); 33 #else 34 psVector *influx = table->values->data[0]; 35 psVector *outflux = table->values->data[1]; 36 pmNonLinearityLookup(input, influx, outflux); 37 #endif 38 psFree(table); 39 return true; 40 } 15 41 16 switch (dataItem->type) { 42 bool ppDetrendNonLinear (pmCell *cell, pmReadout *input, ppOptions *options) { 43 44 psMetadataItem *concept; 45 46 switch (options->nonLinearType) { 17 47 case PS_DATA_VECTOR: 18 // These are the polynomial coefficients 19 coeff = dataItem->data.V; // The coefficient vector 20 if (coeff->type.type != PS_TYPE_F64) { 21 psVector *temp = psVectorCopy(NULL, coeff, PS_TYPE_F64); // F64 version 22 coeff = temp; 23 } 24 psPolynomial1D *correction = psPolynomial1DAlloc(coeff->n - 1, 25 PS_POLYNOMIAL_ORD); 26 psFree(correction->coeff); 27 correction->coeff = psMemIncrRefCounter(coeff->data.F64); 28 (void)pmNonLinearityPolynomial(inputReadout, correction); 29 psFree(coeff); 30 psFree(correction); 48 ppDetrendNonLinearPolynomial (input, options->nonLinearData); 31 49 return true; 32 50 33 51 case PS_DATA_STRING: 34 // This is a filename 35 name = dataItem->data.V; // Filename 36 psLookupTable *table = psLookupTableAlloc(name, "%f %f", 0); 37 if (psLookupTableRead(table) <= 0) { 38 psErrorStackPrint(stderr, "Unable to read non-linearity correction file " 39 "%s --- ignored\n", name); 40 return false; 41 } 42 #ifdef PRODUCTION 43 (void)pmNonLinearityLookup(inputReadout, table); 44 #else 45 psVector *influx = table->values->data[0]; 46 psVector *outflux = table->values->data[1]; 47 (void)pmNonLinearityLookup(inputReadout, table->values->data[0], 48 table->values->data[1]); 49 #endif 50 psFree(table); 52 ppDetrendNonLinearLookup (input, options->nonLinearData); 51 53 return true; 52 54 53 55 case PS_DATA_METADATA: 54 // This is a menu 55 options = dataItem->data.V; // Options with concept values as keys 56 bool mdok = false; // Success of MD lookup 57 psString concept = psMetadataLookupStr(&mdok, recipe, "NONLIN.SOURCE"); 58 if (! mdok || ! concept) { 59 psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction desired, but " 60 "unable to find NONLIN.SOURCE in recipe --- ignored.\n"); 56 // XXX this is somewhat confusing : let's wrap in a function when i understand it 57 concept = pmCellGetConcept(cell, options->nonLinearSource); 58 if (! concept) { 59 psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s " 60 "for non-linearity correction --- ignored.\n", options->nonLinearSource); 61 61 return false; 62 62 } 63 psMetadataItem *conceptValueItem = pmCellGetConcept(inputCell, concept); 64 if (! conceptValueItem) { 65 psLogMsg("phase2", PS_LOG_WARN, "Unable to find value of concept %s " 66 "for non-linearity correction --- ignored.\n", concept); 67 return false; 68 } 69 if (conceptValueItem->type != PS_DATA_STRING) { 63 if (concept->type != PS_DATA_STRING) { 70 64 psLogMsg("phase2", PS_LOG_WARN, "Type for concept %s isn't STRING, as" 71 65 " expected for non-linearity correction --- ignored.\n", … … 74 68 } 75 69 76 psString conceptValue = conceptValueItem->data.V;77 70 // Get the value of the concept 78 psMetadataItem *optionItem = psMetadataLookup(options, conceptValue); 71 psString conceptValue = concept->data.V; 72 psMetadata *folder = (psMetadata *)options->nonLinearData->data.V; 73 psMetadataItem *optionItem = psMetadataLookup(folder, conceptValue); 79 74 if (!optionItem) { 80 75 psLogMsg("phase2", PS_LOG_WARN, "Unable to find %s in NONLIN.DATA" … … 82 77 return false; 83 78 } 84 if (optionItem->type == PS_DATA_VECTOR) { 85 // These are the polynomial coefficients 86 coeff = optionItem->data.V; // The coefficient vector 87 if (coeff->type.type != PS_TYPE_F64) { 88 psVector *temp = psVectorCopy(NULL, coeff, PS_TYPE_F64); 89 coeff = temp; 90 } 91 // Polynomial correction 92 psPolynomial1D *correction = psPolynomial1DAlloc(coeff->n - 1, 93 PS_POLYNOMIAL_ORD); 94 psFree(correction->coeff); 95 correction->coeff = psMemIncrRefCounter(coeff->data.F64); 96 (void)pmNonLinearityPolynomial(inputReadout, correction); 97 psFree(coeff); 98 psFree(correction); 79 80 switch (optionItem->type) { 81 case PS_DATA_VECTOR: 82 ppDetrendNonLinearPolynomial (input, optionItem); 99 83 return true; 100 } 101 if (optionItem->type == PS_DATA_STRING) { 102 // This is a filename 103 psString tableName = optionItem->data.V; // The filename 104 psLookupTable *table = psLookupTableAlloc(tableName, "%f %f", 0); 105 int numLines = 0; // Number of lines read from table 106 if ((numLines = psLookupTableRead(table)) <= 0) { 107 psErrorStackPrint(stderr, "Unable to read non-linearity " 108 "correction file %s --- ignored\n", 109 tableName); 110 return false; 111 } 112 #ifdef PRODUCTION 113 (void)pmNonLinearityLookup(inputReadout, table); 114 #else 115 printf("XXX: Non-linearity correction from lookup table not " 116 "yet implemented.\n"); 117 #endif 118 psFree(table); 84 case PS_DATA_STRING: 85 ppDetrendNonLinearLookup (input, optionItem); 119 86 return true; 87 default: 88 psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction " 89 "desired but unable to interpret NONLIN.DATA for %s" 90 " --- ignored\n", conceptValue); 91 return false; 120 92 } 121 122 psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction "123 "desired but unable to interpret NONLIN.DATA for %s"124 " --- ignored\n", conceptValue);125 return false;126 127 93 default: 128 psLogMsg("phase2", PS_LOG_WARN, "Non-linearity correction desired, but " 129 "NONLIN.DATA is of invalid type --- ignored.\n"); 94 psAbort("phase2", "Invalid options->nonLinearType"); 130 95 } 131 return false;96 return true; 132 97 } 133 98 -
trunk/ppImage/src/ppImageDetrendPedestal.c
r5857 r5858 1 1 # include "ppImage.h" 2 2 3 psImage *ppDetrendPedestal (pmCell *input, psImage *bias, psImage *dark, ppRecipe *options) { 3 // XXX check on image overlaps, as well as image sizes 4 // XXX what constraints do we put on the detrend images? 5 // XXX this function is much easier if we can assume all detrend images 6 // should have the same size and represent the same pixels... 4 7 5 psImage *pedestal = NULL; // Pedestal image (bias + scaled dark) 8 pmReadout *ppDetrendPedestal (pmReadout *pedestal, pmCell *input, pmReadout *bias, pmReadout *dark, float darkTime, ppOptions *options) { 6 9 7 10 #ifdef PRODUCTION 11 static float lastExptime = 0.0; 12 bool reusePedestal = true; 13 8 14 if (options->doDark) { 9 15 // Dark time for input image … … 14 20 exit(EXIT_FAILURE); 15 21 } 16 pedestal = (psImage*)psBinaryOp(NULL, dark, "*", psScalarAlloc(inputTime * darkTime, PS_TYPE_F32)); 22 23 if (inputTime != lastExptime) { 24 // this will create a new pedestal if the input one is NULL 25 // XXX EAM : this function had darkTime * inputTime, which is wrong, yes? 26 if (pedestal == NULL) { 27 pedestal = pmReadoutAlloc (NULL); 28 } 29 pedestal->col0 = dark->col0; 30 pedestal->row0 = dark->row0; 31 pedestal->colBins = dark->colBins; 32 pedestal->rowBins = dark->rowBins; 33 34 pedestal->image = (psImage *) psBinaryOp(pedestal->image, dark->image, "*", psScalarAlloc(inputTime / darkTime, PS_TYPE_F32)); 35 reusePedestal = false; 36 lastExptime = inputTime 37 } 17 38 } 18 if (options->doBias) { 19 if (pedestal) { 20 if (bias->numRows != dark->numRows || 21 bias->numCols != dark->numCols) { 22 psError(PS_ERR_IO, true, "Bias and dark images have different dimensions: " 23 "%dx%d vs %dx%d\n", bias->numCols, bias->numRows, 24 dark->numCols, dark->numRows); 25 exit(EXIT_FAILURE); 26 } 27 (void)psBinaryOp(pedestal, pedestal, "+", bias); 28 } else { 39 40 // no bias image, return dark pedestal or NULL 41 if (!options->doBias) { 42 return pedestal; 43 } 44 45 // no dark image, return bias pedestal, or reuse 46 if (!options->doDark) { 47 if (!pedestal) { 29 48 pedestal = psMemIncrRefCounter(bias); 30 49 } 50 return pedestal; 31 51 } 52 53 if (reusePedestal) { 54 return pedestal; 55 } 56 57 if (bias->image->numRows != dark->image->numRows || 58 bias->image->numCols != dark->image->numCols) { 59 psError(PS_ERR_IO, true, "Bias and dark images have different dimensions: %dx%d vs %dx%d\n", 60 bias->image->numCols, bias->image->numRows, 61 dark->image->numCols, dark->image->numRows); 62 exit(EXIT_FAILURE); 63 } 64 65 psBinaryOp(pedestal->image, pedestal->image, "+", bias->image); 66 return pedestal; 67 #else 68 return NULL; 32 69 #endif 33 34 return pedestal;35 70 } 36 71 72 // creates a new pedestal image for this readout 73 // if the current exptime is the same as the last exptime, 74 // reuses the supplied pedestal -
trunk/ppImage/src/ppImageLoop.c
r5857 r5858 1 1 # include "ppImage.h" 2 2 3 bool ppImageLoop (ppData *data, pp Recipe*options, ppConfig *config) {3 bool ppImageLoop (ppData *data, ppOptions *options, ppConfig *config) { 4 4 5 psArray *inputChips = data->input->chips; // Array of chips in input image 6 psArray *biasChips = data->bias->chips; // Array of chips in bias image 7 psArray *darkChips = data->dark->chips; // Array of chips in dark image 8 psArray *maskChips = data->mask->chips; // Array of chips in mask image 9 psArray *flatChips = data->flat->chips; // Array of chips in flat image 5 ppDetrend detrend; 10 6 11 for (int i = 0; i < inputChips->n; i++) { 12 pmChip *inputChip = inputChips->data[i]; // Chip of interest in input image 13 pmChip *biasChip = biasChips->data[i]; // Chip of interest in bias image 14 pmChip *darkChip = darkChips->data[i]; // Chip of interest in dark image 15 pmChip *maskChip = maskChips->data[i]; // Chip of interest in mask image 16 pmChip *flatChip = flatChips->data[i]; // Chip of interest in flat image 7 if (options->imageLoadDepth == PP_LOAD_FPA) { 8 ppImageLoadPixels (data->input, data->process, config->database, -1, -1); 9 ppImageLoadPixels (data->bias, data->process, config->database, -1, -1); 10 ppImageLoadPixels (data->dark, data->process, config->database, -1, -1); 11 ppImageLoadPixels (data->mask, data->process, config->database, -1, -1); 12 ppImageLoadPixels (data->flat, data->process, config->database, -1, -1); 13 } 14 for (int i = 0; i < data->input->fpa->chips->n; i++) { 15 pmChip *inputChip = data->input->fpa->chips->data[i]; // Chip of interest in input image 16 pmChip *biasChip = data->bias->fpa->chips->data[i]; // Chip of interest in bias image 17 pmChip *darkChip = data->dark->fpa->chips->data[i]; // Chip of interest in dark image 18 pmChip *maskChip = data->mask->fpa->chips->data[i]; // Chip of interest in mask image 19 pmChip *flatChip = data->flat->fpa->chips->data[i]; // Chip of interest in flat image 17 20 18 21 if (! inputChip->valid) { continue; } 19 22 20 psArray *inputCells = inputChip->cells; // Array of cells in input image 21 psArray *biasCells = biasChip->cells; // Array of cells in bias image 22 psArray *darkCells = darkChip->cells; // Array of cells in dark image 23 psArray *maskCells = maskChip->cells; // Array of cells in mask image 24 psArray *flatCells = flatChip->cells; // Array of cells in flat image 23 if (options->imageLoadDepth == PP_LOAD_CHIP) { 24 ppImageLoadPixels (data->input, data->process, config->database, i, -1); 25 ppImageLoadPixels (data->bias, data->process, config->database, i, -1); 26 ppImageLoadPixels (data->dark, data->process, config->database, i, -1); 27 ppImageLoadPixels (data->mask, data->process, config->database, i, -1); 28 ppImageLoadPixels (data->flat, data->process, config->database, i, -1); 29 } 30 for (int j = 0; j < inputChip->cells->n; j++) { 31 detrend.input = inputChip->cells->data[j]; // Cell of interest in input image 32 detrend.bias = biasChip->cells->data[j]; // Cell of interest in bias image 33 detrend.dark = darkChip->cells->data[j]; // Cell of interest in dark imag 34 detrend.mask = maskChip->cells->data[j]; // Cell of interest in mask image 35 detrend.flat = flatChip->cells->data[j]; // Cell of interest in flat image 25 36 26 for (int j = 0; j < inputCells->n; j++) { 27 pmCell *inputCell = inputCells->data[j]; // Cell of interest in input image 28 pmCell *biasCell = biasCells->data[j]; // Cell of interest in bias image 29 pmCell *darkCell = darkCells->data[j]; // Cell of interest in dark imag 30 pmCell *maskCell = maskCells->data[j]; // Cell of interest in mask image 31 pmCell *flatCell = flatCells->data[j]; // Cell of interest in flat image 37 if (! detrend.input->valid) { continue; } 32 38 33 if (! inputCell->valid) { continue; } 34 35 ppReadoutDetrend (inputCell, maskCell, biasCell, darkCell, flatCell); 39 if (options->imageLoadDepth == PP_LOAD_CELL) { 40 ppImageLoadPixels (data->input, data->process, config->database, i, j); 41 ppImageLoadPixels (data->bias, data->process, config->database, i, j); 42 ppImageLoadPixels (data->dark, data->process, config->database, i, j); 43 ppImageLoadPixels (data->mask, data->process, config->database, i, j); 44 ppImageLoadPixels (data->flat, data->process, config->database, i, j); 45 } 46 ppDetrendCell (&detrend, options, config); 36 47 } 37 48 } 38 49 return true; 39 50 } 51 52 /* if we allow per-readout loads, we need to load detrend images here */
Note:
See TracChangeset
for help on using the changeset viewer.
