Changeset 14768
- Timestamp:
- Sep 6, 2007, 5:27:02 PM (19 years ago)
- Location:
- trunk/pswarp/src
- Files:
-
- 3 edited
-
pswarpLoop.c (modified) (3 diffs)
-
pswarpParseCamera.c (modified) (1 diff)
-
pswarpTransformReadout_Opt.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pswarp/src/pswarpLoop.c
r14219 r14768 66 66 pmFPAfileActivate(config->files, false, "PSWARP.OUTPUT.MASK"); 67 67 pmFPAfileActivate(config->files, false, "PSWARP.OUTPUT.WEIGHT"); 68 pmFPAfileActivate(config->files, false, "PSWARP.OUTPUT.SOURCES"); 68 69 pmFPAfileIOChecks (config, view, PM_FPA_BEFORE); 69 70 pmChip *chip; … … 89 90 pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.MASK"); 90 91 pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.WEIGHT"); 92 pmFPAfileActivate(config->files, true, "PSWARP.OUTPUT.SOURCES"); 91 93 } 92 94 … … 156 158 if (!readout->data_exists) { 157 159 continue; 160 } 161 162 // Copy the sources from the astrometry carrier to the input, so they can be accessed by 163 // pswarpTransformReadout 164 pmReadout *astromRO = pmFPAviewThisReadout(view, astrom->fpa); // Readout for astrometry 165 psArray *sources = psMetadataLookupPtr(&mdok, astromRO->analysis, 166 "PSPHOT.SOURCES"); // Sources from astrometry 167 if (sources) { 168 psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, 169 "Sources from input astrometry", sources); 158 170 } 159 171 -
trunk/pswarp/src/pswarpParseCamera.c
r14226 r14768 80 80 } 81 81 82 if (astrom) { 83 pmFPAfile *outSources = pmFPAfileDefineSkycell(config, output->fpa, "PSWARP.OUTPUT.SOURCES"); 84 if (!outSources) { 85 psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT.SOURCES"); 86 return false; 87 } 88 outSources->save = true; 89 } 90 91 82 92 // Chip selection: turn on only the chips specified 83 93 bool mdok; // Status of MD lookup -
trunk/pswarp/src/pswarpTransformReadout_Opt.c
r13903 r14768 1 1 # include "pswarp.h" 2 3 #define SOURCE_ARRAY_BUFFER 100 // Size to grow the array of sources at a time 2 4 3 5 // NOTE: in this function, the coordinates are transformed from the OUTPUT to the INPUT … … 83 85 84 86 // Iterate over the output image pixels (parent frame) 87 bool goodPixels = false; // Any input pixels landing on the output image? 85 88 for (int y = minY; y < maxY; y++) { 86 89 if (y >= nextGridY) { … … 111 114 if (inPix->y - inRow0 < 0) continue; 112 115 if (inPix->y - inRow0 >= inImage->numRows) continue; 116 117 goodPixels = true; 113 118 114 119 // XXX include mask … … 135 140 } 136 141 137 output->data_exists = true;138 139 142 psFree(interp); 140 143 psFree (inPix); 141 144 psFree (grid); 145 146 // Transform sources 147 bool mdok; 148 psArray *inSources = psMetadataLookupPtr(&mdok, input->analysis, "PSPHOT.SOURCES"); // Sources in source 149 if (goodPixels && mdok && inSources) { 150 pswarpMapGrid *sourceGrid = pswarpMapGridFromImage(output, input, nGridX, nGridY); // Grid for sources 151 152 psArray *outSources = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, output->analysis, 153 "PSPHOT.SOURCES")); // Target sources 154 if (!outSources) { 155 outSources = psArrayAllocEmpty(SOURCE_ARRAY_BUFFER); 156 psMetadataAddPtr(output->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY, 157 "Warped sources", outSources); 158 } 159 160 for (int i = 0; i < inSources->n; i++) { 161 pmSource *source = inSources->data[i]; // Source of interest 162 pmModel *model = source->modelPSF; // Model for this source 163 float xIn, yIn; // Coordinates of source 164 xIn = model->params->data.F32[PM_PAR_XPOS] - inCol0; 165 yIn = model->params->data.F32[PM_PAR_YPOS] - inRow0; 166 int xGrid, yGrid; // Grid coordinates for local map 167 if (!pswarpMapGridSetGrid(sourceGrid, xIn + 0.5, yIn + 0.5, &xGrid, &yGrid)) { 168 psError(PS_ERR_UNKNOWN, false, "Unable to get grid coordinates for source at %f,%f\n", 169 xIn, yIn); 170 psFree(outSources); 171 psFree(sourceGrid); 172 return false; 173 } 174 if (xGrid < 0 || xGrid >= sourceGrid->nXpts || yGrid < 0 || yGrid >= sourceGrid->nYpts) { 175 // It's not even on the grid 176 continue; 177 } 178 179 pswarpMap *map = sourceGrid->maps[xGrid][yGrid]; // Locally linear transformation 180 double xOut, yOut; // Output coordinates 181 if (!pswarpMapApply(&xOut, &yOut, map, xIn, yIn)) { 182 psError(PS_ERR_UNKNOWN, false, "Unable to transform coordinates for source at %f,%f\n", 183 xIn, yIn); 184 psFree(outSources); 185 psFree(sourceGrid); 186 return false; 187 } 188 xOut += outCol0; 189 yOut += outRow0; 190 if (xOut < minX || xOut > maxX || yOut < minY || yOut > maxY) { 191 // It's not in the output image 192 continue; 193 } 194 195 // Generate the new source in the output frame 196 pmSource *new = pmSourceAlloc(); // New source 197 new->peak = pmPeakAlloc(xOut, yOut, source->peak->flux, PM_PEAK_LONE); 198 new->peak->flux = source->peak->flux; 199 new->type = PM_SOURCE_TYPE_STAR; 200 new->psfMag = source->psfMag; 201 new->errMag = source->errMag; 202 new->sky = source->sky; 203 new->skyErr = source->skyErr; 204 new->pixWeight = source->pixWeight; 205 new->modelPSF = pmModelAlloc(source->modelPSF->type); 206 207 #if 0 208 // XXX Note that this will not set the correct axes 209 pmPSF_AxesToModel(new->modelPSF->params->data.F32, 210 pmPSF_ModelToAxes(source->modelPSF->params->data.F32, 20.0)); 211 #endif 212 213 // Propagate the position erorrs 214 float dxIn, dyIn; // Errors in input coordinates 215 dxIn = model->dparams->data.F32[PM_PAR_XPOS]; 216 dyIn = model->dparams->data.F32[PM_PAR_YPOS]; 217 218 float dxOut, dyOut; // Errors in output coordinates 219 dxOut = sqrt(PS_SQR(map->Xx * dxIn) + PS_SQR(map->Xy * dyIn)); 220 dxOut = sqrt(PS_SQR(map->Xx * dxIn) + PS_SQR(map->Xy * dyIn)); 221 222 new->modelPSF->params->data.F32[PM_PAR_XPOS] = xOut; 223 new->modelPSF->params->data.F32[PM_PAR_YPOS] = yOut; 224 new->modelPSF->dparams->data.F32[PM_PAR_XPOS] = dxOut; 225 new->modelPSF->dparams->data.F32[PM_PAR_YPOS] = dyOut; 226 227 psArrayAdd(outSources, SOURCE_ARRAY_BUFFER, new); 228 psFree(new); // Drop reference 229 } 230 psFree(sourceGrid); 231 psFree(outSources); // Drop reference 232 } 233 234 output->data_exists = true; 235 142 236 psLogMsg ("pswarp", 3, "warping analysis: %f sec\n", psTimerMark ("warp")); 143 237
Note:
See TracChangeset
for help on using the changeset viewer.
