Changeset 6747
- Timestamp:
- Mar 31, 2006, 3:24:14 PM (20 years ago)
- Location:
- trunk/ppImage/src
- Files:
-
- 23 edited
-
Makefile.am (modified) (3 diffs)
-
ppFile.c (modified) (3 diffs)
-
ppFile.h (modified) (2 diffs)
-
ppImage.c (modified) (3 diffs)
-
ppImage.h (modified) (3 diffs)
-
ppImageConfig.c (modified) (3 diffs)
-
ppImageDetrend.h (modified) (2 diffs)
-
ppImageDetrendBias.c (modified) (1 diff)
-
ppImageDetrendCell.c (modified) (2 diffs)
-
ppImageDetrendFlat.c (modified) (2 diffs)
-
ppImageDetrendMask.c (modified) (1 diff)
-
ppImageDetrendNonLinear.c (modified) (1 diff)
-
ppImageDetrendPedestal.c (modified) (3 diffs)
-
ppImageLoadPixels.c (modified) (1 diff)
-
ppImageLoop.c (modified) (5 diffs)
-
ppImageOptions.c (modified) (11 diffs)
-
ppImageOptions.h (modified) (2 diffs)
-
ppImageOutput.c (modified) (1 diff)
-
ppImageParseCamera.c (modified) (6 diffs)
-
ppImageParseDetrend.c (modified) (2 diffs)
-
ppImagePhot.c (modified) (1 diff)
-
ppImageWeights.c (modified) (1 diff)
-
ppTest.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/Makefile.am
r6566 r6747 2 2 3 3 noinst_HEADERS = \ 4 ppFile.h \ 4 5 ppImage.h \ 5 6 ppImageData.h \ 6 7 ppImageDetrend.h \ 7 ppImageOptions.h 8 ppImageOptions.h \ 9 ppMem.h 8 10 9 11 ppImage_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(ppImage_CFLAGS) 10 12 ppImage_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) 11 13 ppImage_SOURCES = \ 14 ppFile.c \ 12 15 ppImage.c \ 16 ppImageConfig.c \ 13 17 ppImageData.c \ 14 18 ppImageDetrendBias.c \ … … 19 23 ppImageOptions.c \ 20 24 ppImageParseCamera.c \ 21 ppImage ParseDetrend.c \22 pp ImageWeights.c25 ppImageWeights.c \ 26 ppMem.c 23 27 # ppImageLoadPixels.c 24 28 # ppDetrendFlat.c … … 30 34 ppTest_CPPFLAGS = $(PSLIB_CFLAGS) $(PSMODULE_CFLAGS) $(ppImage_CFLAGS) 31 35 ppTest_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) 32 ppTest_SOURCES = ppTest.c 36 ppTest_SOURCES = \ 37 ppTest.c \ 38 ppMem.c 33 39 34 40 -
trunk/ppImage/src/ppFile.c
r6260 r6747 12 12 psFitsClose(file->fits); 13 13 } 14 psFree(file->view); 14 15 return; 15 16 } … … 25 26 file->fits = NULL; 26 27 file->phu = NULL; 28 file->view = NULL; 27 29 28 30 return file; … … 30 32 31 33 34 bool ppFileOpen(ppFile *file, const char *name, pmConfig *config, psMetadata *camera, psMetadata *format) 35 { 36 file->fpa = pmFPAConstruct(camera); 37 psString filename = psMetadataLookupStr(NULL, config->arguments, name); 38 if (strlen(filename) == 0) { 39 return false; 40 } 41 file->filename = psMemIncrRefCounter(filename); 42 file->fits = psFitsOpen(filename, "r"); 43 file->phu = psFitsReadHeader(NULL, file->fits); 44 if (!pmConfigValidateCameraFormat(format, file->phu)) { 45 psLogMsg(__func__, PS_LOG_WARN, "File %s doesn't match camera format --- ignored.\n", filename); 46 psFitsClose(file->fits); 47 return false; 48 } 49 file->view = pmFPAAddSource(file->fpa, file->phu, format); 50 return true; 51 } 52 -
trunk/ppImage/src/ppFile.h
r6260 r6747 3 3 4 4 #include "pslib.h" 5 #include "p mFPA.h"5 #include "psmodules.h" 6 6 7 7 // A file to process … … 11 11 psMetadata *phu; // The FITS header 12 12 pmFPA *fpa; // The FPA, with pixels and extensions 13 pmFPAview *view; // The view 13 14 } ppFile; 14 15 15 16 16 // Allocator s17 // Allocator 17 18 ppFile *ppFileAlloc(void); 18 19 20 bool ppFileOpen(ppFile *file, const char *name, pmConfig *config, psMetadata *camera, psMetadata *format); 19 21 20 22 #endif -
trunk/ppImage/src/ppImage.c
r6396 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "p mConcepts.h"3 #include "psmodules.h" 4 4 #include "ppImage.h" 5 5 #include "ppMem.h" … … 11 11 ppImageData *data = ppImageDataAlloc(); 12 12 ppImageOptions *options = ppImageOptionsAlloc(); 13 ppConfig *config = ppConfigAlloc();14 13 15 14 psTimerStart(TIMERNAME); 16 15 17 16 // Parse the configuration and arguments 18 p pImageConfig(config,argc, argv);17 pmConfig *config = ppImageConfig(argc, argv); 19 18 20 19 // Open the input image, output image, output mask … … 26 25 ppImageOptionsParse(data, options, config); 27 26 27 #if 0 28 // XXX I think we do this in ppImageParseCamera 29 28 30 // open detrend images, load headers, optionally load pixels 29 31 ppImageParseDetrend(data, options, config); 32 #endif 30 33 31 34 // Image Arithmetic Loop -
trunk/ppImage/src/ppImage.h
r6260 r6747 3 3 4 4 #include "pslib.h" 5 #include "pmFPA.h" 6 #include "ppConfig.h" 7 #include "ppFile.h" 5 #include "psmodules.h" 6 8 7 #include "ppImageData.h" 9 8 #include "ppImageOptions.h" 10 9 11 12 #if 0 13 #include <strings.h> 14 #include "psAdditionals.h" 15 #include "pmFPA.h" 16 #include "pmFPAConstruct.h" 17 #include "pmFPARead.h" 18 #include "pmFPAWrite.h" 19 #include "pmReadout.h" 20 #include "pmConfig.h" 21 #include "pmFlatField.h" 22 #include "pmMaskBadPixels.h" 23 #include "pmNonLinear.h" 24 #include "pmChipMosaic.h" 25 #include "pmSubtractBias.h" 26 #endif 27 28 29 #define RECIPE "PHASE2" // Name of the recipe to use 10 #define RECIPE_NAME "PHASE2" // Name of the recipe to use 30 11 #define TIMERNAME "ppImage" // Name of timer 31 12 32 13 // Get the configuration 33 bool ppImageConfig(ppConfig *config,int argc, char **argv);14 pmConfig *ppImageConfig(int argc, char **argv); 34 15 35 16 // Determine what type of camera, and initialise 36 17 bool ppImageParseCamera(ppImageData *data, // The data to be processed 37 p pConfig *config // Configuration18 pmConfig *config // Configuration 38 19 ); 39 20 40 21 41 22 // Loop over the input 42 bool ppImageLoop(ppImageData *data, ppImageOptions *options, p pConfig *config);23 bool ppImageLoop(ppImageData *data, ppImageOptions *options, pmConfig *config); 43 24 44 25 // Load the pixels for the given file … … 49 30 ); 50 31 51 bool ppImageParseDetrend(ppImageData *data, ppImageOptions *options, p pConfig *config);32 bool ppImageParseDetrend(ppImageData *data, ppImageOptions *options, pmConfig *config); 52 33 53 34 bool ppReadoutWeights(pmReadout *readout); … … 56 37 // These functions are not implemented, or not needed 57 38 pmReadout* ppDetrendPedestal(pmReadout *pedestal, pmCell *input, pmReadout *bias, pmReadout *dark, float darkTime, ppImageOptions *options); 58 bool ppImageOutput(ppImageData *data, p pConfig *config);59 bool ppImagePhot(ppImageData *data, ppImageOptions *options, p pConfig *config);60 bool ppFileOpen(ppFile *fpa, psMetadata *camera,char *name, bool doThis);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); 61 42 #endif 62 43 -
trunk/ppImage/src/ppImageConfig.c
r6318 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "pmConfig.h" 4 #include "ppConfig.h" 3 #include "psmodules.h" 5 4 #include "ppImage.h" 6 5 7 bool ppImageConfig(ppConfig *config,int argc, char **argv)6 pmConfig *ppImageConfig(int argc, char **argv) 8 7 { 9 // XXX - this should be split into a function to parse argc,argv 10 // and a second to read the config files. 11 // all argc,argv should be interpretted before work is done. 12 if (! pmConfigRead(&config->site, &config->camera, &config->recipe, &argc, argv, RECIPE)) { 8 pmConfig *config = pmConfigRead(&argc, argv); 9 if (! config) { 13 10 psErrorStackPrint(stderr, "Can't find site configuration!\n"); 14 11 exit(EXIT_FAILURE); … … 17 14 // Parse other command-line arguments 18 15 config->arguments = psMetadataAlloc(); // The arguments, with default values 19 20 16 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-key", 0, "exposure ID", ""); 21 17 psMetadataAddStr(config->arguments, PS_LIST_TAIL, "-bias", 0, "Name of the bias image", ""); … … 43 39 #endif 44 40 45 return true;41 return config; 46 42 } -
trunk/ppImage/src/ppImageDetrend.h
r6260 r6747 3 3 4 4 #include "pslib.h" 5 #include "pmFPA.h" 6 #include "ppConfig.h" 5 #include "psmodules.h" 7 6 #include "ppImageOptions.h" 8 7 … … 17 16 18 17 19 bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, p pConfig *config);18 bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config); 20 19 bool ppImageDetrendMask(pmCell *cell, pmReadout *input, pmReadout *mask); 21 20 bool ppImageDetrendNonLinear(pmCell *cell, pmReadout *input, ppImageOptions *options); -
trunk/ppImage/src/ppImageDetrendBias.c
r6260 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "p mFPA.h"3 #include "psmodules.h" 4 4 #include "ppImageOptions.h" 5 5 #include "ppImageDetrend.h" -
trunk/ppImage/src/ppImageDetrendCell.c
r6260 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "pmFPA.h" 4 #include "pmFlatField.h" 3 #include "psmodules.h" 5 4 #include "ppImageDetrend.h" 5 #include "ppImageOptions.h" 6 6 7 7 // mask, bias, dark, flat are defined per Cell … … 22 22 } 23 23 24 bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, p pConfig *config)24 bool ppImageDetrendCell(ppImageDetrend *detrend, ppImageOptions *options, pmConfig *config) 25 25 { 26 #if 0 26 27 pmCellSetWeights(detrend->input); 28 #endif 27 29 28 30 pmReadout *mask = ppImageDetrendSelectFirst(detrend->mask, "mask", options->doMask); -
trunk/ppImage/src/ppImageDetrendFlat.c
r5858 r6747 1 # include "ppImage.h" 1 #include <stdio.h> 2 #include "pslib.h" 3 #include "psmodules.h" 4 #include "ppImage.h" 2 5 3 6 // why does this use the flat pmReadout? … … 7 10 psLogMsg("phase2", PS_LOG_INFO, "Performing flat field.\n"); 8 11 9 12 10 13 11 14 #ifndef PRODUCTION 12 15 psImage *dummyImage = psImageAlloc(inputReadout->image->numCols, 13 inputReadout->image->numRows,14 PS_TYPE_U8);16 inputReadout->image->numRows, 17 PS_TYPE_U8); 15 18 pmReadout *dummyMask = pmReadoutAlloc(NULL); 16 19 dummyMask->image = dummyImage; -
trunk/ppImage/src/ppImageDetrendMask.c
r6260 r6747 1 1 #include <stdio.h> 2 #include "pmFPA.h" 3 #include "pmMaskBadPixels.h" 2 #include "psmodules.h" 4 3 #include "ppImageDetrend.h" 5 4 -
trunk/ppImage/src/ppImageDetrendNonLinear.c
r6260 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "pmFPA.h" 4 #include "pmNonLinear.h" 3 #include "psmodules.h" 5 4 #include "ppImageDetrend.h" 6 5 -
trunk/ppImage/src/ppImageDetrendPedestal.c
r5858 r6747 1 # include "ppImage.h" 1 #include <stdio.h> 2 #include "pslib.h" 3 #include "psmodules.h" 4 #include "ppImage.h" 2 5 3 6 // XXX check on image overlaps, as well as image sizes … … 13 16 14 17 if (options->doDark) { 15 // Dark time for input image16 float inputTime = psMetadataLookupF32(NULL, input->concepts, "CELL.DARKTIME");17 if (inputTime <= 0) {18 psErrorStackPrint(stderr, "DARKTIME for input image (%f) is non-positive.\n",19 inputTime);20 exit(EXIT_FAILURE);21 }18 // Dark time for input image 19 float inputTime = psMetadataLookupF32(NULL, input->concepts, "CELL.DARKTIME"); 20 if (inputTime <= 0) { 21 psErrorStackPrint(stderr, "DARKTIME for input image (%f) is non-positive.\n", 22 inputTime); 23 exit(EXIT_FAILURE); 24 } 22 25 23 if (inputTime != lastExptime) {24 // this will create a new pedestal if the input one is NULL25 // 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;26 if (inputTime != lastExptime) { 27 // this will create a new pedestal if the input one is NULL 28 // XXX EAM : this function had darkTime * inputTime, which is wrong, yes? 29 if (pedestal == NULL) { 30 pedestal = pmReadoutAlloc (NULL); 31 } 32 pedestal->col0 = dark->col0; 33 pedestal->row0 = dark->row0; 34 pedestal->colBins = dark->colBins; 35 pedestal->rowBins = dark->rowBins; 33 36 34 pedestal->image = (psImage *) psBinaryOp(pedestal->image, dark->image, "*", psScalarAlloc(inputTime / darkTime, PS_TYPE_F32));35 reusePedestal = false;36 lastExptime = inputTime37 }37 pedestal->image = (psImage *) psBinaryOp(pedestal->image, dark->image, "*", psScalarAlloc(inputTime / darkTime, PS_TYPE_F32)); 38 reusePedestal = false; 39 lastExptime = inputTime 40 } 38 41 } 39 42 40 43 // no bias image, return dark pedestal or NULL 41 44 if (!options->doBias) { 42 return pedestal;45 return pedestal; 43 46 } 44 47 45 48 // no dark image, return bias pedestal, or reuse 46 49 if (!options->doDark) { 47 if (!pedestal) {48 pedestal = psMemIncrRefCounter(bias);49 }50 return pedestal;50 if (!pedestal) { 51 pedestal = psMemIncrRefCounter(bias); 52 } 53 return pedestal; 51 54 } 52 55 53 56 if (reusePedestal) { 54 return pedestal;57 return pedestal; 55 58 } 56 59 57 60 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);61 bias->image->numCols != dark->image->numCols) { 62 psError(PS_ERR_IO, true, "Bias and dark images have different dimensions: %dx%d vs %dx%d\n", 63 bias->image->numCols, bias->image->numRows, 64 dark->image->numCols, dark->image->numRows); 65 exit(EXIT_FAILURE); 63 66 } 64 67 … … 71 74 72 75 // creates a new pedestal image for this readout 73 // if the current exptime is the same as the last exptime, 76 // if the current exptime is the same as the last exptime, 74 77 // reuses the supplied pedestal -
trunk/ppImage/src/ppImageLoadPixels.c
r6079 r6747 1 // XXX PAP: Need to look this over some more 2 1 #include <stdio.h> 2 #include "pslib.h" 3 #include "psmodules.h" 3 4 #include "ppImage.h" 4 5 -
trunk/ppImage/src/ppImageLoop.c
r6396 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "pmFPA.h" 4 #include "pmFPARead.h" 5 #include "pmChipMosaic.h" 6 #include "pmFPAWrite.h" 3 #include "psmodules.h" 7 4 #include "ppImageDetrend.h" 8 5 #include "ppImage.h" … … 13 10 // Read the entire FPA 14 11 void readFPA(ppFile *file, // File to read 15 p pConfig *config // Configuration, containing the DB handle12 pmConfig *config // Configuration, containing the DB handle 16 13 ) 17 14 { 18 15 if (file->fpa && file->fits) { 19 if (! pmFPARead(file->fpa, file->fits, file->phu, config->database)) { 20 psErrorStackPrint(stderr, "Unable to populate camera from input FITS file\n"); 21 exit(EXIT_FAILURE); 22 } 16 pmFPARead(file->fpa, file->fits, config->database); 23 17 } 24 18 } … … 26 20 // Read a specified chip only 27 21 void readChip(ppFile *file, // File to read 28 p pConfig *config, // Configuration22 pmConfig *config, // Configuration 29 23 int chipNum // Chip number to read 30 24 ) 31 25 { 32 pmFPASelectChip(file->fpa, chipNum); 33 readFPA(file, config); 26 pmFPA *fpa = file->fpa; // The FPA 27 if (fpa && file->fits) { 28 pmChip *chip = fpa->chips->data[chipNum]; // The chip 29 pmChipRead(chip, file->fits, config->database); 30 } 34 31 } 35 32 36 33 37 void readCell(ppFile *file, p pConfig *config, int chipNum, int cellNum)34 void readCell(ppFile *file, pmConfig *config, int chipNum, int cellNum) 38 35 { 39 pmChip *chip = file->fpa->chips->data[chipNum]; 40 pmChipSelectCell(chip, cellNum); 41 readFPA(file, config); 36 pmFPA *fpa = file->fpa; // The FPA 37 if (fpa && file->fits) { 38 pmChip *chip = fpa->chips->data[chipNum]; // The chip 39 if (chip) { 40 pmCell *cell = chip->cells->data[cellNum]; // The cell 41 pmCellRead(cell, file->fits, config->database); 42 } 43 } 42 44 } 43 45 44 46 45 bool ppImageLoop(ppImageData *data, ppImageOptions *options, p pConfig *config)47 bool ppImageLoop(ppImageData *data, ppImageOptions *options, pmConfig *config) 46 48 { 47 49 ppImageDetrend detrend; … … 108 110 } 109 111 112 #if 0 110 113 int numMosaicked = pmChipMosaic(inputChip, 1, 1); // Number of cells mosaicked together 111 114 psLogMsg(__func__, PS_LOG_INFO, "%d cells mosaicked.\n", numMosaicked); 112 113 // XXX EAM: Photometry goes here!114 115 115 116 // XXX A kludge to get the write to behave w.r.t. the concepts --- we've changed the camera format, so … … 117 118 const psMetadata *camera = data->input->fpa->camera; 118 119 data->input->fpa->camera = NULL; 119 pmFPAWrite(data->output, data->input->fpa, config->database); 120 #endif 121 122 // XXX Photometry goes here! 123 124 pmChipWrite(inputChip, data->output, config->database); 125 126 #if 0 120 127 data->input->fpa->camera = camera; 128 #endif 121 129 122 130 // Now I can blow away the mosaic so I can then read more. -
trunk/ppImage/src/ppImageOptions.c
r6396 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "pp Config.h"3 #include "ppImage.h" 4 4 #include "ppImageData.h" 5 5 #include "ppImageOptions.h" … … 28 28 // XXX EAM : this needs signficant work to choose the detrend images based on the detrend database 29 29 30 bool ppImageOptionsParse(ppImageData *data, ppImageOptions *options, p pConfig *config)30 bool ppImageOptionsParse(ppImageData *data, ppImageOptions *options, pmConfig *config) 31 31 { 32 32 … … 56 56 57 57 bool mdStatus = false; // Result of MD lookup 58 const char *depth = psMetadataLookupStr(&mdStatus, config->recipe, "LOAD.DEPTH"); 58 psMetadata *recipe = psMetadataLookupMD(&mdStatus, config->recipes, RECIPE_NAME); 59 if (! mdStatus || !recipe) { 60 psLogMsg("ppImage", PS_LOG_ERROR, "Can't find recipe %s in the RECIPES.\n", RECIPE_NAME); 61 exit(EXIT_FAILURE); 62 } 63 64 const char *depth = psMetadataLookupStr(&mdStatus, recipe, "LOAD.DEPTH"); 59 65 if (! mdStatus || ! depth || strlen(depth) == 0) { 60 66 psLogMsg("ppImage", PS_LOG_ERROR, "LOAD.DEPTH not specified in recipe."); … … 68 74 options->imageLoadDepth = PP_LOAD_CELL; 69 75 } else { 70 psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe is not FPA, CHIP or CELL.");76 psLogMsg(__func__, PS_LOG_ERROR, "LOAD.DEPTH in recipe %s is not FPA, CHIP or CELL.", RECIPE_NAME); 71 77 exit(EXIT_FAILURE); 72 78 } 73 79 74 80 // Mask recipe options 75 if (psMetadataLookupBool(NULL, config->recipe, "MASK")) {81 if (psMetadataLookupBool(NULL, recipe, "MASK")) { 76 82 data->mask->filename = psMetadataLookupStr(NULL, config->arguments, "-mask"); 77 83 if (data->mask->filename && strlen(data->mask->filename) > 0) { … … 84 90 85 91 // Non-linearity recipe options 86 if (psMetadataLookupBool(NULL, config->recipe, "NONLIN")) {87 psMetadataItem *dataItem = psMetadataLookup( config->recipe, "NONLIN.DATA");92 if (psMetadataLookupBool(NULL, recipe, "NONLIN")) { 93 psMetadataItem *dataItem = psMetadataLookup(recipe, "NONLIN.DATA"); 88 94 if (! dataItem) { 89 95 psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to " 90 "find NONLIN.DATA in recipe .");96 "find NONLIN.DATA in recipe %s.", RECIPE_NAME); 91 97 exit(EXIT_FAILURE); 92 98 } … … 106 112 { 107 113 bool status; 108 options->nonLinearSource = psMetadataLookupStr(&status, config->recipe, "NONLIN.SOURCE");114 options->nonLinearSource = psMetadataLookupStr(&status, recipe, "NONLIN.SOURCE"); 109 115 if (! status || ! options->nonLinearSource) { 110 116 psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but unable to " 111 "find NONLIN.SOURCE in recipe ");117 "find NONLIN.SOURCE in recipe %s.", RECIPE_NAME); 112 118 exit(EXIT_FAILURE); 113 119 } … … 116 122 default: 117 123 psLogMsg(__func__, PS_LOG_ERROR, "Non-linearity correction desired, but " 118 "NONLIN.DATA is of invalid type .");124 "NONLIN.DATA is of invalid type in recipe %s.", RECIPE_NAME); 119 125 exit(EXIT_FAILURE); 120 126 } … … 122 128 123 129 // Bias recipe options 124 if (psMetadataLookupBool(NULL, config->recipe, "BIAS")) {130 if (psMetadataLookupBool(NULL, recipe, "BIAS")) { 125 131 data->bias->filename = psMetadataLookupStr(NULL, config->arguments, "-bias"); 126 132 if (data->bias->filename && strlen(data->bias->filename) > 0) { 127 133 options->doBias = true; 128 134 } else { 129 psLogMsg(__func__, PS_LOG_WARN, "Bias subtraction is desired , but no bias was supplied ---"130 " no bias subtraction will be performed.\n");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); 131 137 } 132 138 } 133 139 134 140 // Dark recipe options 135 if (psMetadataLookupBool(NULL, config->recipe, "DARK")) {141 if (psMetadataLookupBool(NULL, recipe, "DARK")) { 136 142 data->dark->filename = psMetadataLookupStr(NULL, config->arguments, "-dark"); 137 143 if (data->dark->filename && strlen(data->dark->filename) > 0) { 138 144 options->doDark = true; 139 145 } else { 140 psLogMsg(__func__, PS_LOG_WARN, "Dark subtraction is desired , but no dark was supplied ---"141 " no dark subtraction will be performed.\n");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); 142 148 } 143 149 } … … 147 153 // Overscan recipe options 148 154 // XXX EAM : we should abort on invalid options. default options? 149 if (psMetadataLookupBool(NULL, config->recipe, "OVERSCAN")) {155 if (psMetadataLookupBool(NULL, recipe, "OVERSCAN")) { 150 156 options->doOverscan = true; 151 157 152 158 // Do the overscan as a single value? 153 overscanSingle = psMetadataLookupBool(NULL, config->recipe, "OVERSCAN.SINGLE");159 overscanSingle = psMetadataLookupBool(NULL, recipe, "OVERSCAN.SINGLE"); 154 160 155 161 // How do we fit it? 156 psString fit = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.FIT");162 psString fit = psMetadataLookupStr(NULL, recipe, "OVERSCAN.FIT"); 157 163 if (! strcasecmp(fit, "POLYNOMIAL")) { 158 164 overscanFit = PM_FIT_POLY_ORD; 159 overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER");165 overscanOrder = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER"); 160 166 } else if (! strcasecmp(fit, "CHEBYSHEV")) { 161 167 overscanFit = PM_FIT_POLY_CHEBY; 162 overscanOrder = psMetadataLookupS32(NULL, config->recipe, "OVERSCAN.ORDER");168 overscanOrder = psMetadataLookupS32(NULL, recipe, "OVERSCAN.ORDER"); 163 169 } else if (! strcasecmp(fit, "SPLINE")) { 164 170 overscanFit = PM_FIT_SPLINE; 165 171 } else if (strcasecmp(fit, "NONE")) { 166 psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) i s not one of NONE, POLYNOMIAL, or SPLINE:"167 " assuming NONE.\n", fit);168 } 169 170 psString stat = psMetadataLookupStr(NULL, config->recipe, "OVERSCAN.STAT");172 psLogMsg(__func__, PS_LOG_WARN, "OVERSCAN.FIT (%s) in recipe %s is not one of NONE, " 173 "POLYNOMIAL, or SPLINE: assuming NONE.\n", fit, RECIPE_NAME); 174 } 175 176 psString stat = psMetadataLookupStr(NULL, recipe, "OVERSCAN.STAT"); 171 177 if (! strcasecmp(stat, "MEAN")) { 172 178 overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); … … 174 180 overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEDIAN); 175 181 } else { 176 psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) is not one of MEAN, MEDIAN: assuming MEAN\n", stat); 182 psErrorStackPrint(stderr, "OVERSCAN.STAT (%s) in recipe %s is not one of MEAN, MEDIAN: " 183 "assuming MEAN\n", stat, RECIPE_NAME); 177 184 overscanStats = psStatsAlloc(PS_STAT_SAMPLE_MEAN); 178 185 } … … 184 191 185 192 // flat-field - recipe options 186 if (psMetadataLookupBool(NULL, config->recipe, "FLAT")) {193 if (psMetadataLookupBool(NULL, recipe, "FLAT")) { 187 194 data->flat->filename = psMetadataLookupStr(NULL, config->arguments, "-flat"); 188 195 if (strlen(data->flat->filename) > 0) { 189 196 options->doFlat = true; 190 197 } else { 191 psLogMsg(__func__, PS_LOG_WARN, "Flat-fielding is desired , but no flat was supplied ---"192 " no flat-fielding will be performed.\n");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); 193 200 } 194 201 } -
trunk/ppImage/src/ppImageOptions.h
r6260 r6747 3 3 4 4 #include "pslib.h" 5 #include "p mSubtractBias.h"5 #include "psmodules.h" 6 6 #include "ppImageData.h" 7 7 #include "ppConfig.h" … … 38 38 bool ppImageOptionsParse(ppImageData *data, // The data to be processed 39 39 ppImageOptions *options, // Processing options 40 p pConfig *config // Configuration40 pmConfig *config // Configuration 41 41 ); 42 42 -
trunk/ppImage/src/ppImageOutput.c
r6114 r6747 1 # include "ppImage.h" 1 #include <stdio.h> 2 #include "pslib.h" 3 #include "psmodules.h" 4 #include "ppImage.h" 2 5 3 bool ppImageOutput(ppData *data, p pConfig *config)6 bool ppImageOutput(ppData *data, pmConfig *config) 4 7 { 5 8 const char *outname = psMetadataLookupStr(NULL, config->arguments, "-output"); // Name of output file -
trunk/ppImage/src/ppImageParseCamera.c
r6260 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "pmFPA.h" 4 #include "pmFPAConstruct.h" 5 #include "pmConfig.h" 3 #include "psmodules.h" 6 4 #include "ppImage.h" 7 5 8 bool ppImageParseCamera(ppImageData *data, p pConfig *config)6 bool ppImageParseCamera(ppImageData *data, pmConfig *config) 9 7 { 10 8 // Initialise the containers where the files will go … … 22 20 data->input->fits = psFitsOpen(data->input->filename, "r"); // File handle for FITS file 23 21 if (! data->input->fits) { 24 // There's no point in continuing if we can't open the input22 // We can't open the input 25 23 psErrorStackPrint(stderr, "Can't open input image: %s\n", data->input->filename); 26 24 exit(EXIT_FAILURE); … … 29 27 30 28 // Get camera configuration from header if not already defined 29 psMetadata *cameraFormat = NULL; // Camera format description 31 30 if (! config->camera) { 32 c onfig->camera = pmConfigCameraFromHeader(config->site, data->input->phu);31 cameraFormat = pmConfigCameraFormatFromHeader(config, data->input->phu); 33 32 if (! config->camera) { 34 33 // There's no point in continuing if we can't recognise what we've got … … 36 35 exit(EXIT_FAILURE); 37 36 } 38 } else if (! pmConfigValidateCamera(config->camera, data->input->phu)) {39 // There's no point in continuing if what we've got doesn't match what we've been told37 } else if (! pmConfigValidateCameraFormat(config->camera, data->input->phu)) { 38 // What we've got doesn't match what we've been told 40 39 psError(PS_ERR_IO, true, "%s does not seem to be from the specified camera.\n", 41 40 data->input->filename); … … 43 42 } 44 43 45 // Determine the correct recipe to use 46 if (! config->recipe && !(config->recipe = pmConfigRecipeFromCamera(config->camera, RECIPE))) { 47 // There's no point in continuing if we can't work out what recipe to use 48 psErrorStackPrint(stderr, "Can't find recipe configuration!\n"); 49 exit(EXIT_FAILURE); 50 } 44 // Construct cameras in preparation for reading 45 data->input->fpa = pmFPAConstruct(config->camera); 46 data->input->view = pmFPAAddSource(data->input->fpa, data->input->phu, cameraFormat); 51 47 52 // Construct cameras in preparation for reading53 data->input->fpa = pmFPAConstruct(config->camera);54 data->mask->fpa = pmFPAConstruct(config->camera);55 data->bias->fpa = pmFPAConstruct(config->camera);56 data->dark->fpa = pmFPAConstruct(config->camera);57 data->flat->fpa = pmFPAConstruct(config->camera); 58 data->fringe->fpa = pmFPAConstruct(config->camera);48 ppFileOpen(data->mask, "-mask", config, config->camera, cameraFormat); 49 ppFileOpen(data->bias, "-bias", config, config->camera, cameraFormat); 50 ppFileOpen(data->dark, "-dark", config, config->camera, cameraFormat); 51 ppFileOpen(data->flat, "-flat", config, config->camera, cameraFormat); 52 ppFileOpen(data->fringe, "-fringe", config, config->camera, cameraFormat); 53 54 psFree(cameraFormat); 59 55 60 56 // Open output file … … 66 62 } 67 63 68 // XXX EAM : extend this to allow an array of selected chips by name69 // Chip selection: if we are using a single chip, select it for each FPA70 int chipNum = psMetadataLookupS32(NULL, config->arguments, "-chip"); // Chip number to work on71 if (chipNum >= 0) {72 if (! pmFPASelectChip(data->input->fpa, chipNum)) {73 psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum);74 exit(EXIT_FAILURE);75 }76 psLogMsg("ppImage", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);77 }78 64 return true; 79 65 } 80 66 81 // XXX EAM : I dropped the pre-open of the output files; replace with a stats test of output permissions82 83 // XXX : for split data (data spread across multiple files), this step is only operating on a component84 // of the FPA. the other components should be set to 'invalid' in this case? -
trunk/ppImage/src/ppImageParseDetrend.c
r6260 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "p mConfig.h"3 #include "psmodules.h" 4 4 #include "ppFile.h" 5 5 #include "ppImageData.h" … … 14 14 // XXX : add fringe frame 15 15 16 bool ppFileOpen(ppFile *file, psMetadata *camera, char *name, bool doThis) { 17 18 if (!doThis) { 19 return false; 20 } 21 22 psLogMsg("phase2", PS_LOG_INFO, "Opening %s image: %s\n", name, file->filename); 23 file->fits = psFitsOpen(file->filename, "r"); // File handle 24 file->phu = psFitsReadHeader(NULL, file->fits); // primary header 25 if (! pmConfigValidateCamera(camera, file->phu)) { 26 psError(PS_ERR_IO, true, "%s (%s) does not seem to be from the correct camera.\n", name, 27 file->filename); 28 exit(EXIT_FAILURE); 29 } 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); 30 22 return true; 31 23 } 32 33 bool ppImageParseDetrend(ppImageData *data, ppImageOptions *options, ppConfig *config) {34 35 ppFileOpen(data->mask, config->camera, "mask", options->doMask);36 ppFileOpen(data->bias, config->camera, "bias", options->doBias);37 ppFileOpen(data->dark, config->camera, "dark", options->doDark);38 ppFileOpen(data->flat, config->camera, "flat", options->doFlat);39 return true;40 } -
trunk/ppImage/src/ppImagePhot.c
r6114 r6747 1 #include <stdio.h> 2 #include "pslib.h" 3 #include "psmodules.h" 1 4 #include "ppImage.h" 2 5 3 bool ppImagePhot(ppData *data, ppOptions *options, p pConfig *config)6 bool ppImagePhot(ppData *data, ppOptions *options, pmConfig *config) 4 7 { 5 8 ppFile *input = data->input; // The input file information -
trunk/ppImage/src/ppImageWeights.c
r6260 r6747 1 1 #include <stdio.h> 2 2 #include "pslib.h" 3 #include "p mFPA.h"3 #include "psmodules.h" 4 4 #include "ppImage.h" 5 5 -
trunk/ppImage/src/ppTest.c
r6624 r6747 3 3 #include "pslib.h" 4 4 #include "psmodules.h" 5 #include "ppMem.h" 5 6 6 7 int main(int argc, char *argv[]) … … 96 97 // Read the FPA 97 98 pmFPARead(fpa, inFile, NULL); 99 // Copy to new camera format 100 pmFPA *newFPA = pmFPAConstruct(config->camera); 101 psMetadata *newFormat = psMetadataConfigParse(NULL, NULL, "mcshort_splice.config", true); 102 pmConfigConformHeader(phu, newFormat); 103 pmFPAview *newView = pmFPAAddSource(newFPA, phu, newFormat); 104 printf("View chip: %d\n", newView->chip); 105 printf("View cell: %d\n", newView->cell); 106 pmFPACopy(newFPA, fpa); 107 pmFPAWrite(newFPA, outFile, NULL); 108 pmFPAPrint(newFPA, false, true); 98 109 99 // How'd we do? 100 pmFPAPrint(fpa, true); 101 #if 1 102 pmChip *chip = fpa->chips->data[13]; 103 psString chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME"); 104 printf("CELL.NAME for chip 13: %s\n", chipName); 105 pmCell *cell = chip->cells->data[0]; 106 psMetadataPrint(cell->concepts, 10); 107 #endif 108 109 110 pmFPAWrite(fpa, outFile, NULL); 111 110 psFree(newView); 111 psFree(newFormat); 112 psFree(newFPA); 113 psFree(view); 114 psFree(fpa); 115 psFree(config); 112 116 psFitsClose(inFile); 113 117 psFitsClose(outFile); 114 118 psFree(phu); 115 119 psFree(cameraFormat); 116 psFree(fpa); 120 121 psTimerStop(); 122 psTraceReset(); 123 pmConceptsDone(); 124 ppMemCheck(); 117 125 118 126 // Pau.
Note:
See TracChangeset
for help on using the changeset viewer.
