Changeset 15891 for trunk/psastro/src/psastroModelBoresite.c
- Timestamp:
- Dec 22, 2007, 7:42:46 AM (19 years ago)
- File:
-
- 1 edited
-
trunk/psastro/src/psastroModelBoresite.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/psastroModelBoresite.c
r15887 r15891 1 1 # include "psastroStandAlone.h" 2 2 3 // chisq = sum ((L_obs - L_fit(t))^2 + (M_obs - M_fit(t))^2) 4 // coord[0] = measured L or measured M 3 // the full chisq is built of two associated sums over coordinates: 4 // chisq = sum ((X_obs - X_fit(t))^2 + (Y_obs - Y_fit(t))^2) 5 // we use split this into a 2x long vector and use coord[1] to distinguish the X and Y terms: 6 // coord[0] = measured X or measured Y 5 7 // coord[1] = 0 or 1 6 8 psF32 psastroModelBoresite (psVector *deriv, const psVector *params, const psVector *coord) { … … 15 17 float sntht = sin(dtheta); 16 18 17 // value is L19 // value is X 18 20 if (coord->data.F32[1] == 0) { 19 21 20 float value = PAR[PAR_ L0] + PAR[PAR_RL]*cstht*csphi + PAR[PAR_RM]*sntht*snphi;22 float value = PAR[PAR_X0] + PAR[PAR_RX]*cstht*csphi + PAR[PAR_RY]*sntht*snphi; 21 23 22 24 if (deriv) { 23 25 psF32 *dPAR = deriv->data.F32; 24 dPAR[PAR_ L0] = 1.0;25 dPAR[PAR_ M0] = 0.0;26 dPAR[PAR_R L] = +cstht*csphi;27 dPAR[PAR_R M] = +sntht*snphi;28 dPAR[PAR_P0] = -PAR[PAR_R L]*cstht*snphi + PAR[PAR_RM]*sntht*csphi;29 dPAR[PAR_T0] = PAR[PAR_R L]*sntht*csphi - PAR[PAR_RM]*cstht*snphi;26 dPAR[PAR_X0] = 1.0; 27 dPAR[PAR_Y0] = 0.0; 28 dPAR[PAR_RX] = +cstht*csphi; 29 dPAR[PAR_RY] = +sntht*snphi; 30 dPAR[PAR_P0] = -PAR[PAR_RX]*cstht*snphi + PAR[PAR_RY]*sntht*csphi; 31 dPAR[PAR_T0] = PAR[PAR_RX]*sntht*csphi - PAR[PAR_RY]*cstht*snphi; 30 32 } 31 33 return (value); 32 34 } 33 35 34 // value is M36 // value is Y 35 37 if (coord->data.F32[1] == 1) { 36 float value = PAR[PAR_ M0] + PAR[PAR_RM]*sntht*csphi - PAR[PAR_RL]*cstht*snphi;38 float value = PAR[PAR_Y0] + PAR[PAR_RY]*sntht*csphi - PAR[PAR_RX]*cstht*snphi; 37 39 38 40 if (deriv) { 39 41 psF32 *dPAR = deriv->data.F32; 40 dPAR[PAR_ L0] = 0.0;41 dPAR[PAR_ M0] = 1.0;42 dPAR[PAR_R L] = -cstht*snphi;43 dPAR[PAR_R M] = +sntht*csphi;44 dPAR[PAR_P0] = -PAR[PAR_R M]*sntht*snphi - PAR[PAR_RL]*cstht*csphi;45 dPAR[PAR_T0] = -PAR[PAR_R M]*sntht*csphi - PAR[PAR_RL]*cstht*snphi;42 dPAR[PAR_X0] = 0.0; 43 dPAR[PAR_Y0] = 1.0; 44 dPAR[PAR_RX] = -cstht*snphi; 45 dPAR[PAR_RY] = +sntht*csphi; 46 dPAR[PAR_P0] = -PAR[PAR_RY]*sntht*snphi - PAR[PAR_RX]*cstht*csphi; 47 dPAR[PAR_T0] = -PAR[PAR_RY]*sntht*csphi - PAR[PAR_RX]*cstht*snphi; 46 48 } 47 49 return (value); … … 49 51 psAbort ("programming error: invalid coordinate"); 50 52 } 51 52 # undef PAR_L053 # undef PAR_RL54 # undef PAR_PHI55 # define PAR_L0 056 # define PAR_RL 157 # define PAR_PHI 258 59 psF32 psastroModelBoresiteL (psVector *deriv, const psVector *params, const psVector *coord) {60 61 psF32 *PAR = params->data.F32;62 63 float csphi = cos(PAR[PAR_PHI]);64 float snphi = sin(PAR[PAR_PHI]);65 66 float theta = coord->data.F32[0];67 float cstht = cos(theta);68 float sntht = sin(theta);69 70 float value = PAR[PAR_L0] + PAR[PAR_RL]*cstht*csphi - PAR[PAR_RL]*sntht*snphi;71 72 if (deriv) {73 psF32 *dPAR = deriv->data.F32;74 dPAR[PAR_L0] = 1.0;75 dPAR[PAR_RL] = cstht*csphi - sntht*snphi;76 dPAR[PAR_PHI] = -PAR[PAR_RL]*cstht*snphi - PAR[PAR_RL]*sntht*csphi;77 }78 return (value);79 }80 81 psF32 psastroModelBoresiteM (psVector *deriv, const psVector *params, const psVector *coord) {82 83 psF32 *PAR = params->data.F32;84 85 float csphi = cos(PAR[PAR_PHI]);86 float snphi = sin(PAR[PAR_PHI]);87 88 float theta = coord->data.F32[0];89 float cstht = cos(theta);90 float sntht = sin(theta);91 92 float value = PAR[PAR_L0] + PAR[PAR_RL]*sntht*csphi + PAR[PAR_RL]*cstht*snphi;93 94 if (deriv) {95 psF32 *dPAR = deriv->data.F32;96 dPAR[PAR_L0] = 1.0;97 dPAR[PAR_RL] = +sntht*csphi + cstht*snphi;98 dPAR[PAR_PHI] = -PAR[PAR_RL]*sntht*snphi + PAR[PAR_RL]*cstht*csphi;99 }100 return (value);101 }
Note:
See TracChangeset
for help on using the changeset viewer.
