Changeset 12587
- Timestamp:
- Mar 24, 2007, 8:01:21 AM (19 years ago)
- Location:
- trunk/psphot/src
- Files:
-
- 1 added
- 5 edited
-
Makefile.am (modified) (1 diff)
-
psphot.h (modified) (1 diff)
-
psphotImageLoop.c (modified) (7 diffs)
-
psphotImageMedian.c (modified) (2 diffs)
-
psphotMosaicChip.c (added)
-
psphotParseCamera.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psphot/src/Makefile.am
r11554 r12587 16 16 psphotArguments.c \ 17 17 psphotParseCamera.c \ 18 psphotMosaicChip.c \ 18 19 psphotImageLoop.c \ 19 20 psphotMaskReadout.c \ -
trunk/psphot/src/psphot.h
r11583 r12587 24 24 bool psphotParseCamera (pmConfig *config); 25 25 bool psphotImageLoop (pmConfig *config); 26 bool psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile); 26 27 27 28 bool psphotModelTest (pmReadout *readout, psMetadata *recipe); -
trunk/psphot/src/psphotImageLoop.c
r11310 r12587 1 1 # include "psphot.h" 2 2 3 // XXX the errors in the pmFPAfileIOChecks could also be due to a programming or config error4 // XXX we need to either handle those errors or handle the error in pmFPAfileIOChecks and exit5 3 bool psphotImageLoop (pmConfig *config) { 6 4 … … 10 8 pmReadout *readout; 11 9 10 pmFPAfile *load = psMetadataLookupPtr (&status, config->files, "PSPHOT.LOAD"); 11 if (!status) { 12 psError(PSPHOT_ERR_PROG, false, "Can't find input data!"); 13 return false; 14 } 12 15 pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT"); 13 16 if (!status) { … … 25 28 } 26 29 27 while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) { 30 // for psphot, we force data to be read at the chip level 31 while ((chip = pmFPAviewNextChip (view, load->fpa, 1)) != NULL) { 28 32 psLogMsg ("psphot", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 29 33 if (! chip->process || ! chip->file_exists) { continue; } 34 35 // load just the input image data (image, mask, weight) 36 pmFPAfileActivate (config->files, false, NULL); 37 pmFPAfileActivate (config->files, true, "PSPHOT.LOAD"); 38 pmFPAfileActivate (config->files, true, "PSPHOT.MASK"); 39 pmFPAfileActivate (config->files, true, "PSPHOT.WEIGHT"); 30 40 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 31 41 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip); … … 33 43 return false; 34 44 } 45 pmFPAfileActivate (config->files, true, NULL); 35 46 47 // mosaic the cells of a chip into a single contiguous chip. 48 // this probably needs to return a new fpa? 49 if (!psphotMosaicChip(config, view, "PSPHOT.INPUT", "PSPHOT.LOAD")) { 50 psError(PS_ERR_UNKNOWN, false, "Unable to mosaic chip.\n"); 51 return false; 52 } 53 54 // try to load the data 55 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 56 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip); 57 psFree (view); 58 return false; 59 } 60 61 // there is now only a single chip (multiple readouts?). loop over it and process 62 // XXX activate / de-activate files? no I/O here? 36 63 while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) { 37 64 psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 38 if (! cell->process || ! cell->file_exists) { continue; } 39 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 40 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell); 41 psFree (view); 42 return false; 43 } 65 // if (! cell->process || ! cell->file_exists) { continue; } 66 if (! cell->process) { continue; } 44 67 45 68 // process each of the readouts 46 69 while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) { 47 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) { 48 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout); 49 psFree (view); 50 return false; 51 } 52 70 psLogMsg ("psphot", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 53 71 if (! readout->data_exists) { continue; } 54 72 55 73 // run the actual photometry analysis 74 // XXX calling psphotReadout here will operate on the mosaic'ed chips (for each readout) 56 75 if (!psphotReadout (config, view)) { 57 76 psError(psErrorCodeLast(), false, "failure in psphotReadout for chip %d, cell %d, readout %d\n", view->chip, view->cell, view->readout); … … 59 78 return false; 60 79 } 61 62 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {63 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d, readout %d in psphot\n", view->chip, view->cell, view->readout);64 psFree (view);65 return false;66 }67 }68 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {69 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d, cell %d in psphot\n", view->chip, view->cell);70 psFree (view);71 return false;72 80 } 73 81 } 82 83 // save output which is saved at the chip level 74 84 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 75 85 psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in psphot\n", view->chip); … … 78 88 } 79 89 } 90 // save output which is saved at the fpa level 80 91 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) { 81 92 psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in psphot\n"); … … 101 112 // PSPHOT.PSF : sample PSF images 102 113 114 // PSPHOT.MASK 115 // PSPHOT.WEIGHT 116 // -
trunk/psphot/src/psphotImageMedian.c
r12451 r12587 122 122 } else { 123 123 if (file->mode == PM_FPA_MODE_INTERNAL) { 124 // we are not using PSPHOT.BACKMDL as an I/O file: already defined above 124 125 model = file->readout; 125 126 } else { … … 128 129 if (model == NULL) { 129 130 // readout does not yet exist: create from input 131 // XXX we have an inconsistency in this calculation here and in pmFPACopy 130 132 pmFPAfileCopyStructureView (file->fpa, inFPA, DX, DY, view); 131 133 model = pmFPAviewThisReadout (view, file->fpa); -
trunk/psphot/src/psphotParseCamera.c
r12545 r12587 6 6 bool status = false; 7 7 8 // the input image defines the camera 9 pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PSPHOT.INPUT", "INPUT"); 8 // the file to be loaded may have subdivisions at the cell and readout level 9 // we load into pmFPAfile *load, then reformat into pmFPAfile *input 10 pmFPAfile *load = pmFPAfileDefineFromArgs (&status, config, "PSPHOT.LOAD", "INPUT"); 10 11 if (!status) { 11 psError(PSPHOT_ERR_CONFIG, false, "Failed to build FPA from PSPHOT. INPUT");12 psError(PSPHOT_ERR_CONFIG, false, "Failed to build FPA from PSPHOT.LOAD"); 12 13 return status; 14 } 15 load->dataLevel = PM_FPA_LEVEL_CHIP; // force load at the CHIP level 16 17 // the psphot analysis is performed on chips 18 pmFPAfile *input = pmFPAfileDefineChipMosaic(config, input->fpa, "PSPHOT.INPUT"); 19 if (!input) { 20 psError(PSPHOT_ERR_CONFIG, false, _("Unable to generate new file from PSPHOT.INPUT")); 21 return NULL; 13 22 } 14 23 15 24 // if we have requested PSPHOT.SRC, attempt to resolve it 25 // this is a list of input sources, stored in a psphot output format file 26 # if (0) 16 27 if (psMetadataLookupPtr(NULL, config->arguments, "SRC")) { 17 28 pmFPAfileDefineFromArgs (&status, config, "PSPHOT.SRC", "SRC"); … … 21 32 } 22 33 } 34 # endif 23 35 24 36 // select recipe options supplied on command line 25 37 psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE); 26 38 39 // these values are used below to define the background subtraction images. 40 27 41 // if MASK or WEIGHT was supplied on command line, bind files to input fpa 28 42 // XXX these do not quite yet work: pmFPAAddSourceFromHeader is not appropriate 29 pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.MASK", "MASK"); 30 pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.WEIGHT", "WEIGHT"); 43 // the mask and weight will be mosaic'ed with the image 44 pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.MASK", "MASK"); 45 pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.WEIGHT", "WEIGHT"); 31 46 32 47 // optionally load the PSF Model and/or fixed stars 33 pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF"); 34 35 // set default recipe values here 36 // XXX drop this? we put this in the default recipe? 37 psMetadataAddStr (recipe, PS_LIST_TAIL, "FITMODE", PS_META_NO_REPLACE, "default fitting mode", "NONE"); 38 psMetadataAddStr (recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_NO_REPLACE, "default break point", "NONE"); 39 psMetadataAddF32 (recipe, PS_LIST_TAIL, "ZERO_PT", PS_META_NO_REPLACE, "default zero point", 25.00); 40 psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.XBIN", PS_META_NO_REPLACE, "default binning", 64); 41 psMetadataAddS32 (recipe, PS_LIST_TAIL, "BACKGROUND.YBIN", PS_META_NO_REPLACE, "default binning", 64); 42 psMetadataAddStr (recipe, PS_LIST_TAIL, "PHOTCODE", PS_META_NO_REPLACE, "default photcode", "NONE"); 43 // photcode will be added in psphotReadout 48 // XXX bind this to the input or the load file? 49 // if the readout->analysis entries are copied, we can bind to the load file 50 // XXX add this back in later 51 // pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF"); 44 52 45 53 // XXX we need to be able to distinguish several cases: … … 49 57 // 4) the particular output data was requested but was not generated (surprising failure) 50 58 51 // these calls bind the I/O handle to the specified fpa 52 bool saveOutput = psMetadataLookupBool (NULL, recipe, "SAVE.OUTPUT"); 53 if (saveOutput) { 59 // the output sources are carried on the input->fpa structures 60 if (psMetadataLookupBool (NULL, recipe, "SAVE.OUTPUT")) { 54 61 if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT")) { 55 62 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.OUTPUT"); … … 57 64 } 58 65 } 59 60 66 // optionally save the residual image 61 67 if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) { … … 65 71 } 66 72 } 67 68 int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");69 int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");70 71 // these calls construct a new fpa for the I/O handle72 73 73 // optionally save the background model (small FITS image) 74 74 if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) { 75 int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN"); 76 int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN"); 75 77 if (!pmFPAfileDefineFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL")) { 76 78 psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
Note:
See TracChangeset
for help on using the changeset viewer.
