Skip to content

Commit

Permalink
Merge pull request #196 from nlesc-dirac/cspice
Browse files Browse the repository at this point in the history
Cspice integration
  • Loading branch information
SarodYatawatta authored May 1, 2024
2 parents 9e85e86 + f8ca529 commit f916c76
Show file tree
Hide file tree
Showing 27 changed files with 1,020 additions and 84 deletions.
23 changes: 14 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ pkg_check_modules(GLIB_PKG glib-2.0)
if (GLIB_PKG_FOUND)
include_directories(${GLIB_PKG_INCLUDE_DIRS})
endif()

#CSPICE find if -DCSPICE_PREFIX=... given
set(CSPICE_PREFIX
""
CACHE FILEPATH "Path to CSPICE install root")
if(NOT "${CSPICE_PREFIX}" STREQUAL "")
set(ENV{PKG_CONFIG_PATH} "${CSPICE_PREFIX}/lib/pkgconfig")
pkg_search_module(CSPICE libcspice)
endif()
if(CSPICE_FOUND)
message(STATUS "Found CSPICE: ${CSPICE_INCLUDE_DIRS}")
include_directories(${CSPICE_INCLUDE_DIRS})
add_definitions(-DHAVE_CSPICE)
endif()
#--------------------------------------- check environment variables

