Unverified Commit 88ca48be authored by Kelvin Rodriguez's avatar Kelvin Rodriguez Committed by GitHub
Browse files

redid style, removed useless sites (#56)

* redid style, removed useless sites

* updated home

* removed unused paths
parent 26c1789b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@
#include <spdlog/spdlog.h>

int main(int argc, char **argv) {
   spdlog::set_level(spdlog::level::debug);
   spdlog::set_level(spdlog::level::trace);
   spdlog::set_pattern("SpiceQL-TESTS [%H:%M:%S %z] [%l] [%s@%# %!] %v"); 
   
   testing::Environment* const spiceql_env = testing::AddGlobalTestEnvironment(new TempTestingFiles);
+112 −68
Original line number Diff line number Diff line
# SpiceQL
---

hide:
  - navigation
  - toc
  - title
---

<style>
  .md-typeset h1,
  .md-content__button {
    display: none;
  }
</style>

![banner](assets/banner3.png)


This Library provides a C++ interface querying, reading and writing Naif SPICE kernels. Built on the [Naif Toolkit](https://naif.jpl.nasa.gov/naif/toolkit.html).

## Building The Library

The library leverages anaconda to maintain all of its dependencies. So in order to build SpiceQL, you'll need to have Anaconda installed.
## Getting Started

> **NOTE**:If you already have Anaconda installed, skip to step 3.
We reccomend installing using [miniforge](https://github.com/conda-forge/miniforge) 

1. Download either the Anaconda or Miniconda installation script for your OS platform. Anaconda is a much larger distribtion of packages supporting scientific python, while Miniconda is a minimal installation and not as large: Anaconda installer, Miniconda installer
1. If you are running on some variant of Linux, open a terminal window in the directory where you downloaded the script, and run the following commands. In this example, we chose to do a full install of Anaconda, and our OS is Linux-based. Your file name may be different depending on your environment.
   * If you are running Mac OS X, a pkg file (which looks similar to Anaconda3-5.3.0-MacOSX-x86_64.pkg) will be downloaded. Double-click on the file to start the installation process.
1. Open a Command line prompt and run the following commands:
```
mamba install -c conda-forge spiceql
```

To create the inital database, set your required environment variables. 

```bash 
# Clone the Github repo, note the recursive flag, this library depends on
# submodules that also need to be cloned. --recurse-submodules enables this and
# the -j8 flag parallelizes the cloning process.
git clone --recurse-submodules -j8 https://github.com/DOI-USGS/SpiceQL.git

# cd into repo dir
cd SpiceQL

# Create new environment from the provided dependency file, the -n flag is
# proceded by the name of the new environment, change this to whatever works for you
conda env create -f environment.yml -n ssdev

# activate the new env
conda activate ssdev

# make and cd into the build directory. This can be placed anywhere, but here, we make
# it in the repo (build is in .gitingore, so no issues there)
mkdir build
cd build

# Configure the project, install directory can be anything, here, it's the conda env
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX

# Optional: DB files are installed by default in $CONDA_PREFIX/etc/SpiceQL/db to 
# use files that are included within the repo, you must create and define 
# an environment variable named SSPICE_DEBUG. 
# note SSPICE_DEBUG can be set to anything as long as it is defined
export SSPICE_DEBUG=True

# Set the environment variable(s) to point to your kernel install 
# The following environment variables are used by default in order of priority: 
# $SPICEROOT, $ALESPICEROOT, $ISISDATA. 
# SPICEROOT is unique to this lib, while ALESPICEROOT, and ISISDATA are used 
# by both ALE and ISIS respectively. 
# note you can set each of these environment variables path to point to the
# correspoding kernels downloaded location, ie 
SPICEROOT=~/spiceQL/Kernals/spiceRootKernel
ALESPICEROOT=~/spiceQL/Kernals/aleSpiceRootKernel
ISISDATA=~/spiceQL/Kernals/isisData

# build and install project
make install

# Optional, Run tests
ctest -j8
# Path to some directory with kernels. SpiceQL searches for them recusively
export SPICEROOT="path/to/spice/kernels/"
# anywhere you have write permissions to
export SPICEQL_CACHE_DIR="path/to/cache/"
```

You can disable different components of the build by setting the CMAKE variables `SPICEQL_BUILD_DOCS`, `SPICEQL_BUILD_TESTS`, `SPICEQL_BUILD_BINDINGS`, or `SPICEQL_BUILD_LIB` to `OFF`. For example, the following cmake configuration command will not build the documentation or the tests:
Run `create_database()`, this is more easily done through python. 

!!! warning 
    This might take serveral hours depending on the number of kernels in your folder

```bash 
SPICEQL_LOG_LEVEL=INFO python -c "import pyspiceql; pyspiceql.create_database()"
```
cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX -DSPICEQL_BUILD_DOCS=OFF -DSPICEQL_BUILD_TESTS=OFF

### Basic usage

=== "Python"

    ```python 
    import pyspiceql as psql 

    # search for a kernel set
    kernels = psql.search_for_kernelsets(["odyssey", "mars"], ["sclk", "spk", "tspk", "ck"], 715662878.32324, 715663065.2303)
    print(kernels)


    # Make a query and it will return the kernels used 
    orientations, kernels = spql.getTargetOrientations([690201375.8323615], -74000, -74690, "ctx", searchKernels=True) 
    print(kernels)
    print(orientations)
    ```

## Bindings
=== "C++"

The SpiceQL API is available via Python bindings in the module `pyspiceql`. The bindings are built using SWIG and are on by default. You can disable the bindings in your build by setting `SPICEQL_BUILD_BINDINGS` to `OFF` when configuring your build.
    ```C++ 
    #include <spiceql/spiceql.h>
    #include <spiceql/inventory.h>
    #include <nlohmann/json.hpp>
    
    // search for a kernel set
    nlohmann::json kernels1 = SpiceQL::Inventory::search_for_kernelsets({"odyssey", "mars"}, {"sclk", "spk", "tspk", "ck"}, 715662878.32324, 715663065.2303);
    std::cout << kernels1.dump(2) << std::endl;
    
    // Make a query and it will return the kernels used 
    auto [orientations, kernels2] = SpiceQL::getTargetOrientations({690201375.8323615}, -74000, -74690, "ctx", {"smithed", "reconstructed"}, false, true);
    std::cout << kernels2.dump(2) << std::endl;
    // nx4 aray of quaternions 
    std::cout << orientations.size() << std::endl;
    ```

### Online Interface 

Some functions allow for running over the web, these contain the optional parameter `useWeb`. See the [function list](SpiceQLCPPAPI/namespace_spice_q_l.md) for a list of functions with this parameter. 

## Memoization Header Library 
=== "Python"

    ```python 
    import pyspiceql as psql 

    # Make a query and it will return the kernels used 
    orientations, kernels = spql.getTargetOrientations([690201375.8323615], -74000, -74690, "ctx", useWeb=True) 
    print(kernels)
    print(orientations)
    ```

SpiceQL has a simple memoization header only library at `Spiceql/include/memo.h`. This can cache function results on disk using a binary archive format mapped using a combined hash of a function ID and its input parameters. 
=== "C++"

TLDR 
    ```C++ 
#include "memo.h"
    #include <spiceql/spiceql.h>
    #include <nlohmann/json.hpp>
    
    // Make a query and it will return the kernels used 
    auto [orientations, kernels] = SpiceQL::getTargetOrientations({690201375.8323615}, -74000, -74690, "ctx", {"smithed", "reconstructed"}, true);
    std::cout << kernels.dump(2) << std::endl;
    // nx4 aray of quaternions 
    std::cout << orientations.size() << std::endl;
    ```

int func(int) { ... }
memoization::disk c("cache_path");
## Where to get NAIF kernels

// use case 1: wrap function call
// (function ID, the function to wrap and then params
int result1 = c("func_id", func, 3);
=== "downloadIsisData.py"
    
// use case 2: wrap function
// (cache object, function ID, function)
auto func_memoed = memoization::make_memoized(c, "func_id", func);
int result2 = func_memoed(3);
    `downloadIsisData.py` is a script that downloads from NAIF and USGS sources in parallel. It includes a SpiceQL database. 

assert(result1 == result2);
    ```bash
    # Install rclone 
    mamba install rclone
    
    # Download the script and rclone config file
    curl -LJO https://github.com/USGS-Astrogeology/ISIS3/raw/dev/isis/scripts/downloadIsisData
    curl -LJO https://github.com/USGS-Astrogeology/ISIS3/raw/dev/isis/config/rclone.conf
    
    # Use python 3 when you run the script,
    # and use --config to point to where you downloaded the config file 
    python3 downloadIsisData --config rclone.conf <mission> $SPICEROOT
    # set your cache dir to the same as SPICEROOT
    export SPICEQL_CACHE_DIR=$SPICEROOT
    ```

=== "Direct from NAIF" 

    Download data from [NAIF](https://naif.jpl.nasa.gov/naif/data_archived.html) 

    You can download using `wget` or similar application. 

+1 −1
Original line number Diff line number Diff line
@@ -31,4 +31,4 @@ dependencies:
    - mkdocs-swagger-ui-tag
    - mkdoxy
    - check-jsonschema
    - mkdocs-simple-blog
 No newline at end of file
    - mkdocs-material
 No newline at end of file
+39 −52
Original line number Diff line number Diff line
site_name: "SpiceQL Manual"

theme:
  name: simple-blog
  name: material
  palette:
    scheme: slate
  # favicon: assets/favicon.ico
  site_name_style: bold
  title_style: light 
  icon:
    annotation: material/chevron-right-circle
  font:
    text: Inter
    code: Roboto Mono
  colors:
    primary: blue
    title: black

  highlightjs: true
  components:
    site_name: true
    title: false
    menu: false
    preview: true
    footer: false

  features:
      - navigation.tabs
@@ -18,63 +27,41 @@ theme:
      - navigation.indexes
      - search.suggest
      - search.suggest
      - content.tabs.link

  palette:
      # Palette toggle for dark mode
      - media: "(prefers-color-scheme: dark)"
        scheme: slate
        primary: yellow
        accent: blue
        toggle:
          icon: material/toggle-switch-off-outline
          name: Switch to light mode

      # Palette toggle for light mode
      - media: "(prefers-color-scheme: light)"
        scheme: default
        primary: yellow
        accent: blue
        toggle:
          icon: material/toggle-switch
          name: Switch to dark mode
extra_css: 
  - assets/extra.css

nav:
  - Home: index.md
  - C++ API:
      - SpiceQL C++ API:
          - 'Links': 'SpiceQLCPPAPI/links.md'
          - 'Classes':
              - 'Class List': 'SpiceQLCPPAPI/annotated.md'
              - 'Class Index': 'SpiceQLCPPAPI/classes.md'
              - 'Class Hierarchy': 'SpiceQLCPPAPI/hierarchy.md'
              - 'Class Members': 'SpiceQLCPPAPI/class_members.md'
              - 'Class Member Functions': 'SpiceQLCPPAPI/class_member_functions.md'
              - 'Class Member Variables': 'SpiceQLCPPAPI/class_member_variables.md'
              - 'Class Member Typedefs': 'SpiceQLCPPAPI/class_member_typedefs.md'
              - 'Class Member Enumerations': 'SpiceQLCPPAPI/class_member_enums.md'
  - index.md
  - "[ C++ API ]":
      - 'Namespaces':
          - 'Namespace List': 'SpiceQLCPPAPI/namespaces.md'
              - 'Namespace Members': 'SpiceQLCPPAPI/namespace_members.md'
              - 'Namespace Member Functions': 'SpiceQLCPPAPI/namespace_member_functions.md'
              - 'Namespace Member Variables': 'SpiceQLCPPAPI/namespace_member_variables.md'
              - 'Namespace Member Typedefs': 'SpiceQLCPPAPI/namespace_member_typedefs.md'
              - 'Namespace Member Enumerations': 'SpiceQLCPPAPI/namespace_member_enums.md'
          - 'Variables': 'SpiceQLCPPAPI/variables.md'
          - 'Macros': 'SpiceQLCPPAPI/macros.md'
          - 'Files': 'SpiceQLCPPAPI/files.md'
  - RESTful API: 
      - SpiceQL RESTful API: 
          - 'Home': 'RestAPI.md' 

          - 'Functions': 'SpiceQLCPPAPI/namespace_member_functions.md'
  - "[ RESTful API ]": 
      - 'OpenAPI Docs': 'RestAPI.md' 
  - "[ USGS Astrogeology Docs ]" : https://astrogeology.usgs.gov/docs/

markdown_extensions:
  - pymdownx.highlight:
      anchor_linenums: true
  - pymdownx.superfences
  - pymdownx.caret
  - pymdownx.mark
  - pymdownx.tilde
  - admonition
  - pymdownx.details
  - pymdownx.superfences 
  - pymdownx.tabbed:
      alternate_style: true
plugins:
  - search
  - swagger-ui-tag
  - mkdoxy:
      projects:
        SpiceQLCPPAPI: 
          src-dirs: SpiceQL/src/ SpiceQL/include/  
          src-dirs: SpiceQL/include/
          FILE_PATTERNS: 'api.h inventory.h'  
          full-doc: True # if you want to generate full documentation
          doxy-cfg: # standard doxygen configuration (key: value)
            FILE_PATTERNS: "*.cpp *.h*" # specify file patterns to filter out
            RECURSIVE: True # recursive search in source directories
            RECURSIVE: false # recursive search in source directories