Skip to content

Commit

Permalink
added stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ljrobins committed Jan 28, 2024
1 parent c5788f9 commit 4b9e65e
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 31 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean test all install docs
.PHONY: clean test all install docs stubs

install:
source bin/activate && pip install -e .
Expand All @@ -11,9 +11,12 @@ test:
pytest tests/*.py

sphinx:
cd docs && make html
cd docs && sphinx-apidoc -o ./source ../src -f && make html

start-runner:
actions-runner/run.sh

all: clean install test
stubs:
pybind11-stubgen gravitas --numpy-array-remove-parameters --ignore-all-errors --output-dir src

all: clean install sphinx
6 changes: 6 additions & 0 deletions docs/source/_generate/gravitas.earth_acceleration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gravitas.earth\_acceleration
============================

.. currentmodule:: gravitas

.. autofunction:: earth_acceleration
6 changes: 6 additions & 0 deletions docs/source/_generate/gravitas.moon_acceleration.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gravitas.moon\_acceleration
===========================

.. currentmodule:: gravitas

.. autofunction:: moon_acceleration
9 changes: 6 additions & 3 deletions docs/source/gravitas.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
gravitas
========
gravitas module
===============

.. automodule:: gravitas
.. automodule:: gravitas
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
src
===

.. toctree::
:maxdepth: 4

gravitas
55 changes: 34 additions & 21 deletions src/gravitas.pyi
Original file line number Diff line number Diff line change
@@ -1,26 +1,39 @@
from typing import Any
from numpy import ndarray
"""
def earth_acceleration(r_ecef_km: ndarray, nmax: int) -> float:
"""Acceleration due to the Earth's gravity field, as defined by the EGM96 model.
Pybind11 example plugin
-----------------------
:param r_ecef_km: Position in ECEF coordinates, in km.
:type r_ecef_km: ndarray [nx3]
:param nmax: Maximum degree of the spherical harmonic expansion, 0 <= nmax <= 360.
:type nmax: int
:return: Acceleration in ECEF coordinates, in km/s^2.
:rtype: float
"""
pass
.. currentmodule:: gravitas
def moon_acceleration(r_mcmf_km: ndarray, nmax: int) -> float:
"""Acceleration due to the Earth's gravity field, as defined by the GRGM360 model produced by the GRAIL mission.
.. autosummary::
:toctree: _generate
:param r_mcmf_km: Position in MCMF coordinates, in km.
:type r_mcmf_km: ndarray [nx3]
:param nmax: Maximum degree of the spherical harmonic expansion, 0 <= nmax <= 360.
:type nmax: int
:return: Acceleration in MCMF coordinates, in km/s^2.
:rtype: float
earth_acceleration
moon_acceleration
"""
from __future__ import annotations
import numpy
__all__ = ['earth_acceleration', 'moon_acceleration']
def earth_acceleration(arg0: numpy.ndarray, arg1: int) -> numpy.ndarray:
"""
Acceleration due to the Earth's gravity field, as defined by the EGM96 model.
:param r_ecef_km: Position in ECEF coordinates, in km.
:type r_ecef_km: ndarray [nx3]
:param nmax: Maximum degree of the spherical harmonic expansion, 0 <= nmax <= 360.
:type nmax: int
:return: Acceleration in ECI coordinates, in km/s^2.
:rtype: float
"""
def moon_acceleration(arg0: numpy.ndarray, arg1: int) -> numpy.ndarray:
"""
Acceleration due to the Moon's gravity field, as defined by the GRGM360 model.
:param r_mcmf_km: Position in MCMF coordinates, in km.
:type r_mcmf_km: ndarray [nx3]
:param nmax: Maximum degree of the spherical harmonic expansion, 0 <= nmax <= 360.
:type nmax: int
:return: Acceleration in MCI coordinates, in km/s^2.
:rtype: float
"""
pass
1 change: 1 addition & 0 deletions src/libgrav.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Eigen::MatrixXd acceleration(Eigen::MatrixXd r_ecef, char* model_name, int nmax)
}

Eigen::MatrixXd earth_acceleration(Eigen::MatrixXd r_ecef, int nmax) {

char model_name[] = "EGM96";
return acceleration(r_ecef, model_name, nmax);
}
Expand Down
26 changes: 22 additions & 4 deletions src/python_bindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,27 @@ PYBIND11_MODULE(gravitas, m) {
.. autosummary::
:toctree: _generate
add
subtract
earth_acceleration
moon_acceleration
)pbdoc";
m.def("earth_acceleration", &earth_acceleration, "A function that returns the acceleration of a body due to a gravity model");
m.def("moon_acceleration", &moon_acceleration, "A function that returns the acceleration of a body due to a gravity model");
m.def("earth_acceleration", &earth_acceleration, R"mydelimiter(
Acceleration due to the Earth's gravity field, as defined by the EGM96 model.
:param r_ecef_km: Position in ECEF coordinates, in km.
:type r_ecef_km: ndarray [nx3]
:param nmax: Maximum degree of the spherical harmonic expansion, 0 <= nmax <= 360.
:type nmax: int
:return: Acceleration in ECI coordinates, in km/s^2.
:rtype: float
)mydelimiter");
m.def("moon_acceleration", &moon_acceleration, R"mydelimiter(
Acceleration due to the Moon's gravity field, as defined by the GRGM360 model.
:param r_mcmf_km: Position in MCMF coordinates, in km.
:type r_mcmf_km: ndarray [nx3]
:param nmax: Maximum degree of the spherical harmonic expansion, 0 <= nmax <= 360.
:type nmax: int
:return: Acceleration in MCI coordinates, in km/s^2.
:rtype: float
)mydelimiter");
}

0 comments on commit 4b9e65e

Please sign in to comment.