Changeset 5976 for trunk/ppImage/src/ppImageParseCamera.c
- Timestamp:
- Jan 13, 2006, 5:14:07 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImageParseCamera.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImageParseCamera.c
r5860 r5976 1 # include "ppImage.h"1 #include "ppImage.h" 2 2 3 static void ppFPA_Free (ppFPA *fpa) { 4 return; 5 } 3 bool ppImageParseCamera(ppData *data, ppConfig *config) 4 { 5 // Initialise the containers where the files will go 6 data->input = ppFileAlloc(); 7 data->mask = ppFileAlloc(); 8 data->bias = ppFileAlloc(); 9 data->dark = ppFileAlloc(); 10 data->flat = ppFileAlloc(); 11 data->fringe = ppFileAlloc(); 12 #if 0 13 data->process = ppFileAlloc(); 14 #endif 6 15 7 ppFPA *ppFPA_Alloc (void) { 8 9 ppFPA *fpa = psAlloc (sizeof(ppFPA)); 10 psMemSetDeallocator(fpa, (psFreeFunc) ppFPA_Free); 11 12 fpa->filename = NULL; 13 fpa->fpa = NULL; 14 fpa->fits = NULL; 15 fpa->header = NULL; 16 17 return fpa; 18 } 19 20 bool ppImageParseCamera (ppData *data, ppConfig *config) { 21 22 bool status; 23 24 data->input = ppFPA_Alloc (); 25 data->mask = ppFPA_Alloc (); 26 data->bias = ppFPA_Alloc (); 27 data->dark = ppFPA_Alloc (); 28 data->flat = ppFPA_Alloc (); 29 data->fringe = ppFPA_Alloc (); 30 data->process = ppFPA_Alloc (); 31 32 data->input->filename = psMetadataLookupPtr (NULL, config->arguments, "-input"); 16 data->input->filename = psMemIncrRefCounter(psMetadataLookupStr(NULL, config->arguments, "-input")); 33 17 34 18 // Open the input image 35 psLogMsg("p hase2", PS_LOG_INFO, "Opening input image: %s\n", data->input->filename);19 psLogMsg("ppImage", PS_LOG_INFO, "Opening input image: %s\n", data->input->filename); 36 20 data->input->fits = psFitsOpen(data->input->filename, "r"); // File handle for FITS file 37 21 if (! data->input->fits) { 22 // There's no point in continuing if we can't open the input 38 23 psErrorStackPrint(stderr, "Can't open input image: %s\n", data->input->filename); 39 24 exit(EXIT_FAILURE); 40 25 } 41 data->input-> header= psFitsReadHeader(NULL, data->input->fits); // FITS header26 data->input->phu = psFitsReadHeader(NULL, data->input->fits); // FITS header 42 27 43 28 // Get camera configuration from header if not already defined 44 29 if (! config->camera) { 45 config->camera = pmConfigCameraFromHeader(config->site, data->input-> header);30 config->camera = pmConfigCameraFromHeader(config->site, data->input->phu); 46 31 if (! config->camera) { 32 // There's no point in continuing if we can't recognise what we've got 47 33 psErrorStackPrint(stderr, "Can't find camera configuration!\n"); 48 34 exit(EXIT_FAILURE); 49 35 } 50 } else if (! pmConfigValidateCamera(config->camera, data->input->header)) { 51 psError(PS_ERR_IO, true, "%s does not seem to be from the camera.\n", data->input->filename); 36 } else if (! pmConfigValidateCamera(config->camera, data->input->phu)) { 37 // There's no point in continuing if what we've got doesn't match what we've been told 38 psError(PS_ERR_IO, true, "%s does not seem to be from the specified camera.\n", 39 data->input->filename); 52 40 exit(EXIT_FAILURE); 53 41 } 54 42 55 // determine the correct recipe to use43 // Determine the correct recipe to use 56 44 if (! config->recipe && !(config->recipe = pmConfigRecipeFromCamera(config->camera, RECIPE))) { 45 // There's no point in continuing if we can't work out what recipe to use 57 46 psErrorStackPrint(stderr, "Can't find recipe configuration!\n"); 58 47 exit(EXIT_FAILURE); 59 48 } 60 49 61 // Construct camera in preparation for reading50 // Construct cameras in preparation for reading 62 51 data->input->fpa = pmFPAConstruct(config->camera); 63 52 data->mask->fpa = pmFPAConstruct(config->camera); … … 66 55 data->flat->fpa = pmFPAConstruct(config->camera); 67 56 data->fringe->fpa = pmFPAConstruct(config->camera); 57 #if 0 68 58 data->process->fpa = pmFPAConstruct(config->camera); 59 #endif 69 60 70 61 // XXX EAM : extend this to allow an array of selected chips by name 71 62 // Chip selection: if we are using a single chip, select it for each FPA 72 // data->process acts as a process mask for the full FPA 73 int chipNum = psMetadataLookupS32(&status, config->arguments, "-chip"); // Chip number to work on 63 int chipNum = psMetadataLookupS32(NULL, config->arguments, "-chip"); // Chip number to work on 74 64 if (chipNum >= 0) { 75 if (! pmFPASelectChip(data-> process->fpa, chipNum)) {65 if (! pmFPASelectChip(data->input->fpa, chipNum)) { 76 66 psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum); 77 67 exit(EXIT_FAILURE); 78 68 } 79 psLogMsg("p hase2", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);69 psLogMsg("ppImage", PS_LOG_INFO, "Operating only on chip %d\n", chipNum); 80 70 } 81 71 return true; … … 84 74 // XXX EAM : I dropped the pre-open of the output files; replace with a stats test of output permissions 85 75 86 // XXX : for split data (data spread across multiple files), this step is only operating on a component 76 // XXX : for split data (data spread across multiple files), this step is only operating on a component 87 77 // of the FPA. the other components should be set to 'invalid' in this case?
Note:
See TracChangeset
for help on using the changeset viewer.
