Changeset 6715 for trunk/psphot/src/psphotParseCamera.c
- Timestamp:
- Mar 27, 2006, 4:31:17 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psphot/src/psphotParseCamera.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/psphotParseCamera.c
r6571 r6715 1 1 # include "psphot.h" 2 3 # define METADATA_ADD_DEFAULT(CONFIG, TYPE, NAME, VALUE, COMMENT)\4 { psMetadataItem *ITEM; \5 ITEM = psMetadataLookup (CONFIG, NAME); \6 if (ITEM == NULL) { \7 psMetadataAdd##TYPE (CONFIG, PS_LIST_TAIL, NAME, 0, COMMENT, VALUE); \8 } }9 2 10 3 bool psphotParseCamera (pmConfig *config) { 11 4 5 bool status; 6 psFits *fits = NULL; 7 psMetadata *phu = NULL; 8 psMetadata *format = NULL; 9 12 10 // psphot is supplied with a list of input images (may be only one image) 13 psArray *infiles = psMetadataLookupPtr(NULL, config->arguments, "INPUT"); 11 psArray *infiles = psMetadataLookupPtr(&status, config->arguments, "INPUT"); 12 if (!status) psAbort (__func__, "missing INPUT entry"); 14 13 if (infiles->n < 1) psAbort (__func__, "empty input list"); 15 14 16 15 // if no camera has been specified, use the first image as a template for the rest. 17 16 if (config->camera == NULL) { 18 psFits *fits = psFitsOpen (infiles->data[0], "r");19 p sMetadata *phu = psFitsReadHeader (NULL, fits);20 config->camera = pmConfigCameraFromHeader (config->site, phu);17 fits = psFitsOpen (infiles->data[0], "r"); 18 phu = psFitsReadHeader (NULL, fits); 19 format = pmConfigCameraFormatFromHeader (config, phu); 21 20 psFitsClose (fits); 22 psFree (phu);23 21 } 24 22 // There's no point in continuing if we can't recognize what we've got … … 28 26 } 29 27 30 // XXX place the "data" element on the pmConfig structure?28 // files 31 29 config->files = psMetadataAlloc (); 32 30 33 31 // build the template fpa, set up the basic view 34 pmFPA *input = pmFPAConstruct (camera); 32 // XXX : 216 leaks in pmFPAConstruct / psFree (input) 33 pmFPA *input = pmFPAConstruct (config->camera); 35 34 36 35 // assign the I/O files (potentially) needed by psphot 37 pmFPAfile *file = pmFPAfileDefine (config->files, camera, input, "PSPHOT.INPUT"); 36 // the output file is just a view to the file on config->files 37 pmFPAfile *file = pmFPAfileDefine (config->files, format, input, "PSPHOT.INPUT"); 38 if (!file) { 39 exit(EXIT_FAILURE); 40 } 38 41 39 pmFPAview *view = pmFPAviewAlloc (input, config->camera, 0);40 42 for (int i = 0; i < infiles->n; i++) { 41 // XXX save the phu from above? 42 psFits *fits = psFitsOpen (infiles->data[i], "r"); 43 psMetadata *phu = psFitsReadHeader (NULL, fits); 44 pmConfigValidateCamera (config->camera, phu); 43 if (phu == NULL) { 44 fits = psFitsOpen (infiles->data[i], "r"); 45 phu = psFitsReadHeader (NULL, fits); 46 pmConfigValidateCameraFormat (format, phu); 47 psFitsClose (fits); 48 } 45 49 46 50 // set the view to the corresponding entry for this phu 47 // XXX should I save the phu data at the appropriate location in the fpa? 48 pmFPAsetView (view, phu); 51 pmFPAview *view = pmFPAAddSource (input, phu, format); 49 52 50 53 // XXX is this the correct psMD to save the filename? 51 name = pmFPAviewNameFromRule (file->filextra, view);54 char *name = pmFPAfileNameFromRule (file->filextra, file, view); 52 55 psMetadataAddStr (file->names, PS_LIST_TAIL, name, 0, "", infiles->data[i]); 56 57 psFree (view); 58 psFree (name); 59 psFree (phu); 60 phu = NULL; 53 61 } 54 pmFPAfileDefine (config->files, camera, input, "PSPHOT.OUTPUT"); 55 pmFPAfileDefine (config->files, camera, input, "PSPHOT.RESID"); 56 pmFPAfileDefine (config->files, camera, input, "PSPHOT.PSF_INPUT"); 57 pmFPAfileDefine (config->files, camera, input, "PSPHOT.PSF_OUTPUT"); 62 63 pmFPAfileDefine (config->files, format, input, "PSPHOT.OUTPUT"); 64 65 // pmFPAfileDefine (config->files, format, input, "PSPHOT.RESID"); 66 // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_INPUT"); 67 // pmFPAfileDefine (config->files, format, input, "PSPHOT.PSF_OUTPUT"); 58 68 59 69 // build the template fpa, set up the basic view 60 70 // supply the backgnd with a different camera? 61 pmFPAfileDefine (config->files, camera, NULL, "PSPHOT.BACKSUB"); 62 pmFPAfileDefine (config->files, camera, NULL, "PSPHOT.BACKGND"); 63 pmFPAfileDefine (config->files, camera, NULL, "PSPHOT.BACKMDL"); 64 pmFPAfileDefine (config->files, camera, NULL, "PSPHOT.PSF_SAMPLE"); 71 // allow alternate format? 72 // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.BACKSUB"); 73 // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.BACKGND"); 74 // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.BACKMDL"); 75 // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE"); 76 77 // psphot is supplied with the output name 78 char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT"); 79 file = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT"); 80 if (!status) psAbort (__func__, "missing OUTPUT entry"); 81 psMetadataAddStr (file->names, PS_LIST_TAIL, "OUTPUT", 0, "", output); 65 82 66 83 // recipe override values (command-line options): 67 psMetadata *options = psMetadataLookupPtr ( status, config->arguments, "PSPHOT.OPTIONS");68 psMetadata *recipe = psMetadataLookupPtr ( status, config->recipes, "PSPHOT");84 psMetadata *options = psMetadataLookupPtr (&status, config->arguments, "PSPHOT.OPTIONS"); 85 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, "PSPHOT"); 69 86 psMetadataIterator *iter = psMetadataIteratorAlloc (options, PS_LIST_HEAD, NULL); 70 while ((psMetadataItem *item = psMetadataGetAndIncrement (iter)) != NULL) { 87 psMetadataItem *item = NULL; 88 while ((item = psMetadataGetAndIncrement (iter)) != NULL) { 71 89 psMetadataAddItem (recipe, item, PS_LIST_TAIL, PS_META_REPLACE); 72 90 } … … 74 92 75 93 // set default recipe values here 76 // XXX this needs re-thinking... 77 METADATA_ADD_DEFAULT (recipe, Str, "FITMODE", "NONE", ""); 78 METADATA_ADD_DEFAULT (recipe, Str, "PHOTCODE", "NONE", ""); 79 METADATA_ADD_DEFAULT (recipe, Str, "BREAK_POINT", "NONE", ""); 94 psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE", PS_META_NO_REPLACE, "default fitting mode", "NONE"); 95 psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_NO_REPLACE, "default photcode", "NONE"); 96 psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default break point", "NONE"); 80 97 81 98 // Chip selection: if we are using a single chip, select it for each FPA 82 99 // Chip numbers to work on: -chip 1,2,3,5,8,10 100 # if (0) 83 101 char *chips = psMetadataLookupStr(NULL, config->arguments, "CHIP_SELECTIONS"); 84 102 if (chips != NULL) { … … 102 120 } 103 121 } 122 # endif 123 124 psFree (input); 125 psFree (format); 126 104 127 psTrace(__func__, 1, "Done with psphotParseCamera...\n"); 105 128 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
