forked from ivoa-std/MOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappendix_algo.tex
102 lines (92 loc) · 3.86 KB
/
appendix_algo.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
\section{Suggested algorithms for basic operations}
Mapping a MOC to a unique sorted list of cells at the deepest
resolution order allows usage of very easy and very fast
algorithms. Basic operations such as unions or intersections can be
computed via bit shifts and simple dichotomic algorithms on sorted
lists. To reduce as much as possible the memory requirement, a good
practice is to store range sets of continuous cells [minValue
.. maxValue[, instead of individual cells.
\subsection{Union: moc1 $\cup$ moc2}
\begin{lstlisting}
Map moc1 to rangeList
Map moc2 in the same rangeList
Unmap the resulting rangeList
\end{lstlisting}
\subsection{Intersection: moc1 $\cap$ moc2}
\begin{lstlisting}
Map moc1 in rangeList1
foreach order/index of moc2
shift=2*(maxOrder-order)
append in a rangeList2 the intersection between
[index << shift .. index+1 << shift[
and the corresponding range(s) of rangeList1
Unmap rangeList2
\end{lstlisting}
\subsection{Map: moc To rangeList}
\begin{lstlisting}
foreach order/index of moc
shift=2*(maxOrder-order)
append in rangeList [index << shift , (index+1) << shift[
(the range overlapping must be adjusted)
\end{lstlisting}
\subsection{Unmap: rangeList To moc}
\begin{lstlisting}
for order = 0 to maxOrder
end if rangeList is empty
shift = 2*(maxOrder-order)
offset = (1<<shift) -1
foreach range [min..max[ of rangeList
append in moc order/index where index is in [m1 .. m2[
m1 = (min+offset) >> shift
m2 = max >> shift
remove from rangeList [m1<<shift .. m2<<shift[
\end{lstlisting}
\section{Basic HEALPix functions}
For generating space MOC from observations, or drawing them on the
sphere, an HEALPix library is required. The basic functions available
in all HEALPix libraries are the following :
\begin{itemize}
\item npix <= coordToNpix(order, alpha,delta) : returns the HEALPix
cell index containing the alpha,delta coordinates.
\item ArrayOfNpix <= queryDisc(order, alpha,delta,radius) : returns
the list of cell indices covering the (long,lat,radius) cone
\item ArrayOfNpix <= queryPolygon(order, alpha1,delta1, $\cdots$
alphaN,deltaN): returns the list of cell indices covering the
spherical polygon
\item (alpha,delta) <= NpixToCoord(order,npix) : returns the
coordinates of the center of order/npix cell.
\item ArrayOf(alpha,delta) <= NpixToCorners(order,npix) : returns
the corner coordinates of order/npix cell.
\end{itemize}
\section{Basic time functions}
For generating TMOC from observations, a time library might be required
to convert the dates are not expressed in JD TCB
\begin{itemize}
\item \url{http://www.iausofa.org/}
\item \url{http://javastro.github.io/jsofa/}
\item \url{https://docs.astropy.org/en/stable/time/#module-astropy.time}
\item Obtain the index from the JD: calculating the TMOC index from
a JD expressed as a double can be done by simple multiplication,
but will only allow millisecond accuracy around the present time
because of the conversion from double to long.
\begin{lstlisting}[language=C]
long getMicrosec(double jd) {
return (long)(jd*86400000000L);
}
\end{lstlisting}
To guarantee microsecond accuracy, a solution may be to use a second
parameter to indicate an origin expressed as a long integer from JD=0,
close to the observation dates, and to use the offsets of these
observations, expressed as double, from this new origin.
\begin{lstlisting}[language=C]
long getMicrosec(double offset, long origin) {
long x = (long)(offset*86400000000L);
return x + (origin*86400000000L);
}
\end{lstlisting}
%\begin{lstlisting}[language=C]
%static public long getMicrosec(double jd, long offset) {
% long micron = (long)(jd*DAYMICROSEC);
% return micron + (offset*86400000000L);
%}
\end{itemize}