Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dependent variable dictionary - definitive and inside hybrid kernel #120

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
148 commits
Select commit Hold shift + click to select a range
182b1c5
Working on modifying coefficient inputs
DominicDirkx Feb 24, 2023
fb7f5d2
Small iterface updates
DominicDirkx Mar 13, 2023
415f8d0
Exposed the function "setConstantPerObservableAndLinkEndsWeights" to …
rashikajain11 Mar 16, 2023
9192ace
Update .bumpversion.cfg
DominicDirkx Apr 21, 2023
36f3c6d
Update version
DominicDirkx Apr 21, 2023
9238261
Bump version: 0.7.3.dev0 → 0.7.3.dev1
Delfi-C3 Apr 22, 2023
2e3b096
Added manual ObservationCollection creation
DominicDirkx May 15, 2023
f79fd0b
Exposed missing function
DominicDirkx May 15, 2023
f01f7c6
Merge branch 'develop' into feature/extended_aerodynamic_coefficients
DominicDirkx May 15, 2023
8c3c311
Bump version: 0.7.3.dev1 → 0.7.3.dev2
Delfi-C3 May 16, 2023
7be411a
Added python exposures of new functionality
DominicDirkx May 22, 2023
e4812e9
Merge pull request #100 from tudat-team/feature/extended_aerodynamic_…
DominicDirkx May 23, 2023
507a1ac
Exposed US76 atmosphere model
DominicDirkx May 23, 2023
b5cca1b
Added option to make mars high-accuracy rotation model more flexible
DominicDirkx May 23, 2023
0a82c1f
Bump version: 0.7.3.dev2 → 0.7.3.dev3
Delfi-C3 May 24, 2023
69eee6c
Added ground station state functions
DominicDirkx May 25, 2023
d962b85
Bump version: 0.7.3.dev3 → 0.7.3.dev4
Delfi-C3 May 26, 2023
b913ed4
Moved new body properties to new submodule; modified moment reference…
DominicDirkx May 27, 2023
088638f
Merge remote-tracking branch 'origin/develop' into develop
DominicDirkx May 27, 2023
47d1e43
Bump version: 0.7.3.dev4 → 0.7.3.dev5
Delfi-C3 May 28, 2023
baab934
Update environment_readthedocs.yaml
DominicDirkx Jun 5, 2023
8f3f641
Added test of new alternate default body creation
DominicDirkx Jun 5, 2023
2485479
Merge remote-tracking branch 'origin/develop' into develop
DominicDirkx Jun 5, 2023
0918a75
Corrected docstrings references
DominicDirkx Jun 5, 2023
2bf3698
Removed boost unit test dependency
DominicDirkx Jun 5, 2023
fd5a90c
Add missing inputs for atmosphere-related dependent variables
DominicDirkx Jun 5, 2023
0851f99
Small updates to gravitation for docs
DominicDirkx Jun 5, 2023
ecec512
Bump version: 0.7.3.dev5 → 0.7.3.dev6
Delfi-C3 Jun 6, 2023
11acf23
Re-enabling unit test inclusion...
DominicDirkx Jun 6, 2023
3891940
Merge remote-tracking branch 'origin/develop' into develop
DominicDirkx Jun 6, 2023
5fed5f8
Bump version: 0.7.3.dev6 → 0.7.3.dev7
Delfi-C3 Jun 7, 2023
294b287
Added new integrator factory functions
DominicDirkx Jun 8, 2023
7751d64
Bump version: 0.7.3.dev7 → 0.7.3.dev8
Delfi-C3 Jun 9, 2023
15c79ca
Re-exposed single-type observation collection
DominicDirkx Jun 13, 2023
94527d2
Merge remote-tracking branch 'origin/develop' into develop
DominicDirkx Jun 13, 2023
d0bb597
Bump version: 0.7.3.dev8 → 0.7.3.dev9
Delfi-C3 Jun 14, 2023
50fbdd9
Added exposure of new integrator functions
DominicDirkx Jun 14, 2023
615eb48
Modified names; added BS
DominicDirkx Jun 14, 2023
16cde2c
Added docstrings, and minor name modifications
DominicDirkx Jun 15, 2023
d38b85b
Small docs update
DominicDirkx Jun 16, 2023
649973b
exposed non-sequential termination settings.
SamFayolle Jun 20, 2023
79e6c16
Extended date-time exposure
DominicDirkx Jun 20, 2023
2fa2454
Merge remote-tracking branch 'marie-origin/feature/nonSequentialPropa…
DominicDirkx Jun 20, 2023
a61fb67
Merged
DominicDirkx Jun 21, 2023
b1252eb
Merge remote-tracking branch 'origin/develop' into feature/time_inter…
DominicDirkx Jun 21, 2023
4a46a36
Bump version: 0.7.3.dev9 → 0.7.3.dev10
Delfi-C3 Jun 22, 2023
e24229b
Added docstrings references
DominicDirkx Jun 22, 2023
abe2dc9
Merge branch 'develop' into feature/extended_aerodynamic_coefficients
DominicDirkx Jun 22, 2023
e78f236
Merge branch 'develop' into feature/time_interfaces
DominicDirkx Jun 22, 2023
535c166
Merge pull request #104 from tudat-team/feature/stepsize_control
DominicDirkx Jun 22, 2023
4bf0290
Bump version: 0.7.3.dev10 → 0.7.3.dev11
Delfi-C3 Jun 23, 2023
7b1527c
Final corrections before pull request
DominicDirkx Jun 23, 2023
e6d1956
Merge pull request #105 from tudat-team/feature/time_interfaces
DominicDirkx Jun 23, 2023
24ce924
Update environment_readthedocs.yaml
DominicDirkx Jun 23, 2023
b539dc2
Bump version: 0.7.3.dev11 → 0.7.3.dev12
Delfi-C3 Jun 24, 2023
37269cf
Added ring model exposure
DominicDirkx Jun 27, 2023
c8927a4
Merge remote-tracking branch 'origin/develop' into develop
DominicDirkx Jul 3, 2023
ee2c085
Small modifications to damping function naming
DominicDirkx Jul 3, 2023
c8f7f0f
.
DominicDirkx Jul 3, 2023
e76ccfd
Bump version: 0.7.3.dev12 → 0.7.3.dev13
Delfi-C3 Jul 4, 2023
b3b03c6
Correction to time conversions
DominicDirkx Jul 6, 2023
1965039
Merge remote-tracking branch 'origin/develop' into develop
DominicDirkx Jul 6, 2023
04a5604
Bump version: 0.7.3.dev13 → 0.7.3.dev14
Delfi-C3 Jul 7, 2023
0d93e37
Corrected date time conversions for times before 1970
DominicDirkx Jul 10, 2023
e9e5f65
Merge remote-tracking branch 'origin/develop' into develop
DominicDirkx Jul 10, 2023
d5df933
Bump version: 0.7.3.dev14 → 0.7.3.dev15
Delfi-C3 Jul 11, 2023
89af9b7
Remove cout statements
DominicDirkx Jul 11, 2023
7a91bfa
Merge remote-tracking branch 'origin/develop' into develop
DominicDirkx Jul 11, 2023
98c3e2a
exposed consider parameters feature.
SamFayolle Jul 11, 2023
19b297e
fixed merging conflicts.
SamFayolle Jul 11, 2023
8c036d7
Bump version: 0.7.3.dev15 → 0.7.3.dev16
Delfi-C3 Jul 12, 2023
2d8e9a2
exposed inverse tidal quality factor feature.
SamFayolle Jul 12, 2023
95407eb
ODF functions
MiguelAvillez Jul 13, 2023
6d7ade8
Fixing exposure of default function
MiguelAvillez Jul 14, 2023
f678161
Exposing SolarActivityData
MiguelAvillez Jul 18, 2023
40d69fe
Added factory function for libration parameter
DominicDirkx Jul 18, 2023
1e8a180
Merge remote-tracking branch 'origin/develop' into develop
DominicDirkx Jul 18, 2023
de2b8c9
Added missing input to libration function
DominicDirkx Jul 18, 2023
69992b0
Merge remote-tracking branch 'marie-origin/feature/consider_parameter…
DominicDirkx Jul 18, 2023
d74ed43
Merge remote-tracking branch 'marie-origin/feature/tidal_quality_fact…
DominicDirkx Jul 18, 2023
220a5d7
Merged
DominicDirkx Jul 18, 2023
1898eab
Minor correction for compatibility
DominicDirkx Jul 18, 2023
7487dc2
Bump version: 0.7.3.dev16 → 0.7.3.dev17
Delfi-C3 Jul 19, 2023
d92e0ad
Update environment_readthedocs.yaml
DominicDirkx Jul 20, 2023
0968f2a
Bump version: 0.7.3.dev17 → 0.7.3.dev18
Delfi-C3 Jul 21, 2023
30091ed
Corrected default input types
DominicDirkx Aug 14, 2023
7afafe8
Minor modifications for compatibility
DominicDirkx Aug 21, 2023
2d00d54
Removing pointing angles for now
DominicDirkx Aug 21, 2023
c27fa63
Merged
DominicDirkx Aug 22, 2023
4beff4a
Modified iterface for state transition interface
DominicDirkx Aug 22, 2023
f9cacf9
Adding dependent variable id function
DominicDirkx Sep 8, 2023
91cd63f
Added functions to check existing bodies
DominicDirkx Sep 11, 2023
06ff06a
Added global frame origin and orientation retrieval
DominicDirkx Sep 15, 2023
97fe7d2
Bumping version
DominicDirkx Sep 16, 2023
b25f085
Added new definition of weights
DominicDirkx Sep 16, 2023
d37a4ce
Porkchop plot mission design module proposal
alopezrivera Sep 17, 2023
50163b5
Moved Lambert ΔV calculator to budgeting submodule
alopezrivera Sep 17, 2023
279b7fa
Refactored hand-rolled datetime processing with Tudat built-ins
alopezrivera Sep 17, 2023
96d9e72
Porkchop plot final draft, pending relocation
alopezrivera Sep 18, 2023
6303683
Dependent variable dictionary final draft, pending exposure of variab…
alopezrivera Sep 18, 2023
3ac97b1
Upscaling turned off by default, improved colorbar robustness
alopezrivera Sep 18, 2023
9ef5c0e
Added functions to retrieve more information on dependent variables
DominicDirkx Sep 20, 2023
8da163e
Corrected dependent variable saving
DominicDirkx Sep 20, 2023
00c9ce5
Merge pull request #111 from tudat-team/feature/flexible_dependent_va…
DominicDirkx Sep 21, 2023
649a9bf
Exposed yarkovsky acceleration and parameter
DominicDirkx Sep 26, 2023
1d3874c
Added exposure of new estimation settings
DominicDirkx Sep 26, 2023
28c4c05
Small exposure updates; version bump
DominicDirkx Sep 30, 2023
c967acb
Added functionality fot tudatpy issue 113
DominicDirkx Sep 30, 2023
6c60209
Merge branch 'develop' into feature/odf_merge
DominicDirkx Sep 30, 2023
04340ca
Corrected compilation
DominicDirkx Sep 30, 2023
98fe626
Updated version
DominicDirkx Sep 30, 2023
3c0c27c
Generalized delta V calculation function interface
alopezrivera Oct 1, 2023
b9e6cfb
Documentation improved, completion pending
alopezrivera Oct 1, 2023
8110e58
Hybrid Python/C++ module drafted
alopezrivera Oct 1, 2023
4b31d0b
Dependent variable dict final draft including documentation, ready fo…
alopezrivera Oct 3, 2023
74979c3
Merge branch 'develop' into porkchop
alopezrivera Oct 8, 2023
c0a339a
Porkchop modules refactored into `hybrid_kernel` directory
alopezrivera Oct 10, 2023
5aa045d
WIP - C++/Python module exposure Python script and CMake setup
alopezrivera Oct 10, 2023
d6ac7b1
Hybrid module exposure complete
alopezrivera Oct 11, 2023
38f8989
Ensured kernel module exposure takes place reliably
alopezrivera Oct 11, 2023
b4d19f6
Lambert arc used for ΔV calculation by default in porkchop plots
alopezrivera Oct 12, 2023
77ae96b
BUG SOLVED: ΔV calculation function, porkchop component imports
alopezrivera Oct 12, 2023
26ddfc4
Porkchop documentation complete
alopezrivera Oct 13, 2023
ae94de7
Version bump
DominicDirkx Oct 13, 2023
14ff2d0
Merge remote-tracking branch 'antonio-origin/porkchop_and_hybrid_modu…
DominicDirkx Oct 14, 2023
26d09b2
Updated examples
DominicDirkx Oct 14, 2023
8ac32f3
Corrected compile error for newly templated functions
DominicDirkx Oct 14, 2023
edaee3a
Implemented pull request feedback
alopezrivera Oct 15, 2023
bd26347
Hybrid module exposure test
alopezrivera Oct 15, 2023
f2a9f9d
Attempt to fix compilation issues in MacOS and Windows
alopezrivera Oct 15, 2023
c9ad04c
Merge pull request #117 from alopezrivera/porkchop_and_hybrid_modules
DominicDirkx Oct 16, 2023
c51a1b5
Bumping version number
DominicDirkx Oct 16, 2023
d866cb6
Commented out hybrid module stuff
DominicDirkx Oct 18, 2023
d8cf039
Bumping version
DominicDirkx Oct 18, 2023
beb0b23
Changed _version import statement
alopezrivera Oct 22, 2023
d0f0426
Automatic hybrid kernel exposure on halt
alopezrivera Oct 22, 2023
1d3b148
Plan B for hybrid module exposure
alopezrivera Oct 22, 2023
34b8f4a
Merge branch 'develop' into porkchop_and_hybrid_modules
alopezrivera Oct 23, 2023
7dd55ad
Merge remote-tracking branch 'antonio-origin/porkchop_and_hybrid_modu…
DominicDirkx Oct 23, 2023
69392ff
Bump version
DominicDirkx Oct 23, 2023
e2a118c
Time conversion modifications/corrections
DominicDirkx Oct 28, 2023
ee3761c
Corrected version files
DominicDirkx Oct 28, 2023
c885dbe
Commenting out day conversion function for now
DominicDirkx Oct 28, 2023
a79385a
Bumping version
DominicDirkx Oct 28, 2023
0c94f3f
Merge branch 'develop' into dependent_variable_dict
alopezrivera Oct 29, 2023
125fcd5
Dependent variable dictionary final draft
alopezrivera Oct 29, 2023
95bd008
tudapty.util import statement errors resolved
alopezrivera Oct 29, 2023
ae0e338
Dependent variable dictionary tested
alopezrivera Oct 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.7.3
current_version = 0.7.3.dev28
commit = True
tag = True
parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+)(?P<dev>\d+))?
Expand Down
2 changes: 1 addition & 1 deletion examples
Submodule examples updated 28 files
+4 −0 .github/sync.yml
+22 −0 .github/workflows/sync.yml
+11 −0 README.md
+ estimation/ORMM_T19_031222180906_00052.BSP
+166 −381 estimation/covariance_estimated_parameters.ipynb
+126 −177 estimation/covariance_estimated_parameters.py
+684 −0 estimation/estimation_dynamical_models.ipynb
+443 −0 estimation/estimation_dynamical_models.py
+809 −0 estimation/full_estimation_example.ipynb
+475 −0 estimation/full_estimation_example.py
+720 −0 estimation/galilean_moons_state_estimation.ipynb
+487 −0 estimation/galilean_moons_state_estimation.py
+163 −0 mission_design/earth_mars_transfer_window.py
+1,294 −0 propagation/coupled_translational_rotational_dynamics.ipynb
+699 −0 propagation/coupled_translational_rotational_dynamics.py
+3 −1 propagation/reentry_trajectory.py
+804 −0 propagation/thrust_between_Earth_Moon.ipynb
+480 −0 propagation/thrust_between_Earth_Moon.py
+6 −76 propagation/two_stage_rocket_ascent.ipynb
+32 −29 propagation/two_stage_rocket_ascent.py
+8 −4 pygmo/asteroid_orbit_optimization/aoo_custom_environment.ipynb
+3 −3 pygmo/asteroid_orbit_optimization/aoo_custom_environment.py
+1 −1 pygmo/asteroid_orbit_optimization/aoo_design_space_exploration.ipynb
+1 −1 pygmo/asteroid_orbit_optimization/aoo_design_space_exploration.py
+1 −1 pygmo/asteroid_orbit_optimization/aoo_optimization.ipynb
+1 −1 pygmo/asteroid_orbit_optimization/aoo_optimization.py
+2 −2 pygmo/cassini1_mga_optimization.ipynb
+2 −2 pygmo/cassini1_mga_optimization.py
212 changes: 212 additions & 0 deletions tests/test_dependent_variable_dictionary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
# Load standard modules
import numpy as np
import matplotlib
from matplotlib import pyplot as plt

