Changeset 41748
- Timestamp:
- Jul 30, 2021, 3:01:24 PM (5 years ago)
- Location:
- trunk/Ohana/src/opihi/cmd.astro
- Files:
-
- 3 edited
-
astrom_ops.c (modified) (1 diff)
-
init.c (modified) (2 diffs)
-
parallax_factor.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/cmd.astro/astrom_ops.c
r39610 r41748 41 41 } 42 42 43 /* given RA, DEC, Time, calculate the parallax factor */ 44 // RA,DEC are decimal degrees 45 // Time is MJD 46 int ParFactor_3d (double *pR, double *pD, double *pZ, double RA, double DEC, double Time) { 47 48 double lambda, beta, epsilon, Radius; 49 50 // Time must be mjd 51 sun_ecliptic (Time, &lambda, &beta, &epsilon, &Radius); 52 53 double lambda_rad = lambda*RAD_DEG; 54 double epsilon_rad = epsilon*RAD_DEG; 55 double RA_rad = RA*RAD_DEG; 56 double DEC_rad = DEC*RAD_DEG; 57 58 double x = Radius*cos(lambda_rad); 59 double y = Radius*cos(epsilon_rad)*sin(lambda_rad); 60 double z = Radius*sin(epsilon_rad)*sin(lambda_rad); 61 62 *pR = +(y*cos(RA_rad) - x*sin(RA_rad)); 63 *pD = -(y*sin(RA_rad) + x*cos(RA_rad))*sin(DEC_rad) + z*cos(DEC_rad); 64 *pZ = -(y*sin(RA_rad) + x*cos(RA_rad))*cos(DEC_rad) + z*sin(DEC_rad); 65 66 return TRUE; 67 } 68 43 69 // allocate arrays but not the container 44 70 int PlxFitDataAlloc (PlxFitData *data, int N) { -
trunk/Ohana/src/opihi/cmd.astro/init.c
r41666 r41748 52 52 int outline PROTO((int, char **)); 53 53 int parallax_factor PROTO((int, char **)); 54 int parallax_factor_3d PROTO((int, char **)); 54 55 int polar PROTO((int, char **)); 55 56 int precess PROTO((int, char **)); … … 125 126 {1, "outline", outline, "fit outline region"}, 126 127 {1, "parallax_factor", parallax_factor, "generate parallax_factors"}, 128 {1, "parallax_factor_3d", parallax_factor_3d, "generate parallax_factors (include in direction of star)"}, 127 129 {1, "polar", polar, "convert polar image to cartesian"}, 128 130 {1, "precess", precess, "precess coordinates"}, -
trunk/Ohana/src/opihi/cmd.astro/parallax_factor.c
r39591 r41748 99 99 return FALSE; 100 100 } 101 102 int parallax_factor_3d (int argc, char **argv) { 103 104 Vector *rvec = NULL; 105 Vector *dvec = NULL; 106 Vector *tvec = NULL; 107 Vector *pRvec = NULL; 108 Vector *pDvec = NULL; 109 Vector *pZvec = NULL; 110 111 if ((argc != 4) && (argc != 8)) { 112 gprint (GP_ERR, "USAGE: parallax_factor (ra) (dec) (time) [to (parR) (parD) (parZ)]\n"); 113 return (FALSE); 114 } 115 if ((argc == 8) && strcasecmp (argv[4], "to")) { 116 gprint (GP_ERR, "USAGE: parallax_factor (ra) (dec) (time) to (parR) (parD) (parZ)\n"); 117 return (FALSE); 118 } 119 120 double time, ra, dec; 121 122 if (SelectScalar (argv[1], &ra)) { 123 if (!SelectScalar (argv[2], &dec)) goto escape; 124 if (!SelectScalar (argv[3], &time)) goto escape; 125 126 double parR, parD, parZ; 127 128 ParFactor_3d (&parR, &parD, &parZ, ra, dec, time); 129 130 if (argc == 4) { 131 gprint (GP_LOG, "%10.6f %10.6f %10.6f\n", parR, parD, parZ); 132 } else { 133 set_variable (argv[5], parR); 134 set_variable (argv[6], parD); 135 set_variable (argv[7], parZ); 136 } 137 138 return TRUE; 139 } 140 141 if (argc == 4) { 142 gprint (GP_ERR, "must supply output vectors for input vectors\n"); 143 return (FALSE); 144 } 145 if ((argc == 8) && strcasecmp (argv[4], "to")) { 146 gprint (GP_ERR, "USAGE: parallax_factor (ra) (dec) (time) to (parR) (parD) (parZ)\n"); 147 return (FALSE); 148 } 149 150 if ((rvec = SelectVector (argv[1], OLDVECTOR, TRUE)) == NULL) goto escape; 151 if ((dvec = SelectVector (argv[2], OLDVECTOR, TRUE)) == NULL) goto escape; 152 if ((tvec = SelectVector (argv[3], OLDVECTOR, TRUE)) == NULL) goto escape; 153 154 if (rvec[0].Nelements != dvec[0].Nelements) { 155 gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[2]); 156 return (FALSE); 157 } 158 if (rvec[0].Nelements != tvec[0].Nelements) { 159 gprint (GP_ERR, "vectors %s and %s not the same length\n", argv[1], argv[3]); 160 return (FALSE); 161 } 162 163 if (rvec->type != OPIHI_FLT) { 164 gprint (GP_ERR, "input vectors must be floating point\n"); 165 return (FALSE); 166 } 167 if (dvec->type != OPIHI_FLT) { 168 gprint (GP_ERR, "input vectors must be floating point\n"); 169 return (FALSE); 170 } 171 if (tvec->type != OPIHI_FLT) { 172 gprint (GP_ERR, "input vectors must be floating point\n"); 173 return (FALSE); 174 } 175 176 if ((pRvec = SelectVector (argv[5], ANYVECTOR, TRUE)) == NULL) goto escape; 177 if ((pDvec = SelectVector (argv[6], ANYVECTOR, TRUE)) == NULL) goto escape; 178 if ((pZvec = SelectVector (argv[7], ANYVECTOR, TRUE)) == NULL) goto escape; 179 180 ResetVector (pRvec, OPIHI_FLT, rvec[0].Nelements); 181 ResetVector (pDvec, OPIHI_FLT, rvec[0].Nelements); 182 ResetVector (pZvec, OPIHI_FLT, rvec[0].Nelements); 183 184 opihi_flt *Rv = rvec[0].elements.Flt; 185 opihi_flt *Dv = dvec[0].elements.Flt; 186 opihi_flt *Tv = tvec[0].elements.Flt; 187 opihi_flt *pRv = pRvec[0].elements.Flt; 188 opihi_flt *pDv = pDvec[0].elements.Flt; 189 opihi_flt *pZv = pZvec[0].elements.Flt; 190 191 for (int i = 0; i < rvec[0].Nelements; i++, Rv++, Dv++, Tv++, pRv++, pDv++, pZv++) { 192 ParFactor_3d (pRv, pDv, pZv, *Rv, *Dv, *Tv); 193 } 194 195 return (TRUE); 196 197 escape: 198 FREE (rvec); 199 FREE (dvec); 200 FREE (tvec); 201 FREE (pRvec); 202 FREE (pDvec); 203 FREE (pZvec); 204 return FALSE; 205 }
Note:
See TracChangeset
for help on using the changeset viewer.
