Changeset 335 for trunk/doc/pslib/psLibADD.tex
- Timestamp:
- Mar 31, 2004, 3:54:50 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibADD.tex (modified) (36 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibADD.tex
r318 r335 43 43 ``heapsort'', ``quicksort'', and ``mergesort'' (see, e.g., 44 44 \citealt{knuth}, \citealt{sedgewick}, \citealt{press}). These three 45 sorting algorithms all run in a time of $O(n \log n)$ in the best46 case, but have different worse-case run times. Implementations of all 47 three sorting algorithms are described in references above and in 48 variousplaces online (e.g.,45 sorting algorithms all run in a time of $O(n \log n)$ on the average, 46 but have different worse-case run times. Implementations of all three 47 sorting algorithms are described in references above and in various 48 places online (e.g., 49 49 http://www.iti.fh-flensburg.de/lang/algorithmen/sortieren/algoen.htm). 50 The linux \code{qsort} function orignially mades use of the quicksort 51 algorithm, but now uses \tbd{what algorithm?}. The GSL function 52 \code{gsl_heapsort} uses the heapsort algorithm. Both of these 53 implemenations require a pointer to the comparison function, which may 54 result in a slower code. 55 56 For PSLib, the sorting functions shall be implemented via 50 The linux \code{qsort} function uses a heapsort if it can allocate a 51 sufficiently large temporary buffer, and otherwise resorts to a 52 quicksort in-place. The GSL function \code{gsl_heapsort} uses the 53 heapsort algorithm. Both of these implemenations require a pointer to 54 the comparison function, which may result in a slower code than if the 55 comparison were done within the sort function. 56 57 For PSLib, the sorting functions shall be implemented via the system 57 58 \code{qsort}. The function \code{psSort} shall return the sorted 58 59 result of the input array without over-writing the input array. The … … 73 74 neighbors in the form: 74 75 75 \[ g_i = \sum_{n=-N}^N c_n f_i \] 76 \begin{equation} 77 g_i = \sum_{n=-N}^N c_n f_i 78 \end{equation} 76 79 % 77 80 where the values of $c_n$ determine the filter type. For boxcar … … 80 83 the ends of the data range to reduce the value of $c_n$ as fewer input 81 84 data points may be used). For Gaussian smoothing, the crucial 82 parameter is $\sigma$, the standard deviation. The 83 value of $N$ should be chosen to be large enough, $N = 5\sigma$, and 84 the values of $c_n$ are then just the Gaussian curve: 85 86 \[ c_n = \frac{e^{\frac{-n^2}{2\sigma^2}}}{\sqrt{2\pi\sigma^2}} \] 85 parameter is $\sigma$, the standard deviation. The value of $N$ 86 should be chosen to be large enough to sample the Gaussian, $N = 87 5\sigma$, and the values of $c_n$ are then just the Gaussian curve: 88 89 \begin{equation} 90 c_n = \frac{e^{\frac{-n^2}{2\sigma^2}}}{\sqrt{2\pi\sigma^2}} 91 \end{equation} 87 92 88 93 \subsection{Statistics} … … 97 102 use may vary depending on the context. In addition, certain 98 103 sigma-clipped values are defined as an intermediate choice between the 99 sample and robust estimators. 104 sample and robust estimators. 100 105 101 106 \subsubsection{Sample Statistics} … … 106 111 \paragraph{Mean} 107 112 108 The mean is defined as: \[ \bar{x} = \frac{1}{N} \sum_{i = 1}^{N} x_i \] 113 The mean is defined as: 114 \begin{equation} 115 \bar{x} = \frac{1}{N} \sum_{i = 1}^{N} x_i 116 \end{equation} 109 117 110 118 \paragraph{Median} … … 115 123 number of values is odd, and by the average of the two middle values 116 124 if the number of values is even. This median should be avoided for 117 samples which are large (e.g., $N > 10 000$ elements) as the basic125 samples which are large (e.g., $N > 10^4$ elements) as the basic 118 126 robust median is quicker and more accurate. 119 127 … … 129 137 lower quartile, it is sufficient to provide the closest integer entry 130 138 to these values. The sample quartiles should be avoided for samples 131 which are large (e.g., $N > 10 000$ elements) as the robust quartiles139 which are large (e.g., $N > 10^4$ elements) as the robust quartiles 132 140 are quicker and more accurate. 133 141 … … 136 144 The standard deviation of the sample is given by: 137 145 138 \[ \sigma = \sqrt{\sum_{i = 1}^N \frac{(x_i - \bar{x})^2}{N - 1}} \] 146 \begin{equation} 147 \sigma = \sqrt{\sum_{i = 1}^N \frac{(x_i - \bar{x})^2}{N - 1}} 148 \end{equation} 139 149 140 150 To minimize the numerical rounding error, this should be calculated 141 151 numerically as: 142 152 143 \[ \sigma = \sqrt{\frac{1}{N - 1} [ \sum_{i = 1}^{N} (x_i - \bar{x})^2 - \frac{1}{N} (\sum_{i = 1}^{N} (x_i - \bar{x}))^2 ]} \] 153 \begin{equation} 154 \sigma = \sqrt{\frac{1}{N - 1} \left[ \sum_{i = 1}^{N} (x_i - \bar{x})^2 - \frac{1}{N} \left(\sum_{i = 1}^{N} (x_i - \bar{x})\right)^2 \ \right]} 155 \end{equation} 144 156 145 157 \subsubsection{Clipped Statistics} 146 158 147 The clipped statistics are used to determine the mean and $\sigma$ of 148 a distribution in the presence of outliers. The clipped statistics are 149 quicker than the complete robust statistical estimators and more 150 reliable than the sample statistics. The clipped statistics algorithm 151 produces the clipped mean and clipped standard deviation. The 152 algorithm has 2 parameters: $N$, the number of iterations and $k$, the 153 multiplying factor of $\sigma$ used to exclude outliers. Typical 154 values for both $N$ and $k$ are 3. The algorithm is as follows: 159 The clipped statistics are used to determine the mean and standard 160 deviation of a distribution in the presence of outliers. The clipped 161 statistics are quicker than the complete robust statistical estimators 162 and more reliable than the sample statistics. The clipped statistics 163 algorithm produces the clipped mean and clipped standard deviation. 164 The algorithm has 2 parameters: $N$, the number of iterations and $k$, 165 the multiplying factor of the standard deviation used to exclude 166 outliers. Typical values for both $N$ and $k$ are 3. The algorithm 167 is as follows: 155 168 156 169 \begin{enumerate} … … 162 175 \item Repeat the following N times: 163 176 \begin{enumerate} 164 \item Exclude all values $x_{i}$ for whi le$|x_{i} - \bar{x}| > k \sigma$.177 \item Exclude all values $x_{i}$ for which $|x_{i} - \bar{x}| > k \sigma$. 165 178 \item Compute the mean and standard deviation of the sub-sample. 166 179 \item Use the new mean for $\bar{x}$. 167 180 \item Use the new standard deviations for $\sigma$. 168 181 \end{enumerate} 169 \item The last calulcated value of $\bar{x}$ is the clipped mean. 170 \item The last calulcated value of $\sigma$ is the clipped standard deviation. 182 \item The last calculated value of $\bar{x}$ is the clipped mean. 183 \item The last calculated value of $\sigma$ is the clipped standard 184 deviation. 171 185 \end{enumerate} 172 186 173 187 \subsubsection{Robust Statistics} 174 188 175 The robust version of the statistics provide estimators of basic189 The robust version of the statistics provides estimators of basic 176 190 statistical concepts which are reliable even for data samples with 177 191 significant contamination. A typical case is the situation in which … … 202 216 4$. 203 217 \item Find the bin with the peak value in the range $L_{\frac{1}{4}}$ 204 to $U_{\frac{1}{4}}$; this is the robust mode $\mbox{mode}_r$.218 to $U_{\frac{1}{4}}$; this is the robust mode, $\mbox{mode}_r$. 205 219 \item Determine $dL = (U_{\frac{1}{4}} - L_{\frac{1}{4}}) / 8$. 206 220 \item Fit a Gaussian to the bins in the range $\mbox{mode}_r - dL$ to … … 242 256 diagonal matrices that satisfy the relationship $A = L U$ where $L$ is 243 257 a lower-diagonal matrix of the form: 244 \[ L = \left( 258 \begin{equation} 259 L = \left( 245 260 \begin{matrix} 246 261 \alpha_{11} & 0 & 0 & 0 \\ … … 249 264 \alpha_{41} & \alpha_{42} & \alpha_{43} & \alpha_{44} \\ 250 265 \end{matrix} \right) 251 \ ]266 \end{equation} 252 267 % 253 (where all diagonal values $\alpha){ii} = 1$) and $U$ is an upper-diagonal matrix of the form: 254 \[ U = \left( 268 (where all diagonal values $\alpha_{ii} = 1$) and $U$ is an upper-diagonal matrix of the form: 269 \begin{equation} 270 U = \left( 255 271 \begin{matrix} 256 272 \beta_{11} & \beta_{12} & \beta_{13} & \beta_{14} \\ … … 259 275 0 & 0 & 0 & \beta_{44} \\ 260 276 \end{matrix} \right) 261 \ ]262 % 277 \end{equation} 278 263 279 We can find the values of $\alpha_{ij}$ and $\beta_{ij}$ by following 264 280 this procedure. First, $\alpha_{ii} = 1$. For all values of $j = 1, 265 281 2, \dots, N$, follow the next steps: For each value of $i = 1, 2, 266 282 \dots, j$, solve for $\beta_{ij}$ using the relationship: 267 \[ \beta_{ij} = a_{ij} - \sum_{k=1}^{i-1} \alpha_{ik}\beta_{kj} \] 283 \begin{equation} 284 \beta_{ij} = a_{ij} - \sum_{k=1}^{i-1} \alpha_{ik}\beta_{kj} 285 \end{equation} 268 286 For the values of $i = j+1, j+2, \dots, N$, solve for the values of 269 287 $\alpha_{ij}$ with the following: 270 288 % 271 \[ \alpha_{ij} = \frac{1}{\beta_{jj}} \left( a_{ij} - \sum_{k=1}^{j-1} \alpha_{ik}\beta_{kj} \right) \] 289 \begin{equation} 290 \alpha_{ij} = \frac{1}{\beta_{jj}} \left( a_{ij} - \sum_{k=1}^{j-1} \alpha_{ik}\beta_{kj} \right) 291 \end{equation} 272 292 273 293 \subsubsection{Calculate a matrix determinant} … … 275 295 The determinant $D$ of a matrix $a_{ij}$ is calculated from the 276 296 product of the diagonal elements of the LU decomposition: 277 \[ D = P_{i=1}{N} U_{ii} \] 297 \begin{equation} 298 D = P_{i=1}{N} U_{ii} 299 \end{equation} 278 300 279 301 This shall be calculated using the GSL function … … 293 315 $\beta_{ij}$, the technique of back-substitution is used to solve the 294 316 equation above. First solve the equation $L y = B$: 295 \[ y_1 = \frac{b_1}{\alpha_{11}}\] 296 \[ y_i = \frac{1}{\alpha_{ii}}\left(b_i - \sum_{j=1}^{i-1} \alpha_{ij} y_i\right) \] 297 % 317 \begin{eqnarray} 318 y_1 & = & \frac{b_1}{\alpha_{11}} \\ 319 y_i & = & \frac{1}{\alpha_{ii}}\left(b_i - \sum_{j=1}^{i-1} \alpha_{ij} y_i\right) 320 \end{eqnarray} 321 298 322 The values of $y$ may be used to solve for $x_i$ using the 299 323 relationship $U x = b$: 300 \[ x_N = \frac{y_N}{\beta_{NN}}\] 301 \[ x_i = \frac{1}{\beta_{ii}}\left(y_i - \sum_{j=i+1}^N \beta_{ij} y_ij\right) \] 324 \begin{eqnarray} 325 x_N & = & \frac{y_N}{\beta_{NN}} \\ 326 x_i & = & \frac{1}{\beta_{ii}}\left(y_i - \sum_{j=i+1}^N \beta_{ij} y_ij\right) 327 \end{eqnarray} 302 328 303 329 \subsubsection{Invert a matrix} … … 313 339 314 340 Matrix binary arithmetic operations differ from image binary 315 arithmetic operations in a fundamental way: For image operations, the341 arithmetic operations in a fundamental way: For image operations, the 316 342 resulting pixel value is determined by performing the operation on the 317 343 two corresponding input operand pixels. For matrix operations, the 318 344 resulting element value results from the operation on the 319 corresponding pair of row and colum from the input matri x. So, for345 corresponding pair of row and colum from the input matrices. So, for 320 346 example, given the input matrices $\alpha_{ij}$ and $\beta_{ij}$, the 321 image and matrix multiplication correspond to:347 image and matrix multiplications correspond to: 322 348 % 323 \[ \mbox{image}_{ij} = \alpha_{ij} \times \beta_{ij} \] 324 \[ \mbox{matrix}_{jk} = \sum_{i=1}^N \alpha_{ij} \times \beta_{ki} \] 349 \begin{eqnarray} 350 \mbox{image}_{ij} & = & \alpha_{ij} \times \beta_{ij} \\ 351 \mbox{matrix}_{jk} = \sum_{i=1}^N \alpha_{ij} \times \beta_{ki} 352 \end{eqnarray} 325 353 % 326 The matrix math function \code{psMatrixOp} shall implement the matrix 327 version of the binary arithmetical operations for the following 328 operators: $+, -, \times, /$ 354 The matrix and image operations for addition and subtraction are 355 identical: the operation is performed on the corresponding elements in 356 each matrix. Matrix division is not defined (to divide, the user 357 should first invert the matrix, and then multiply). The matrix math 358 function \code{psMatrixOp} shall implement the matrix version of the 359 binary arithmetical operations for the following operators: $+, -, 360 \times$. 329 361 330 362 \subsubsection{Transpose a matrix} … … 336 368 given by 337 369 % 338 \[ T_{ij} = M_{ji} \] 370 \begin{equation} 371 T_{ij} = M_{ji} 372 \end{equation} 339 373 where $M_{ij}$ is the matrix to be transposed. 340 374 341 375 \subsubsection{Convert a matrix to a vector} 342 \TBD{write me} 376 377 Matrix-to-vector conversion is only defined for a matrix that has a 378 size of one in at least one dimension. In that case, the elements 379 should be extracted, and placed in a vector, with care that the 380 \code{psType} is defined correctly --- a $1\times N$ matrix is 381 converted to a \code{PS_DIMEN_VECTOR}-type vector, while a $N\times 1$ 382 matrix is converted to a \code{PS_DIMEN_TRANV}-type vector. 343 383 344 384 \subsection{Fitting} 345 385 386 \subsubsection{Chi-squared} 387 \label{chisq} 388 389 Given a set of N ordinates, $x_i$, measured coordinates, $y_i$, with 390 errors, $\sigma_i$, and a model function, $f(x_i)$, then $\chi^2$ 391 (``chi-squared'') is defined: 392 393 \begin{equation} 394 \chi^2 = \sum_{i=0}^{N-1} \left( \frac{y_i - f(x_i)}{\sigma_i} \right)^2 395 \end{equation} 396 346 397 \subsubsection{General Polynomial Fitting} 347 348 \TBD{define for use with psGetArrayPolynomial}349 350 \TBD{change psGetArrayPolynomial to return a psPolynomial}351 398 352 399 Given a set of data values $y_i$ with errors $\sigma_i$, related to … … 354 401 of $N_{par}$ free parameters of the form $y = \sum_{j=0}^{N_{par}} 355 402 \alpha_j x^j$. The model is determined by minimizing the value of 356 $\chi^2$ as defined above (\ref{chisq}), and the minimization is 357 determined by solving for the set of parameters $\alpha_j$ for which 358 the partial derivatives of the $\chi^2$ with respect to those 359 parameters are zero. The partial derivatives are 360 361 \[ \frac{\partial \chi^2}{\partial \alpha_k} = -2 \sum_i (y_i - \sum_j x_i^j \alpha_j) \frac{x_i^k}{\sigma_i^2} \] 403 $\chi^2$ (\ref{chisq}), and the minimization is determined by solving 404 for the set of parameters $\alpha_j$ for which the partial derivatives 405 of the $\chi^2$ with respect to those parameters are zero. The 406 partial derivatives are 407 408 \begin{equation} 409 \frac{\partial \chi^2}{\partial \alpha_k} = -2 \sum_i (y_i - \sum_j x_i^j \alpha_j) \frac{x_i^k}{\sigma_i^2} 410 \end{equation} 362 411 363 412 Setting the derivatives to zero, this may be reduced to the following 364 413 matrix equation: 365 414 366 \[ \sum_j \alpha_j \sum_i \frac{x_i^k x_i^j}{\sigma_i^2} = \sum_i \frac{x_i^k y_i}{\sigma_i^2} \] 415 \begin{equation} 416 \sum_j \alpha_j \sum_i \frac{x_i^k x_i^j}{\sigma_i^2} = \sum_i \frac{x_i^k y_i}{\sigma_i^2} 417 \end{equation} 367 418 368 419 This matrix equation may be solved with LU Decomposition … … 375 426 For models in which the system of equations defined by the partial 376 427 derivatives cannot be solved with the linear technique, other options 377 are necessary. The Levenberg-Marquardt Method (LMM; see N umerical378 Recipes for a discusion) may be used for these situations. In LMM, we379 make a guess at the input parameters, measure the $\chi^2$, vary the 380 par ameters by a particular choice based on the gradient, measure the381 $\chi^2$ again, and adjust the parameters and the parameter varient 382 based on theresults.428 are necessary. The Levenberg-Marquardt Method (LMM; see NR \S 15.5) 429 may be used for these situations. In LMM, we make a guess at the 430 input parameters, measure the $\chi^2$, vary the parameters by a 431 particular choice based on the gradient, measure the $\chi^2$ again, 432 and adjust the parameters and the parameter varient based on the 433 results. 383 434 384 435 Given a set of $N$ data values $y_i$ with errors $\sigma_i$, dependent … … 389 440 $\alpha_{j,k}$ at this parameter selection as follows: 390 441 391 \[ \beta_k = \sum_{i=1}^{N} \frac{\partial f(x_i)}{\partial a_k} \frac{(y_i - f(x_i))}{\sigma_i^2} \] 392 \[ \alpha_{j,k} = \sum_{i=1}^{N} \frac{\partial f(x_i)}{\partial a_k} \frac{\partial f(x_i)}{\partial a_j} \frac{1}{\sigma_i^2} \] 442 \begin{eqnarray} 443 \beta_k & = & \sum_{i=1}^{N} \frac{\partial f(x_i)}{\partial a_k} \frac{(y_i - f(x_i))}{\sigma_i^2} \\ 444 \alpha_{j,k} & = & \sum_{i=1}^{N} \frac{\partial f(x_i)}{\partial a_k} \frac{\partial f(x_i)}{\partial a_j} \frac{1}{\sigma_i^2} 445 \end{eqnarray} 393 446 % 394 447 We now define the new parameter guess for $a_k$ based on the gradient … … 396 449 follows: 397 450 398 \[ A_{j,k} = \alpha_{j,k} ~ (j \ne k) \] 399 \[ A_{j,k} = (1 + \lambda) \alpha_{j,k} ~ (j = k) \] 451 \begin{eqnarray} 452 A_{j,k} & = & \alpha_{j,k} ~ (j \ne k) \\ 453 A_{j,k} & = & (1 + \lambda) \alpha_{j,k} ~ (j = k) 454 \end{eqnarray} 400 455 % 401 456 and solve the system of equations represented by: 402 \[ A_{j,k} \alpha^\prime_k = \beta_j \] 457 \begin{equation} 458 A_{j,k} a^\prime_k = \beta_j 459 \end{equation} 403 460 % 404 where $ \alpha^\prime_k$ represents our new attempt at a parameter461 where $a^\prime_k$ represents our new attempt at a parameter 405 462 guess. We use this parameter set to calculate $\chi^2$. If the new 406 463 value of $\chi^2$ is lower than the previous guess, we accept this new … … 437 494 \end{center} 438 495 496 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 497 439 498 \subsection{Polynomials} 440 499 … … 446 505 \begin{itemize} 447 506 \item They are bounded on $-1 < x < 1$, with the maxima and minima 448 over this range being 1 and -1, respectively;507 over this range being 1 and $-1$, respectively; 449 508 \item Truncation of the higher-order terms leaves one with the most accurate 450 509 lower-order polynomial representation of the desired function. … … 477 536 478 537 Multi-dimensional polynomials shall be composed of multiplications of 479 1D Chebyshev polynomials. 480 538 1D Chebyshev polynomials, with the coefficients stored in tensors of 539 the appropriate rank. 540 541 542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 481 543 482 544 \subsection{(Fast) Fourier Transforms} … … 500 562 will be specified as a configuration variable for the IPP (defaulting 501 563 to \code{/etc/fftw/wisdom}). The \code{wisdom} should be read in upon 502 initialisation of the PSLib FFT functions and saved at the conclusion. 564 initialisation of the PSLib FFT functions (\code{psFFTInit()}) and 565 saved at the conclusion (\code{psFFTDone()}). 503 566 504 567 \subsubsection{Function mapping} … … 515 578 516 579 These plans should be formulated using the \code{FFTW_ESTIMATE} flag, 517 which will allow FFTW to default to a shortplanning time if the580 which will allow FFTW to default to a minimal planning time if the 518 581 wisdom has not been loaded. Transforms should be performed out of 519 582 place to avoid the need to pad the input array to hold the output. … … 521 584 \subsubsection{More Complicated Functions} 522 585 523 The \code{psFFTFilter } and \code{psFFTFilterComplex} functions provide586 The \code{psFFTFilter()} and \code{psFFTFilterComplex()} functions provide 524 587 the means to apply a filter (purely real and imaginary multipliers, 525 588 respectively) to the data in the Fourier plane. If the filter 526 function specified for \code{psFFTFilter } returns a real value, $r$,589 function specified for \code{psFFTFilter()} returns a real value, $r$, 527 590 then the corresponding value in the Fourier plane should be multiplied 528 591 by $r$. If the real and imaginary filter functions specified for 529 \code{psFFTFilterComplex } return the values $r$ and $s$, respectively,592 \code{psFFTFilterComplex()} return the values $r$ and $s$, respectively, 530 593 then the corresponding value in the Fourier plane should be multiplied 531 594 by the complex number $r + si$. … … 535 598 Fourier transform is multiplied by the complex conjugate of the second 536 599 Fourier transform to yield the Fourier transform of the 537 cross-correlation (NR 13.2). In the latter, the two Fourier600 cross-correlation (NR \S 13.2). In the latter, the two Fourier 538 601 transforms are multiplied directly to yield the Fourier transform of 539 the convolution (NR 13.1).602 the convolution (NR \S 13.1). 540 603 541 604 If the elements of the discrete Fourier transform are $C_k$, then the 542 the elements of the power spectrum are (NR 13.4):605 the elements of the power spectrum are (NR \S 13.4): 543 606 \begin{eqnarray} 544 607 P_0 & = & \left| C_0 \right|^2 / N^2 \\ … … 550 613 Note that we leave the issue of ``windowing'' the data up to the 551 614 caller, and choose to normalise by $1/N^2$. 615 616 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 552 617 553 618 \subsection{Astronomy Utilities} … … 557 622 \href{http://star-www.rl.ac.uk/star/docs/sun67.htx/sun67.html}{SLALIB 558 623 Positional Astronomy Library}. 624 625 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 559 626 560 627 \subsubsection{Celestial Coordinate Conversions} … … 571 638 \end{tabular} 572 639 640 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 641 573 642 \subsubsection{Projections} 574 643 … … 584 653 585 654 \begin{eqnarray} 586 x & = & R \sin \phi\\587 y & = & -R \cos \phi655 x & = & R \sin (\phi) \\ 656 y & = & -R \cos (\phi) 588 657 \end{eqnarray} 589 658 … … 600 669 601 670 \begin{eqnarray} 602 R & = & \cot \theta180^\circ/\pi \\671 R & = & \cot (\theta) 180^\circ/\pi \\ 603 672 \theta & = & \arctan (180^\circ/(\pi R)) 604 673 \end{eqnarray} … … 609 678 610 679 \begin{eqnarray} 611 R & = & \cos \theta180^\circ/\pi \\680 R & = & \cos (\theta) 180^\circ/\pi \\ 612 681 \theta & = & \arccos (\pi R / 180^\circ) 613 682 \end{eqnarray} … … 637 706 638 707 \begin{eqnarray} 639 x & = & 2 \alpha \cos \theta\sin (\phi/2) \\708 x & = & 2 \alpha \cos (\theta) \sin (\phi/2) \\ 640 709 y & = & \alpha \sin \theta \\ 641 {\rm where}\hspace{1cm} \alpha^{-1} & \equiv & (180^\circ/\pi) \sqrt{\left(1 + \cos \theta\cos (\phi/2) \right) / 2}710 {\rm where}\hspace{1cm} \alpha^{-1} & \equiv & (180^\circ/\pi) \sqrt{\left(1 + \cos (\theta) \cos (\phi/2) \right) / 2} 642 711 \end{eqnarray} 643 712 … … 649 718 {\rm where}\hspace{1cm} z & \equiv & \sqrt{1 - (x\pi/720^\circ)^2 - (y\pi/360^\circ)^2} 650 719 \end{eqnarray} 720 721 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 722 723 \subsection{Tangent Plane to Sky} 724 725 Mappings between the tangent plane and the sky will be implemented 726 using SLALIB. 727 728 To speed up the transformations, SLALIB allows the storage of 729 ``apparent-to-observed parameters'', which will be contained in a 730 \code{psGrommit}. The \code{psGrommit} consists of the following: 731 \begin{enumerate} 732 \item geodetic latitude (radians) 733 \item sine and cosine of geodetic latitude 734 \item magnitude of diurnal aberration vector 735 \item height (metres) 736 \item ambient temperature (degrees K) 737 \item pressure (mB) 738 \item relative humidity (0--1) 739 \item wavelength ($\mu$m) 740 \item lapse rate (degrees K per metre) 741 \item refraction constants A and B (radians) 742 \item longitude + eqn of equinoxes + ``sidereal $\Delta$ UT'' (radians) 743 \item local apparent sidereal time (radians) 744 \end{enumerate} 745 These may be calculated using \code{sla_AOPPA}. Note that a 746 \code{psGrommit} is only appropriate for a single exposure. 747 748 Once the \code{psGrommit} has been calculated, the functions 749 \code{sla_OAPQK} and \code{sla_AOPQK} convert from the tangent plane 750 to the sky, and the sky to the tangent plane, respectively. (Note 751 that ``observed'' in SLALIB refers to the tangent plane, and 752 ``apparent'' refers to the apparent position on the sky.) 753 754 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 755 756 \subsection{The One-to-Many Problem with Mosaic Cameras} 757 758 The \PS{} focal plane consists of several chips, so we will often want 759 to identify which chip a source lies on, when we know the coordinates 760 in the focal plane. This is an example of the one-to-many problem 761 (one coordinate, many chips that it may lie on). 762 763 If this needs to be repeated for only one (or a small number of) focal 764 plane coordinates, then the fastest method is to simply convert the 765 focal plane coordinates to chip coordinates for each of the chips, and 766 determine for which of the chips the chip coordinates are valid (i.e.\ 767 on the chip). 768 769 On the other hand, if this needs to be repeated for many source focal 770 plane coordinates, then it is most efficient to convert the centers of 771 each of the chips to coordinates on the focal plane and to use the 772 distance of the source to each of the centers to optimise which chips 773 are tested first. This saves testing many chips for every source. 774 775 776 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 777 778 \subsection{General Astronomy Functions} 779 780 The airmass is calculated using the SLALIB function \code{sla_AIRMAS}. 781 782 The parallactic angle is calculated using the SLALIB function \code{sla_PA}. 783 784 %The parallax factors are calculated using the following formulae 785 %(Smart et al.\ 2003, A\&A, 404, 317): 786 %\begin{eqnarray} 787 %P_\xi & = & \cos \alpha \sin \lambda \cos \epsilon - \sin \alpha \cos \lambda \\ 788 %P_\eta & = & (\sin \epsilon \cos \delta - \cos \epsilon \sin \alpha \sin \delta) \sin \lambda - \cos \alpha \sin \delta \cos \lambda 789 %\end{eqnarray} 790 %where $\alpha$ is the Right Ascension, $\delta$ is the Declination, 791 %$\lambda$ is the solar longitude, and $\epsilon = 23^\circ 27'08''.26$ 792 %is the inclination of the ecliptic. The solar longitude is obtained 793 %from the ecliptic coordinates of the Sun. 794 795 To calculate the parallax factors, get the mean-to-apparent parameters 796 (\code{sla_MAPPA}) for a mean epoch of 2000.0, and, given the mean 797 position of interest, calculate the apparent position 798 (\code{sla_MAPQK}) for a parallax of 1.0 arcsec $(\alpha_1,\delta_1)$, 799 and a parallax of 0.0 arcsec $(\alpha_0,\delta_0)$. Then the parallax 800 factors in radians are: 801 \begin{eqnarray} 802 P_x & = & 3,600 (180^\circ/\pi) (\alpha_1 - \alpha_0) cos (\delta_0) \\ 803 P_y & = & 3,600 (180^\circ/\pi) (\delta_1 - \delta_0) 804 \end{eqnarray} 805 806 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 807 808 \subsection{Positions of Major Solar System Objects} 809 810 The SLALIB function \code{SLA_RDPLAN} returns the apparent position of 811 a specified planet, or the Moon. 812 813 To calculate the position of the Sun, use \code{sla_EVP} to get the 814 position of the earth relative to the Sun, and convert from the 815 cartesian coordinates to spherical using \code{sla_DCC2S}, and 816 calculate the position on the opposite side of the sphere ($\alpha 817 \rightarrow \alpha + 12 {\rm hrs}$ and $\delta \rightarrow -\delta$). 818 819 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 820 821 \subsection{Offsets} 822 823 824 651 825 652 826
Note:
See TracChangeset
for help on using the changeset viewer.