# Load tudatpy modules
from tudatpy.interface import spice
from tudatpy import numerical_simulation
from tudatpy.numerical_simulation import environment_setup, propagation_setup
from tudatpy.astro import element_conversion
from tudatpy import constants
from tudatpy.util import result2array

# Semantic variable history stuff
import pickle
from tudatpy.numerical_simulation.propagation import create_dependent_variable_dictionary


def test_dependent_variable_dictionary():

#%% SET UP A PROPAGATION TO TEST THE SEMANTIC VARIABLE HISTORY FUNCTIONALITY
#===========================================================================

# Load spice kernels
spice.load_standard_kernels()

# Set simulation start and end epochs
simulation_start_epoch = 0.0
simulation_end_epoch = constants.JULIAN_DAY

# Define string names for bodies to be created from default.
bodies_to_create = ["Sun", "Earth", "Moon", "Mars", "Venus"]

# Use "Earth"/"J2000" as global frame origin and orientation.
global_frame_origin = "Earth"
global_frame_orientation = "J2000"

# Create default body settings, usually from `spice`.
body_settings = environment_setup.get_default_body_settings(
bodies_to_create,
global_frame_origin,
global_frame_orientation)

# Create system of selected celestial bodies
bodies = environment_setup.create_system_of_bodies(body_settings)

