Skip to content

Instantly share code, notes, and snippets.

View translunar's full-sized avatar

Dr. Juno Woods translunar

View GitHub Profile
from spice_helpers import *
load_kernels()
spice.furnsh(['kernels/ndosl_140530_v01.tf',
'kernels/ndosl_140530_v01.bsp'])
et = spice.utc2et("2021 JUL 22 20:06:47") # get ephemeris time
station = 'NDOSL_AG33'
station_ecef = spice.spkezr(tracker, et, 'ITRF93', 'NONE', 'EARTH')[0][0:3]
# -3700: NOVA-C (for 3700 Bay Area Blvd)
# 399: Earth
# J2000: inertial frame
x_eci = spice.spkez(-3700, et, 'J2000', 'NONE', 399)[0]
x_lci = spice.spkez(-3700, et, 'J2000', 'NONE', 301)[0]
# contains position and velocity information in an np array
# Get 3x3 DCM for position only
Tr_inrtl_to_body = spice.pxform('J2000', 'NOVAC_SPACECRAFT', et)
import numpy as np
from spiceypy import spiceypy as spice
r_lclf = spice.georec(lon, lat, 0.0, r_eq, f)
normal = spice.latrec(1.0, lon, lat)
topo_xform = spice.twovec(normal, 3, np.array([0.0, 0.0, 1.0]), 1)
# Get sun state relative to topo frame
x_sun, lt = spice.spkcpo('SUN', et, 'MOON_ME', 'OBSERVER', 'NONE', r_lclf, 'MOON', 'MOON_ME')
import numpy as np
from spiceypy import spiceypy as spice
r_lclf = spice.georec(lon, lat, 0.0, r_eq, f)
normal = spice.latrec(1.0, lon, lat)
topo_xform = spice.twovec(normal, 3, np.array([0.0, 0.0, 1.0]), 1)
# Get sun state relative to topo frame
x_sun, lt = spice.spkcpo('SUN', et, 'MOON_ME', 'OBSERVER', 'NONE', r_lclf, 'MOON', 'MOON_ME')
from spice_helpers import *
if len(get_loaded_kernels()) == 0:
load_kernels() # loads relevant solar system kernels, which never change
# Load data product kernels for NOVA-C, which change fairly frequently:
spice.furnsh(['kernels/full_trajectory_ish.spk', # SPK = reference trajectory
'kernels/full_trajectory_ish.ck', # CK = reference attitudes
'kernels/nova-c.fk', # FK = frame kernels (instruments)
'kernels/nova-c_structures.spk', # instrument locations
# body 301 is the moon (note: bodvrd allows 'MOON' instead of 301)
mu = spice.bodvcd(301, 'GM', 1)[1][0] # gravity
req = spice.bodvcd(301, 'RADII', 3)[1][0] # equatorial radius
rpol = spice.bodvcd(301, 'RADII', 3)[1][2] # polar radius
f = (req - rpol) / req # first flattening
# Rectangular to geodetic coordinates (radians is default)
lon, lat, alt = spice.recgeo(r_lclf, req, f)
# Geodetic to rectangular coordinates
from spiceypy import spiceypy as spice
# Tell SPICE where to look for things
spice.furnsh(['de432s.bsp', # planet pos/vels 1950-2050
'pck00010.tpc', # radii and orientations
'naif0012.tls', # leap-seconds
'de-403-masses.tpc', # mu
'earthstns_itrf93_050714.bsp', # ground station locations
'earth_070425_370426_predict.bpc', # earth orientation 2007-2037
'moon_080317.tf']) # MOON_ME frame (LCLF)
@translunar
translunar / output.txt
Created February 26, 2016 15:20
Comparing Ruby string concatenations
t1 = 0.0185549259185791
t2 = 0.01390695571899414
t3 = 0.05935215950012207
%==============================================================================
% Beamer style for the poster template posted at
% www.nathanieljohnston.com/index.php/2009/08/latex-poster-template
%
% Created by the Computational Physics and Biophysics Group at Jacobs University
% https://teamwork.jacobs-university.de:8443/confluence/display/CoPandBiG/LaTeX+Poster
% Modified by Nathaniel Johnston (nathaniel@nathanieljohnston.com) in August 2009
% =============================================================================
\ProvidesPackage{beamerthemeMWEConfPoster}
@translunar
translunar / extconf.rb
Created March 5, 2015 21:45
Example of C and Ruby interfacing
require "mkmf"
$srcs = [
'hypergeometric.c'
]
#if have_header("gsl/gsl_sf_exp.h", ["/usr/local/Cellar/gsl/1.15/include/"])
# have_library("gsl")
#end