# Check pre-defined environment variables
Expand Down Expand Up @@ -181,8 +195,6 @@ message(STATUS "\n############################\n# Configuration summary\n#####
message (STATUS "CMAKE_SYSTEM .............. = ${CMAKE_SYSTEM}")
message (STATUS "CMAKE_INSTALL_PREFIX ...... = ${CMAKE_INSTALL_PREFIX}")
message (STATUS "CMAKE_BUILD_TYPE .......... = ${CMAKE_BUILD_TYPE}")
# message (STATUS "BUILD_SHARED_LIBS ......... = ${BUILD_SHARED_LIBS}")
# message (STATUS "USE_STACKTRACE ............ = ${USE_STACKTRACE}")
message (STATUS "CMAKE_CXX_COMPILER ........ = ${CMAKE_CXX_COMPILER}")
message (STATUS "CMAKE_CXX_FLAGS_RELEASE ... = ${CMAKE_CXX_FLAGS_RELEASE}")

Expand Down Expand Up @@ -224,11 +236,8 @@ message (STATUS "OpenBLAS_LIB .............. = ${OpenBLAS_LIB}")
message (STATUS "GLIB_PKG_INCLUDE_DIRS...... = ${GLIB_PKG_INCLUDE_DIRS}")
message (STATUS "GLIB_PKG_LIBRARIES......... = ${GLIB_PKG_LIBRARIES}")

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

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

message (STATUS "CFITSIO_ROOT_DIR........... = ${CFITSIO_ROOT_DIR}")
Expand All @@ -238,10 +247,6 @@ message (STATUS "CFITSIO_LIB................ = ${CFITSIO_LIB}")
message (STATUS "WCSLIB_INCLUDE_DIRS........ = ${WCSLIB_INCLUDE_DIRS}")
message (STATUS "WCSLIB_LIBRARIES .......... = ${WCSLIB_LIBRARIES}")

# message (STATUS "HDF5_INCLUDE_DIR........... = ${HDF5_INCLUDE_DIRS}")
# message (STATUS "HDF5_LIBRARIES............. = ${HDF5_LIBRARIES}")


#--------------------------------------- include directories
add_subdirectory(src)

Expand Down
6 changes: 5 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
do 15 jun 2023 14:23:00 CEST
di 30 apr 2024 13:00:36 CEST
# SAGECal Installation

## Cmake Build
Expand Down Expand Up @@ -31,3 +31,7 @@ SAGECal can use ***libmvec*** vectorized math operations, both in GPU and CPU ve
```
cmake .. -DCMAKE_CXX_FLAGS='-g -O3 -Wall -ffast-math -lmvec -lm -mavx2' -DCMAKE_C_FLAGS='-g -O3 -Wall -ffast-math -lmvec -lm -mavx2'
```


### Linking with CSPICE
See [linking with CSPICE](https://github.com/nlesc-dirac/sagecal/blob/cspice/scripts/CSPICE/README.md).
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
- Bandpass calibration and unprecedented RFI mitigation with stochastic LBFGS
- Stochastic calibration for handling data at highest resolution (with federated averaging and consensus optimization)
- Spectral and spatial regularization of calibration solutions
- Large scale diffuse sky models via shapelet decomposition
- Lunar frame interferometric simulation via the SPICE toolkit

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.

Expand Down
52 changes: 52 additions & 0 deletions scripts/CSPICE/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Installing CSPICE toolkit
This document describes building the CSPICE toolkit to link with sagecal.

# Download
Get the latest [cspice.tar.Z](https://naif.jpl.nasa.gov/pub/naif/toolkit//C/PC_Linux_GCC_64bit/packages/cspice.tar.Z)

```
wget https://naif.jpl.nasa.gov/pub/naif/toolkit//C/PC_Linux_GCC_64bit/packages/cspice.tar.Z
```

Extract the files

```
tar xvf cspice.tar.Z
```
and there will be directory ```cspice```.

# Copy files
Copy all files in this directory to the ```cspice``` directory.

```
cp makeall.sh mkprodct.sh pkgconfig.stub /full_path_to/cspice/
```

Note that ```/full_path_to/cspice/``` is the directory created by extracting cspice.tar.Z.

# Build
In the ```cspice``` directory, run

```
bash ./makeall.sh
```
and you are ready to link with sagecal.


# Linking with sagecal
Use cmake flag ```-DCSPICE_PREFIX=/full_path_to/cspice``` to point to ```cspice``` directory created after exctracting CSPICE.


# Download kernels
The following kernels are required.

```
wget https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/pck00011.tpc
wget https://naif.jpl.nasa.gov/pub/naif/generic_kernels/lsk/naif0012.tls
wget https://naif.jpl.nasa.gov/pub/naif/generic_kernels/fk/satellites/moon_de440_220930.tf
wget https://naif.jpl.nasa.gov/pub/naif/generic_kernels/pck/moon_pa_de440_200625.bpc
```

Download them and save them in a directory, and set your environment variable ```CSPICE_KERNEL_PATH``` to point to this directory before running sagecal.

zo 28 apr 2024 20:16:15 CEST
139 changes: 139 additions & 0 deletions scripts/CSPICE/makeall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
echo This script builds the SPICE delivery
echo for the cspice package of the toolkit.
echo
echo The script must be executed from the
echo cspice directory.
echo
cd src
echo
echo Creating cspice
echo
cd cspice
../../mkprodct.sh
cd ..
echo
echo Creating csupport
echo
cd csupport
../../mkprodct.sh
cd ..
echo
echo Creating brief_c
echo
cd brief_c
../../mkprodct.sh
cd ..
echo
echo Creating chrnos_c
echo
cd chrnos_c
../../mkprodct.sh
cd ..
echo
echo Creating ckbref_c
echo
cd ckbref_c
../../mkprodct.sh
cd ..
echo
echo Creating commnt_c
echo
cd commnt_c
../../mkprodct.sh
cd ..
echo
echo Creating cook_c
echo
cd cook_c
../../mkprodct.sh
cd ..
echo
echo Creating dskbrief_c
echo
cd dskbrief_c
../../mkprodct.sh
cd ..
echo
echo Creating dskexp_c
echo
cd dskexp_c
../../mkprodct.sh
cd ..
echo
echo Creating frmdif_c
echo
cd frmdif_c
../../mkprodct.sh
cd ..
echo
echo Creating inspkt_c
echo
cd inspkt_c
../../mkprodct.sh
cd ..
echo
echo Creating mkdsk_c
echo
cd mkdsk_c
../../mkprodct.sh
cd ..
echo
echo Creating mkspk_c
echo
cd mkspk_c
../../mkprodct.sh
cd ..
echo
echo Creating msopck_c
echo
cd msopck_c
../../mkprodct.sh
cd ..
echo
echo Creating spacit_c
echo
cd spacit_c
../../mkprodct.sh
cd ..
echo
echo Creating spkdif_c
echo
cd spkdif_c
../../mkprodct.sh
cd ..
echo
echo Creating spkmrg_c
echo
cd spkmrg_c
../../mkprodct.sh
cd ..
echo
echo Creating tobin_c
echo
cd tobin_c
../../mkprodct.sh
cd ..
echo
echo Creating toxfr_c
echo
cd toxfr_c
../../mkprodct.sh
cd ..
echo
echo Creating versn_c
echo
cd versn_c
../../mkprodct.sh
cd ..
cd ..
echo Toolkit Build Complete

echo Making links
cd ./lib && ln -s cspice.a libcspice.a && ln -s csupport.a libcsupport.a && cd ..
echo Done making links

echo Making pkgconfig file
mkdir -p ./lib/pkgconfig && echo "prefix=\"`pwd`\"" > ./lib/pkgconfig/libcspice.pc && cat pkgconfig.stub >> ./lib/pkgconfig/libcspice.pc
echo Done making pkgconfig

echo All done
Loading

0 comments on commit f916c76

Please sign in to comment.