Skip to content

Commit f916c76

Browse files
Merge pull request #196 from nlesc-dirac/cspice
Cspice integration
2 parents 9e85e86 + f8ca529 commit f916c76

27 files changed

Lines changed: 1020 additions & 84 deletions

CMakeLists.txt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,20 @@ pkg_check_modules(GLIB_PKG glib-2.0)
123123
if (GLIB_PKG_FOUND)
124124
include_directories(${GLIB_PKG_INCLUDE_DIRS})
125125
endif()
126+
127+
#CSPICE find if -DCSPICE_PREFIX=... given
128+
set(CSPICE_PREFIX
129+
""
130+
CACHE FILEPATH "Path to CSPICE install root")
131+
if(NOT "${CSPICE_PREFIX}" STREQUAL "")
132+
set(ENV{PKG_CONFIG_PATH} "${CSPICE_PREFIX}/lib/pkgconfig")
133+
pkg_search_module(CSPICE libcspice)
134+
endif()
135+
if(CSPICE_FOUND)
136+
message(STATUS "Found CSPICE: ${CSPICE_INCLUDE_DIRS}")
137+
include_directories(${CSPICE_INCLUDE_DIRS})
138+
add_definitions(-DHAVE_CSPICE)
139+
endif()
126140
#--------------------------------------- check environment variables
127141

128142
# Check pre-defined environment variables
@@ -181,8 +195,6 @@ message(STATUS "\n############################\n# Configuration summary\n#####
181195
message (STATUS "CMAKE_SYSTEM .............. = ${CMAKE_SYSTEM}")
182196
message (STATUS "CMAKE_INSTALL_PREFIX ...... = ${CMAKE_INSTALL_PREFIX}")
183197
message (STATUS "CMAKE_BUILD_TYPE .......... = ${CMAKE_BUILD_TYPE}")
184-
# message (STATUS "BUILD_SHARED_LIBS ......... = ${BUILD_SHARED_LIBS}")
185-
# message (STATUS "USE_STACKTRACE ............ = ${USE_STACKTRACE}")
186198
message (STATUS "CMAKE_CXX_COMPILER ........ = ${CMAKE_CXX_COMPILER}")
187199
message (STATUS "CMAKE_CXX_FLAGS_RELEASE ... = ${CMAKE_CXX_FLAGS_RELEASE}")
188200

@@ -224,11 +236,8 @@ message (STATUS "OpenBLAS_LIB .............. = ${OpenBLAS_LIB}")
224236
message (STATUS "GLIB_PKG_INCLUDE_DIRS...... = ${GLIB_PKG_INCLUDE_DIRS}")
225237
message (STATUS "GLIB_PKG_LIBRARIES......... = ${GLIB_PKG_LIBRARIES}")
226238

227-
#message (STATUS "LAPACK-INC ................ = ${LAPACK_INCLUDE_DIR}")
228239
message (STATUS "LAPACK_LIBRARIES........... = ${LAPACK_LIBRARIES}")
229240

230-
# message (STATUS "GFORTRAN-INC ............. = ${GFORTRAN_INCLUDE_DIR}")
231-
# message (STATUS "GFORTRAN-LIBS ............. = ${LIBGFORTRAN_LIBRARIES}")
232241
message (STATUS "CMAKE_Fortran_COMPILER..... = ${CMAKE_Fortran_COMPILER}")
233242

234243
message (STATUS "CFITSIO_ROOT_DIR........... = ${CFITSIO_ROOT_DIR}")
@@ -238,10 +247,6 @@ message (STATUS "CFITSIO_LIB................ = ${CFITSIO_LIB}")
238247
message (STATUS "WCSLIB_INCLUDE_DIRS........ = ${WCSLIB_INCLUDE_DIRS}")
239248
message (STATUS "WCSLIB_LIBRARIES .......... = ${WCSLIB_LIBRARIES}")
240249

241-
# message (STATUS "HDF5_INCLUDE_DIR........... = ${HDF5_INCLUDE_DIRS}")
242-
# message (STATUS "HDF5_LIBRARIES............. = ${HDF5_LIBRARIES}")
243-
244-
245250
#--------------------------------------- include directories
246251
add_subdirectory(src)
247252

INSTALL.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
do 15 jun 2023 14:23:00 CEST
1+
di 30 apr 2024 13:00:36 CEST
22
# SAGECal Installation
33

44
## Cmake Build
@@ -31,3 +31,7 @@ SAGECal can use ***libmvec*** vectorized math operations, both in GPU and CPU ve
3131
```
3232
cmake .. -DCMAKE_CXX_FLAGS='-g -O3 -Wall -ffast-math -lmvec -lm -mavx2' -DCMAKE_C_FLAGS='-g -O3 -Wall -ffast-math -lmvec -lm -mavx2'
3333
```
34+
35+
36+
### Linking with CSPICE
37+
See [linking with CSPICE](https://github.com/nlesc-dirac/sagecal/blob/cspice/scripts/CSPICE/README.md).

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
- Bandpass calibration and unprecedented RFI mitigation with stochastic LBFGS
1717
- Stochastic calibration for handling data at highest resolution (with federated averaging and consensus optimization)
1818
- Spectral and spatial regularization of calibration solutions
19+
- Large scale diffuse sky models via shapelet decomposition
20+
- Lunar frame interferometric simulation via the SPICE toolkit
1921

2022
Please read INSTALL.md for installation instructions, but 'cmake' should work in most cases. We give a brief guide to use SAGECal here but there is extensive documentation in the links at the end.
2123

scripts/CSPICE/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Installing CSPICE toolkit
2+
This document describes building the CSPICE toolkit to link with sagecal.
3+
4+
# Download
5+
Get the latest [cspice.tar.Z](https://naif.jpl.nasa.gov/pub/naif/toolkit//C/PC_Linux_GCC_64bit/packages/cspice.tar.Z)
6+
7+
```
8+
wget https://naif.jpl.nasa.gov/pub/naif/toolkit//C/PC_Linux_GCC_64bit/packages/cspice.tar.Z
9+
```
10+
11+
Extract the files
12+
13+
```
14+
tar xvf cspice.tar.Z
15+
```
16+
and there will be directory ```cspice```.
17+
18+
# Copy files
19+
Copy all files in this directory to the ```cspice``` directory.
20+
21+
```
22+
cp makeall.sh mkprodct.sh pkgconfig.stub /full_path_to/cspice/
23+
```
24+
25+
Note that ```/full_path_to/cspice/``` is the directory created by extracting cspice.tar.Z.
26+
27+
# Build
28+
In the ```cspice``` directory, run
29+
30+
```
31+
bash ./makeall.sh
32+
```
33+
and you are ready to link with sagecal.
34+
35+
36+
# Linking with sagecal
37+
Use cmake flag ```-DCSPICE_PREFIX=/full_path_to/cspice``` to point to ```cspice``` directory created after exctracting CSPICE.
38+
39+
40+
# Download kernels
41+
The following kernels are required.
42+
43+
```
44+
wget https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00011.tpc
45+
wget https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls
46+
wget https://naif.jpl.nasa.gov/pub/naif/generic_kernels/fk/satellites/moon_de440_220930.tf
47+
wget https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/moon_pa_de440_200625.bpc
48+
```
49+
50+
Download them and save them in a directory, and set your environment variable ```CSPICE_KERNEL_PATH``` to point to this directory before running sagecal.
51+
52+
zo 28 apr 2024 20:16:15 CEST

scripts/CSPICE/makeall.sh

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
echo This script builds the SPICE delivery
2+
echo for the cspice package of the toolkit.
3+
echo
4+
echo The script must be executed from the
5+
echo cspice directory.
6+
echo
7+
cd src
8+
echo
9+
echo Creating cspice
10+
echo
11+
cd cspice
12+
../../mkprodct.sh
13+
cd ..
14+
echo
15+
echo Creating csupport
16+
echo
17+
cd csupport
18+
../../mkprodct.sh
19+
cd ..
20+
echo
21+
echo Creating brief_c
22+
echo
23+
cd brief_c
24+
../../mkprodct.sh
25+
cd ..
26+
echo
27+
echo Creating chrnos_c
28+
echo
29+
cd chrnos_c
30+
../../mkprodct.sh
31+
cd ..
32+
echo
33+
echo Creating ckbref_c
34+
echo
35+
cd ckbref_c
36+
../../mkprodct.sh
37+
cd ..
38+
echo
39+
echo Creating commnt_c
40+
echo
41+
cd commnt_c
42+
../../mkprodct.sh
43+
cd ..
44+
echo
45+
echo Creating cook_c
46+
echo
47+
cd cook_c
48+
../../mkprodct.sh
49+
cd ..
50+
echo
51+
echo Creating dskbrief_c
52+
echo
53+
cd dskbrief_c
54+
../../mkprodct.sh
55+
cd ..
56+
echo
57+
echo Creating dskexp_c
58+
echo
59+
cd dskexp_c
60+
../../mkprodct.sh
61+
cd ..
62+
echo
63+
echo Creating frmdif_c
64+
echo
65+
cd frmdif_c
66+
../../mkprodct.sh
67+
cd ..
68+
echo
69+
echo Creating inspkt_c
70+
echo
71+
cd inspkt_c
72+
../../mkprodct.sh
73+
cd ..
74+
echo
75+
echo Creating mkdsk_c
76+
echo
77+
cd mkdsk_c
78+
../../mkprodct.sh
79+
cd ..
80+
echo
81+
echo Creating mkspk_c
82+
echo
83+
cd mkspk_c
84+
../../mkprodct.sh
85+
cd ..
86+
echo
87+
echo Creating msopck_c
88+
echo
89+
cd msopck_c
90+
../../mkprodct.sh
91+
cd ..
92+
echo
93+
echo Creating spacit_c
94+
echo
95+
cd spacit_c
96+
../../mkprodct.sh
97+
cd ..
98+
echo
99+
echo Creating spkdif_c
100+
echo
101+
cd spkdif_c
102+
../../mkprodct.sh
103+
cd ..
104+
echo
105+
echo Creating spkmrg_c
106+
echo
107+
cd spkmrg_c
108+
../../mkprodct.sh
109+
cd ..
110+
echo
111+
echo Creating tobin_c
112+
echo
113+
cd tobin_c
114+
../../mkprodct.sh
115+
cd ..
116+
echo
117+
echo Creating toxfr_c
118+
echo
119+
cd toxfr_c
120+
../../mkprodct.sh
121+
cd ..
122+
echo
123+
echo Creating versn_c
124+
echo
125+
cd versn_c
126+
../../mkprodct.sh
127+
cd ..
128+
cd ..
129+
echo Toolkit Build Complete
130+
131+
echo Making links
132+
cd ./lib && ln -s cspice.a libcspice.a && ln -s csupport.a libcsupport.a && cd ..
133+
echo Done making links
134+
135+
echo Making pkgconfig file
136+
mkdir -p ./lib/pkgconfig && echo "prefix=\"`pwd`\"" > ./lib/pkgconfig/libcspice.pc && cat pkgconfig.stub >> ./lib/pkgconfig/libcspice.pc
137+
echo Done making pkgconfig
138+
139+
echo All done

0 commit comments

Comments
 (0)