Skip to content

Commit

Permalink
docstrings from python native files must be rendered on the API docs …
Browse files Browse the repository at this point in the history
…website
  • Loading branch information
niketagrawal committed Oct 1, 2024
1 parent 88fcab0 commit 30e25ab
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 42 deletions.
11 changes: 6 additions & 5 deletions docs/source/ephemeris.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ ephemeris models of celestial bodies in an environment. Below a short
overview of aspects of some of the ephemeris models in order to aid in
properly selecting an choosing a model.

**Spice-based models** For many typical applications, natural body ephemerides
will be calculated from `Spice kernels <https://docs.tudat.space/en/latest/_src_user_guide/state_propagation/environment_setup/default_env_models.html#spice-in-tudat>`_.
In some cases, a user may find that the default Spice kernels are insufficient
**Spice-based models** For many typical applications, natural body ephemerides
will be calculated from `Spice kernels <https://docs.tudat.space/en/latest/_src_user_guide/state_propagation/environment_setup/default_env_models.html#spice-in-tudat>`_.
In some cases, a user may find that the default Spice kernels are insufficient
for their purposes, due to one of two reasons:

* The body for which the state is required *is* in the ephemeris Spice kernel, but the time at which the state is needed lies outside of the bounds for which the Spice kernel has data
Expand Down Expand Up @@ -36,7 +36,7 @@ inertial Cartesian state elements produced by the ephemeris.
where the ``epoch`` input is (as always in Tudat) the time in seconds since J2000. The ``earth_state_at_epoch`` is always in a frame with inertial orientation. The specific orientation and origin can be access from the :attr:`~tudatpy.numerical_simulation.environment.Ephemeris.frame_orientation` and :attr:`~tudatpy.numerical_simulation.environment.Ephemeris.frame_origin` attributes.


* jpl_horizons (:func:`~tudatpy.numerical_simulation.environment_setup.ephemeris.horizons_wrapper.jpl_horizons`)



Expand Down Expand Up @@ -77,6 +77,7 @@ Functions

tabulated_from_existing

horizons_wrapper.jpl_horizons


.. autofunction:: tudatpy.numerical_simulation.environment_setup.ephemeris.direct_spice
Expand All @@ -103,7 +104,7 @@ Functions

.. autofunction:: tudatpy.numerical_simulation.environment_setup.ephemeris.tabulated_from_existing


.. autofunction:: tudatpy.numerical_simulation.environment_setup.ephemeris.horizons_wrapper.jpl_horizons



Expand Down
7 changes: 6 additions & 1 deletion docs/source/gravity_field.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Rigid body properties will always be created automatically when a body is endowe
* Spherical harmonic gravity field: mass computed from gravitational parameter, center of mass computed from degree 1 gravity field coefficients, inertia tensor as described in :func:`~tudatpy.numerical_simulation.environment_setup.gravity_field.spherical_harmonic`
* Polyhedron gravity field: mass computed from gravitational parameter, center of mass and inertia tensor computed from homogeneous mas distribution inside body


* sbdb_wrapper (:func:`~tudatpy.numerical_simulation.environment_setup.gravity_field.sbdb_wrapper.central_sbdb`)



Expand Down Expand Up @@ -59,6 +59,9 @@ Functions

polyhedron_from_density

sbdb_wrapper.central_sbdb

sbdb_wrapper.central_sbdb_density


.. autofunction:: tudatpy.numerical_simulation.environment_setup.gravity_field.central
Expand All @@ -79,7 +82,9 @@ Functions

.. autofunction:: tudatpy.numerical_simulation.environment_setup.gravity_field.polyhedron_from_density

.. autofunction:: tudatpy.numerical_simulation.environment_setup.gravity_field.sbdb_wrapper.central_sbdb

.. autofunction:: tudatpy.numerical_simulation.environment_setup.gravity_field.sbdb_wrapper.central_sbdb_density


Enumerations
Expand Down
12 changes: 7 additions & 5 deletions docs/source/propagation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Functionalities and utilities of propagation objects.