# Create vehicle objects.
bodies.create_empty_body("Delfi-C3")

bodies.get("Delfi-C3").mass = 400.0

# Create aerodynamic coefficient interface settings, and add to vehicle
reference_area = 4.0
drag_coefficient = 1.2
aero_coefficient_settings = environment_setup.aerodynamic_coefficients.constant(
reference_area, [drag_coefficient, 0, 0]
)
environment_setup.add_aerodynamic_coefficient_interface(
bodies, "Delfi-C3", aero_coefficient_settings)

# To account for the pressure of the solar radiation on the satellite, let's add another interface. This takes a radiation pressure coefficient of 1.2, and a radiation area of 4m$^2$. This interface also accounts for the variation in pressure cause by the shadow of Earth.

# Create radiation pressure settings, and add to vehicle
reference_area_radiation = 4.0
radiation_pressure_coefficient = 1.2
occulting_bodies = ["Earth"]
radiation_pressure_settings = environment_setup.radiation_pressure.cannonball(
"Sun", reference_area_radiation, radiation_pressure_coefficient, occulting_bodies
)
environment_setup.add_radiation_pressure_interface(
bodies, "Delfi-C3", radiation_pressure_settings)

# Define bodies that are propagated
bodies_to_propagate = ["Delfi-C3"]

# Define central bodies of propagation
central_bodies = ["Earth"]

# Define accelerations acting on Delfi-C3 by Sun and Earth.
accelerations_settings_delfi_c3 = dict(
Sun=[
propagation_setup.acceleration.cannonball_radiation_pressure(),
propagation_setup.acceleration.point_mass_gravity()
],
Earth=[
propagation_setup.acceleration.spherical_harmonic_gravity(5, 5),
propagation_setup.acceleration.aerodynamic()
],
Moon=[
propagation_setup.acceleration.point_mass_gravity()
],
Mars=[
propagation_setup.acceleration.point_mass_gravity()
],
Venus=[
propagation_setup.acceleration.point_mass_gravity()
]
)

# Create global accelerations settings dictionary.
acceleration_settings = {"Delfi-C3": accelerations_settings_delfi_c3}

# Create acceleration models.
acceleration_models = propagation_setup.create_acceleration_models(
bodies,
acceleration_settings,
bodies_to_propagate,
central_bodies)

# Set initial conditions for the satellite that will be
# propagated in this simulation. The initial conditions are given in
# Keplerian elements and later on converted to Cartesian elements
earth_gravitational_parameter = bodies.get("Earth").gravitational_parameter
initial_state = element_conversion.keplerian_to_cartesian_elementwise(
gravitational_parameter=earth_gravitational_parameter,
semi_major_axis=7500.0e3,
eccentricity=0.1,
inclination=np.deg2rad(85.3),
argument_of_periapsis=np.deg2rad(235.7),
longitude_of_ascending_node=np.deg2rad(23.4),
true_anomaly=np.deg2rad(139.87),
)

# Define list of dependent variables to save
dependent_variables_to_save = [
propagation_setup.dependent_variable.total_acceleration("Delfi-C3"),
propagation_setup.dependent_variable.keplerian_state("Delfi-C3", "Earth"),
propagation_setup.dependent_variable.latitude("Delfi-C3", "Earth"),
propagation_setup.dependent_variable.longitude("Delfi-C3", "Earth"),
propagation_setup.dependent_variable.single_acceleration_norm(
propagation_setup.acceleration.point_mass_gravity_type, "Delfi-C3", "Sun"
),
propagation_setup.dependent_variable.single_acceleration_norm(
propagation_setup.acceleration.point_mass_gravity_type, "Delfi-C3", "Moon"
),
propagation_setup.dependent_variable.single_acceleration_norm(
propagation_setup.acceleration.point_mass_gravity_type, "Delfi-C3", "Mars"
),
propagation_setup.dependent_variable.single_acceleration_norm(
propagation_setup.acceleration.point_mass_gravity_type, "Delfi-C3", "Venus"
),
propagation_setup.dependent_variable.single_acceleration_norm(
propagation_setup.acceleration.spherical_harmonic_gravity_type, "Delfi-C3", "Earth"
),
propagation_setup.dependent_variable.single_acceleration_norm(
propagation_setup.acceleration.aerodynamic_type, "Delfi-C3", "Earth"
),
propagation_setup.dependent_variable.single_acceleration_norm(
propagation_setup.acceleration.cannonball_radiation_pressure_type, "Delfi-C3", "Sun"
)
]

