Changeset 15891 for trunk/psastro/src/psastroModelAnalysis.c
- Timestamp:
- Dec 22, 2007, 7:42:46 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroModelAnalysis.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroModelAnalysis.c
r15887 r15891 12 12 } 13 13 14 pmFPAfile *output = psMetadataLookupPtr (&status, config->files, "PSASTRO.OUT.MODEL"); 15 if (!status) psAbort ("Can't find output pmFPAfile PSASTRO.OUT.MODEL"); 16 14 17 // physical pixel scale in microns per pixel 15 18 char *refChip = psMetadataLookupStr (&status, recipe, "PSASTRO.MODEL.REF.CHIP"); … … 19 22 } 20 23 21 /* model analysis steps: 22 23 1) determine POS_ZERO: 24 * choose a reference chip 25 * what is posangle of chip 26 * posangle = FPA.POSANGLE - POS_ZERO 27 * POS_ZERO = FPA.POSANGLE - posangle 28 29 ** average over input images 30 31 2) determine boresite model 32 33 * find CRPIX1,2 for a series of images 34 * fit ellipse 35 36 */ 37 38 /***** find the POSANGLE offset *****/ 24 /* model analysis: 25 * 26 * determine POS_ZERO via comparison of measured and reported posangles 27 * POS_ZERO = FPA.POSANGLE - posangle 28 * 29 * determine boresite model: 30 * X = Xo + R_X cos(FPA.POSANGLE - T_0) cos(P_0) + R_Y sin(FPA.POSANGLE - T_0) sin(P_0) 31 * Y = Yo + R_Y sin(FPA.POSANGLE - T_0) cos(P_0) - R_X cos(FPA.POSANGLE - T_0) sin(P_0) 32 * position of reported boresite in reference chip pixels 33 * Xo, Yo : true coordinate of boresite (rotator center) in reference chip pixels 34 * R_X, R_Y : amplitude of boresite offset 35 * T_0 : reference angle for rotator 36 * P_0 : orientation of boresite ellipse 37 */ 39 38 40 39 // select the input pmFPAfile pointers … … 44 43 psArray *files = psListToArray (item->data.list); 45 44 46 // temp data vectors45 // data storage vectors for measurements 47 46 psVector *posZero = psVectorAlloc (files->n, PS_TYPE_F32); 48 47 psVector *Po = psVectorAlloc (files->n, PS_TYPE_F32); 49 psVector * Lo = psVectorAlloc (files->n, PS_TYPE_F32);50 psVector * Mo = psVectorAlloc (files->n, PS_TYPE_F32);48 psVector *Xo = psVectorAlloc (files->n, PS_TYPE_F32); 49 psVector *Yo = psVectorAlloc (files->n, PS_TYPE_F32); 51 50 51 // counter for accepted measured values 52 52 int n = 0; 53 53 54 // convert the headers for the input file into fpa astrometry terms 54 // Re-select the output fpa. The output fpa needs to have valid astrometry for the 55 // refChip. output->fpa is a copy of the pointer to one of the input->fpa, but the choice 56 // is arbitrary. select a new one that has an existing ref chip 57 psFree (output->fpa); 58 output->fpa = NULL; 59 60 // extract the relevant measured and reported values from the reference chip 55 61 for (int i = 0; i < files->n; i++) { 56 62 psMetadataItem *file = files->data[i]; 57 63 pmFPAfile *input = file->data.V; 58 64 65 // reported rotator position angle (this should perhaps be ROT, not POS) 59 66 double POSANGLE = psMetadataLookupF64 (&status, input->fpa->concepts, "FPA.POSANGLE"); 60 67 if (!status) psAbort ("missing FPA.POSANGLE"); 61 68 62 // get chip from name69 // get reference chip from name 63 70 pmChip *chip = pmConceptsChipFromName (input->fpa, refChip); 64 71 if (!chip) psAbort ("invalid chip name for reference"); 65 72 73 fprintf (stderr, "input %d : %zx : %zx : %zx\n", i, (size_t) input, (size_t) chip, (size_t) chip->toFPA); 66 74 if (!chip->toFPA) continue; 75 76 if (!output->fpa) { 77 // this one matches 78 output->fpa = psMemIncrRefCounter(input->fpa); 79 } 67 80 68 81 // we have two measurements of the posangle (may be parity flipped to different quadrants) … … 72 85 while (posZero->data.F32[n] < 0.0) posZero->data.F32[n] += 360.0; 73 86 74 Po->data.F32[n] = POSANGLE * PM_RAD_DEG; 75 Lo->data.F32[n] = chip->toFPA->x->coeff[0][0];76 Mo->data.F32[n] = chip->toFPA->y->coeff[0][0];77 fprintf (stderr, "%d : %f %f : %f = %f - %f\n", i, Lo->data.F32[n], Mo->data.F32[n], posZero->data.F32[n], POSANGLE, posangle);87 Po->data.F32[n] = POSANGLE * PM_RAD_DEG; // reported position angle 88 Xo->data.F32[n] = chip->fromFPA->x->coeff[0][0]; // reported boresite x position in ref chip coordinates 89 Yo->data.F32[n] = chip->fromFPA->y->coeff[0][0]; // reported boresite y position in ref chip coordinates 90 fprintf (stderr, "%d : %f %f : %f = %f - %f\n", i, Xo->data.F32[n], Yo->data.F32[n], posZero->data.F32[n], POSANGLE, posangle); 78 91 n ++; 79 92 } 80 93 81 Lo->n = n;82 Mo->n = n;94 Xo->n = n; 95 Yo->n = n; 83 96 Po->n = n; 84 97 posZero->n = n; … … 88 101 89 102 fprintf (stderr, "pos zero %f +/- %f\n", stats->sampleMedian, stats->sampleStdev); 103 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.POS_ZERO", PS_META_REPLACE, "offset between obs and meas posangle", stats->sampleMedian); 90 104 91 psastroModelFitBoresite (Lo, Mo, Po); 105 psVector *params = psastroModelFitBoresite (Xo, Yo, Po); 106 if (params->n != 6) psAbort ("error"); 107 108 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.X0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_X0]); 109 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.Y0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_Y0]); 110 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.RX", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_RX]); 111 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.RY", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_RY]); 112 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.T0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_T0]); 113 psMetadataAddF32 (output->fpa->concepts, PS_LIST_TAIL, "FPA.BORE.P0", PS_META_REPLACE, "boresite parameter", params->data.F32[PAR_P0]); 114 psMetadataAddStr (output->fpa->concepts, PS_LIST_TAIL, "FPA.REF.CHIP", PS_META_REPLACE, "boresite parameter", refChip); 92 115 93 116 return true;
Note:
See TracChangeset
for help on using the changeset viewer.