This module provides functionalities for propagation settings
objects. It also contains some utility functions that extract specific quantities from propagation settings and body
objects. Note that the classes in this module are rarely created manually,
but are instead created by the functionality in the :ref:`\`\`propagation_setup\`\`` module.
objects. Note that the classes in this module are rarely created manually,
but are instead created by the functionality in the :ref:`\`\`propagation_setup\`\`` module.



Expand All @@ -30,15 +30,15 @@ Functions

combine_initial_states


dependent_variable_dictionary.dependent_variable_dictionary.create_dependent_variable_dictionary

.. autofunction:: tudatpy.numerical_simulation.propagation.get_state_of_bodies

.. autofunction:: tudatpy.numerical_simulation.propagation.get_damped_proper_mode_initial_rotational_state

.. autofunction:: tudatpy.numerical_simulation.propagation.combine_initial_states


.. autofunction:: tudatpy.numerical_simulation.propagation.dependent_variable_dictionary.dependent_variable_dictionary.create_dependent_variable_dictionary


Enumerations
Expand Down Expand Up @@ -73,6 +73,7 @@ Classes

RotationalProperModeDampingResults

dependent_variable_dictionary.dependent_variable_dictionary.DependentVariableDictionary


.. autoclass:: tudatpy.numerical_simulation.propagation.SimulationResults
Expand All @@ -90,5 +91,6 @@ Classes
.. autoclass:: tudatpy.numerical_simulation.propagation.RotationalProperModeDampingResults
:members:


