Skip to content

ISD to Kernel support#116

Open
chkim-usgs wants to merge 11 commits intoDOI-USGS:mainfrom
chkim-usgs:isd_to_kern
Open

ISD to Kernel support#116
chkim-usgs wants to merge 11 commits intoDOI-USGS:mainfrom
chkim-usgs:isd_to_kern

Conversation

@chkim-usgs
Copy link
Copy Markdown
Collaborator

@chkim-usgs chkim-usgs commented Apr 1, 2026

Supports ALE's ISD to Kernel PR

writeCkFromBuffers() and ck_writer.py was created to bypass SWIG so there is no conversion hang. I ran into the hang when calling pyspiceql.writeCk() with an ISD that had around 1500 quaternions.

A check was added to writeSpk() to see if there is only one state, meaning the same start and stop time (e.g., tests/pytest/isds/mexsrc_isd.json). A padding of 1E-6 was added to create a valid stop time but let me know if the value should be different or this should be addressed another way.

Licensing

This project is mostly composed of free and unencumbered software released into the public domain, and we are unlikely to accept contributions that are not also released into the public domain. Somewhere near the top of each file should have these words:

This work is free and unencumbered software released into the public domain. In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain.

  • I dedicate any and all copyright interest in this software to the public domain. I make this dedication for the benefit of the public at large and to the detriment of my heirs and successors. I intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

Comment on lines +1 to +9
import ctypes
import numpy as np
import os
import sys

def _find_lib():
# Load library
try:
from . import _pyspiceql as mod
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mention you did this to avoid latency, which is valid, but how bad was the latency? It will be awkward having a single function exposed this way.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The kernel would crash in a Jupyter Notebook but I'll check it out again.

Copy link
Copy Markdown
Collaborator Author

@chkim-usgs chkim-usgs Apr 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the isd_to_kernel script to use writeCk() and tested with ALE's tests/pytest/data/isds/mexhrsc_isd.json which has ~1500 quats. It works randomly(?) and when it fails this is the error message RuntimeError: std::exception: Error Occured:SPICE(ZEROQUATERNION) The quaternion at index 1133 has magnitude zero.. The index value changes sometimes but the output seems inconsistent.

Comment on lines +383 to +398
namespace {
thread_local std::string g_writeCkFromBuffersLastError;

std::vector<std::string> split(const std::string& s, char delim) {
std::vector<std::string> out;
std::istringstream ss(s);
std::string part;
while (std::getline(ss, part, delim)) {
auto start = part.find_first_not_of(" \t");
if (start == std::string::npos) continue;
auto end = part.find_last_not_of(" \t");
out.push_back(part.substr(start, end == std::string::npos ? part.size() : end - start + 1));
}
return out;
}
}
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why an anonymous namespace?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was debating on a name and I just forgot, I can name it helper.

@Kelvinrr
Copy link
Copy Markdown
Collaborator

Kelvinrr commented Apr 1, 2026

wrt to only having one time, I can't think of a better solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants