diff --git a/docs/source/ephemeris.rst b/docs/source/ephemeris.rst index bf5b19e0..da94405a 100644 --- a/docs/source/ephemeris.rst +++ b/docs/source/ephemeris.rst @@ -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 `_. -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 `_. +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 @@ -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`) @@ -77,6 +77,7 @@ Functions tabulated_from_existing + horizons_wrapper.jpl_horizons .. autofunction:: tudatpy.numerical_simulation.environment_setup.ephemeris.direct_spice @@ -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 diff --git a/docs/source/gravity_field.rst b/docs/source/gravity_field.rst index 20a1f2c0..04da1928 100644 --- a/docs/source/gravity_field.rst +++ b/docs/source/gravity_field.rst @@ -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`) @@ -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 @@ -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 diff --git a/docs/source/propagation.rst b/docs/source/propagation.rst index 62ea1150..2a494449 100644 --- a/docs/source/propagation.rst +++ b/docs/source/propagation.rst @@ -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. @@ -30,7 +30,7 @@ Functions combine_initial_states - + dependent_variable_dictionary.dependent_variable_dictionary.create_dependent_variable_dictionary .. autofunction:: tudatpy.numerical_simulation.propagation.get_state_of_bodies @@ -38,7 +38,7 @@ Functions .. autofunction:: tudatpy.numerical_simulation.propagation.combine_initial_states - +.. autofunction:: tudatpy.numerical_simulation.propagation.dependent_variable_dictionary.dependent_variable_dictionary.create_dependent_variable_dictionary Enumerations @@ -73,6 +73,7 @@ Classes RotationalProperModeDampingResults + dependent_variable_dictionary.dependent_variable_dictionary.DependentVariableDictionary .. autoclass:: tudatpy.numerical_simulation.propagation.SimulationResults @@ -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: diff --git a/tudatpy/numerical_simulation/propagation/dependent_variable_dictionary/dependent_variable_dictionary.py b/tudatpy/numerical_simulation/propagation/dependent_variable_dictionary/dependent_variable_dictionary.py index eb42546b..278130ee 100644 --- a/tudatpy/numerical_simulation/propagation/dependent_variable_dictionary/dependent_variable_dictionary.py +++ b/tudatpy/numerical_simulation/propagation/dependent_variable_dictionary/dependent_variable_dictionary.py @@ -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: @@ -36,7 +36,7 @@ class DependentVariableDictionary(dict): propagation_setup.dependent_variable.total_acceleration("Delfi-C3") ] ``` - + Example usage: -------------- @@ -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` @@ -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)` | +===========+=============+ @@ -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` @@ -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: @@ -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. """ @@ -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. @@ -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. @@ -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 """ #-------------------------------------------------------------------- @@ -261,15 +263,15 @@ 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[ @@ -277,7 +279,7 @@ def create_dependent_variable_dictionary( i:i+m, : ].T.reshape((n, A, B)) ) - + # Construct dependent variable dictionary dependent_variable_dictionary = DependentVariableDictionary({ dependent_variable: {