# Create termination settings
termination_condition = propagation_setup.propagator.time_termination(simulation_end_epoch)

# Create numerical integrator settings
fixed_step_size = 10.0
integrator_settings = propagation_setup.integrator.runge_kutta_4(fixed_step_size)

# Create propagation settings
propagator_settings = propagation_setup.propagator.translational(
central_bodies,
acceleration_models,
bodies_to_propagate,
initial_state,
simulation_start_epoch,
integrator_settings,
termination_condition,
output_variables=dependent_variables_to_save
)

# Create simulation object and propagate the dynamics
dynamics_simulator = numerical_simulation.create_dynamics_simulator(
bodies, propagator_settings
)

#%% TEST SEMANTIC VARIABLE HISTORY FUNCTIONALITY
#===============================================

# Create semantic dependent variable history
dep_vars_dict = create_dependent_variable_dictionary(dynamics_simulator)

# Retrieve time history
dependent_variable_history_array = result2array(dynamics_simulator.dependent_variable_history)

arrays_are_equal = lambda a, b: np.allclose(a, b, rtol=1e-10, atol=1e-10)

# TEST 1: Assert that the time histories obtained from newly created dependent variable settings
# objects and from those used to set up the propagation are the same.
assert arrays_are_equal(
dep_vars_dict.asarray(dependent_variables_to_save[0]),
dep_vars_dict.asarray(propagation_setup.dependent_variable.total_acceleration("Delfi-C3"))
)

