Changeset 39686
- Timestamp:
- Sep 11, 2016, 2:33:18 PM (10 years ago)
- Location:
- branches/czw_branch/20160809/psastro/src
- Files:
-
- 7 edited
-
psastroAstromGuess.c (modified) (3 diffs)
-
psastroDemoDump.c (modified) (1 diff)
-
psastroModelAdjust.c (modified) (3 diffs)
-
psastroMosaicAstrom.c (modified) (3 diffs)
-
psastroMosaicGradients.c (modified) (1 diff)
-
psastroMosaicOneChip.c (modified) (1 diff)
-
psastroOneChipFit.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/20160809/psastro/src/psastroAstromGuess.c
r31333 r39686 75 75 pmFPA *fpa = input->fpa; 76 76 77 if (DEBUG) psastroDumpCorners ("corners.up.guess1.dat", "corners.dn.guess1.dat", fpa); 77 // this call only works if we have loaded a model : seg fault if not 78 if (DEBUG && useModel) psastroDumpCorners ("corners.up.guess1.dat", "corners.dn.guess1.dat", fpa); 78 79 79 80 // load mosaic-level astrometry? … … 91 92 if (!psastroAstromGuessSetChip (fpa, chip, view, pixelScale, bilevelAstrometry)) continue; 92 93 } 94 95 if (!chip->toFPA || !chip->fromFPA) { 96 char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 97 fprintf (stderr, "no astrom model for %s, skipping\n", name); 98 continue; 99 } 93 100 94 101 if (newFPA) { … … 312 319 while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) { 313 320 if (!chip->process || !chip->file_exists || !chip->data_exists) { continue; } 321 322 if (!chip->toFPA || !chip->fromFPA) { 323 char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 324 fprintf (stderr, "no astrom model for %s, skipping\n", name); 325 continue; 326 } 314 327 315 328 // XXX we are currently inconsistent with marking the good vs the bad data -
branches/czw_branch/20160809/psastro/src/psastroDemoDump.c
r26259 r39686 234 234 if (!chip->process || !chip->file_exists || !chip->data_exists) { continue; } 235 235 236 if (!chip->toFPA || !chip->fromFPA) { 237 char *name = psMetadataLookupStr (NULL, chip->concepts, "CHIP.NAME"); 238 fprintf (stderr, "no astrom model for %s, skipping\n", name); 239 continue; 240 } 241 236 242 // XXX write out the four corners for a test 237 243 psRegion *region = pmChipPixels (chip); -
branches/czw_branch/20160809/psastro/src/psastroModelAdjust.c
r21409 r39686 52 52 return false; 53 53 } 54 float refChipAngleNominal = PS_RAD_DEG*psMetadataLookupF32 (&status, recipe, "PSASTRO.MODEL.REF.CHIP.ANGLE"); 55 if (!refChipName) { 56 psError(PS_ERR_IO, true, "reference chip is missing from recipe"); 57 return false; 58 } 54 59 55 60 // get reference chip from name … … 87 92 // get the current posangle of the ref chip 88 93 float chipAngle = atan2 (refChip->toFPA->y->coeff[1][0], refChip->toFPA->x->coeff[1][0]); 89 fprintf (stderr, "chipAngle: %f\n", chipAngle*PS_DEG_RAD); 94 95 // chipAngle should be refChipAngleNominal @ POSANGLE = 0.0 96 float posAngleOffset = chipAngle - refChipAngleNominal; 97 98 fprintf (stderr, "chipAngle is: %f, at PA = 0.0, it should be %f, rotating model by %f\n", 99 chipAngle*PS_DEG_RAD, refChipAngleNominal*PS_DEG_RAD, posAngleOffset*PS_DEG_RAD); 100 90 101 // psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POSANGLE", PS_META_REPLACE, "boresite parameter", posangle); 91 102 … … 99 110 psRegion *region = pmChipPixels (chip); 100 111 101 psPlaneTransform *toFPA = psPlaneTransformRotate (NULL, chip->toFPA, chipAngle);112 psPlaneTransform *toFPA = psPlaneTransformRotate (NULL, chip->toFPA, posAngleOffset); 102 113 psFree (chip->toFPA); 103 114 chip->toFPA = toFPA; -
branches/czw_branch/20160809/psastro/src/psastroMosaicAstrom.c
r27558 r39686 15 15 16 16 bool psastroMosaicFit (pmFPA *fpa, psMetadata *recipe, const char *rootname, int pass); 17 bool psastroProjectionRefit (pmFPA *fpa, psMetadata *recipe); 17 18 18 19 // XXX require this fpa to have multiple chip extensions and a PHU? … … 42 43 int nIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER"); 43 44 if (!status) psAbort ("missing config value"); 45 46 // XXX if projection is not TAN, fit the measured projection here and combine toTPA/fromTPA functions 47 if ((fpa->toSky->type != PS_PROJ_TAN) && (fpa->toSky->type != PS_PROJ_DIS)) { 48 if (!psastroProjectionRefit (fpa, recipe)) psAbort ("failed to refit distortion"); 49 } 44 50 45 51 // this should be in a loop with nIter = … … 154 160 return true; 155 161 } 162 163 // we have a fpa->toSky projection which is NOT of type TAN along with a toTPA which is 164 // the Identity transform. we want to convert this to TAN projection plus a non-identity 165 // transformation to take the non-TAN components. 166 167 // we are going to generate a set of FP->(x,y) using the current projection + fromTPA 168 // transformations along with a set of TP->(x,y) values using the desired TAN projection, 169 // then we will fit TP vs FP 170 171 bool psastroProjectionRefit (pmFPA *fpa, psMetadata *recipe) { 172 173 bool status; 174 175 // allocate mosaic-level polynomial transformation and set masks needed by DVO 176 int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER"); 177 if (!status) { 178 psError(PSASTRO_ERR_UNKNOWN, false, "failed to find mosaic distortion fit order\n"); 179 return false; 180 } 181 182 pmChip *chip = NULL; 183 pmCell *cell = NULL; 184 pmReadout *readout = NULL; 185 pmFPAview *view = pmFPAviewAlloc (0); 186 187 psVector *L = psVectorAllocEmpty (1000, PS_TYPE_F32); 188 psVector *M = psVectorAllocEmpty (1000, PS_TYPE_F32); 189 190 psVector *P = psVectorAllocEmpty (1000, PS_TYPE_F32); 191 psVector *Q = psVectorAllocEmpty (1000, PS_TYPE_F32); 192 193 psProjection *toSkyTan = psProjectionAlloc (fpa->toSky->R, fpa->toSky->D, fpa->toSky->Xs, fpa->toSky->Ys, PS_PROJ_TAN); 194 195 float xMin = NAN; 196 float xMax = NAN; 197 float yMin = NAN; 198 float yMax = NAN; 199 200 bool firstObject = true; 201 202 // this loop selects the matched stars for all chips 203 while ((chip = pmFPAviewNextChip (view, fpa, 1)) != NULL) { 204 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 205 if (!chip->process || !chip->file_exists) continue; 206 207 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 208 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 209 if (!cell->process || !cell->file_exists) continue; 210 211 // process each of the readouts 212 // XXX there can only be one readout per chip, right? 213 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 214 if (! readout->data_exists) continue; 215 216 // select the raw objects for this readout 217 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS.SUBSET"); 218 if (refstars == NULL) continue; 219 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n); 220 221 psArray *matches = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.MATCH"); 222 if (matches == NULL) continue; 223 224 // we are looking over the matched refstars only to be sure we are 225 // covering the valid space of the projection + transformation, and not 226 // beyond 227 228 for (int i = 0; i < matches->n; i++) { 229 pmAstromMatch *match = matches->data[i]; 230 pmAstromObj *ref = refstars->data[match->ref]; 231 232 psPlane fpOld, tpNew, tpOld; 233 234 psProject (&tpOld, ref->sky, fpa->toSky); // find the focal-plane coord of this RA,DEC coord using the ref chip projection 235 psPlaneTransformApply (&fpOld, fpa->fromTPA, &tpOld); 236 237 psProject (&tpNew, ref->sky, toSkyTan); // find the focal-plane coord of this RA,DEC coord using the ref chip projection 238 239 psVectorAppend (L, fpOld.x); 240 psVectorAppend (M, fpOld.y); 241 242 psVectorAppend (P, tpNew.x); 243 psVectorAppend (Q, tpNew.y); 244 245 if (firstObject) { 246 xMin = xMax = fpOld.x; 247 yMin = yMax = fpOld.y; 248 firstObject = false; 249 } 250 251 xMin = PS_MIN (xMin, fpOld.x); 252 xMax = PS_MAX (xMax, fpOld.x); 253 yMin = PS_MIN (yMin, fpOld.y); 254 yMax = PS_MAX (yMax, fpOld.y); 255 } 256 } 257 } 258 } 259 260 // the original transforms are (1, 1), but we will need higher order to fit the distortions 261 psFree (fpa->toTPA); 262 263 // the original transforms are (1, 1), but we will need higher order to fit the distortions 264 fpa->toTPA = psPlaneTransformAlloc (order, order); 265 for (int i = 0; i <= fpa->toTPA->x->nX; i++) { 266 for (int j = 0; j <= fpa->toTPA->x->nY; j++) { 267 if (i + j > order) { 268 fpa->toTPA->x->coeffMask[i][j] = PS_POLY_MASK_SET; 269 fpa->toTPA->y->coeffMask[i][j] = PS_POLY_MASK_SET; 270 } 271 } 272 } 273 274 psVectorFitPolynomial2D (fpa->toTPA->x, NULL, 0, P, NULL, L, M); 275 psVectorFitPolynomial2D (fpa->toTPA->y, NULL, 0, Q, NULL, L, M); 276 277 psRegion fitRegion = psRegionSet (xMin, xMax, yMin, yMax); 278 279 // psPlaneTransformInvert will generate a new fromTPA with order to match toTPA 280 fpa->fromTPA = psPlaneTransformInvert (fpa->fromTPA, fpa->toTPA, fitRegion, 100); 281 282 psFree (fpa->toSky); 283 fpa->toSky = toSkyTan; 284 285 psFree (L); 286 psFree (M); 287 psFree (P); 288 psFree (Q); 289 290 psFree (view); 291 return true; 292 } 293 -
branches/czw_branch/20160809/psastro/src/psastroMosaicGradients.c
r26259 r39686 79 79 int order = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.ORDER"); 80 80 if (!status) { 81 psError(PSASTRO_ERR_UNKNOWN, false, "failed to find single-chipfit order\n");81 psError(PSASTRO_ERR_UNKNOWN, false, "failed to find mosaic distortion fit order\n"); 82 82 psFree (gradients); 83 83 psFree (view); -
branches/czw_branch/20160809/psastro/src/psastroMosaicOneChip.c
r26259 r39686 100 100 } 101 101 102 // XXX allow stati tic to be set by the user102 // XXX allow statistic to be set by the user 103 103 // only clip if we are fitting the chip parameters. 104 104 psStats *fitStats = NULL; 105 // if (order == 0) {106 //fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);107 //fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");108 //fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");109 //} else {110 fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV);111 fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA");112 fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER");113 //}105 if (FALSE && (order == 0)) { 106 fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 107 fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA"); 108 fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER"); 109 } else { 110 fitStats = psStatsAlloc (PS_STAT_CLIPPED_MEAN | PS_STAT_CLIPPED_STDEV); 111 fitStats->clipSigma = psMetadataLookupF32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NSIGMA"); 112 fitStats->clipIter = psMetadataLookupS32 (&status, recipe, "PSASTRO.MOSAIC.CHIP.NITER"); 113 } 114 114 115 115 // need to pass in an update header, sent in from above 116 pmAstromFitResults *results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats );116 pmAstromFitResults *results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats, recipe); 117 117 if (!results) { 118 118 psError(PSASTRO_ERR_DATA, false, "failed to perform the matched fit\n"); -
branches/czw_branch/20160809/psastro/src/psastroOneChipFit.c
r36914 r39686 124 124 125 125 // improved fit for astrometric terms 126 results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats );126 results = pmAstromMatchFit (chip->toFPA, rawstars, refstars, match, fitStats, recipe); 127 127 if (!results) { 128 128 psLogMsg ("psastro", 3, "failed to perform the matched fit\n");
Note:
See TracChangeset
for help on using the changeset viewer.
