Changeset 12485
- Timestamp:
- Mar 18, 2007, 12:06:58 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/astrom/pmAstrometryDistortion.c
r11461 r12485 7 7 * @author EAM, IfA 8 8 * 9 * @version $Revision: 1.1 5$ $Name: not supported by cvs2svn $10 * @date $Date: 2007-0 1-31 03:12:27$9 * @version $Revision: 1.16 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2007-03-18 22:06:58 $ 11 11 * 12 12 * Copyright 2006 Institute for Astronomy, University of Hawaii … … 47 47 psMemSetDeallocator(gradient, (psFreeFunc) pmAstromGradientFree); 48 48 49 // XXX init any of the data values?50 51 49 return (gradient); 52 50 } 53 51 54 psArray *pmAstromMeasureGradients(psArray *gradients, psArray *rawstars, psArray *refstars, psArray *matches, ps Metadata *config)52 psArray *pmAstromMeasureGradients(psArray *gradients, psArray *rawstars, psArray *refstars, psArray *matches, psRegion *region, int Nx, int Ny) 55 53 { 56 54 … … 59 57 } 60 58 59 // NOTE: region specifies the FP region in pixels covered by the chip (NOT in FP units) 61 60 // determine range 62 // XXX for the moment, I'm hard-wiring this for megacam 63 // XXX we need to get the chip dimensions from the metadata somewhere 64 int Nx = 2; 65 int Ny = 2; 66 int DX = 2080 / Nx; 67 int DY = 4600 / Ny; 61 int DX = (region->x1 - region->x0) / Nx; 62 int DY = (region->y1 - region->y0) / Ny; 68 63 69 64 psPolynomial2D *local = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, 1, 1); … … 97 92 pmAstromObj *raw = rawstars->data[match->raw]; 98 93 99 if (raw->chip->x < Xmin) 100 continue; 101 if (raw->chip->x > Xmax) 102 continue; 103 if (raw->chip->y < Ymin) 104 continue; 105 if (raw->chip->y > Ymax) 106 continue; 94 if (raw->chip->x < Xmin) continue; 95 if (raw->chip->x > Xmax) continue; 96 if (raw->chip->y < Ymin) continue; 97 if (raw->chip->y > Ymax) continue; 107 98 108 99 pmAstromObj *ref = refstars->data[match->ref]; … … 177 168 } 178 169 179 bool pmAstromFitDistortion(pmFPA *fpa, psArray *gradients, psMetadata *config)170 bool pmAstromFitDistortion(pmFPA *fpa, psArray *gradients, double pixelScale) 180 171 { 181 172 … … 233 224 if (!psVectorClipFitPolynomial2D (localX, stats, mask, 0xff, dPdL, NULL, L, M)) { 234 225 psLogMsg ("psastro", 3, "failed to fit x-dir gradient\n"); 235 return false; 226 psFree (localX); 227 psFree (localY); 228 goto escape; 236 229 } 237 230 238 231 if (!psVectorClipFitPolynomial2D (localY, stats, mask, 0xff, dPdM, NULL, L, M)) { 239 232 psLogMsg ("psastro", 3, "failed to fit y-dir gradient\n"); 240 return false; 233 psFree (localX); 234 psFree (localY); 235 goto escape; 241 236 } 242 237 … … 310 305 psFree (localY); 311 306 312 // XXXfree unneeded structures307 // free unneeded structures 313 308 psFree (dPdL); 314 309 psFree (dPdM); … … 320 315 psFree (mask); 321 316 322 // XXX need to reset the fromTPA terms here 323 // XXX choose an appropriate region based on the range of values 324 // in L and M? 325 // psRegion region = psRegionSet (-125000, +125000, -125000, +125000); 317 // reset the fromTPA terms here. choose an appropriate region based on the dimensions of 318 // the complete FPA 326 319 psRegion *region = pmFPAExtent (fpa); 320 region->x0 *= pixelScale; 321 region->x1 *= pixelScale; 322 region->y0 *= pixelScale; 323 region->y1 *= pixelScale; 324 int xCenter = 0.5*(region->x0 + region->x1); 325 int yCenter = 0.5*(region->y0 + region->y1); 326 region->x0 -= xCenter; 327 region->x1 -= xCenter; 328 region->y0 -= yCenter; 329 region->y1 -= yCenter; 327 330 psFree (fpa->fromTPA); 328 331 fpa->fromTPA = psPlaneTransformInvert(NULL, fpa->toTPA, *region, 50); 329 332 psFree (region); 330 333 334 if (fpa->fromTPA == NULL) { 335 psError (PS_ERR_UNKNOWN, false, "failed to invert fpa->toTPA\n"); 336 return false; 337 } 338 331 339 return true; 340 341 escape: 342 // free unneeded structures 343 psFree (dPdL); 344 psFree (dPdM); 345 psFree (dQdL); 346 psFree (dQdM); 347 psFree (L); 348 psFree (M); 349 psFree (stats); 350 psFree (mask); 351 return false; 332 352 }
Note:
See TracChangeset
for help on using the changeset viewer.