# TEST 2: Assert that the time history of the dependent variables is the same as the one obtained from the
# dynamics simulator.
assert arrays_are_equal(
dep_vars_dict.asarray(dependent_variables_to_save[2]),
dependent_variable_history_array[:, 10]
)

# TEST 3: Assert (by virtue of an error not happening) that result2array works as expected on time histories of
# scalar dependent variables.
# This will fail for vectorial or matrix dependent variables because the shape of the array associated to each
# epoch is not flat. It is not recommended to use result2array together with the create_dependent_variable_dictionary due
# to this. The test is useful though as the entries of the semantic variable history associated to scalar dependent
# variables should be perfectly compatible with result2array.
delfi_latitude_array = result2array(dep_vars_dict[dependent_variables_to_save[2]])

# TEST 4: Assert that the shape of the vectorial dependent variable histories is correct
assert dep_vars_dict.asarray(dependent_variables_to_save[0])[0].shape == (3,)
assert dep_vars_dict.asarray(dependent_variables_to_save[1])[0].shape == (6,)
54 changes: 54 additions & 0 deletions tests/test_hybrid_module_exposure.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# General imports
import inspect
import unittest
from importlib import import_module


def _recursively_find_children(module):
"""
Recursively find all children of a module.
"""

children = inspect.getmembers(module, inspect.ismodule)

if children:
for (name, child) in children:
children += _recursively_find_children(child)
return children
else:
return []


def test_tudatpy_kernel_module_exposure():

import tudatpy.kernel as kernel

exposed_kernel_modules = [
# 'utils',
'astro',
'trajectory_design',
'constants',
'interface',
# 'io',
'math',
'numerical_simulation'
]

module_methods = lambda module: inspect.getmembers(module, inspect.isroutine)

module_variables = lambda module: [
(name, value) for name, value in inspect.getmembers(module)
if (not inspect.isroutine(value) and not inspect.ismodule(value) and not name.startswith('__'))
]

for (submodule_name, submodule) in _recursively_find_children(kernel):

if submodule.__name__.split('.')[2] in exposed_kernel_modules:
kernel_module = import_module(submodule.__name__)
exposed_module = import_module(submodule.__name__.replace('kernel.', ''))

# Assert both modules contain the same methods
assert all([method in module_methods(kernel_module) for method in module_methods(exposed_module)])

# Assert both modules contain the same variables
assert all([variable in module_variables(kernel_module) for variable in module_variables(exposed_module)])
37 changes: 37 additions & 0 deletions tests/test_time_conversions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# import sys
# sys.path.insert(0, "/home/dominic/Tudat/tudat-bundle/tudat-bundle/cmake-build-default/tudatpy")

import math
from datetime import datetime
from tudatpy.kernel.astro import time_conversion


def test_datetime_conversions():

python_datetime = datetime.fromisoformat('2023-06-20T00:05:23.281765')
tudat_datetime = time_conversion.datetime_to_tudat( python_datetime )
tudat_datetime_string = tudat_datetime.iso_string( False )
python_datetime_reconstructed = time_conversion.datetime_to_python( tudat_datetime )

while (tudat_datetime_string[-1] == '0'):
tudat_datetime_string = tudat_datetime_string[:-1]

assert tudat_datetime_string == str( python_datetime )

assert str( python_datetime_reconstructed ) == str( python_datetime )

assert '2023-06-20 00:05:23.281765' == str(python_datetime)

julian_day = 2443494.5
tudat_datettime = time_conversion.datetime_to_tudat(time_conversion.julian_day_to_calendar_date(julian_day))
assert julian_day == tudat_datettime.julian_day( )

pre_1970_date = datetime(1960,1,1,13,7,23,891234)
julian_day_to_check = time_conversion.calendar_date_to_julian_day(pre_1970_date)

assert math.floor( julian_day_to_check ) == 2436935
seconds_in_day_to_check = ( julian_day_to_check - math.floor( julian_day_to_check ) ) * 86400.0
manual_seconds_in_day = 1 * 3600 + 7 * 60 + 23.891234
assert math.fabs( manual_seconds_in_day - seconds_in_day_to_check ) < 1.0E-4
print('DATE TIME TEST SUCCESFUL')

Loading
Loading