.. autoclass:: tudatpy.numerical_simulation.propagation.dependent_variable_dictionary.dependent_variable_dictionary.DependentVariableDictionary
:members:

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'''
'''
Copyright (c) 2010-2023, Delft University of Technology
All rigths reserved
This file is part of the Tudat. Redistribution and use in source and
This file is part of the Tudat. Redistribution and use in source and
binary forms, with or without modification, are permitted exclusively
under the terms of the Modified BSD license. You should have received
a copy of the license with this file. If not, please or visit:
Expand Down Expand Up @@ -36,7 +36,7 @@ class DependentVariableDictionary(dict):
propagation_setup.dependent_variable.total_acceleration("Delfi-C3")
]
```
Example usage:
--------------
Expand All @@ -54,7 +54,7 @@ class DependentVariableDictionary(dict):
# Create DependentVariableDictionary
dep_vars_dict = result2dict(dynamics_simulator)
# Retrieve the time history (in `dict[epoch: value]` form) of the total acceleration experienced by Delft-C3
total_acceleration_history = dep_vars_dict[
# This can be done using either the `SingleAccelerationDependentVariableSaveSettings`
Expand All @@ -71,26 +71,26 @@ class DependentVariableDictionary(dict):
-----------------------------------------------------------
A `DependentVariableDictionary` maps which maps dependent variables, identified by either their
corresponding dependent variable settings object (an instance of a `VariableSettings`-derived
corresponding dependent variable settings object (an instance of a `VariableSettings`-derived
class) or its string ID, to their time histories.
The time history of each dependent variable is a Python `dict` which maps epochs (`float`) to
NumPy arrays (`np.ndarray`) of shape `(A, B)`:
dict[epoch: np.ndarray[A, B]]
**Important**: in `(A, B)`, we remove singleton/trivial dimensions (dimensions, `A` or `B`, of size 1).
In the case of scalar dependent variables, the value associated to each epoch is a `np.ndarray` of shape `(1,)`.
In the case of vectorial dependent variables, it is a **row** vector of size `(A,)`. This is done by using
**Important**: in `(A, B)`, we remove singleton/trivial dimensions (dimensions, `A` or `B`, of size 1).
In the case of scalar dependent variables, the value associated to each epoch is a `np.ndarray` of shape `(1,)`.
In the case of vectorial dependent variables, it is a **row** vector of size `(A,)`. This is done by using
`np.squeeze` to remove any dimensions of size 1. Practical examples:
Dimensions of dependent variable values associated to each epoch based on their type:
+-----------+-------------+
| Data Type | Shape |
+===========+=============+
+-----------+-------------+
| Data Type | Shape |
+===========+=============+
| Scalar | `(1,)` |
| Vectorial | `(3,)` |
| Vectorial | `(3,)` |
| Matrix | `(A, B)` |
| Tensor | `(A, B, C)` |
+===========+=============+
Expand All @@ -103,7 +103,7 @@ def __read_key(self, key: VariableSettings):
* If the `key` is an instance of a `VariableSettings`-derived class, return the
object's string ID, obtained using `get_dependent_variable_id`.
* If the `key` is a string, use it directly, assuming it is the string ID of a
* If the `key` is a string, use it directly, assuming it is the string ID of a
dependent variable settings object
* If the `key` is neither type, raise a `TypeError`
Expand All @@ -125,7 +125,7 @@ def __read_key(self, key: VariableSettings):

def __init__(self, mapping=None, /, **kwargs):
"""
Create a `DependentVariableDictionary` from either a dictionary (`mapping`), or a series of
Create a `DependentVariableDictionary` from either a dictionary (`mapping`), or a series of
keyword-value pairs (`kwargs`).
"""
if mapping is not None:
Expand Down Expand Up @@ -170,7 +170,7 @@ def __getitem__(self, __key: VariableSettings):# -> dict[float: np.ndarray]:
Output
------
* Time history of the dependent variable, returned as a `dict` mapping epochs (`float`)
to `np.ndarray`s containing the value of the dependent variable at each given epoch.
"""
Expand All @@ -182,7 +182,7 @@ def __getitem__(self, __key: VariableSettings):# -> dict[float: np.ndarray]:
f'{"-"*width}\n' + self.__summary__()
print(message)
raise e

def __summary__(self) -> str:
"""
Return a string summary of the contents of a `DependentVariableDictionary` for print.
Expand All @@ -202,14 +202,14 @@ def __repr__(self) -> str:
"""
Return a string summary of the contents of a `DependentVariableDictionary` for print.
"""

width = max([len(ID) for ID in self.keys()]) + 10
title = f'{"Depent Variable Dictionary Summary":^{width}}'

representation_string = f'\n{"="*width}\n' + title + f'\n{"="*width}\n' + self.__summary__()

return representation_string

def asarray(self, key: VariableSettings) -> np.ndarray:
"""
Return the time history of a given dependent variable as a NumPy array.
Expand All @@ -233,13 +233,15 @@ def create_dependent_variable_dictionary(
to their time histories. See the documentation of `DependentVariableDictionary` to learn more about how
time histories are saved, and how the time history of a given dependent variable can be retrieved.
Arguments
---------
- dynamics_simulator: `SingleArcSimulator` object containing the results of the numerical propagation
Parameters
----------
dynamics_simulator : SingleArcSimulator
SingleArcSimulator object containing the results of the numerical propagation
Output
------
- dependent_variable_dictionary: `DependentVariableDictionary` of propagation
Returns
-------
dependent_variable_dictionary : DependentVariableDictionary
DependentVariableDictionary of propagation
"""

#--------------------------------------------------------------------
Expand All @@ -261,23 +263,23 @@ def create_dependent_variable_dictionary(
#--------------------------------------------------------------------
#%% CONSTRUCT DEPENDENT VARIABLE DICTIONARY
#--------------------------------------------------------------------

# Construct dependent variable matrices
dependent_variable_matrices = []
for ((i, m), dependent_variable) in dependent_variable_settings.items():

# Retrieve dependent variable shape
A, B = get_dependent_variable_shape(dependent_variable, dynamics_simulator.bodies)
# Save dependent variable history as a tensor of (A, B)-sized

# Save dependent variable history as a tensor of (A, B)-sized
# matrices with `n` entries, where `n` is the number of epochs
dependent_variable_matrices.append(
dependent_variable_history[
# From index i to index i+m (the flattened dimension of the dependent variable)
i:i+m, :
].T.reshape((n, A, B))
)

# Construct dependent variable dictionary
dependent_variable_dictionary = DependentVariableDictionary({
dependent_variable: {
Expand Down

0 comments on commit 30e25ab

Please sign in to comment.