Changeset 6817
- Timestamp:
- Apr 7, 2006, 5:57:23 PM (20 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 10 deleted
- 12 edited
-
Makefile.am (modified) (1 diff)
-
ppConfig.c (deleted)
-
ppConfig.h (deleted)
-
ppFile.c (deleted)
-
ppFile.h (deleted)
-
ppImage.c (modified) (2 diffs)
-
ppImage.h (modified) (2 diffs)
-
ppImageConfig.c (modified) (2 diffs)
-
ppImageData.c (deleted)
-
ppImageData.h (deleted)
-
ppImageDetrendBias.c (modified) (1 diff)
-
ppImageDetrendCell.c (modified) (1 diff)
-
ppImageDetrendMask.c (modified) (2 diffs)
-
ppImageDetrendNonLinear.c (modified) (2 diffs)
-
ppImageLoadPixels.c (deleted)
-
ppImageLoop.c (modified) (1 diff)
-
ppImageOptions.c (modified) (5 diffs)
-
ppImageOptions.h (modified) (3 diffs)
-
ppImageOutput.c (deleted)
-
ppImageParseCamera.c (deleted)
-
ppImageParseDetrend.c (modified) (1 diff)
-
ppImageWeights.c (deleted)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/Makefile.am
r6747 r6817 12 12 ppImage_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) 13 13 ppImage_SOURCES = \ 14 ppFile.c \15 14 ppImage.c \ 16 15 ppImageConfig.c \ 17 ppImageData.c \ 18 ppImageDetrendBias.c \ 16 ppImageOptions.c \ 17 ppImageParseDetrend.c \ 18 ppImageLoop.c \ 19 19 ppImageDetrendCell.c \ 20 20 ppImageDetrendMask.c \ 21 ppImageDetrendBias.c \ 21 22 ppImageDetrendNonLinear.c \ 22 ppImageLoop.c \23 ppImageOptions.c \24 ppImageParseCamera.c \25 ppImageWeights.c \26 23 ppMem.c 24 # ppImageParseCamera.c \ 25 # ppDetrendFlat.c \ 26 # ppImageWeights.c \ 27 27 # ppImageLoadPixels.c 28 # ppDetrendFlat.c29 28 # ppImageOutput.c 30 29 # ppImageDetrendPedestal.c -
trunk/ppImage/src/ppImage.c
r6775 r6817 1 #include <stdio.h>2 #include "pslib.h"3 #include "psmodules.h"4 1 #include "ppImage.h" 5 #include "ppMem.h"6 2 7 int main(int argc, char **argv) 8 { 9 // psErrorRegister(NULL, -1); 10 11 ppImageData *data = ppImageDataAlloc(); 12 ppImageOptions *options = ppImageOptionsAlloc(); 3 int main(int argc, char **argv) { 13 4 14 5 psTimerStart(TIMERNAME); 15 6 16 7 // Parse the configuration and arguments 8 // Open the input image(s) 9 // Determine camera, format from header if not already defined 10 // Construct camera in preparation for reading 17 11 pmConfig *config = ppImageConfig(argc, argv); 18 12 19 // Open the input image, output image, output mask 20 // Get camera configuration from header if not already defined 21 // Construct camera in preparation for reading 22 ppImageParseCamera(data, config); 13 // Set various tasks (define optional operations) 14 ppImageOptions *options = ppImageOptionsParse(config); 23 15 24 // Set various tasks (define optional operations) 25 ppImageOptionsParse(data, options, config); 26 27 #if 0 28 // XXX I think we do this in ppImageParseCamera 29 30 // open detrend images, load headers, optionally load pixels 31 ppImageParseDetrend(data, options, config); 32 #endif 16 // define the active I/O files 17 ppImageParseDetrend(options, config); 33 18 34 19 // Image Arithmetic Loop 35 ppImageLoop( data,options, config);20 ppImageLoop(options, config); 36 21 37 22 // Cleaning up 38 psFree(data);39 23 psFree(options); 40 24 psFree(config); … … 43 27 pmConceptsDone(); 44 28 pmConfigDone(); 45 ppMemCheck();46 29 // ppMemCheck(); 30 fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppImage"); 47 31 return EXIT_SUCCESS; 48 32 } -
trunk/ppImage/src/ppImage.h
r6747 r6817 2 2 #define PP_IMAGE_H 3 3 4 #include <stdio.h> 4 5 #include "pslib.h" 5 6 #include "psmodules.h" 6 7 #include "ppImageData.h"8 7 #include "ppImageOptions.h" 8 #include "ppMem.h" 9 9 10 10 #define RECIPE_NAME "PHASE2" // Name of the recipe to use … … 15 15 16 16 // Determine what type of camera, and initialise 17 bool ppImageParseCamera(ppImageData *data, // The data to be processed 18 pmConfig *config // Configuration 19 ); 20 17 bool ppImageParseDetrend(ppImageOptions *options, pmConfig *config); 21 18 22 19 // Loop over the input 23 bool ppImageLoop(ppImage Data *data, ppImageOptions *options, pmConfig *config);20 bool ppImageLoop(ppImageOptions *options, pmConfig *config); 24 21 25 // Load the pixels for the given file 26 bool ppImageLoadPixels(ppFile *input, // File for which to load the pixels 27 psDB *db, // Database handle (for reading concepts) 28 int nChip, // Chip number to load 29 int nCell // Cell number to load 30 ); 22 // perform the detrend analysis on the current readout 23 bool ppImageDetrendReadout (ppImageOptions *options, pmConfig *config, pmFPAview *view); 31 24 32 bool ppImageParseDetrend(ppImageData *data, ppImageOptions *options, pmConfig *config); 25 bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options); 26 bool ppImageDetrendMask(pmReadout *input, pmReadout *mask); 33 27 34 bool ppReadoutWeights(pmReadout *readout); 35 36 #if 0 37 // These functions are not implemented, or not needed 38 pmReadout* ppDetrendPedestal(pmReadout *pedestal, pmCell *input, pmReadout *bias, pmReadout *dark, float darkTime, ppImageOptions *options); 39 bool ppImageOutput(ppImageData *data, pmConfig *config); 40 bool ppImagePhot(ppImageData *data, ppImageOptions *options, pmConfig *config); 41 bool ppFileOpen(ppFile *fpa, char *name, bool doThis); 42 #endif 28 bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options); 29 bool ppImageDetrendNonLinearLookup(pmReadout *input, psMetadataItem *dataItem); 30 bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem); 43 31 44 32 #endif // Pau. -
trunk/ppImage/src/ppImageConfig.c
r6747 r6817 1 #include <stdio.h>2 #include "pslib.h"3 #include "psmodules.h"4 1 #include "ppImage.h" 2 3 static void usage (void) { 4 fprintf (stderr, "USAGE: ppImage [-file INPUT.fits] [-list INPUT.txt] OUTPUT\n"); 5 exit (2); 6 } 5 7 6 8 pmConfig *ppImageConfig(int argc, char **argv) 7 9 { 10 11 bool status; 12 13 if (argc == 1) usage (); 14 15 // load the site-wide configuration information 8 16 pmConfig *config = pmConfigRead(&argc, argv); 9 17 if (! config) { … … 12 20 } 13 21 14 // Parse other command-line arguments 22 // Parse other command-line arguments, save for future use 15 23 config->arguments = psMetadataAlloc(); // The arguments, with default values 16 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-key", 0, "exposure ID", "");17 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-bias", 0, "Name of the bias image", "");18 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-dark", 0, "Name of the dark image", "");19 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-flat", 0, "Name of the flat-field image", "");20 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-mask", 0, "Name of the mask image", "");21 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-fringe", 0, "Name of the fringe image", "");22 psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-chip", 0, "Chip number to process (if positive)", -1);23 24 24 if (! psArgumentParse(config->arguments, &argc, argv) || argc != 3) { 25 printf("\nPan-STARRS Phase 2 processing\n\n"); 26 printf("Usage: %s INPUT.fits OUTPUT.fits\n\n", argv[0]); 27 psArgumentHelp(config->arguments); 28 psFree(config->arguments); 29 exit(EXIT_FAILURE); 25 // if these command-line options are supplied, load the file name lists into config->arguments 26 // override any configuration-specified source for these files 27 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "BIAS", "-bias", "-biaslist"); 28 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "DARK", "-dark", "-darklist"); 29 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "FLAT", "-flat", "-flatlist"); 30 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "MASK", "-mask", "-masklist"); 31 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "FRINGE", "-fringe", "-fringelist"); 32 33 // other command-line options 34 // XXX not sure how these are to be used at the moment 35 // psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-key", 0, "exposure ID", ""); 36 // psMetadataAddS32(config->arguments, PS_LIST_TAIL, "-chip", 0, "Chip number to process (if positive)", -1); 37 38 // the input file is a required argument; if not found, we will exit 39 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "INPUT", "-file", "-list"); 40 if (!status) { usage ();} 41 42 if (! psArgumentParse(config->arguments, &argc, argv) || argc != 2) { 43 usage (); 30 44 } 31 45 32 46 // Add the input and output images (which remain on the command-line) to the arguments list 33 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-input", 0, "Name of the input image", argv[1]); 34 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-output", 0, "Name of the output image", argv[2]); 47 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Name of the output image", argv[1]); 48 49 // the input image(s) are required arguments 50 // the first one defines the camera 51 status = false; 52 pmFPAfileFromArgs (&status, config, "PPIMAGE.INPUT", "INPUT"); 53 if (!status) { 54 psAbort (__func__, "missing INPUT entry"); 55 } 35 56 36 57 // Define database handle, if used -
trunk/ppImage/src/ppImageDetrendBias.c
r6747 r6817 1 #include <stdio.h> 2 #include "pslib.h" 3 #include "psmodules.h" 4 #include "ppImageOptions.h" 5 #include "ppImageDetrend.h" 1 #include "ppImage.h" 6 2 7 3 bool ppImageDetrendBias(pmReadout *inputReadout, pmReadout *bias, pmReadout *dark, ppImageOptions *options) -
trunk/ppImage/src/ppImageDetrendCell.c
r6747 r6817 1 #include <stdio.h> 2 #include "pslib.h" 3 #include "psmodules.h" 4 #include "ppImageDetrend.h" 5 #include "ppImageOptions.h" 1 #include "ppImage.h" 6 2 7 // mask, bias, dark, flat are defined per Cell 3 bool ppImageDetrendReadout (ppImageOptions *options, pmConfig *config, pmFPAview *view) { 8 4 9 pmReadout *ppImageDetrendSelectFirst(pmCell *cell, char *name, bool doThis) 10 { 11 if (!doThis) { 12 return NULL; 5 bool status; 6 pmFPAfile *file; 7 8 // construct a view for the detrend images (which have only one readout) 9 pmFPAview *detview = pmFPAviewAlloc (0); 10 *detview = *view; 11 detview->readout = 0; 12 13 // find the currently selected readout 14 file = psMetadataLookupPtr (&status, config->files, "PPIMAGE.INPUT"); 15 pmReadout *input = pmFPAviewThisReadout (view, file->fpa); 16 17 pmReadoutSetWeights (input); 18 19 // Mask bad pixels 20 if (options->doMask) { 21 file = psMetadataLookupPtr (&status, config->files, "PPIMAGE.MASK"); 22 pmReadout *mask = pmFPAviewThisReadout (detview, file->fpa); 23 ppImageDetrendMask(input, mask); 13 24 } 14 25 15 if (cell->readouts->n > 1) { 16 psLogMsg("phase2", PS_LOG_WARN, "%s contains multiple readouts: only the first will be used.", name); 26 # if 0 27 // Non-linearity correction 28 if (options->doNonLin) { 29 ppImageDetrendNonLinear(detrend->input, input, options); 30 } 31 # endif 32 33 // set up the readouts for dark and bias 34 pmReadout *dark = NULL; 35 pmReadout *bias = NULL; 36 if (options->doBias) { 37 file = psMetadataLookupPtr (&status, config->files, "PPIMAGE.BIAS"); 38 bias = pmFPAviewThisReadout (detview, file->fpa); 39 } 40 if (options->doDark) { 41 file = psMetadataLookupPtr (&status, config->files, "PPIMAGE.DARK"); 42 dark = pmFPAviewThisReadout (detview, file->fpa); 17 43 } 18 44 19 pmReadout *readout = cell->readouts->data[0]; // Readout of interest in this cell 45 // Bias, dark and overscan subtraction are all merged. 46 ppImageDetrendBias(input, bias, dark, options); 20 47 21 return readout; 48 // Flat-field correction (no options used?) 49 if (options->doFlat) { 50 file = psMetadataLookupPtr (&status, config->files, "PPIMAGE.FLAT"); 51 pmReadout *flat = pmFPAviewThisReadout (detview, file->fpa); 52 pmFlatField(input, flat); 53 } 54 55 psFree (detview); 56 return true; 22 57 } 23 58 24 bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config) 25 { 26 #if 0 27 pmCellSetWeights(detrend->input); 28 #endif 59 // XXX in psphot, the recipe options are parsed at this depth 60 // XXX consider if we move ppImageOptions in here 61 // psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, "PSPHOT"); 29 62 30 pmReadout *mask = ppImageDetrendSelectFirst(detrend->mask, "mask", options->doMask);31 pmReadout *bias = ppImageDetrendSelectFirst(detrend->bias, "bias", options->doBias);32 pmReadout *dark = ppImageDetrendSelectFirst(detrend->dark, "dark", options->doDark);33 pmReadout *flat = ppImageDetrendSelectFirst(detrend->flat, "flat", options->doFlat);34 35 #if 036 printf("Flat type: %x\n", flat->image->type.type);37 printf("Flat value: %f\n", flat->image->data.F32[flat->image->numRows/2][flat->image->numCols/2]);38 #endif39 40 for (int k = 0; k < detrend->input->readouts->n; k++) {41 42 pmReadout *input = detrend->input->readouts->data[k]; // Readout of interest in input image43 44 // Mask bad pixels45 if (options->doMask) {46 ppImageDetrendMask(detrend->input, input, mask);47 }48 49 // Non-linearity correction50 if (options->doNonLin) {51 ppImageDetrendNonLinear(detrend->input, input, options);52 }53 54 // Bias, dark and overscan subtraction are all merged.55 ppImageDetrendBias(input, bias, dark, options);56 57 // Flat-field correction (no options used?)58 if (options->doFlat) {59 pmFlatField(input, flat);60 }61 }62 return true;63 } -
trunk/ppImage/src/ppImageDetrendMask.c
r6747 r6817 1 #include <stdio.h> 2 #include "psmodules.h" 3 #include "ppImageDetrend.h" 1 #include "ppImage.h" 4 2 5 3 # define MASK_MODE (PM_MASK_TRAP | PM_MASK_BADCOL | PM_MASK_SAT) … … 7 5 // XXX pass 'concepts' not 'cell' to this function? 8 6 9 bool ppImageDetrendMask(pm Cell *cell, pmReadout *input, pmReadout *mask) {7 bool ppImageDetrendMask(pmReadout *input, pmReadout *mask) { 10 8 11 float saturation = psMetadataLookupF32(NULL, cell->concepts, "CELL.SATURATION"); 9 psImage *image = NULL; 10 11 float saturation = psMetadataLookupF32(NULL, input->parent->concepts, "CELL.SATURATION"); 12 12 13 13 // Need to change this later to grow the mask by the size of the convolution kernel 14 14 // XXX does this function respect the mask / image cell region information? 15 15 // XXX should probably take pmRegion *mask 16 pmMaskBadPixels(input, mask->image, MASK_MODE, saturation, PM_MASK_TRAP, 0); 16 17 if (mask->image->type.type != PS_TYPE_MASK) { 18 image = psImageCopy (NULL, mask->image, PS_TYPE_MASK); 19 } else { 20 image = psMemIncrRefCounter (mask->image); 21 } 22 23 pmMaskBadPixels(input, image, MASK_MODE, saturation, PM_MASK_TRAP, 0); 24 psFree (image); 17 25 18 26 return true; 19 27 } 28 29 30 // XXX the translation here should not be needed 31 // the mask should (but is not) be read in using the mask read functions 32 // by identifying the image type as a mask (in pmFPAfile). 33 // currently, pmFPAfileReadImage converts the image to F32 -
trunk/ppImage/src/ppImageDetrendNonLinear.c
r6747 r6817 1 #include <stdio.h> 2 #include "pslib.h" 3 #include "psmodules.h" 4 #include "ppImageDetrend.h" 1 #include "ppImage.h" 5 2 6 3 bool ppImageDetrendNonLinearPolynomial(pmReadout *input, psMetadataItem *dataItem) { … … 43 40 } 44 41 45 bool ppImageDetrendNonLinear(pm Cell *cell, pmReadout *input, ppImageOptions *options) {42 bool ppImageDetrendNonLinear(pmReadout *input, ppImageOptions *options) { 46 43 47 44 psMetadataItem *concept; 45 pmCell *cell = input->parent; 48 46 49 47 switch (options->nonLinearType) { -
trunk/ppImage/src/ppImageLoop.c
r6775 r6817 1 #include <stdio.h> 2 #include "pslib.h" 3 #include "psmodules.h" 4 #include "ppImageDetrend.h" 5 #include "ppImage.h" 6 #include "ppMem.h" 1 # include "ppImage.h" 7 2 8 #define MEM_LEAKS 1 3 bool ppImageLoop (ppImageOptions *options, pmConfig *config) { 9 4 10 // Read the entire FPA 11 void readFPA(ppFile *file, // File to read 12 pmConfig *config // Configuration, containing the DB handle 13 ) 14 { 15 if (file->fpa && file->fits) { 16 pmFPARead(file->fpa, file->fits, config->database); 5 bool status; 6 pmChip *chip; 7 pmCell *cell; 8 pmReadout *readout; 9 10 pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PPIMAGE.INPUT"); 11 if (!status) { 12 psErrorStackPrint(stderr, "Can't find input data!\n"); 13 exit(EXIT_FAILURE); 17 14 } 15 16 pmFPAview *view = pmFPAviewAlloc (0); 17 18 // files associated with the science image 19 pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE); 20 21 while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 22 psLogMsg ("psphot", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 23 if (!chip->process || !chip->file_exists) { continue; } 24 pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE); 25 26 while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) { 27 psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 28 if (!cell->process || !cell->file_exists) { continue; } 29 pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE); 30 31 // process each of the readouts 32 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 33 pmFPAfileIOChecks (config->files, view, PM_FPA_BEFORE); 34 if (! readout->data_exists) { continue; } 35 36 // perform the detrend analysis 37 ppImageDetrendReadout (options, config, view); 38 39 pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER); 40 } 41 pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER); 42 } 43 44 // ppImageChipMosaic (config, view); 45 // ppImagePSPhot (config, view); 46 // ppImagePSAstro (config, view); 47 48 pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER); 49 50 // XXX paul added these frees: make sure the same is happening in the pmFileIOChecks 51 // Now I can blow away the mosaic so I can then read more. 52 // psFree(inputChip); 53 // psFree(biasChip); 54 // psFree(darkChip); 55 // psFree(maskChip); 56 // psFree(flatChip); 57 // ppMemUsed(); 58 } 59 60 // ppImageFPAMosaic (config, view); 61 // ppImageJpegFPA (config, view); 62 63 pmFPAfileIOChecks (config->files, view, PM_FPA_AFTER); 64 65 psFree (view); 66 return true; 18 67 } 19 68 20 // Read a specified chip only21 void readChip(ppFile *file, // File to read22 pmConfig *config, // Configuration23 int chipNum // Chip number to read24 )25 {26 pmFPA *fpa = file->fpa; // The FPA27 if (fpa && file->fits) {28 pmChip *chip = fpa->chips->data[chipNum]; // The chip29 pmChipRead(chip, file->fits, config->database);30 }31 }32 33 34 void readCell(ppFile *file, pmConfig *config, int chipNum, int cellNum)35 {36 pmFPA *fpa = file->fpa; // The FPA37 if (fpa && file->fits) {38 pmChip *chip = fpa->chips->data[chipNum]; // The chip39 if (chip) {40 pmCell *cell = chip->cells->data[cellNum]; // The cell41 pmCellRead(cell, file->fits, config->database);42 }43 }44 }45 46 47 bool ppImageLoop(ppImageData *data, ppImageOptions *options, pmConfig *config)48 {49 ppImageDetrend detrend;50 51 int processChip = psMetadataLookupS32(NULL, config->arguments, "-chip"); // Chip number to process or -152 53 // Load at FPA level if requested54 if (processChip < 0 && options->imageLoadDepth == PP_LOAD_FPA) {55 psTrace(__func__, 1, "Loading pixels for FPA...\n");56 readFPA(data->input, config);57 readFPA(data->bias, config);58 readFPA(data->dark, config);59 readFPA(data->mask, config);60 readFPA(data->flat, config);61 }62 63 psArray *chips = data->input->fpa->chips; // Component chips64 for (int i = 0; i < chips->n; i++) {65 66 if (processChip >= 0 && i != processChip) {67 continue;68 }69 if (options->imageLoadDepth == PP_LOAD_CHIP) {70 psTrace(__func__, 1, "Loading pixels for chip %d...\n", i);71 readChip(data->input, config, i);72 readChip(data->bias, config, i);73 readChip(data->dark, config, i);74 readChip(data->mask, config, i);75 readChip(data->flat, config, i);76 }77 78 pmChip *inputChip = chips->data[i];79 pmChip *biasChip = data->bias->fpa->chips->data[i];80 pmChip *darkChip = data->dark->fpa->chips->data[i];81 pmChip *maskChip = data->mask->fpa->chips->data[i];82 pmChip *flatChip = data->flat->fpa->chips->data[i];83 84 psArray *cells = inputChip->cells;85 for (int j = 0; j < cells->n; j++) {86 detrend.input = inputChip->cells->data[j]; // Cell of interest in input image87 detrend.bias = biasChip->cells->data[j]; // Cell of interest in bias image88 detrend.dark = darkChip->cells->data[j]; // Cell of interest in dark imag89 detrend.mask = maskChip->cells->data[j]; // Cell of interest in mask image90 detrend.flat = flatChip->cells->data[j]; // Cell of interest in flat image91 92 if (! detrend.input->process) { continue; }93 94 if (options->imageLoadDepth == PP_LOAD_CELL) {95 psTrace(__func__, 1, "Loading pixels for chip %d, cell %d...\n", i, j);96 readCell(data->input, config, i, j);97 readCell(data->bias, config, i, j);98 readCell(data->dark, config, i, j);99 readCell(data->mask, config, i, j);100 readCell(data->flat, config, i, j);101 }102 103 ppImageDetrendCell(&detrend, options, config);104 105 // Need to free detrend cells here so we have enough memory to do other stuff106 psFree(detrend.bias);107 psFree(detrend.dark);108 psFree(detrend.mask);109 psFree(detrend.flat);110 }111 112 #if 0113 int numMosaicked = pmChipMosaic(inputChip, 1, 1); // Number of cells mosaicked together114 psLogMsg(__func__, PS_LOG_INFO, "%d cells mosaicked.\n", numMosaicked);115 116 // XXX A kludge to get the write to behave w.r.t. the concepts --- we've changed the camera format, so117 // the concepts don't know what on earth to do.118 const psMetadata *camera = data->input->fpa->camera;119 data->input->fpa->camera = NULL;120 #endif121 122 // XXX Photometry goes here!123 124 pmChipWrite(inputChip, data->output, config->database);125 126 #if 0127 data->input->fpa->camera = camera;128 #endif129 130 // Now I can blow away the mosaic so I can then read more.131 psFree(inputChip);132 psFree(biasChip);133 psFree(darkChip);134 psFree(maskChip);135 psFree(flatChip);136 137 ppMemUsed();138 }139 140 return true;141 } -
trunk/ppImage/src/ppImageOptions.c
r6747 r6817 1 #include <stdio.h>2 #include "pslib.h"3 1 #include "ppImage.h" 4 #include "ppImageData.h"5 #include "ppImageOptions.h"6 2 7 3 static void imageOptionsFree(ppImageOptions *options) … … 25 21 } 26 22 27 28 // XXX EAM : this needs signficant work to choose the detrend images based on the detrend database 29 30 bool ppImageOptionsParse(ppImageData *data, ppImageOptions *options, pmConfig *config) 23 ppImageOptions *ppImageOptionsParse(pmConfig *config) 31 24 { 32 25 33 // Flags for various activities 34 options->doMask = false; // Mask bad pixels 35 options->doNonLin = false; // Non-linearity correction 36 options->doBias = false; // Bias subtraction 37 options->doDark = false; // Dark subtraction 26 ppImageOptions *options = ppImageOptionsAlloc (); 27 28 // default flags for various activities 29 options->doMask = false; // Mask bad pixels 30 options->doNonLin = false; // Non-linearity correction 31 options->doBias = false; // Bias subtraction 32 options->doDark = false; // Dark subtraction 38 33 options->doOverscan = false; // Overscan subtraction 39 options->doFlat = false; // Flat-field normalisation 40 options->doFringe = false; // Fringe subtraction 41 options->doSource = false; // Source identification and photometry 42 options->doAstrom = false; // Astrometry 43 // Overscan options 44 options->overscan = NULL; // Overscan options 45 bool overscanSingle = false; // A single value for entire overscan? 46 pmFit overscanFit = PM_FIT_NONE; // Fit type for overscan 47 int overscanOrder = 0; // Order for overscan fit 34 options->doFlat = false; // Flat-field normalisation 35 options->doFringe = false; // Fringe subtraction 36 options->doSource = false; // Source identification and photometry 37 options->doAstrom = false; // Astrometry 38 39 // Overscan defaults 40 options->overscan = NULL; // Overscan options 41 bool overscanSingle = false; // A single value for entire overscan? 42 pmFit overscanFit = PM_FIT_NONE; // Fit type for overscan 43 int overscanOrder = 0; // Order for overscan fit 48 44 psStats *overscanStats = NULL; // Statistics for overscan 49 // Non-linearity options 50 options->nonLinearType = 0; // Type of non-linearity data (vector, string or metadata) 51 options->nonLinearData = NULL; // The non-linearity data 45 46 // Non-linearity default options 47 options->nonLinearType = 0; // Type of non-linearity data (vector, string or metadata) 48 options->nonLinearData = NULL; // The non-linearity data 52 49 options->nonLinearSource = NULL; // If the non-linearity data is a menu, this provides the key 53 // Various others54 options->imageLoadDepth = PP_LOAD_NONE; // No load depth specified yet55 50 56 51 // select the recipe for this analysis 57 52 bool mdStatus = false; // Result of MD lookup 58 53 psMetadata *recipe = psMetadataLookupMD(&mdStatus, config->recipes, RECIPE_NAME); … … 60 55 psLogMsg("ppImage", PS_LOG_ERROR, "Can't find recipe %s in the RECIPES.\n", RECIPE_NAME); 61 56 exit(EXIT_FAILURE); 62 }63 64 const char *depth = psMetadataLookupStr(&mdStatus, recipe, "LOAD.DEPTH");65 if (! mdStatus || ! depth || strlen(depth) == 0) {66 psLogMsg("ppImage", PS_LOG_ERROR, "LOAD.DEPTH not specified in recipe.");67 exit(EXIT_FAILURE);68 }69 if (!strcasecmp(depth, "FPA")) {70 options->imageLoadDepth = PP_LOAD_FPA;71 } else if (!strcasecmp(depth, "CHIP")) {72 options->imageLoadDepth = PP_LOAD_CHIP;73 } else if (!strcasecmp(depth, "CELL")) {74 options->imageLoadDepth = PP_LOAD_CELL;75 } else {76 psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe %s is not FPA, CHIP or CELL.", RECIPE_NAME);77 exit(EXIT_FAILURE);78 }79 80 // Mask recipe options81 if (psMetadataLookupBool(NULL, recipe, "MASK")) {82 data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask");83 if (data->mask->filename && strlen(data->mask->filename) > 0) {84 options->doMask = true;85 } else {86 psLogMsg(__func__, PS_LOG_WARN, "Masking is desired, but no mask was supplied"87 " --- no masking will be performed.\n");88 }89 57 } 90 58 … … 124 92 "NONLIN.DATA is of invalid type in recipe %s.", RECIPE_NAME); 125 93 exit(EXIT_FAILURE); 126 }127 }128 129 // Bias recipe options130 if (psMetadataLookupBool(NULL, recipe, "BIAS")) {131 data->bias->filename = psMetadataLookupStr(NULL, config->arguments, "-bias");132 if (data->bias->filename && strlen(data->bias->filename) > 0) {133 options->doBias = true;134 } else {135 psLogMsg(__func__, PS_LOG_WARN, "Bias subtraction is desired in recipe %s, but no bias was "136 "supplied --- no bias subtraction will be performed.\n", RECIPE_NAME);137 }138 }139 140 // Dark recipe options141 if (psMetadataLookupBool(NULL, recipe, "DARK")) {142 data->dark->filename = psMetadataLookupStr(NULL, config->arguments, "-dark");143 if (data->dark->filename && strlen(data->dark->filename) > 0) {144 options->doDark = true;145 } else {146 psLogMsg(__func__, PS_LOG_WARN, "Dark subtraction is desired in recipe %s, but no dark was "147 "supplied --- no dark subtraction will be performed.\n", RECIPE_NAME);148 94 } 149 95 } … … 190 136 } 191 137 192 // flat-field - recipe options 193 if (psMetadataLookupBool(NULL, recipe, "FLAT")) { 194 data->flat->filename = psMetadataLookupStr(NULL, config->arguments, "-flat"); 195 if (strlen(data->flat->filename) > 0) { 196 options->doFlat = true; 197 } else { 198 psLogMsg(__func__, PS_LOG_WARN, "Flat-fielding is desired in recipe %s, but no flat was " 199 "supplied --- no flat-fielding will be performed.\n", RECIPE_NAME); 200 } 138 // Mask recipe options 139 if (psMetadataLookupBool(NULL, recipe, "MASK")) { 140 options->doMask = true; 201 141 } 202 142 203 // XXX need to add the following: 143 // Bias recipe options 144 if (psMetadataLookupBool(NULL, recipe, "BIAS")) { 145 options->doBias = true; 146 } 204 147 205 // fringe - recipe options 148 // Dark recipe options 149 if (psMetadataLookupBool(NULL, recipe, "DARK")) { 150 options->doDark = true; 151 } 206 152 207 // photom - recipe options 153 // Flat recipe options 154 if (psMetadataLookupBool(NULL, recipe, "FLAT")) { 155 options->doFlat = true; 156 } 208 157 209 // astrom - recipe options 210 211 return true; 158 return options; 212 159 } -
trunk/ppImage/src/ppImageOptions.h
r6747 r6817 1 1 #ifndef PP_IMAGE_OPTIONS_H 2 2 #define PP_IMAGE_OPTIONS_H 3 4 #include "pslib.h"5 #include "psmodules.h"6 #include "ppImageData.h"7 #include "ppConfig.h"8 9 // How much of the FPA to load at a time10 typedef enum {11 PP_LOAD_NONE, // Don't load anything12 PP_LOAD_FPA, // Load the entire FPA at once13 PP_LOAD_CHIP, // Load by chip14 PP_LOAD_CELL, // Load by cell15 } ppImageLoadDepth;16 3 17 4 // Options for ppImage processing … … 30 17 psMetadataItem *nonLinearData; 31 18 void *nonLinearSource; 32 ppImageLoadDepth imageLoadDepth; // How much of the FPA to load at once33 19 } ppImageOptions; 34 20 … … 36 22 37 23 // Determine the processing options 38 bool ppImageOptionsParse(ppImageData *data, // The data to be processed 39 ppImageOptions *options, // Processing options 40 pmConfig *config // Configuration 41 ); 24 ppImageOptions *ppImageOptionsParse(pmConfig *config); 42 25 43 26 #endif -
trunk/ppImage/src/ppImageParseDetrend.c
r6747 r6817 1 #include <stdio.h>2 #include "pslib.h"3 #include "psmodules.h"4 #include "ppFile.h"5 #include "ppImageData.h"6 #include "ppImageOptions.h"7 1 #include "ppImage.h" 8 2 9 // open all needed detrend files 10 // read in primary headers 11 // validate camera for each detrend image 3 // identify all needed detrend and other I/O files 4 // create the pmFPAfiles for the active I/O files 12 5 13 // XXX : keep the primary headers in data? 14 // XXX : add fringe frame 6 bool ppImageParseDetrend(ppImageOptions *options, pmConfig *config) 7 { 15 8 16 bool ppImageParseDetrend(ppImageData *data, ppImageOptions *options, pmConfig *config) 17 { 18 ppFileOpen(data->mask, "mask", options->doMask); 19 ppFileOpen(data->bias, "bias", options->doBias); 20 ppFileOpen(data->dark, "dark", options->doDark); 21 ppFileOpen(data->flat, "flat", options->doFlat); 9 bool status; 10 11 // some of the output files are associated with the input fpa 12 pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PPIMAGE.INPUT"); 13 14 // the following are defined from the argument list, if given, 15 // otherwise they revert to the config information 16 17 if (options->doBias) { 18 bool status = false; 19 pmFPAfileFromArgs (&status, config, "PPIMAGE.BIAS", "BIAS"); 20 pmFPAfileFromConf (&status, config, "PPIMAGE.BIAS", input->fpa); 21 if (!status) psAbort ("ppImageParseDetrend", "can't find a bias image source"); 22 } 23 24 if (options->doDark) { 25 bool status = false; 26 pmFPAfileFromArgs (&status, config, "PPIMAGE.DARK", "DARK"); 27 pmFPAfileFromConf (&status, config, "PPIMAGE.DARK", input->fpa); 28 if (!status) psAbort ("ppImageParseDetrend", "can't find a dark image source"); 29 } 30 31 if (options->doMask) { 32 bool status = false; 33 pmFPAfileFromArgs (&status, config, "PPIMAGE.MASK", "MASK"); 34 pmFPAfileFromConf (&status, config, "PPIMAGE.MASK", input->fpa); 35 if (!status) psAbort ("ppImageParseDetrend", "can't find a mask image source"); 36 } 37 38 if (options->doFlat) { 39 bool status = false; 40 pmFPAfileFromArgs (&status, config, "PPIMAGE.FLAT", "FLAT"); 41 pmFPAfileFromConf (&status, config, "PPIMAGE.FLAT", input->fpa); 42 if (!status) psAbort ("ppImageParseDetrend", "can't find a flat image source"); 43 } 44 45 // the following files are output targets 46 // XXX which of these are required? 47 pmFPAfileDefine (config->files, config->camera, input->fpa, "PPIMAGE.OUTPUT"); 48 49 // XXX do these need to construct a new fpa? 50 // pmFPAfileDefine (config->files, config->camera, input->input, "PPIMAGE.BIN1"); 51 // pmFPAfileDefine (config->files, config->camera, input->input, "PPIMAGE.BIN2"); 52 // pmFPAfileDefine (config->files, config->camera, input->input, "PPIMAGE.JPG1"); 53 // pmFPAfileDefine (config->files, config->camera, input->input, "PPIMAGE.JPG2"); 54 55 // ppImage is supplied with an output name, which may be used by multiple 56 // output files to construct the output names. supply this value to the 57 // files which are write types. 58 char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT"); 59 pmFPAfileAddFileNames (config->files, "OUTPUT", output, PM_FPA_MODE_WRITE); 60 22 61 return true; 23 62 }
Note:
See TracChangeset
for help on using the changeset viewer.
