Changeset 3564 for trunk/doc/pslib/psLibADD.tex
- Timestamp:
- Mar 30, 2005, 11:14:48 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibADD.tex (modified) (63 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibADD.tex
r3448 r3564 1 %%% $Id: psLibADD.tex,v 1. 69 2005-03-18 20:40:14 jhoblittExp $1 %%% $Id: psLibADD.tex,v 1.70 2005-03-30 21:14:48 eugene Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 … … 14 14 \project{Pan-STARRS Image Processing Pipeline} 15 15 \organization{Institute for Astronomy} 16 \version{ 09}16 \version{10} 17 17 \docnumber{PSDC-430-006} 18 19 \setcounter{tocdepth}{5} % lowest level to be included in toc 18 20 19 21 \newcommand\citealt{} … … 31 33 01 & 2004 May 21 & Added section on 2D Chebyshev fitting, then removed. \\ \hline 32 34 02 & 2004 Jun 22 & modified stats specification \\ \hline 33 03--05 & ??? & ??? \\ \hline 34 06 & 2004 Sep 7 & Frozen for PSLib-2 \\ \hline 35 03 & 2004 Jul 13 & \\ \hline 36 04 & 2004 Aug 16 & \\ \hline 37 05 & 2004 Sep 01 & \\ \hline 38 06 & 2004 Sep 07 & Frozen for PSLib-2 \\ \hline 35 39 07 & 2004 Nov 24 & Frozen for Cycle 4 \\ \hline 36 40 08 & 2005 Jan 21 & Draft for Cycle 5 \\ \hline 37 41 09 & 2005 Feb 14 & Frozen for Cycle 5 \\ \hline 42 10 & 2005 Mar 21 & Draft for Cycle 6 \\ \hline 38 43 \RevisionsEnd 39 44 … … 69 74 \pagenumbering{arabic} 70 75 71 \section{Pan-STARRS Library PSLib}72 73 \s ubsection{Math Utilities}74 75 \subs ubsection{Sorting}76 % \section{Pan-STARRS Library PSLib} 77 78 \section{PSLib Math Utilities} 79 80 \subsection{Sorting} 76 81 77 82 A variety of sorting algorithms exist, with a wide range in speed for … … 103 108 \code{in.arr[out->arr[0]]} to \code{in.arr[out->arr[in.n - 1]]}. 104 109 105 \subs ubsection{Smoothing: Boxcar and Gaussian}110 \subsection{Smoothing: Boxcar and Gaussian} 106 111 \label{smooth} 107 112 … … 135 140 \end{equation} 136 141 137 \subs ubsection{Statistics}142 \subsection{Statistics} 138 143 139 144 The general statistics function \code{psStats} performs a variety of … … 148 153 sample and robust estimators. 149 154 150 \ paragraph{Sample Statistics}155 \subsubsection{Sample Statistics} 151 156 152 157 We define the following statistical terms, assuming there is a set of 153 158 data elements $x_i$ with (standard) errors $\sigma_i$. 154 159 155 \ subparagraph{Mean}160 \paragraph{Mean} 156 161 157 162 The simple mean is defined as: … … 160 165 \end{equation} 161 166 162 \ subparagraph{Weighted Mean}167 \paragraph{Weighted Mean} 163 168 164 169 The weighted mean is defined as: … … 170 175 standard definition of the mean. 171 176 172 \ subparagraph{Median}177 \paragraph{Median} 173 178 174 179 The median is defined as the value for which 50\% of the data values … … 181 186 calculating the sample median. 182 187 183 \ subparagraph{Upper and Lower Quartiles}188 \paragraph{Upper and Lower Quartiles} 184 189 185 190 The upper and lower quartiles ($U_{\frac{1}{4}}$ and … … 196 201 the sample quartiles. 197 202 198 \ subparagraph{Standard Deviation}203 \paragraph{Standard Deviation} 199 204 200 205 The standard deviation of the sample is given by: … … 218 223 219 224 220 \ paragraph{Clipped Statistics}225 \subsubsection{Clipped Statistics} 221 226 222 227 The clipped statistics are used to determine the mean and standard … … 255 260 \bar{x}| > k \sigma_i$. 256 261 257 \ paragraph{Robust Statistics}262 \subsubsection{Robust Statistics} 258 263 259 264 The robust version of the statistics provides estimators of basic … … 312 317 quartiles are estimated in the same manner as above. 313 318 314 \ paragraph{Histograms}319 \subsubsection{Histograms} 315 320 316 321 When calculating histograms in the presence of known errors in the … … 342 347 Note that the total adds to one --- the number of values added. 343 348 344 \subs ubsection{Matrix Operations}349 \subsection{Matrix Operations} 345 350 346 351 In this section, we define the linear algebra operations performed on … … 361 366 \code{gsl_linalg_LU_decomp}. 362 367 363 \ paragraph{LU Decomposition}368 \subsubsection{LU Decomposition} 364 369 \label{LUdecomp} 365 370 … … 402 407 \end{equation} 403 408 404 \ paragraph{Calculate a matrix determinant}409 \subsubsection{Calculate a matrix determinant} 405 410 406 411 The determinant $D$ of a matrix $a_{ij}$ is calculated from the … … 418 423 shall be used. 419 424 420 \ paragraph{Solving a Linear Equation}425 \subsubsection{Solving a Linear Equation} 421 426 422 427 The LU decomposition of a matrix may be used to solve the … … 438 443 \end{eqnarray} 439 444 440 \ paragraph{Invert a matrix}445 \subsubsection{Invert a matrix} 441 446 442 447 Inversion of a matrix using the LU decomposition is performed by … … 447 452 operation shall be implemented using the GSL function \code{gsl_linalg_LU_invert}. 448 453 449 \ paragraph{Perform matrix addition, subtraction and multiplication}454 \subsubsection{Perform matrix addition, subtraction and multiplication} 450 455 451 456 Matrix binary arithmetic operations differ from image binary … … 471 476 \times$. 472 477 473 \ paragraph{Transpose a matrix}478 \subsubsection{Transpose a matrix} 474 479 475 480 The transpose of a matrix is simply the reorganization of the matrix … … 484 489 where $M_{ij}$ is the matrix to be transposed. 485 490 486 \ paragraph{Convert a matrix to a vector}491 \subsubsection{Convert a matrix to a vector} 487 492 488 493 Matrix-to-vector conversion is only defined for a matrix that has a … … 493 498 matrix is converted to a \code{PS_DIMEN_TRANV}-type vector. 494 499 495 \subs ubsection{Fitting}496 497 \ paragraph{Chi-squared}500 \subsection{Fitting} 501 502 \subsubsection{Chi-squared} 498 503 \label{chisq} 499 504 … … 506 511 \end{equation} 507 512 508 \ paragraph{General Polynomial Fitting}513 \subsubsection{General Polynomial Fitting} 509 514 510 515 Given a set of data values $y_i$ with errors $\sigma_i$, related to … … 531 536 (section~\ref{LUdecomp}). 532 537 533 \subs ubsection{Non-linear Minimization}534 535 \ paragraph{Levenberg-Marquardt Method}538 \subsection{Non-linear Minimization} 539 540 \subsubsection{Levenberg-Marquardt Method} 536 541 537 542 In the Levenberg-Marquardt Method (LMM; see NR \S 15.5), we make a … … 612 617 613 618 614 \ paragraph{Powell's method}619 \subsubsection{Powell's method} 615 620 616 621 Powell's method is a type of ``Direction Set'' methods in … … 621 626 manner until the advances along the vectors are smaller than some 622 627 pre-defined tolerance. Such direction set methods, including Powell's 623 Quadratically Convergent method are discussed in NR \S10.5.628 Quadratically Convergent method are discussed in NR \S 10.5. 624 629 625 630 We will use for our algorithm the modified version of Powell's … … 665 670 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 666 671 667 \subs ubsection{Polynomials}672 \subsection{Polynomials} 668 673 \label{sec:polynomials} 669 674 … … 703 708 $-1 < x < 1$. 704 709 705 \ paragraph{Multi-dimensional polynomials}710 \subsubsection{Multi-dimensional polynomials} 706 711 707 712 Multi-dimensional polynomials shall be composed of multiplications of … … 711 716 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 712 717 713 \subs ubsection{(Fast) Fourier Transforms}718 \subsection{(Fast) Fourier Transforms} 714 719 715 720 (Fast) Fourier Transforms (FFTs) shall be implemented using the … … 717 722 library}. 718 723 719 \ paragraph{FFTW Plans}724 \subsubsection{FFTW Plans} 720 725 721 726 FFTW requires the user to create a ``plan'' for each transform size, … … 733 738 initialisation of the PSLib FFT functions and saved at the conclusion. 734 739 735 \ paragraph{Function mapping}740 \subsubsection{Function mapping} 736 741 737 742 The forward and reverse transforms call the corresponding … … 750 755 place to avoid the need to pad the input array to hold the output. 751 756 752 \ paragraph{More Complicated Functions}757 \subsubsection{More Complicated Functions} 753 758 754 759 \code{psFFTCrossCorrelate()} and \code{psFFTConvolve()} both involve … … 772 777 caller, and choose to normalise by $1/N^2$. 773 778 779 \subsection{Image Manipulations} 780 781 \subsubsection{Interpolation} 782 783 Interpolation is needed in various image manipulation operations, 784 including rotation and resampling. We have specified a function to 785 perform the interpolation using one of several possible interpolation 786 methods, defined below. It is important in the discussions that 787 follow to remember that a pixel with column,row if $i,j$ has 788 coordinate at the center of $i+0.5,j+0.5$ and corners with coordinates 789 from $i,j$ to $i+1,j+1$. Thus, the interpolation of a coordinate 790 $x,y$ = 5.0,4.0 is a value midway between the four pixels with 791 column,row of (5,4), (5,5), (6,4), (6,5). 792 793 \paragraph{Nearest Pixel Interpolation ({\tt PS\_INTERPOLATE\_FLAT})} 794 795 In this interpolation, the value of the closest pixel is returned. 796 This is equivalent to pixel duplication or replication. 797 798 \paragraph{Bilinear Interpolation ({\tt PS\_INTERPOLATE\_BILINEAR})} 799 800 In this interpolation, the value at the coordinate is calculated using 801 linear interpolation in two dimensions from the four nearest neighbor 802 pixels. The bilinear interpolation value at a coordinate $x,y$ 803 depends on the four nearest neighbor pixels and the fractional 804 distance $fx,fy$ of the given coordinates from the centers of those 805 four pixels. Consider four neighboring pixels at column,row of $i,j$, 806 $i+1,j$, $i,j+1$, and $i+1,j+1$ with pixel values $V_{0,0}$, 807 $V_{1,0}$, $V_{0,1}$, $V_{1,1}$. The value at $x,y$ is given by: 808 \[ V = (V_{0,0}(1 - f_x) + V_{1,0}f_x)(1 - f_y) + (V_{0,1}(1-f_x) + V_{1,1}f_x)f_y \] 809 This expression is more efficiently evaluated by factoring and 810 calculating the expresion as: 811 \[ r_x = V_{0,0} + (V_{1,0} - V_{0,0})f_x \] 812 \[ V = r_x + (V_{0,1} + (V_{1,1} - V_{0,1})f_x - r_x)f_y \] 813 814 Note that the values of $f_x$ and $f_y$ require some care. Given a 815 coordinate $x,y$, the value of $f_x$ is calculated as $f_x - 0.5 - 816 int(f_x - 0.5)$. For example, when interpolating the value at 817 (5.8.5.2), the relevant neighbor pixels are (5,4), (6,4), (5,5), (6,5) 818 and the fractional coordinate values $f_x, f_y = 0.3, 0.7$. The 819 resulting coordinate would be contained within the pixel at column,row 820 (5,5). 821 822 \paragraph{Sinc Interpolation ({\tt PS\_INTERPOLATE\_LANCZOS[234]})} 823 824 Because it would be slow to specify the size of the kernel 825 dynamically, we specify three hard-coded kernel sizes: 4, 6 and 8 826 pixels in each dimension (a kernel of size 2 pixels in each dimension 827 is handled by the bilinear interpolation). These correspond to the 828 options \code{PS_INTERPOLATE_LANCZOS2}, \code{PS_INTERPOLATE_LANCZOS3} and 829 \code{PS_INTERPOLATE_LANCZOS4}, respectively. 830 831 Given a position on the input image, $(x_0,y_0)$, a kernel is derived 832 according to pixels local to the position: 833 \begin{equation} 834 h(x,y) = {\rm sinc}(\pi \delta x) {\rm sinc}(\pi \delta x / N) \rm{sinc}(\pi \delta y) \rm{sinc}(\pi \delta y / N) 835 \end{equation} 836 where 837 \begin{eqnarray} 838 \delta x & = & x - x_0 \\ 839 \delta y & = & y - y_0 \\ 840 {\rm sinc}(z) & = & \sin(z)/z 841 \end{eqnarray} 842 and $N$ corresponds to the choice of kernel size. For $N = 2$, the 843 kernel size is 4 pixels in each dimension (i.e., $-2 < \delta x \le 844 2$). For $N = 3$, the kernel size is 6 pixels in each dimension 845 (i.e., $-3 < \delta x \le 3$). For $N = 4$, the kernel size is 8 846 pixels in each dimension (i.e., $-4 < \delta x \le 4$). 847 848 The interpolated value at the given position, $(x_0,y_0)$, is then 849 simply the dot product of the kernel and the fluxes: 850 \begin{equation} 851 f(x_0,y_0) = \sum_R f(x,y) h(x,y) 852 \end{equation} 853 where $R$ is the region defined by the kernel size, and $f(x,y)$ is 854 the flux at the pixel position. 855 856 For further information, see the 857 \href{http://terapix.iap.fr/IMG/pdf/swarp.pdf}{SWarp manual}. 858 859 \subsubsection{Image Cuts and Slices} 860 861 Several functions specify operations which manipulate a collection of 862 pixels to return a statistic on the pixel collection. In the simplest 863 case, these are trivial to define: if the boundaries of the region of 864 interest are specified along integral pixel coordinates, then the 865 pixels used to measure the statistic are always an exact integer. 866 This is the case for the function \code{psImageSlice} which requires a 867 starting coordinate which is an integer and a width in both dimensions 868 which is an integer. For the case of the functions \code{psImageCut} 869 and \code{psImageRadialCut}, the situation is a bit more subtle. In 870 both of these cases, the region is unlikely to contain only whole 871 pixels and some choices must be made. 872 873 One posibility which we reject is to identify the fractional pixels 874 which are overlapped by the region of interest and add that fraction 875 of the pixel's flux when calculating the statistic of interest. This 876 is computationally intensive, and not necessarily well defined for all 877 statistics. 878 879 In PSLib, we instead identify the pixels overlapped by the region, use 880 the complete set of pixel values, treating all pixels equally, and 881 renormalize as needed. To perform this, the region of interest is 882 laid on top of the image pixels. Any pixels which overlap the region 883 are identified as part of the input sample. The statistic (ie, sample 884 mean, robust mode, etc), is then calculated on this collection of 885 pixels. If the output statistic is an average value, the measured 886 value is reported. If the output statistic is a sum value (sum of 887 counts, sum of pixels), then the value is renormalized by the ratio of 888 pixels used in the calculation to the pixel area of the region of 889 interest. For example, if the sum within a radial aperture is 890 requested, the circle of the specified radius and center is placed on 891 the pixel grid. Any pixels which touch the circle are then placed in 892 a list to be analysed. The statistic of interest is the measured for 893 this collection of pixels. In the case of a circular aperture which 894 is centered at the coordinate (2,2) and has a radius of 2, the number 895 of pixels which are touched by the circle is 16, while the total pixel 896 area of the circle is 12.57 square pixels. In this case, the pixel 897 sum is renormalized by the ratio (12.57/16.00). 898 899 \paragraph{Radial Cuts} 900 901 Consider an image with pixels $x_i,y_i$ and a reference coordinate 902 $x_c, y_c$. We want to construct a radial cut by measuring statistics 903 for pixels in a sequence of radial annulii $r_s < r < r_e$. For each 904 annulus, we need to select the pixels which fall within this annulus. 905 The coordinates of the center of pixel $i,j$ are $i+0.5,j+0.5$. A 906 given pixel has a distance from the reference coordinate of $dX = x_c 907 - i - 0.5, dY = y_c - j - 0.5$. The pixels to be used for a given 908 radial annulus are all of those pixels for which $r_s < \sqrt{dX^2 + 909 dY^2} < r_e$. This is more efficiently calculated by comparing the 910 square of the radii and distances. All pixels which satisfy the above 911 condition are included in a specific annular radius. All average 912 quantities are calculated directly from the pixel ensemble 913 statistics. 914 915 \paragraph{Arbitrary Linear Cuts} 916 917 Select the pixels which lie along a line following steps of 1 pixel 918 length: 919 920 \begin{verbatim} 921 922 dX = xe - xs; 923 dY = ye - ys; 924 L = hypot (dX, dY); 925 dX = dX / L; 926 dY = dY / L; 927 928 REALLOCATE (xvec[0].elements, float, MAX (L, 1)); 929 REALLOCATE (yvec[0].elements, float, MAX (L, 1)); 930 xvec[0].Nelements = L; 931 yvec[0].Nelements = L; 932 933 V = (float *)buf[0].matrix.buffer; 934 for (i = 0; i < L; i++) { 935 xi = xs + i*dX - 0.5; 936 yi = ys + i*dY - 0.5; 937 xvec[0].elements[i] = i; 938 yvec[0].elements[i] = V[xi + Nx*yi]; 939 } 940 \end{verbatim} 941 942 \subsubsection{Image Rotation} 943 944 Image rotation can be performed in two possible ways under different 945 circumstances, identified in the following discussion. 946 947 In the simplest case, the rotation angle is an integer multiple of 90 948 degrees ($\pi/2$ rad). In these cases, the input and output pixels 949 have a one-to-one mapping. If the input image has dimensions of $N_x, 950 N_y$, then the output image will have dimensions of either $N_x, N_y$ 951 (for even multiples of 90 degrees) or $N_y, N_x$ (for odd multiples). 952 953 If the angle of the rotation is not a multiple of 90, then the output 954 pixels necessarily result from the interpolation of several input 955 pixels. In this case, for an input image of dimensions $N_x, N_y$ and 956 rotation angle $\theta$, the output image has dimensions $Lx = |N_x 957 \cos \theta| + |N_y \sin \theta|$ and $Ly = |N_x \sin \theta| + |N_y 958 \cos \theta|$, each dimension rounded up to the nearest integer as 959 needed. Every pixel in the output image is in general derived from an 960 interpolation over 4 neighboring pixels. The coordinate of a pixel in 961 the output image ($i,j$) corresponds to a fractional pixel coordinate 962 ($x,y$) in the input image according to: 963 \[ x = (i - i_o)*\cos\theta + (j - j_o)*\sin\theta \] 964 \[ y = (i_o - i)*\sin\theta + (j - j_o)*\cos\theta \] 965 where the offset coordinate ($i_o,j_o$) depends on the sign of the 966 sine of the angle $\theta$. If the sign of that sine is positive, the 967 offset coordinate is ($N_y\sin\theta$,0), otherwise it is 968 (0,$-N_x\sin\theta$). 969 774 970 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 775 971 776 \subsection{Astronomy Utilities} 972 \pagebreak 973 \section{PSLib Astronomy Utilities} 777 974 778 975 Most of the astronomy utilities will be implemented through wrapping … … 782 979 the next release} 783 980 784 \subs ubsection{Time}981 \subsection{Time} 785 982 786 983 Correct time representation is \emph{critical} in astronomical software. PSLib … … 799 996 ``1970-01-01T00:00:00Z'' UTC. 800 997 801 \ paragraph{Coordinated Universal Time (UTC)}998 \subsubsection{Coordinated Universal Time (UTC)} 802 999 803 1000 Coordinated Univeral Time (UTC) is defined by the International … … 829 1026 timezone is forbidden.} 830 1027 831 \ paragraph{International Atomic Time (TAI)}1028 \subsubsection{International Atomic Time (TAI)} 832 1029 833 1030 International Atomic Time or Temps Atomique International (TAI) is a system of … … 845 1042 seconds since the UNIX epoch of ``1970-01-01T00:00:00Z''. 846 1043 847 \ paragraph{Leap-seconds}1044 \subsubsection{Leap-seconds} 848 1045 849 1046 Leap seconds keep UTC within 0.9s of UT1. The offset between TAI and … … 883 1080 This data is available from: \code{ftp://maia.usno.navy.mil/ser7/tai-utc.dat} 884 1081 885 \ paragraph{Gregorian dates to seconds}1082 \subsubsection{Gregorian dates to seconds} 886 1083 887 1084 The Perl code below, based on an algorithm described in the book ``Calendrical … … 1003 1200 \end{verbatim} 1004 1201 Outputs year, month, day as \code{$y, $m, $d}. 1202 %$ 1005 1203 1006 1204 \emph{The above code was taken [and slightly altered] from … … 1011 1209 1012 1210 1013 \ paragraph{Universal Time (UT1)}1211 \subsubsection{Universal Time (UT1)} 1014 1212 \label{sec:ut1} 1015 1213 … … 1054 1252 IERS publications references above, and should be interpolated in the same way. 1055 1253 1056 \ paragraph{Julian Date and Modified Julian Date}1254 \subsubsection{Julian Date and Modified Julian Date} 1057 1255 1058 1256 The follow definitions of Julian Date (JD) and Modified Julian Date (MJD) was … … 1062 1260 http://www.iers.org/iers/earth/resolutions/UAI\_b1.html}. 1063 1261 1064 \ subparagraph{Julian Date}1262 \paragraph{Julian Date} 1065 1263 1066 1264 \begin{verbatim} … … 1089 1287 \end{verbatim} 1090 1288 1091 \ subparagraph{Modified Julian Date}1289 \paragraph{Modified Julian Date} 1092 1290 1093 1291 \begin{verbatim} … … 1097 1295 \end{verbatim} 1098 1296 1099 \ subparagraph{JD and MJD conversion}1297 \paragraph{JD and MJD conversion} 1100 1298 1101 1299 Conversion between \code{psTime} values and MJD and JD are determined … … 1115 1313 \end{equation} 1116 1314 1117 \ paragraph{Terrestrial Time (TT)}1315 \subsubsection{Terrestrial Time (TT)} 1118 1316 1119 1317 Terrestrial Time (TT) is defined as a fixed offset from TAI. … … 1123 1321 \end{equation} 1124 1322 1125 \ paragraph{TT as Julian Centuries since J2000.0}1323 \subsubsection{TT as Julian Centuries since J2000.0} 1126 1324 1127 1325 The algorithm for calulating GMST requires TT formated in Julian centruies … … 1131 1329 \end{equation} 1132 1330 1133 \ paragraph{UT1 as Julian Centuries since J2000.0}1331 \subsubsection{UT1 as Julian Centuries since J2000.0} 1134 1332 1135 1333 The algorithm for calulating GMST requires UT1 be formated in Julian centuries … … 1140 1338 \end{equation} 1141 1339 1142 \paragraph{Greenwich Mean Sidereal Time (GMST)} 1340 \subsubsection{Local Mean Sidereal Time (LMST)} 1341 1342 Local Mean Sidereal Time (LMST) is Greenwich Mean Sideral Time (GMST) plus the 1343 observer's location in East longitude. Calculating LMST requires the input of 1344 Universal Time (UT1), Terrestrial Dynamical Time (TT) and a longitude (measured 1345 East of Greenwich). 1346 1347 \begin{equation} 1348 LMST = GMST00(t_u, t) + longitude 1349 \end{equation} 1350 1351 Gives $LMST$ in seconds. 1352 1353 \subsubsection{Greenwich Mean Sidereal Time (GMST)} 1143 1354 1144 1355 Greenwich Mean Sidereal Time (GMST) is caclulated from UT1 and TT. This … … 1159 1370 Gives $GMST00$ in seconds. 1160 1371 1161 1162 \paragraph{Longitude} 1372 \subsubsection{Longitude} 1163 1373 1164 1374 Longitudes are often expressed in the form of decimal degrees while the … … 1169 1379 \end{equation} 1170 1380 1171 \paragraph{Local Mean Sidereal Time (LMST)} 1172 1173 Local Mean Sidereal Time (LMST) is Greenwich Mean Sideral Time (GMST) plus the 1174 observer's location in East longitude. Calculating LMST requires the input of 1175 Universal Time (UT1), Terrestrial Dynamical Time (TT) and a longitude (measured 1176 East of Greenwich). 1177 1178 \begin{equation} 1179 LMST = GMST00(t_u, t) + longitude 1180 \end{equation} 1181 1182 Gives $LMST$ in seconds. 1183 1184 \paragraph{Polar Motion} 1381 \subsubsection{Polar Motion} 1382 \tbd{move this to Earth Motion section} 1185 1383 1186 1384 The polar coordinates, $x_p$ and $y_p$, required for the transformation from … … 1190 1388 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1191 1389 1192 \subsubsection{Astronomical Image Manipulations} 1193 1194 \paragraph{Interpolation} 1195 1196 Interpolation is needed in various image manipulation operations, 1197 including rotation and resampling. We have specified a function to 1198 perform the interpolation using one of several possible interpolation 1199 methods, defined below. It is important in the discussions that 1200 follow to remember that a pixel with column,row if $i,j$ has 1201 coordinate at the center of $i+0.5,j+0.5$ and corners with coordinates 1202 from $i,j$ to $i+1,j+1$. Thus, the interpolation of a coordinate 1203 $x,y$ = 5.0,4.0 is a value midway between the four pixels with 1204 column,row of (5,4), (5,5), (6,4), (6,5). 1205 1206 \subparagraph{Nearest Pixel Interpolation ({\tt PS\_INTERPOLATE\_FLAT})} 1207 1208 In this interpolation, the value of the closest pixel is returned. 1209 This is equivalent to pixel duplication or replication. 1210 1211 \subparagraph{Bilinear Interpolation ({\tt PS\_INTERPOLATE\_BILINEAR})} 1212 1213 In this interpolation, the value at the coordinate is calculated using 1214 linear interpolation in two dimensions from the four nearest neighbor 1215 pixels. The bilinear interpolation value at a coordinate $x,y$ 1216 depends on the four nearest neighbor pixels and the fractional 1217 distance $fx,fy$ of the given coordinates from the centers of those 1218 four pixels. Consider four neighboring pixels at column,row of $i,j$, 1219 $i+1,j$, $i,j+1$, and $i+1,j+1$ with pixel values $V_{0,0}$, 1220 $V_{1,0}$, $V_{0,1}$, $V_{1,1}$. The value at $x,y$ is given by: 1221 \[ V = (V_{0,0}(1 - f_x) + V_{1,0}f_x)(1 - f_y) + (V_{0,1}(1-f_x) + V_{1,1}f_x)f_y \] 1222 This expression is more efficiently evaluated by factoring and 1223 calculating the expresion as: 1224 \[ r_x = V_{0,0} + (V_{1,0} - V_{0,0})f_x \] 1225 \[ V = r_x + (V_{0,1} + (V_{1,1} - V_{0,1})f_x - r_x)f_y \] 1226 1227 Note that the values of $f_x$ and $f_y$ require some care. Given a 1228 coordinate $x,y$, the value of $f_x$ is calculated as $f_x - 0.5 - 1229 int(f_x - 0.5)$. For example, when interpolating the value at 1230 (5.8.5.2), the relevant neighbor pixels are (5,4), (6,4), (5,5), (6,5) 1231 and the fractional coordinate values $f_x, f_y = 0.3, 0.7$. The 1232 resulting coordinate would be contained within the pixel at column,row 1233 (5,5). 1234 1235 \subparagraph{Sinc Interpolation ({\tt PS\_INTERPOLATE\_LANCZOS[234]})} 1236 1237 Because it would be slow to specify the size of the kernel 1238 dynamically, we specify three hard-coded kernel sizes: 4, 6 and 8 1239 pixels in each dimension (a kernel of size 2 pixels in each dimension 1240 is handled by the bilinear interpolation). These correspond to the 1241 options \code{PS_INTERPOLATE_LANCZOS2}, \code{PS_INTERPOLATE_LANCZOS3} and 1242 \code{PS_INTERPOLATE_LANCZOS4}, respectively. 1243 1244 Given a position on the input image, $(x_0,y_0)$, a kernel is derived 1245 according to pixels local to the position: 1246 \begin{equation} 1247 h(x,y) = {\rm sinc}(\pi \delta x) {\rm sinc}(\pi \delta x / N) \rm{sinc}(\pi \delta y) \rm{sinc}(\pi \delta y / N) 1248 \end{equation} 1249 where 1250 \begin{eqnarray} 1251 \delta x & = & x - x_0 \\ 1252 \delta y & = & y - y_0 \\ 1253 {\rm sinc}(z) & = & \sin(z)/z 1254 \end{eqnarray} 1255 and $N$ corresponds to the choice of kernel size. For $N = 2$, the 1256 kernel size is 4 pixels in each dimension (i.e., $-2 < \delta x \le 1257 2$). For $N = 3$, the kernel size is 6 pixels in each dimension 1258 (i.e., $-3 < \delta x \le 3$). For $N = 4$, the kernel size is 8 1259 pixels in each dimension (i.e., $-4 < \delta x \le 4$). 1260 1261 The interpolated value at the given position, $(x_0,y_0)$, is then 1262 simply the dot product of the kernel and the fluxes: 1263 \begin{equation} 1264 f(x_0,y_0) = \sum_R f(x,y) h(x,y) 1265 \end{equation} 1266 where $R$ is the region defined by the kernel size, and $f(x,y)$ is 1267 the flux at the pixel position. 1268 1269 For further information, see the 1270 \href{http://terapix.iap.fr/IMG/pdf/swarp.pdf}{SWarp manual}. 1271 1272 \paragraph{Image Cuts and Slices} 1273 1274 Several functions specify operations which manipulate a collection of 1275 pixels to return a statistic on the pixel collection. In the simplest 1276 case, these are trivial to define: if the boundaries of the region of 1277 interest are specified along integral pixel coordinates, then the 1278 pixels used to measure the statistic are always an exact integer. 1279 This is the case for the function \code{psImageSlice} which requires a 1280 starting coordinate which is an integer and a width in both dimensions 1281 which is an integer. For the case of the functions \code{psImageCut} 1282 and \code{psImageRadialCut}, the situation is a bit more subtle. In 1283 both of these cases, the region is unlikely to contain only whole 1284 pixels and some choices must be made. 1285 1286 One posibility which we reject is to identify the fractional pixels 1287 which are overlapped by the region of interest and add that fraction 1288 of the pixel's flux when calculating the statistic of interest. This 1289 is computationally intensive, and not necessarily well defined for all 1290 statistics. 1291 1292 In PSLib, we instead identify the pixels overlapped by the region, use 1293 the complete set of pixel values, treating all pixels equally, and 1294 renormalize as needed. To perform this, the region of interest is 1295 laid on top of the image pixels. Any pixels which overlap the region 1296 are identified as part of the input sample. The statistic (ie, sample 1297 mean, robust mode, etc), is then calculated on this collection of 1298 pixels. If the output statistic is an average value, the measured 1299 value is reported. If the output statistic is a sum value (sum of 1300 counts, sum of pixels), then the value is renormalized by the ratio of 1301 pixels used in the calculation to the pixel area of the region of 1302 interest. For example, if the sum within a radial aperture is 1303 requested, the circle of the specified radius and center is placed on 1304 the pixel grid. Any pixels which touch the circle are then placed in 1305 a list to be analysed. The statistic of interest is the measured for 1306 this collection of pixels. In the case of a circular aperture which 1307 is centered at the coordinate (2,2) and has a radius of 2, the number 1308 of pixels which are touched by the circle is 16, while the total pixel 1309 area of the circle is 12.57 square pixels. In this case, the pixel 1310 sum is renormalized by the ratio (12.57/16.00). 1311 1312 \subparagraph{Radial Cuts} 1313 1314 Consider an image with pixels $x_i,y_i$ and a reference coordinate 1315 $x_c, y_c$. We want to construct a radial cut by measuring statistics 1316 for pixels in a sequence of radial annulii $r_s < r < r_e$. For each 1317 annulus, we need to select the pixels which fall within this annulus. 1318 The coordinates of the center of pixel $i,j$ are $i+0.5,j+0.5$. A 1319 given pixel has a distance from the reference coordinate of $dX = x_c 1320 - i - 0.5, dY = y_c - j - 0.5$. The pixels to be used for a given 1321 radial annulus are all of those pixels for which $r_s < \sqrt{dX^2 + 1322 dY^2} < r_e$. This is more efficiently calculated by comparing the 1323 square of the radii and distances. All pixels which satisfy the above 1324 condition are included in a specific annular radius. All average 1325 quantities are calculated directly from the pixel ensemble 1326 statistics. 1327 1328 \subparagraph{Arbitrary Linear Cuts} 1329 1330 Select the pixels which lie along a line following steps of 1 pixel 1331 length: 1390 \subsection{2D transformations} 1391 1392 In PSLib, we implement 2-dimensional transformations using 1393 \code{psPlaneTransform}, which contains a matrix of polynomial 1394 coefficients for each dimension. Since we are using these to model 1395 the real world, where, for example, a particular point on the detector 1396 maps to a particular point on the sky, we consider only 1397 transformations that are ``one-to-one''. This makes it possible to 1398 speak of inverse transformations, and of combining multiple 1399 transformations. 1400 1401 Given a transformation, $f(x,y)$, the inverse transformation, 1402 $g(x,y)$, is that for which $g(f(x,y)) = (x,y)$ for $(x,y)$ over the 1403 range of interest (not necessarily the entire set of real numbers). 1404 1405 Given two transformations, $f(x,y)$ and $g(x,y)$, the combined 1406 transformation is the transformation, $h(x,y) = g(f(x,y))$ for $(x,y)$ 1407 over the range of interest (not necessarily the entire set of real 1408 numbers). 1409 1410 Both of these operations are straightforward if the transformation is 1411 linear. If the function $(u,v) = f(x,y)$ is: 1412 \begin{eqnarray} 1413 u & = & a + bx + cy \\ 1414 v & = & d + ex + fy 1415 \end{eqnarray} 1416 then the inverse transformation $(x,y) = g(u,v)$ is: 1417 \begin{eqnarray} 1418 x & = & (-fa+cd)/\Delta + fu/\Delta - cv/\Delta \\ 1419 y & = & (ae-bd)/\Delta - eu/\Delta + bv/\Delta 1420 \end{eqnarray} 1421 where $\Delta = bf - ce$ is the matrix determinant. Given two 1422 functions $f_i(x,y)$ for $i=1,2$: 1423 \begin{eqnarray} 1424 u & = & a_i + b_i x + c_i y \\ 1425 v & = & d_i + e_i x + f_i y 1426 \end{eqnarray} 1427 then the combined transformation, $(u,v) = f_2(f_1(x,y))$ is: 1428 \begin{eqnarray} 1429 u & = & (a_2 + b_2 a_1 + c_2 d_1) + (b_2 b_1 + c_2 e_1) x + (b_2 c_1 + c_2 f_1) y \\ 1430 v & = & (d_2 + e_2 a_1 + f_2 d_1) + (e_2 b_1 + f_2 e_1) x + (e_2 c_1 + f_2 f_1) y 1431 \end{eqnarray} 1432 1433 When the transformations are not linear, the inverse and combined 1434 transformations can be estimated by sampling a grid over the region of 1435 interest, calculating the transformation (or double transformation) 1436 for each sample, and using this information to derive the best fit 1437 transformation that produces the inverse or combined transformation. 1438 The inverse transformation should be of the same order as that of the 1439 forward transformation, while the combined transformation should be of 1440 the higher order of the two component transformations. 1441 1442 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1443 1444 \subsection{Spherical Rotations with Quaternions} 1445 1446 \subsubsection{Quaternion Construction} 1447 1448 The following describes the algorithms needed to implement 3-D 1449 rotations in terms of quaternions. A quaternion is an ordered set of 1450 four numbers, $\bar{q} = (q_0, q_1, q_2, q_3)$. A rotation of angle 1451 $\theta$ about the axis defined by the unit vector $(v_x, v_y, v_z)$ 1452 has quaternion components: 1453 \begin{eqnarray} 1454 q_0 & = & v_x sin(\theta/2), \\ 1455 q_1 & = & v_y sin(\theta/2), \\ 1456 q_2 & = & v_z sin(\theta/2), and \\ 1457 q_3 & = & cos(\theta/2). \\ 1458 \end{eqnarray} 1459 Note that the sine and cosine are taken of the half angle of the 1460 rotation. Note also that this implies that the quaternion components 1461 are normalized such that $|\bar{q}| \def q_0^2 + q_1^2 + q_2^2 + q_3^2 1462 = 1$. 1463 1464 The 3-vector representation of the angle of the pole is determined 1465 from the coordinate of the pole ($\alpha_p, \delta_p$) by: 1466 \begin{eqnarray} 1467 v_x & = & \cos \delta_p \cos \alpha_p \\ 1468 v_y & = & \cos \delta_p \sin \alpha_p \\ 1469 v_x & = & \sin \delta_p \\ 1470 \end{eqnarray} 1471 1472 \subsubsection{Combining Two Rotations} 1473 1474 Given two quaternions $\bar{p1}$ and $\bar{p2}$, there is a third 1475 quaternion, $\bar{p}$, which represents the result of first applying 1476 $\bar{p1}$, and then $\bar{p2}$. The components of $\bar{p}$ are given 1477 by: 1332 1478 1333 1479 \begin{verbatim} 1334 1335 dX = xe - xs; 1336 dY = ye - ys; 1337 L = hypot (dX, dY); 1338 dX = dX / L; 1339 dY = dY / L; 1340 1341 REALLOCATE (xvec[0].elements, float, MAX (L, 1)); 1342 REALLOCATE (yvec[0].elements, float, MAX (L, 1)); 1343 xvec[0].Nelements = L; 1344 yvec[0].Nelements = L; 1345 1346 V = (float *)buf[0].matrix.buffer; 1347 for (i = 0; i < L; i++) { 1348 xi = xs + i*dX - 0.5; 1349 yi = ys + i*dY - 0.5; 1350 xvec[0].elements[i] = i; 1351 yvec[0].elements[i] = V[xi + Nx*yi]; 1352 } 1480 p_0 & = & p2_3 p1_0 + p2_2 p1_1 - p2_1 p1_2 + p2_0 p1_3 \\ 1481 p_1 & = & -p2_2 p1_0 + p2_3 p1_1 + p2_0 p1_2 + p2_1 p1_3 \\ 1482 p_2 & = & p2_1 p1_0 - p2_0 p1_1 + p2_3 p1_2 + p2_2 p1_3 \\ 1483 p_3 & = & -p2_0 p1_0 - p2_1 p1_1 - p2_2 p1_2 + p2_3 p1_3 \\ 1353 1484 \end{verbatim} 1354 1485 1355 \paragraph{Image Rotation} 1356 1357 Image rotation can be performed in two possible ways under different 1358 circumstances, identified in the following discussion. 1359 1360 In the simplest case, the rotation angle is an integer multiple of 90 1361 degrees ($\pi/2$ rad). In these cases, the input and output pixels 1362 have a one-to-one mapping. If the input image has dimensions of $N_x, 1363 N_y$, then the output image will have dimensions of either $N_x, N_y$ 1364 (for even multiples of 90 degrees) or $N_y, N_x$ (for odd multiples). 1365 1366 If the angle of the rotation is not a multiple of 90, then the output 1367 pixels necessarily result from the interpolation of several input 1368 pixels. In this case, for an input image of dimensions $N_x, N_y$ and 1369 rotation angle $\theta$, the output image has dimensions $Lx = |N_x 1370 \cos \theta| + |N_y \sin \theta|$ and $Ly = |N_x \sin \theta| + |N_y 1371 \cos \theta|$, each dimension rounded up to the nearest integer as 1372 needed. Every pixel in the output image is in general derived from an 1373 interpolation over 4 neighboring pixels. The coordinate of a pixel in 1374 the output image ($i,j$) corresponds to a fractional pixel coordinate 1375 ($x,y$) in the input image according to: 1376 \[ x = (i - i_o)*\cos\theta + (j - j_o)*\sin\theta \] 1377 \[ y = (i_o - i)*\sin\theta + (j - j_o)*\cos\theta \] 1378 where the offset coordinate ($i_o,j_o$) depends on the sign of the 1379 sine of the angle $\theta$. If the sign of that sine is positive, the 1380 offset coordinate is ($N_y\sin\theta$,0), otherwise it is 1381 (0,$-N_x\sin\theta$). 1382 1383 \subsubsection{Celestial Coordinate Conversions} 1486 \subsubsection{Rotating a Vector} 1487 1488 You may rotate a unit vector by first constructing a quaternion 1489 $\bar{p2}$, whose first three components are the components of the 1490 unit vector, and whose fourth component is zero. To rotate this vector 1491 by a quaternion $\bar{p1}$, you apply the formula above for combining 1492 two quaternions. The rotated vector is found in the first three 1493 components of the resulting quaternion, $\bar{p}$. 1494 1495 \subsubsection{Rotation Matrix} 1496 1497 The rotation matrix representation of a rotation may be derived 1498 directly from the quaternion representation. The following formulae 1499 convert a quaternion to a rotation matrix: 1500 1501 \begin{eqnarray} 1502 rot_{x,x} & = & q_0 q_0 - q_1 q_1 - q_2 q_2 + q_3 q_3 \\ 1503 rot_{y,y} & = & -q_0 q_0 + q_1 q_1 - q_2 q_2 + q_3 q_3 \\ 1504 rot_{z,z} & = & -q_0 q_0 - q_1 q_1 + q_2 q_2 + q_3 q_3 \\ 1505 1506 rot_{x,y} & = & 2 (q_0 q_1 + q_2 q_3) \\ 1507 rot_{y,x} & = & 2 (q_0 q_1 - q_2 q_3) \\ 1508 1509 rot_{x,z} & = & 2 (q_0 q_2 - q_1 q_3) \\ 1510 rot_{z,x} & = & 2 (q_0 q_2 + q_1 q_3) \\ 1511 1512 rot_{y,z} & = & 2 (q_1 q_2 + q_0 q_3) \\ 1513 rot_{z,y} & = & 2 (q_1 q_2 - q_0 q_3) \\ 1514 \end{eqnarray} 1515 1516 \subsubsection{Conversion to Other Representations} 1517 1518 You may convert a rotation matrix, m, to a quaternion, p, with the following 1519 code: 1520 1521 \begin{verbatim} 1522 double diag_sum[3]; 1523 int maxi; 1524 double recip; 1525 1526 diag_sum[0]=1+m[0][0]-m[1][1]-m[2][2]; 1527 diag_sum[1]=1-m[0][0]+m[1][1]-m[2][2]; 1528 diag_sum[2]=1-m[0][0]-m[1][1]+m[2][2]; 1529 diag_sum[3]=1+m[0][0]+m[1][1]+m[2][2]; 1530 1531 1532 maxi=0; 1533 for(i=1;i<4;++i) { 1534 if(diag_sum[i]>diag_sum[maxi]) maxi=i; 1535 } 1536 1537 1538 p[maxi]=0.5*sqrt(diag_sum[maxi]); 1539 recip=1./(4.*p[maxi]); 1540 1541 if(maxi==0) { 1542 p[1]=recip*(m[0][1]+m[1][0]); 1543 p[2]=recip*(m[2][0]+m[0][2]); 1544 p[3]=recip*(m[1][2]-m[2][1]); 1545 1546 } else if(maxi==1) { 1547 p[0]=recip*(m[0][1]+m[1][0]); 1548 p[2]=recip*(m[1][2]+m[2][1]); 1549 p[3]=recip*(m[2][0]-m[0][2]); 1550 1551 } else if(maxi==2) { 1552 p[0]=recip*(m[2][0]+m[0][2]); 1553 p[1]=recip*(m[1][2]+m[2][1]); 1554 p[3]=recip*(m[0][1]-m[1][0]); 1555 1556 } else if(maxi==3) { 1557 p[0]=recip*(m[1][2]-m[2][1]); 1558 p[1]=recip*(m[2][0]-m[0][2]); 1559 p[2]=recip*(m[0][1]-m[1][0]); 1560 } 1561 \end{verbatim} 1562 1563 \subsection{Celestial Coordinate Conversions} 1384 1564 1385 1565 Changes between spherical coordinate systems (ie, Ecliptic, Galactic, … … 1426 1606 the forward transformation. 1427 1607 1428 \ paragraph{Galactic to ICRS}1608 \subsubsection{Galactic to ICRS} 1429 1609 1430 1610 The appropriate values, from the Hipparcos and Tycho Catalogues are: … … 1435 1615 \end{eqnarray} 1436 1616 1437 \ paragraph{Ecliptic to ICRS}1617 \subsubsection{Ecliptic to ICRS} 1438 1618 1439 1619 The appropriate values, from Zombeck, are: … … 1445 1625 where $T$ is the time in Julian centuries since 1900. 1446 1626 1447 \ paragraph{Precession}1627 \subsubsection{Precession} 1448 1628 1449 1629 The appropriate values, from Elixir, are: … … 1457 1637 1458 1638 1459 \ paragraph{Suggested test cases}1639 \subsubsection{Suggested test cases} 1460 1640 1461 1641 $(\alpha,\delta) = (0^\circ,0^\circ)$ transforms to Galactic … … 1479 1659 1480 1660 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1481 \subsubsection{2D transformations} 1482 1483 In PSLib, we implement 2-dimensional transformations using 1484 \code{psPlaneTransform}, which contains a matrix of polynomial 1485 coefficients for each dimension. Since we are using these to model 1486 the real world, where, for example, a particular point on the detector 1487 maps to a particular point on the sky, we consider only 1488 transformations that are ``one-to-one''. This makes it possible to 1489 speak of inverse transformations, and of combining multiple 1490 transformations. 1491 1492 Given a transformation, $f(x,y)$, the inverse transformation, 1493 $g(x,y)$, is that for which $g(f(x,y)) = (x,y)$ for $(x,y)$ over the 1494 range of interest (not necessarily the entire set of real numbers). 1495 1496 Given two transformations, $f(x,y)$ and $g(x,y)$, the combined 1497 transformation is the transformation, $h(x,y) = g(f(x,y))$ for $(x,y)$ 1498 over the range of interest (not necessarily the entire set of real 1499 numbers). 1500 1501 Both of these operations are straightforward if the transformation is 1502 linear. If the function $(u,v) = f(x,y)$ is: 1503 \begin{eqnarray} 1504 u & = & a + bx + cy \\ 1505 v & = & d + ex + fy 1506 \end{eqnarray} 1507 then the inverse transformation $(x,y) = g(u,v)$ is: 1508 \begin{eqnarray} 1509 x & = & (-fa+cd)/\Delta + fu/\Delta - cv/\Delta \\ 1510 y & = & (ae-bd)/\Delta - eu/\Delta + bv/\Delta 1511 \end{eqnarray} 1512 where $\Delta = bf - ce$ is the matrix determinant. Given two 1513 functions $f_i(x,y)$ for $i=1,2$: 1514 \begin{eqnarray} 1515 u & = & a_i + b_i x + c_i y \\ 1516 v & = & d_i + e_i x + f_i y 1517 \end{eqnarray} 1518 then the combined transformation, $(u,v) = f_2(f_1(x,y))$ is: 1519 \begin{eqnarray} 1520 u & = & (a_2 + b_2 a_1 + c_2 d_1) + (b_2 b_1 + c_2 e_1) x + (b_2 c_1 + c_2 f_1) y \\ 1521 v & = & (d_2 + e_2 a_1 + f_2 d_1) + (e_2 b_1 + f_2 e_1) x + (e_2 c_1 + f_2 f_1) y 1522 \end{eqnarray} 1523 1524 When the transformations are not linear, the inverse and combined 1525 transformations can be estimated by sampling a grid over the region of 1526 interest, calculating the transformation (or double transformation) 1527 for each sample, and using this information to derive the best fit 1528 transformation that produces the inverse or combined transformation. 1529 The inverse transformation should be of the same order as that of the 1530 forward transformation, while the combined transformation should be of 1531 the higher order of the two component transformations. 1532 1533 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1534 1535 \subsubsection{Projections} 1536 1537 We implement three types of projections: {\em zenithal}, {\em 1538 cylindrical} and {\em pseudocylindrical}, each requiring slightly 1539 different handling. Our representations are based on the treatment of 1540 projections presented by 1541 \href{http://www.cv.nrao.edu/fits/documents/wcs/wcs.all.ps}{Greisen \& 1542 Calabretta (1995, ADASS, 4, 233)}. In all of these projections, we 1543 are converting from a spherical coordinate $\alpha,\delta$ to a linear 1544 (2-D) coordinate $x_p,y_p$. The projection is defined by the 1545 projection type, the projection center ($\alpha_p, \delta_p$) and the 1546 the plate scales in the $x_p$ and $y_p$ directions ($\rho_x,\rho_y$). 1547 1548 In the structure, \code{psProjection}, the projection type is defined 1549 by the element \code{type}, the projection center $\alpha_p,\delta_p$ 1550 is defined by the elements \code{R,D}, and the plate scales, 1551 $\rho_x,\rho_y$, are defined by the elements \code{Xs,Ys}. The plate 1552 scales are applied independently to the $x$ and $y$ coordinates to 1553 convert them to the corresponding linear units (ie, pixels): 1554 % 1555 \begin{eqnarray} 1556 x_p & = & \rho_x x \\ 1557 y_p & = & \rho_y y \\ 1558 \end{eqnarray} 1559 % 1560 In the discussions below, we ignore this last step (or first step, 1561 depending on the direction of the conversion). 1562 1563 \paragraph{Zenithal Projections} 1564 1565 The {\em zenithal} projections are defined relative to a set of 1566 spherical coordinates with pole at the center of the projection 1567 ($\alpha_p, \delta_p$), and which thus represents a coordinate system 1568 rotated relative to the coordinate system of $\alpha, \delta$. In 1569 this spherical coordinate system, the coordinate of longitude is 1570 labeled $\phi$, and has domain of $-\pi < \phi \le \pi$, while the 1571 latitude, measured from the pole, is labeled $\theta$ and has domain 1572 $0 \le \theta \le \pi$. The coordinate frame of $\phi,\theta$ is 1573 defined so that $\phi_p$, the longitude of the target system pole, is 1574 0.0. 1575 1576 For an arbitrary projection center, it is necessary to convert the 1577 spherical coordinates to be projected ($\alpha,\delta$) to the 1578 projection spherical coordinate system coordinates ($\phi, \theta$). 1579 In practice, we construct the following useful trigonometric 1580 relationships between $\phi$ and $\theta$ which may be employed in the 1581 equations of $x,y$ below: 1582 % 1583 \begin{eqnarray} 1584 \sin \theta & = & \sin \delta \sin \delta_p + \cos \delta \cos \delta_p \cos (\alpha - \alpha_p) \\ 1585 \cos \theta \cos \phi & = & \sin \delta \cos \delta_p - \cos \delta \sin \delta_p \cos (\alpha - \alpha_p) \\ 1586 \cos \theta \sin \phi & = & - \cos \delta \sin (\alpha - \alpha_p) 1587 \end{eqnarray} 1588 % 1589 For the inverse transformations, the equivalent relationships are: 1590 % 1591 \begin{eqnarray} 1592 \sin \delta & = & \sin \theta \sin \delta_p + \cos \theta \cos \delta_p \cos \phi \\ 1593 \cos \delta \cos (\alpha - \alpha_p) & = & \sin \theta \cos \delta_p - \cos \theta \sin \delta_p \cos \phi \\ 1594 \cos \delta \sin (\alpha - \alpha_p) & = & - \cos \theta \sin \phi 1595 \end{eqnarray} 1596 % 1597 For zenithal projections, the linear coordinates are related to 1598 $\phi,\theta$ by: 1599 % 1600 \begin{eqnarray} 1601 x & = & R_\theta \sin \phi \\ 1602 y & = & -R_\theta \cos \phi 1603 \end{eqnarray} 1604 % 1605 and the inverse: 1606 % 1607 \begin{eqnarray} 1608 R_\theta & = & \sqrt{x^2 + y^2} \\ 1609 \phi & = & {\rm atan} (-y,x) 1610 \end{eqnarray} 1611 % 1612 The coordinates $x,y$ above are defined to be in angular units (ie, 1613 radians). 1614 1615 From these relationships, we can calculate $\alpha, \delta$ as: 1616 % 1617 \begin{eqnarray} 1618 \alpha - \alpha_p & = & \arctan (\sin \alpha, \cos \alpha) \\ 1619 \delta & = & \arcsin (\sin \delta) \\ 1620 \end{eqnarray} 1621 % 1622 Note that if $(x,y) = (0,0)$, then $\alpha = \alpha_p, \delta = \delta_p$. 1623 1624 \subparagraph{Gnomonic} 1625 1626 The Gnomonic projection (``TAN'') is a zenithal projection with 1627 $R_\theta = \cot \theta$. The resulting relationships for $(x,y)$ and 1628 for $\sin \theta, \cos \theta$ are: 1629 1630 \begin{eqnarray} 1631 x & = & \frac{\cos \theta \sin \phi}{\sin \theta} \\ 1632 y & = & \frac{-\cos \theta \cos \phi}{\sin \theta} \\ 1633 \sin \theta & = & \zeta / \sqrt{1 + \zeta^2} \\ 1634 \cos \theta & = & 1 / \sqrt{1 + \zeta^2} \\ 1635 \end{eqnarray} 1636 1637 where $\zeta = 1 / R_\theta$. 1638 1639 \subparagraph{Orthographic} 1640 1641 The Orthographic projection (``SIN'') is a zenithal projection with 1642 $R_\theta = \cos \theta$. The resulting relationships for $(x,y)$ and 1643 for $\sin \theta, \cos \theta$ are: 1644 1645 \begin{eqnarray} 1646 x & = & \cos \theta \sin \phi \\ 1647 y & = & -\cos \theta \cos \phi \\ 1648 \sin \theta & = & \sqrt{1 - R_\theta^2} \\ 1649 \cos \theta & = & R_\theta \\ 1650 \end{eqnarray} 1651 1652 \paragraph{Cylindrical and Pseudocylindrical Projections} 1653 1654 The {\em cylindrical} and {\em pseudocylindrical} projections are 1655 defined relative to a set of cylindrical coordinates whose pole is 1656 coincident with the pole of the spherical coordinates. These 1657 projections are particularly used for full-sky representations, and 1658 are only defined for projection centers with $\delta_p = 0$. In this 1659 spherical coordinate system, the coordinate of longitude is labeled 1660 $\phi$, and has domain of $-\pi < \phi \le \pi$, while the latitude, 1661 measured from the pole, is labeled $\theta$ and has domain $0 \le 1662 \theta \le \pi$. The projection center longitude, $\alpha_p$ 1663 corresponds to $\phi = 0$, thus the value of $\phi$ is determined as 1664 $\alpha - \alpha_p$ for all such projections. 1665 1666 \subparagraph{Cartesian} 1667 1668 The Cartesian projection (``CAR'') is a very simple cylindrical 1669 projection with the following relationships between $x,y$ and 1670 $\phi,\theta$: 1671 1672 \begin{eqnarray} 1673 x & = & \phi \\ 1674 y & = & \theta 1675 \end{eqnarray} 1676 1677 \subparagraph{Mercator} 1678 1679 The Mercator projection (``MER'') is a cylindrical projection. 1680 1681 \begin{eqnarray} 1682 x & = & \phi \\ 1683 y & = & \ln \left( \tan (\pi/4 + \theta/2) \right) \\ 1684 {\rm and}\hspace{1cm} \theta & = & 2 \arctan \left( e^y \right) - \pi/2 1685 \end{eqnarray} 1686 1687 \subparagraph{Hammer-Aitoff} 1688 1689 The Hammer-Aitoff projection(``AIT'') is a pseudocylindrical projection, and is defined: 1690 1691 \begin{eqnarray} 1692 x & = & 2 \zeta \cos \theta \sin \frac{\phi}{2} \\ 1693 y & = & \zeta \sin \theta \\ 1694 {\rm where}\hspace{1cm} \zeta^{-1} & \equiv & \sqrt{\frac{1}{2}\left(1 + \cos \theta \cos \frac{\phi}{2} \right)} 1695 \end{eqnarray} 1696 1697 And in reverse: 1698 1699 \begin{eqnarray} 1700 \phi & = & 2 {\rm \arctan} (2z^2 - 1, x z) \\ 1701 \theta & = & \arcsin (yz) \\ 1702 {\rm where}\hspace{1cm} z & \equiv & \sqrt{1 - (x/2)^2 - y^2} 1703 \end{eqnarray} 1704 1705 \subparagraph{Parabolic} 1706 1707 The Parabolic projection (``PAR'') is a pseudocylindrical projection, and is defined: 1708 1709 \begin{eqnarray} 1710 x & = & \phi \left( 2 \cos \frac{2 \theta}{3} - 1 \right) \\ 1711 y & = & \pi \sin \frac{\theta}{3} \\ 1712 \end{eqnarray} 1713 1714 And in reverse: 1715 1716 \begin{eqnarray} 1717 \theta & = & 3 \sin^{-1} \rho \\ 1718 \phi & = & \frac{x}{1 - 4\rho^2} \\ 1719 {\rm where}\hspace{1cm} \rho & \equiv & y/\pi \\ 1720 \end{eqnarray} 1721 1722 \subsubsection{Offset} 1723 1724 Coordinate offsets can be either spherical offsets or linear offsets. 1725 1726 A spherical offset is performed by adding the components of the 1727 offset, after unit conversion, to the given position. The resulting 1728 coordinates must be wrapped to within the allowed range ($-\pi$ to 1729 $\pi$, 0 to $2\pi$). 1730 1731 A linear offset is defined to be a linear offset in a tangent 1732 projection centered on the starting coordinate with $y$ axis aligned 1733 with the local direction or increasing Declination. This projection 1734 is undefined only for the coordinates exactly at the north and south 1735 poles, in which case the orientation is defined to have the $y$ axis 1736 parallel to the line of RA = 0.0. The scale of the projection is 1.0 1737 (ie, 1 'pixel' is 1 radian) and the given offsets must the scaled 1738 based on the given offset units. 1739 1740 Pseudo-code to implement the above for an offset: 1741 1742 \begin{verbatim} 1743 psSphere *psSphereSetOffset (psSphere pos, psSphere offset) { 1744 1745 psPlane lin; 1746 psSphere new; 1747 psProjection proj; 1748 1749 proj.R = pos->r; 1750 proj.D = pos->d; 1751 proj.X = 0; 1752 proj.Y = 0; 1753 proj.type = PS_PROJ_TAN; 1754 1755 lin.x = offset.r; 1756 lin.y = offset.d; 1757 1758 new = psDeproject (&lin, &proj); 1759 return (new); 1760 } 1761 \end{verbatim} 1762 1763 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1764 1765 \subsubsection{Tangent Plane to Sky} 1661 1662 \subsection{Tangent Plane to Sky} 1766 1663 1767 1664 \tbd{we will replace the SLALIB version of AOPPA with a new function} … … 1798 1695 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1799 1696 1800 \subsubsection{The One-to-Many Problem with Mosaic Cameras} 1697 \subsection{Sky to Tangent Plane (II)} 1698 1699 This section describes the transformation between celestial coordinates 1700 (R.A., Dec.) and local terrestrial coordinates (Az, Alt). This transformation 1701 is broken down into a number of steps as described below. 1702 1703 \paragraph{Reference Implementations} 1704 1705 There are two reference implementatins for the code to account for the 1706 motion of the Earth in space. The first are the sample routines 1707 provided by the IERS to accompany chaper 5 of IERS Bulletin 32. This 1708 document and the code can be downloaded from 1709 http://maia.usno.navy.mil/conv2003.html . The second reference 1710 implementation is the SOFA software package managed by the IAU and 1711 available at http://www.iau-sofa.rl.ac.uk Only the 2003-04-29 version 1712 of SOFA should be used. The IERS code requires a few of the rotation 1713 matrix utility routines from SOFA. 1714 1715 Both implementations are in FORTRAN 77. The SOFA code has a more 1716 complex implementation of precession-nutation for backward 1717 compatibility with the pre 2003-01-01 conventions. The IERS code 1718 includes some tricks to achieve greater precision in the fundamental 1719 arguments of nutation, which the SOFA code omits. Therefore, the main 1720 reference for psLib should be the IERS code. Note that the IERS code 1721 calculates the transform from terrestrial to celestial coordinates, 1722 while the SOFA code calculates its inverse. 1723 1724 \subsubsection{Coordinate Systems} 1725 1726 \begin{figure} 1727 \psfig{file=transforms.ps} 1728 \caption{Coordinates systems and the transformations between them} 1729 1730 \end{figure} 1731 Figure X shows the transformation steps and intermediate coordinate systems 1732 between celestial and local terrestrial coordinate systems. The intermediate 1733 coordinate systems are defined below. 1734 1735 \paragraph{ICRS} 1736 The official IAU-sanctioned celestial coordinate system is the 1737 International Celestial Reference System (ICRS). It is defined in terms of 1738 a number of radio sources whose positions have been measured using VLBI. 1739 It can be tied to the optical through the Hipparcos catalog. The ICRS has its 1740 origin at the solar system barycenter. 1741 1742 \paragraph{GCRS} 1743 The Geocentric Celestial Reference System (GCRS) corresponds to the ICRS, but 1744 has its origin at the center of the Earth. The differences between the two 1745 systems are due to the velocity of the Earth (aberration), the position of 1746 the Earth (parallax), and general relativistic bending of light rays. 1747 There is no net rotation between the ICRS and the GCRS. 1748 1749 \paragraph{ITRS} 1750 The International Terrestrial Reference System (ITRS) is a coordinate 1751 system which is fixed with respect to the Earth's crust. 1752 1753 \paragraph{Intermediate Coordinate Systems - CIP, CEO, TEO} 1754 The transform between the GCRS and ITRS is conventionally 1755 decomposed into three parts in order to isolate the relatively rapid rotation 1756 of the Earth from the movement of the Earth's rotational axis in the GCRS 1757 and ITRS. All three sub-transforms are rigid rotations. 1758 1759 This decomposition results in two intermediate coordinate systems. Both of 1760 these share the same pole, known as the Celestial Intermediate Pole (CIP). 1761 The CIP is defined by its motion in the GCRS to match the Tisserand 1762 mean axis of the Earth (Seidelmann 1982, Celesial Mechanics 27, 78-106), 1763 excluding motions with periods less than or equal 1764 to two days. The CIP approximates the angular momentum vector of the 1765 rotating Earth. 1766 1767 The X axes of the intermediate coordinate systems are known as the 1768 Celestial and Terrestrial Ephemeris Origins. (CEO and TEO). Both are defined 1769 to be non-rotating origins. A non-rotating origin is a point on the equator 1770 whose instantaneous motion is always orthogonal to the equator 1771 (Kaplan 2003 IAU XXV Joint Discussion 16 1772 \footnote{http://aa.usno.navy.mil/kaplan/NROs\%5BJD16proc\%5D.pdf}). 1773 Thus the CEO is defined by its position in the GCRS at some epoch and by the 1774 motion of the CIP in the GCRS since that date. Similarly the TEO is 1775 defined by its position in the ITRS at some epoch and the motion of the 1776 CIP in the ITRS since that date. 1777 1778 \subsubsection{ICRS - GCRS} 1779 1780 The transformation between barycentric (ICRS) and geocentric (GCRS) coordinates 1781 involves two components. These are 1782 the general relativistic deflection of light rays by the Sun's gravity, and 1783 aberration, due to the orbital motion 1784 of the Earth. 1785 1786 \paragraph{Gravitational Deflection} 1787 1788 The Sun's gravity bends the path of light rays which pass near it. 1789 To first order, a light ray is deflected by an angle of $4GM/c^2r_0$ radians, 1790 where $G$ is the gravitational constant, 1791 $M$ is the mass of the Sun, 1792 $c$ is the speed of light, and 1793 $r_0$ is the point of closest approach to the light ray to the Sun. 1794 To the same order this is equal to the impact parameter - i.e. the point 1795 of closest approach if the light ray were not deflected. Note that 1796 $r_0/d = \tan(\theta)$, where $d$ is the distance from the Earth 1797 to the Sun, and $\theta$ 1798 is the angular separation of the star from the center of the Sun. 1799 1800 There is a maximum deflection of 1.75 arc seconds if we set 1801 $r_0$ to the radius of the sun. 1802 Since the Sun bends light rays toward it, a star appears shifted away from the sun in the sky. 1803 1804 \paragraph{Aberration} 1805 1806 Aberration is the apparent change in direction of a ray of light in the 1807 reference frame of a moving observer. Traditionally the aberration 1808 calculation has been done with a linear expansion of the full 1809 relativistic expression, often neglecting all but the linear term in 1810 $v/c$, since the relativistic terms are on the order of a miliarcsecond. 1811 However, the full relativistic expression poses no challenge for modern 1812 computers, so psLib will use the following procedure to calculate aberration. 1813 1814 Suppose an observer has a velocity $\beta\hat{\beta}$, with respect to 1815 the Solar System barycenter, where $\beta$ is in units of the speed of 1816 light, and $\hat{\beta}$ is a unit vector. Suppose also that the unit vector 1817 $\hat{r}$ points toward a star in the barycenter frame of reference 1818 (i.e. the ``actual'' position). 1819 and $\hat{r}'$ gives the direction of the star in the observer's frame, 1820 (i.e. the apparent position). 1821 1822 First, decompose $\hat{r}$ into components parallel and perpendicular to 1823 $\hat{\beta}$ by calculating 1824 $\mu = \hat{r}\cdot\hat{\beta}$ and 1825 $\vec{r}_\perp = \hat{r} - \mu \hat{\beta}$. 1826 1827 Next, use the following expression for relativistic beaming, modified 1828 slightly from equation 4.8b of Rybicki and Lightman: 1829 \begin{equation} 1830 \mu' = \mu + \beta \frac{\mu^2 - 1}{1 - \beta\mu} 1831 \end{equation} 1832 where $\mu' = \hat{r}' \cdot \hat{\beta}$. 1833 1834 Now, the component of $\hat{r}'$ perpendicular to $\hat{\beta}$ 1835 (i.e. $\vec{r}_\perp'$) must point 1836 in the same direction as $\vec{r}_\perp$, but will have a different magnitude 1837 because $\hat{r}'$ is a unit vector. In other words, 1838 $\vec{r}_\perp' = a\vec{r}_\perp$, for some scalar $a$. So the next step is 1839 to calculate $a = \sqrt{(1-\mu'^2)/\vec{r}_\perp}$. 1840 1841 Finally, reassemble the components of 1842 $\hat{r}' = \mu'\hat{\beta} + a \vec{r_\perp}$. 1843 1844 1845 \subsubsection{GCRS - ITRS} 1846 The transformation between geocentric celestial coordinates and terrestrial 1847 coordinates is a solid body rotation due to the motion of the Earth is space. 1848 This is conventionally broken down into three components to isolate the 1849 relatively rapid rotation of the Earth from the motion of its rotational axis. 1850 1851 This section is largely a summary of 1852 Chapter 5 of IERS Technical Note 32 \footnote{http://maia.usno.navy.mil/conv2003.html} 1853 (hereafter IERS32), 1854 which is a description of the implementation of the Resoltions of the 1855 XXIVth General Assembly of the IAU, available from the same URL as above. 1856 These two documents describe a set of conventions which have been in effect 1857 since 2003-01-01. The conventions in effect before that date will not be 1858 implemented by psLib. 1859 1860 1861 \paragraph{Precession/Nutation} 1862 1863 The transform between the GCRS and the CIP/CEO coordinate systems is described 1864 by the IAU 2000A precession-nutation model, which is accurate to the 1865 0.2 mas level. 1866 For higher accuracy the user must apply corrections to the model, which are tabulated by the IERS. 1867 1868 1869 1870 The IAU 2000A precession-nutation model may be calculated in the following 1871 way. First calculate the time $t$ as the number of Julian centuries since 1872 2000-01-01T12:00:00 TT. 1873 1874 Next calculate the fundamental arguments of nutation using equations (40) 1875 and (41) of IERS32, reproduced below: 1876 \begin{eqnarray} 1877 F_1\equiv l\quad =~&\ Mean\ Anomaly\ of\ the\ Moon \cr 1878 =~& 134.96340251^\circ + 1717915923.2178'' t 1879 + 31.8792'' t^2 + 0.051635'' t^3 - 0.00024470'' t^4,\cr 1880 F_2\equiv l'\quad =~&\ Mean\ Anomaly\ of\ the\ Sun\cr 1881 =~& 357.52910918^\circ + 129596581.0481'' t 1882 - 0.5532'' t^2 + 0.000136'' t^3 - 0.00001149'' t^4,\cr 1883 F_3\equiv F\quad =~& L - \Omega\cr 1884 =~& 93.27209062^\circ + 1739527262.8478'' t - 12.7512'' t^2 1885 - 0.001037'' t^3 + 0.00000417'' t^4,\cr 1886 F_4\equiv D\quad =~&\ Mean\ Elongation\ of\ the\ Moon\ from\ the\ Sun\cr 1887 =~& 297.85019547^\circ + 1602961601.2090'' t - 6.3706'' t^2 1888 + 0.006593'' t^3 - 0.00003169'' t^4,\cr 1889 F_5\equiv\Omega\quad =~&\ Mean\ Longitude\ of\ the\ Ascending\ Node\ of\ 1890 the\ Moon\cr 1891 =~& 125.04455501^\circ - 6962890.5431'' t + 7.4722'' t^2 + 0.007702'' t^3 - 0.00005939'' t^4 \cr 1892 F_6\ \equiv l_{Me}\quad =~& 4.402 608 842 + 2608.7903 141 574\times t,\cr 1893 F_7\ \equiv l_{Ve}\quad =~& 3.176 146 697 + 1021.3285 546 211 \times t,\cr 1894 F_8\ \equiv l_{E\ }\quad =~& 1.753 470 314 + 628.3075 849 991 \times t,\cr 1895 F_9\equiv l_{Ma}\quad =~& 6.203 480 913 + 334.0612 426 700 \times t,\cr 1896 F_{10}\equiv l_{Ju}\quad =~& 0.599 546 497 + 52.9690 962 641 \times t,\cr 1897 F_{11}\equiv l_{Sa}\quad =~& 0.874 016 757 + 21.3299 104 960 \times t,\cr 1898 F_{12}\equiv l_{Ur}\quad =~& 5.481 293 872 + 7.4781 598 567 \times t,\cr 1899 F_{13}\equiv l_{Ne}\quad =~& 5.311 886 287 + 3.8133 035 638 \times t,\cr 1900 F_{14}\equiv p_{a\ }\quad =~& 0.024 381 750 \times t + 0.000 005 386 91 \times t^2. 1901 \end{eqnarray} 1902 1903 Next calculate the quantities $X$, $Y$, and $s$, using expressions of the form: 1904 1905 \begin{equation} 1906 \sum_{j} p_j t^j + \sum_{j}\sum_{i}[ 1907 (a_{{\rm s},j})_i t^j \sin ({\rm \scriptstyle {ARG_{i,j}}}) 1908 + (a_{{\rm c},j})_i t^j \cos ({\rm \scriptstyle {ARG_{i,j}}})] 1909 , 1910 \end{equation} 1911 1912 where the $\rm \scriptstyle{ARG_{i,j}} = \sum_{k} w_{i,j,k} F_k$ represent linear 1913 combinations of the fundamental arguments of nutation. 1914 1915 The constants $p_j$, $w_{i,j,k}$, $(a_{{\rm s},j})_i$, and $(a_{{\rm c},j})_i$ 1916 are given in the ASCII files: 1917 tab5.2a.txt \footnote{http://maia.usno.navy.mil/conv2000/chapter5/tab5.2a.txt} (for $X$), 1918 tab5.2b.txt \footnote{http://maia.usno.navy.mil/conv2000/chapter5/tab5.2b.txt} (for $Y$), and 1919 tab5.2c.txt \footnote{http://maia.usno.navy.mil/conv2000/chapter5/tab5.2c.txt} (for $s+XY/2$). 1920 Note that the expansion is given for $s+XY/2$, since this series converges 1921 more rapidly than the one for $s$ alone. 1922 1923 Each file contains a human-readable header, which includes the polynomial 1924 coeficients, $p_j$ under the heading ``Polynomial part''. The data part of the 1925 file lists the remaining constants, with rows cycling first through $i$, and 1926 then through $j$. There is a separate heading each time $j$ increments. 1927 Each row contains the following columns: 1928 1929 \begin{itemize} 1930 \item col 1 - A running index of rows in the table. 1931 \item col 2 - The sine coeficients, $(a_{{\rm s},j})_i$ 1932 \item col 3 - The cosine coeficients, $(a_{{\rm c},j})_i$ 1933 \item cols 4 - 17 The weighting factors for the fundamental arguments of 1934 nutation, $w_{i,j,k}$. 1935 \end{itemize} 1936 1937 1938 A FORTRAN reference implementation for the precession/nutation model is available from the IERS 1939 \footnote{http://maia.usno.navy.mil/conv2000/chapter5/XYS2000A.f}. 1940 The psLib results should agree with the reference implementation to within 1941 the limits of numerical precision. 1942 1943 Next, corrections to $X$, and $Y$ may be obtained from the IERS as part of 1944 Bulletin A, or B. It is recommended to use the values published daily in 1945 http://maia.usno.navy.mil/ser7/finals2000A.daily, which has the format 1946 described by http://maia.usno.navy.mil/ser7/readme.finals2000A. The 1947 quantities of interest are labeled dX and dY. Note that UT1$-$UTC and the 1948 polar motion values are obtained from this same table. 1949 1950 By convention, nutation terms with periods of less 1951 than two days 1952 are accounted for by the corresponding polar motion. So it is sufficient to 1953 interpolate the corrections tabulated daily by the IERS, and take the result as 1954 instantaneous values. 1955 1956 The final step is to use $X$, $Y$, and $s$ to calculate the rotation 1957 matrix from the CIP/CEO system to the GCRS using IERS32 equation (10), 1958 reproduced below: 1959 1960 \begin{equation} 1961 \begin{pmatrix}1-aX^2& -aXY& X\cr -aXY& 1-aY^2& Y\cr -X& -Y& 1962 1-a(X^2+Y^2)\cr 1963 \end{pmatrix} \cdot R_3(s), 1964 \end{equation} 1965 where $R_3$ denotes a rotation about the Z axis, 1966 $a = 1/(1+\sqrt{1 - X^2 + Y^2})$, 1967 and $X$ and $Y$ are expressed in radians. 1968 A FORTRAN reference implementation for this calculation is given 1969 by the IERS \footnote{http://maia.usno.navy.mil/conv2000/chapter5/BPN2000.f}. 1970 1971 Note that above we gave the expression for the transform toward celestial 1972 coordinates (upward in figure X), in order to match the IERS reference code. 1973 The inverse transform may be found by inverting the resulting rotation. 1974 1975 \paragraph{Rotation of the Earth} 1976 1977 The transform from the CIP/CEO to CIP/TEO coordinate systems is a 1978 rotation about the CIP (i.e. the Z axis) by an angle known as the 1979 ``Earth Rotation Angle''. 1980 By definition the Earth Rotation Angle is given by 1981 equation (13) of IERS32, reproduced below: 1982 \begin{equation} 1983 \theta(T_u)=2\pi(0.7790572732640 + 1.00273781191135448T_u), 1984 \end{equation} 1985 where $T_u$ is the Julian UT1 date minus 2451545.0 . 1986 1987 \paragraph{Polar Motion} 1988 1989 The motion of the CIP in the ITRS is known as ``polar motion''. Similarly to 1990 precession/nutation, the instantaneous position of the CIP in the 1991 ITRS is specified by the quantites $x_p$, and $y_p$, and a third quantity, 1992 $s'$, gives the position of the TEO with respect to the ITRS. 1993 The values of $x_p$ and $y_p$ are published daily by the IERS in 1994 http://maia.usno.navy.mil/ser7/finals2000A.daily, which has the format 1995 described by http://maia.usno.navy.mil/ser7/readme.finals2000A. 1996 The UT1$-$UTC, and the precession/nutation corrections (discussed elsewhere 1997 in this document) come from this same source. 1998 1999 The polar motion coordinates should be interpolated using a third order 2000 polynomial, as described in 2001 IERS Gazette \#13 \footnote{http://maia.usno.navy.mil/iers-gaz13}, 2002 which gives a 2003 FORTRAN reference implementation of the correct procedure. 2004 2005 \tbd{reference to interpolation in this doc?} 2006 2007 The values published by the IERS are smoothed to remove noise and 2008 variations on the timescale of a day or less. There are two sources of 2009 short timescale variations - tidal effects on the order of 0.1 milliarcseconds, 2010 and short period nutation terms on the order of 15 microarcseconds. 2011 Both of these effects may be modeled and added to the interpolated values 2012 for higher accuracy. 2013 2014 The tidal effects should be included using the FORTRAN reference implementation 2015 of the Ray tidal model given in IERS Gazette \#13. This code should be 2016 mimiced to machine accuracy by psLib. 2017 2018 By definition of the CIP, nutation terms with periods less than 2 days are 2019 not included in the IAU 2000A precession/nutation model. 2020 So these motions 2021 must be compensated for by their equivalent polar motions. These may 2022 be calculated using a form similar to that of the precession/nutation $X$, 2023 and $Y$. The constants to use are given in Table 5.1 of IERS32. 2024 Note that only the terms with periods less than 2 days should be used. 2025 2026 The quantity $s'$ may be approximated with microarcsecond accuracy over this 2027 century by $s' = -4.7 \times 10^{-5} t$ in arcseconds. There is no need 2028 to apply short timescale corrections to $s'$. 2029 2030 The transform from the ITRS to the CIP/TEO frame can be constructed by 2031 first rotating about the X axis by $y_p$, then rotating about the X axis by 2032 $x_p$, and finally rotating about the Z axis by $s'$. 2033 The IERS reference implementation for this is given in the subroutine 2034 POM2000 \footnote{http://maia.usno.navy.mil/conv2000/chapter5/POM2000.f}. 2035 Note that we describe the transform toward celestial coordinates (upward in 2036 figure X), in order to match the reference implementation. 2037 2038 \subsubsection{ITRS - Alt/Az} 2039 2040 \paragraph{Orientation of the Observer} 2041 2042 An observer's astronomical longitude and latitude give the orientation of 2043 the local vertical with respect to the ITRS. Note that these coordinates 2044 can be approximated by the geographic longitude and latitude of the observatory, 2045 but their exact values must be calibrated from observation of stars 2046 with known coordinates in the ICRS. 2047 2048 The transform from the ITRS to Az/Alt in the absence of atmospheric refraction 2049 is first a rotation about the Z axis by the observer's astronomical longitude, 2050 and then a rotation about the Y axis of 90 degrees minus the observer's 2051 astronomical latitude, followed by a rotation about the Z axis of 180 degrees 2052 so that North is zero azimuth. 2053 2054 \paragraph{Atmospheric Refraction} 2055 2056 \tbd{add in summary of Ken's paper} 2057 2058 \subsection{Projections} 2059 2060 We implement three types of projections: {\em zenithal}, {\em 2061 cylindrical} and {\em pseudocylindrical}, each requiring slightly 2062 different handling. Our representations are based on the treatment of 2063 projections presented by 2064 \href{http://www.cv.nrao.edu/fits/documents/wcs/wcs.all.ps}{Greisen \& 2065 Calabretta (1995, ADASS, 4, 233)}. In all of these projections, we 2066 are converting from a spherical coordinate $\alpha,\delta$ to a linear 2067 (2-D) coordinate $x_p,y_p$. The projection is defined by the 2068 projection type, the projection center ($\alpha_p, \delta_p$) and the 2069 the plate scales in the $x_p$ and $y_p$ directions ($\rho_x,\rho_y$). 2070 2071 In the structure, \code{psProjection}, the projection type is defined 2072 by the element \code{type}, the projection center $\alpha_p,\delta_p$ 2073 is defined by the elements \code{R,D}, and the plate scales, 2074 $\rho_x,\rho_y$, are defined by the elements \code{Xs,Ys}. The plate 2075 scales are applied independently to the $x$ and $y$ coordinates to 2076 convert them to the corresponding linear units (ie, pixels): 2077 % 2078 \begin{eqnarray} 2079 x_p & = & \rho_x x \\ 2080 y_p & = & \rho_y y \\ 2081 \end{eqnarray} 2082 % 2083 In the discussions below, we ignore this last step (or first step, 2084 depending on the direction of the conversion). 2085 2086 \subsubsection{Zenithal Projections} 2087 2088 The {\em zenithal} projections are defined relative to a set of 2089 spherical coordinates with pole at the center of the projection 2090 ($\alpha_p, \delta_p$), and which thus represents a coordinate system 2091 rotated relative to the coordinate system of $\alpha, \delta$. In 2092 this spherical coordinate system, the coordinate of longitude is 2093 labeled $\phi$, and has domain of $-\pi < \phi \le \pi$, while the 2094 latitude, measured from the pole, is labeled $\theta$ and has domain 2095 $0 \le \theta \le \pi$. The coordinate frame of $\phi,\theta$ is 2096 defined so that $\phi_p$, the longitude of the target system pole, is 2097 0.0. 2098 2099 For an arbitrary projection center, it is necessary to convert the 2100 spherical coordinates to be projected ($\alpha,\delta$) to the 2101 projection spherical coordinate system coordinates ($\phi, \theta$). 2102 In practice, we construct the following useful trigonometric 2103 relationships between $\phi$ and $\theta$ which may be employed in the 2104 equations of $x,y$ below: 2105 % 2106 \begin{eqnarray} 2107 \sin \theta & = & \sin \delta \sin \delta_p + \cos \delta \cos \delta_p \cos (\alpha - \alpha_p) \\ 2108 \cos \theta \cos \phi & = & \sin \delta \cos \delta_p - \cos \delta \sin \delta_p \cos (\alpha - \alpha_p) \\ 2109 \cos \theta \sin \phi & = & - \cos \delta \sin (\alpha - \alpha_p) 2110 \end{eqnarray} 2111 % 2112 For the inverse transformations, the equivalent relationships are: 2113 % 2114 \begin{eqnarray} 2115 \sin \delta & = & \sin \theta \sin \delta_p + \cos \theta \cos \delta_p \cos \phi \\ 2116 \cos \delta \cos (\alpha - \alpha_p) & = & \sin \theta \cos \delta_p - \cos \theta \sin \delta_p \cos \phi \\ 2117 \cos \delta \sin (\alpha - \alpha_p) & = & - \cos \theta \sin \phi 2118 \end{eqnarray} 2119 % 2120 For zenithal projections, the linear coordinates are related to 2121 $\phi,\theta$ by: 2122 % 2123 \begin{eqnarray} 2124 x & = & R_\theta \sin \phi \\ 2125 y & = & -R_\theta \cos \phi 2126 \end{eqnarray} 2127 % 2128 and the inverse: 2129 % 2130 \begin{eqnarray} 2131 R_\theta & = & \sqrt{x^2 + y^2} \\ 2132 \phi & = & {\rm atan} (-y,x) 2133 \end{eqnarray} 2134 % 2135 The coordinates $x,y$ above are defined to be in angular units (ie, 2136 radians). 2137 2138 From these relationships, we can calculate $\alpha, \delta$ as: 2139 % 2140 \begin{eqnarray} 2141 \alpha - \alpha_p & = & \arctan (\sin \alpha, \cos \alpha) \\ 2142 \delta & = & \arcsin (\sin \delta) \\ 2143 \end{eqnarray} 2144 % 2145 Note that if $(x,y) = (0,0)$, then $\alpha = \alpha_p, \delta = \delta_p$. 2146 2147 \paragraph{Gnomonic} 2148 2149 The Gnomonic projection (``TAN'') is a zenithal projection with 2150 $R_\theta = \cot \theta$. The resulting relationships for $(x,y)$ and 2151 for $\sin \theta, \cos \theta$ are: 2152 2153 \begin{eqnarray} 2154 x & = & \frac{\cos \theta \sin \phi}{\sin \theta} \\ 2155 y & = & \frac{-\cos \theta \cos \phi}{\sin \theta} \\ 2156 \sin \theta & = & \zeta / \sqrt{1 + \zeta^2} \\ 2157 \cos \theta & = & 1 / \sqrt{1 + \zeta^2} \\ 2158 \end{eqnarray} 2159 2160 where $\zeta = 1 / R_\theta$. 2161 2162 \paragraph{Orthographic} 2163 2164 The Orthographic projection (``SIN'') is a zenithal projection with 2165 $R_\theta = \cos \theta$. The resulting relationships for $(x,y)$ and 2166 for $\sin \theta, \cos \theta$ are: 2167 2168 \begin{eqnarray} 2169 x & = & \cos \theta \sin \phi \\ 2170 y & = & -\cos \theta \cos \phi \\ 2171 \sin \theta & = & \sqrt{1 - R_\theta^2} \\ 2172 \cos \theta & = & R_\theta \\ 2173 \end{eqnarray} 2174 2175 \subsubsection{Cylindrical and Pseudocylindrical Projections} 2176 2177 The {\em cylindrical} and {\em pseudocylindrical} projections are 2178 defined relative to a set of cylindrical coordinates whose pole is 2179 coincident with the pole of the spherical coordinates. These 2180 projections are particularly used for full-sky representations, and 2181 are only defined for projection centers with $\delta_p = 0$. In this 2182 spherical coordinate system, the coordinate of longitude is labeled 2183 $\phi$, and has domain of $-\pi < \phi \le \pi$, while the latitude, 2184 measured from the pole, is labeled $\theta$ and has domain $0 \le 2185 \theta \le \pi$. The projection center longitude, $\alpha_p$ 2186 corresponds to $\phi = 0$, thus the value of $\phi$ is determined as 2187 $\alpha - \alpha_p$ for all such projections. 2188 2189 \paragraph{Cartesian} 2190 2191 The Cartesian projection (``CAR'') is a very simple cylindrical 2192 projection with the following relationships between $x,y$ and 2193 $\phi,\theta$: 2194 2195 \begin{eqnarray} 2196 x & = & \phi \\ 2197 y & = & \theta 2198 \end{eqnarray} 2199 2200 \paragraph{Mercator} 2201 2202 The Mercator projection (``MER'') is a cylindrical projection. 2203 2204 \begin{eqnarray} 2205 x & = & \phi \\ 2206 y & = & \ln \left( \tan (\pi/4 + \theta/2) \right) \\ 2207 {\rm and}\hspace{1cm} \theta & = & 2 \arctan \left( e^y \right) - \pi/2 2208 \end{eqnarray} 2209 2210 \paragraph{Hammer-Aitoff} 2211 2212 The Hammer-Aitoff projection(``AIT'') is a pseudocylindrical projection, and is defined: 2213 2214 \begin{eqnarray} 2215 x & = & 2 \zeta \cos \theta \sin \frac{\phi}{2} \\ 2216 y & = & \zeta \sin \theta \\ 2217 {\rm where}\hspace{1cm} \zeta^{-1} & \equiv & \sqrt{\frac{1}{2}\left(1 + \cos \theta \cos \frac{\phi}{2} \right)} 2218 \end{eqnarray} 2219 2220 And in reverse: 2221 2222 \begin{eqnarray} 2223 \phi & = & 2 {\rm \arctan} (2z^2 - 1, x z) \\ 2224 \theta & = & \arcsin (yz) \\ 2225 {\rm where}\hspace{1cm} z & \equiv & \sqrt{1 - (x/2)^2 - y^2} 2226 \end{eqnarray} 2227 2228 \paragraph{Parabolic} 2229 2230 The Parabolic projection (``PAR'') is a pseudocylindrical projection, and is defined: 2231 2232 \begin{eqnarray} 2233 x & = & \phi \left( 2 \cos \frac{2 \theta}{3} - 1 \right) \\ 2234 y & = & \pi \sin \frac{\theta}{3} \\ 2235 \end{eqnarray} 2236 2237 And in reverse: 2238 2239 \begin{eqnarray} 2240 \theta & = & 3 \sin^{-1} \rho \\ 2241 \phi & = & \frac{x}{1 - 4\rho^2} \\ 2242 {\rm where}\hspace{1cm} \rho & \equiv & y/\pi \\ 2243 \end{eqnarray} 2244 2245 \subsection{Offset} 2246 2247 Coordinate offsets can be either spherical offsets or linear offsets. 2248 2249 A spherical offset is performed by adding the components of the 2250 offset, after unit conversion, to the given position. The resulting 2251 coordinates must be wrapped to within the allowed range ($-\pi$ to 2252 $\pi$, 0 to $2\pi$). 2253 2254 A linear offset is defined to be a linear offset in a tangent 2255 projection centered on the starting coordinate with $y$ axis aligned 2256 with the local direction or increasing Declination. This projection 2257 is undefined only for the coordinates exactly at the north and south 2258 poles, in which case the orientation is defined to have the $y$ axis 2259 parallel to the line of RA = 0.0. The scale of the projection is 1.0 2260 (ie, 1 'pixel' is 1 radian) and the given offsets must the scaled 2261 based on the given offset units. 2262 2263 Pseudo-code to implement the above for an offset: 2264 2265 \begin{verbatim} 2266 psSphere *psSphereSetOffset (psSphere pos, psSphere offset) { 2267 2268 psPlane lin; 2269 psSphere new; 2270 psProjection proj; 2271 2272 proj.R = pos->r; 2273 proj.D = pos->d; 2274 proj.X = 0; 2275 proj.Y = 0; 2276 proj.type = PS_PROJ_TAN; 2277 2278 lin.x = offset.r; 2279 lin.y = offset.d; 2280 2281 new = psDeproject (&lin, &proj); 2282 return (new); 2283 } 2284 \end{verbatim} 2285 2286 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2287 2288 \subsection{The One-to-Many Problem with Mosaic Cameras} 1801 2289 1802 2290 The \PS{} focal plane consists of several chips, so we will often want … … 1820 2308 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1821 2309 1822 \subs ubsection{General Astronomy Functions}2310 \subsection{General Astronomy Functions} 1823 2311 1824 2312 \tbd{we will provide a new airmass function} … … 1854 2342 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1855 2343 1856 \subs ubsection{Positions of Major Solar System Objects}2344 \subsection{Positions of Major Solar System Objects} 1857 2345 1858 2346 \tbd{ephemerides code to replace this} … … 1869 2357 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 1870 2358 1871 \subsection{Missing and Todo} 1872 1873 \tbd{define sunrise, sunset, sun position} 1874 1875 \tbd{define moonrise, moonset, moon position, moon phase} 1876 1877 \tbd{define planet functions} 1878 1879 \tbd{clean up FITS I/O issues} 1880 1881 \tbd{define Brent's method \& minimization bracketing} 1882 2359 \pagebreak 1883 2360 \section{Pan-STARRS Modules} 1884 2361 … … 2225 2702 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2226 2703 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2704 2705 \section{Missing and Todo} 2706 2707 \tbd{define sunrise, sunset, sun position} 2708 2709 \tbd{define moonrise, moonset, moon position, moon phase} 2710 2711 \tbd{define planet functions} 2712 2713 \tbd{clean up FITS I/O issues} 2714 2715 \tbd{define Brent's method \& minimization bracketing} 2716 2227 2717 \appendix 2228 2718 \section{Change Log} … … 2230 2720 2231 2721 \end{document} 2232 2233 2234 \section{Modules}2235 2236 \subsection{Image Processing Modules}2237 \subsubsection{debias}2238 \subsubsection{mask}2239 \subsubsection{trim}2240 \subsubsection{flatten}2241 \subsubsection{sky/fringe subtract}2242 \subsubsection{warp}2243 \subsubsection{stack}2244 \subsubsection{difference}2245 \subsubsection{kernel convolution}2246 \subsubsection{special stack}2247 2248 \subsection{Object Detection Modules}2249 \subsubsection{find peaks}2250 \subsubsection{background }2251 \subsubsection{aperture photometry}2252 \subsubsection{get shape}2253 2254 \subsection{Miscellaneous Modules}2255 2256 \section{Analysis Stages}2257 \subsection{Phase 1}2258 \subsection{Phase 2}2259 \subsection{Phase 3}2260 \subsection{Phase 4}2261 \subsection{Cal 1}2262 \subsection{Cal 2}2263 \subsection{Cal 3}2264 \subsection{Astrom Ref}2265 \subsection{Photom Ref}2266 2267 \section{Architectual Components}2268
Note:
See TracChangeset
for help on using the changeset viewer.
