Changeset 27955
- Timestamp:
- May 13, 2010, 6:31:45 PM (16 years ago)
- Location:
- branches/eam_branches/psphot.20100506/src
- Files:
-
- 2 edited
-
psphotPetrosianStats.c (modified) (1 diff)
-
psphotStackImageLoop.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/psphot.20100506/src/psphotPetrosianStats.c
r27919 r27955 195 195 source->extpars->petrosianR90Err = NAN; 196 196 197 fprintf (stderr, "source @ %f,%f\n", source->peak->xf, source->peak->yf);197 // fprintf (stderr, "source @ %f,%f\n", source->peak->xf, source->peak->yf); 198 198 psphotPetrosianVisualStats (binRad, binSB, refRadius, meanSB, petRatio, petRatioErr, fluxSum, petRadius, PETROSIAN_RATIO, petFlux, apRadius); 199 199 -
branches/eam_branches/psphot.20100506/src/psphotStackImageLoop.c
r27909 r27955 1 1 # include "psphotStandAlone.h" 2 3 # define ESCAPE(MESSAGE) { \ 4 psError(PSPHOT_ERR_DATA, false, MESSAGE); \ 5 psFree (view); \ 6 return false; \ 7 } 2 #define WCS_NONLIN_TOL 0.001 // Non-linear tolerance for header WCS 3 4 # define ESCAPE(MESSAGE) { \ 5 psError(PSPHOT_ERR_DATA, false, MESSAGE); \ 6 psFree (view); \ 7 return false; \ 8 } 9 10 bool GetAstrometryFPA (pmConfig *config, pmFPAview *view); 11 bool SetAstrometryFPA (pmConfig *config, pmFPAview *view, bool bilevelAstrometry); 12 bool GetAstrometryChip (pmConfig *config, pmFPAview *view, bool bilevelAstrometry); 8 13 9 14 bool psphotStackImageLoop (pmConfig *config) { … … 16 21 pmFPAfile *inputRaw = psMetadataLookupPtr (&status, config->files, "PSPHOT.STACK.INPUT.RAW"); 17 22 pmFPAfile *inputCnv = psMetadataLookupPtr (&status, config->files, "PSPHOT.STACK.INPUT.CNV"); 18 19 23 pmFPAfile *input = inputRaw ? inputRaw : inputCnv; 20 24 … … 28 32 // XXX for now, just load the full set of images up front 29 33 if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) ESCAPE ("failed input for fpa in psphot."); 34 35 bool bilevelAstrometry = GetAstrometryFPA(config, view); 30 36 31 37 // for psphot, we force data to be read at the chip level … … 71 77 } 72 78 } 79 80 GetAstrometryChip(config, view, bilevelAstrometry); 81 73 82 // save output which is saved at the chip level 74 83 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE ("failed output for Chip in psphot."); 75 84 } 85 86 SetAstrometryFPA(config, view, bilevelAstrometry); 87 76 88 // save output which is saved at the fpa level 77 89 if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) ESCAPE ("failed ouput for FPA in psphot."); … … 89 101 */ 90 102 103 # define UPDATE_HEADER 0 104 105 bool GetAstrometryFPA (pmConfig *config, pmFPAview *view) { 106 107 bool status = false; 108 109 bool foundAstrometry = false; 110 bool bilevelAstrometry = false; 111 112 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 113 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 114 115 // loop over the available readouts 116 for (int i = 0; i < num; i++) { 117 118 // find the currently selected readout 119 pmFPAfile *output = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.OUTPUT.IMAGE", i); // File of interest 120 psAssert (output, "missing file?"); 121 122 pmFPAfile *inputRaw = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.INPUT.RAW", i); // File of interest 123 pmFPAfile *inputCnv = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.INPUT.CNV", i); // File of interest 124 pmFPAfile *input = inputRaw ? inputRaw : inputCnv; 125 psAssert (input, "missing input file"); 126 127 // find the FPA phu 128 pmHDU *phu = pmFPAviewThisPHU(view, input->fpa); 129 if (!phu) { 130 psWarning("Unable to read bilevel mosaic astrometry for input FPA entry %d", i); 131 continue; 132 } 133 134 char *ctype = psMetadataLookupStr(NULL, phu->header, "CTYPE1"); 135 if (!ctype) { 136 psWarning("Error in WCS keywords for input FPA entry %d", i); 137 continue; 138 } 139 140 if (!foundAstrometry) { 141 bilevelAstrometry = !strcmp (&ctype[4], "-DIS"); 142 } else { 143 if (bilevelAstrometry != !strcmp (&ctype[4], "-DIS")) { 144 psAbort("astrometry type mis-match"); 145 } 146 } 147 148 if (bilevelAstrometry) { 149 // update the output structures 150 if (!pmAstromReadBilevelMosaic(output->fpa, phu->header)) { 151 psWarning("Unable to read bilevel mosaic astrometry for input FPA."); 152 } 153 } 154 } 155 return bilevelAstrometry; 156 } 157 158 bool GetAstrometryChip (pmConfig *config, pmFPAview *view, bool bilevelAstrometry) { 159 160 bool status = false; 161 162 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 163 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 164 165 // loop over the available readouts 166 for (int i = 0; i < num; i++) { 167 168 // find the currently selected readout 169 pmFPAfile *output = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.OUTPUT.IMAGE", i); // File of interest 170 psAssert (output, "missing file?"); 171 172 pmFPAfile *inputRaw = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.INPUT.RAW", i); // File of interest 173 pmFPAfile *inputCnv = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.INPUT.CNV", i); // File of interest 174 pmFPAfile *input = inputRaw ? inputRaw : inputCnv; 175 psAssert (input, "missing input file"); 176 177 // Need to update the output for astrometry. Read WCS data from the corresponding 178 // header and save in the output fpa 179 pmHDU *inHDU = pmFPAviewThisHDU (view, input->fpa); 180 pmChip *outChip = pmFPAviewThisChip(view, output->fpa); ///< Chip in the output 181 182 # if (UPDATE_HEADER) 183 pmHDU *outHDU = pmFPAviewThisHDU (view, output->fpa); 184 if (!outHDU) { 185 pmFPAAddSourceFromView(output->fpa, "name", view, output->format); 186 outHDU = pmFPAviewThisHDU (view, output->fpa); 187 psAssert (outHDU, "failed to make HDU"); 188 } 189 # endif 190 191 if (bilevelAstrometry) { 192 if (!pmAstromReadBilevelChip (outChip, inHDU->header)) { 193 psWarning("Unable to read bilevel chip astrometry for input FPA."); 194 continue; 195 } 196 # if (UPDATE_HEADER) 197 if (!pmAstromWriteBilevelChip(outHDU->header, outChip, WCS_NONLIN_TOL)) { 198 psWarning("Unable to generate WCS header."); 199 continue; 200 } 201 # endif 202 } else { 203 // we use a default FPA pixel scale of 1.0 204 if (!pmAstromReadWCS (output->fpa, outChip, inHDU->header, 1.0)) { 205 psWarning("Unable to read WCS astrometry for input FPA."); 206 continue; 207 } 208 # if (UPDATE_HEADER) 209 if (UPDATE_HEADER && !pmAstromWriteWCS(outHDU->header, output->fpa, outChip, WCS_NONLIN_TOL)) { 210 psWarning("Unable to generate WCS header."); 211 continue; 212 } 213 # endif 214 } 215 } 216 217 return true; 218 } 219 220 bool SetAstrometryFPA (pmConfig *config, pmFPAview *view, bool bilevelAstrometry) { 221 222 bool status = false; 223 224 if (!bilevelAstrometry) return true; 225 226 int num = psMetadataLookupS32 (&status, config->arguments, "PSPHOT.INPUT.NUM"); 227 psAssert (status, "programming error: must define PSPHOT.INPUT.NUM"); 228 229 // loop over the available readouts 230 for (int i = 0; i < num; i++) { 231 232 // find the currently selected readout 233 pmFPAfile *output = pmFPAfileSelectSingle(config->files, "PSPHOT.STACK.OUTPUT.IMAGE", i); // File of interest 234 psAssert (output, "missing file?"); 235 236 # if (UPDATE_HEADER) 237 pmHDU *PHU = pmFPAviewThisPHU(view, output->fpa); 238 if (!PHU) { 239 pmFPAAddSourceFromView(output->fpa, "name", view, output->format); 240 PHU = pmFPAviewThisPHU (view, output->fpa); 241 psAssert (PHU, "failed to make PHU"); 242 } 243 244 if (!pmAstromWriteBilevelMosaic(PHU->header, output->fpa, WCS_NONLIN_TOL)) { 245 psWarning("Unable to generate WCS header."); 246 } 247 # endif 248 } 249 250 return true; 251 }
Note:
See TracChangeset
for help on using the changeset viewer.
