Changeset 12807 for trunk/ppImage/src/ppImagePhotom.c
- Timestamp:
- Apr 11, 2007, 2:01:11 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ppImage/src/ppImagePhotom.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppImage/src/ppImagePhotom.c
r11364 r12807 5 5 # include "ppImage.h" 6 6 7 // the top portion of this function is equivalent to psphotParseCamera, 8 // but different in a few important ways. 9 // XXX move this section to ppImageParseCamera? 7 // In this function, we perform the psphot analysis routine for the chip-mosaicked images 10 8 bool ppImagePhotom (pmConfig *config, pmFPAview *view) { 11 9 … … 16 14 psphotModelGroupInit (); 17 15 18 // select recipe options supplied on command line19 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);20 21 16 // find or define a pmFPAfile PSPHOT.INPUT 22 17 pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT"); 23 18 if (!status) { 24 // psphotReadout requires a pmFPAfile supplied with the name PSPHOT.INPUT 25 // create a pmFPAfile which points to PPIMAGE.OUTPUT.CHIP (guaranteed to be mosaiced by chip) 26 // mode is 'REFERENCE' to prevent double frees of the fpa 27 pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PPIMAGE.OUTPUT.CHIP"); 28 input = pmFPAfileDefineInput (config, output->fpa, "PSPHOT.INPUT"); 29 input->mode = PM_FPA_MODE_REFERENCE; 30 31 // we set the freeLevel to be FPA so this pmFPAfile may be used as input to psastro 32 // XXX make this the resonsibility of a ppImageAstrom call? 33 // XXX test for psastro requests? 34 // XXX need to make this an INTERNAL file if output is not requested. 35 bool saveOutput = psMetadataLookupBool (NULL, recipe, "SAVE.OUTPUT"); 36 if (saveOutput) { 37 pmFPAfile *outfile = pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT"); 38 outfile->freeLevel = PM_FPA_LEVEL_FPA; 39 } 19 psError(PSPHOT_ERR_CONFIG, false, "PSPHOT.INPUT I/O file is not defined"); 20 return false; 40 21 } 41 22 42 // if we have requested PSPHOT.SRC (externally supplied sources), attempt to resolve it 43 if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.SRC")) { 44 pmFPAfileDefineFromArgs (&status, config, "PSPHOT.SRC", "PSPHOT.SRC"); 45 if (!status) { 46 psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.SRC"); 47 return status; 48 } 49 } 50 51 // NOTE the difference here from psphotParseCamera: the mask and weight 52 // images are supplied by ppImage and need not / should not be loaded here. 53 54 // optionally load the PSF Model and/or fixed stars 55 pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSPHOT.PSF"); 56 57 // set default recipe values here 58 // XXX place this in a psphot library function? 59 psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE", PS_META_NO_REPLACE, "default fitting mode", "NONE"); 60 psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default break point", "NONE"); 61 psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT", PS_META_NO_REPLACE, "default zero point", 25.00); 62 psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.XBIN", PS_META_NO_REPLACE, "default binning", 64); 63 psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.YBIN", PS_META_NO_REPLACE, "default binning", 64); 64 65 // determine PHOTCODE from fpa & view, overwrite in recipe 66 char *photcode = pmConceptsPhotcodeForView (config, input, view); 67 if (photcode) { 68 psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_REPLACE, "photcode from FPA concepts", photcode); 69 psFree (photcode); 70 } 71 72 // optionally save the residual image 73 if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) { 74 if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.RESID")) { 75 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL"); 76 return false; 77 } 78 } 79 80 int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN"); 81 int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN"); 82 83 // these calls construct a new fpa for the I/O handle 84 85 // optionally save the background model (small FITS image) 86 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) { 87 if (!pmFPAfileDefineFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL")) { 88 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL"); 89 return false; 90 } 91 } 92 // optionally save the full background image 93 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) { 94 if (!pmFPAfileDefineFromFPA (config, input->fpa, 1, 1, "PSPHOT.BACKGND")) { 95 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKGND"); 96 return false; 97 } 98 } 99 // optionally save the background-subtracted image 100 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) { 101 if (!pmFPAfileDefineFromFPA (config, input->fpa, 1, 1, "PSPHOT.BACKSUB")) { 102 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT."); 103 return false; 104 } 105 } 106 // optionally save the PSF Model 107 if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) { 108 if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.PSF.SAVE")) { 109 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.PSF.SAVE"); 110 return false; 111 } 112 } 113 114 // optionally save output plots 115 if (psMetadataLookupBool(NULL, recipe, "SAVE.PLOTS")) { 116 if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.MOMENTS")) { 117 psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.MOMENTS"); 118 } 119 if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.PSFMODEL")) { 120 psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.PSFMODEL"); 121 } 122 } 123 124 // XXX not tested (or defined?) 125 // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE"); 126 127 // XXX probably need to deactivate all files and activate the psphot ones explicitly 128 129 // In this section, we iterate over the cells and readout for this chip 130 // and run the psphot analysis routine here 131 // XXX worry about this not having unique PHOTCODES... 132 // view->cell = -1; 133 // iterate over the cells in the current chip 23 // iterate over the cells and readout for this chip 134 24 while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) { 135 25 psLogMsg ("ppImagePhotom", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); … … 146 36 147 37 // the PSPHOT.INPUT file is a temporary file used to carry PPIMAGE.OUTPUT.CHIP to psphotReadout 38 // XXX not sure that this is needed... 148 39 pmFPAfileActivate (config->files, false, "PSPHOT.INPUT"); 149 40 150 41 return true; 151 42 } 43 44 // XXX do we need to deactivate all files and activate the psphot ones explicitly?
Note:
See TracChangeset
for help on using the changeset viewer.
