From 0a56503defe366ef86d3acac039081d9d2309e35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20G=C3=B3mez?= Date: Wed, 15 Feb 2023 11:47:15 +0100 Subject: [PATCH 1/6] Small doc update --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index c72159fb..d15f6893 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,13 @@ Alternatively to the default `paseos.PowerDeviceType.SolarPanel` you can also us Note that at the moment only one power device is supported. Adding another will override the existing one. +You can check the battery's state of charge and level in wattseconds with: + +```py +print(my_actor.state_of_charge) +print(my_actor.battery_level_in_Ws) +``` + #### Thermal Modelling To model thermal constraints on spacecraft we utilize a model inspired by the one-node model described in [Martínez - Spacecraft Thermal Modelling and Test](http://imartinez.etsiae.upm.es/~isidoro/tc3/Spacecraft%20Thermal%20Modelling%20and%20Testing.pdf). Thus, we model the change in temperature as From 5006f0c77c86bed96ec3ede59a01451bbdbd9081 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20G=C3=B3mez?= Date: Wed, 15 Feb 2023 13:19:31 +0100 Subject: [PATCH 2/6] Update README.md Co-authored-by: Gabriele Meoni <70584239+GabrieleMeoni@users.noreply.github.com> --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d15f6893..667c9753 100644 --- a/README.md +++ b/README.md @@ -286,7 +286,7 @@ Alternatively to the default `paseos.PowerDeviceType.SolarPanel` you can also us Note that at the moment only one power device is supported. Adding another will override the existing one. -You can check the battery's state of charge and level in wattseconds with: +You can check the battery's state of charge and level in Ws with: ```py print(my_actor.state_of_charge) From 6582a01b58cc1d68a22357f5a9dbcf92ae7675f3 Mon Sep 17 00:00:00 2001 From: johanos1 Date: Mon, 20 Feb 2023 14:59:37 +0100 Subject: [PATCH 3/6] Fix broken visualization example --- examples/visualization/example_sentinel2.py | 87 +++++++++++++++++++++ paseos/visualization/space_animation.py | 2 +- 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 examples/visualization/example_sentinel2.py diff --git a/examples/visualization/example_sentinel2.py b/examples/visualization/example_sentinel2.py new file mode 100644 index 00000000..f5002391 --- /dev/null +++ b/examples/visualization/example_sentinel2.py @@ -0,0 +1,87 @@ +import sys + +sys.path.append("../..") + +import numpy as np +from paseos.utils.set_log_level import set_log_level +from paseos.utils.load_default_cfg import load_default_cfg +import paseos +from paseos.visualization.space_animation import SpaceAnimation +from paseos.actors.spacecraft_actor import SpacecraftActor +from paseos.actors.actor_builder import ActorBuilder +import pykep as pk + +set_log_level("INFO") + +# Define central body +earth = pk.planet.jpl_lp("earth") +# Define today (27-10-22) +today = pk.epoch(8335.5, "mjd2000") + + +S2A = ActorBuilder.get_actor_scaffold("Satellite-A", SpacecraftActor, today) + +# Define local actor +S2B = ActorBuilder.get_actor_scaffold("Satellite-B", SpacecraftActor, today) + +sentinel2A_line1 = ( + "1 40697U 15028A 22300.01175178 -.00001065 00000+0 -38995-3 0 9999" +) +sentinel2A_line2 = ( + "2 40697 98.5650 12.8880 0001080 78.8662 281.2690 14.30806819383668" +) +sentinel2A = pk.planet.tle(sentinel2A_line1, sentinel2A_line2) + +# Calculating S2A ephemerides. +sentinel2A_eph = sentinel2A.eph(today) + +sentinel2B_line1 = ( + "1 42063U 17013A 22300.18652110 .00000099 00000+0 54271-4 0 9998" +) +sentinel2B_line2 = ( + "2 42063 98.5693 13.0364 0001083 104.3232 255.8080 14.30819357294601" +) +sentinel2B = pk.planet.tle(sentinel2B_line1, sentinel2B_line2) + +# Calculating S2B ephemerides. +sentinel2B_eph = sentinel2B.eph(today) + +# Define local actor +S2B = ActorBuilder.get_actor_scaffold("Satellite-B", SpacecraftActor, today) + + +# Adding orbits around Earth based on previously calculated ephemerides +ActorBuilder.set_orbit(S2A, sentinel2A_eph[0], sentinel2A_eph[1], today, earth) + +# To enable the communication between S2A and S2B, the velocity vector is multiplied by - 1 making the satellite to orbit with opposite direction. +ActorBuilder.set_orbit( + S2B, + sentinel2B_eph[0], + [-sentinel2B_eph[1][0], -sentinel2B_eph[1][1], -sentinel2B_eph[1][2]], + today, + earth, +) + +# Adding power devices +ActorBuilder.set_power_devices(S2A, 500, 10000, 1) +ActorBuilder.set_power_devices(S2B, 500, 10000, 1) +# Adding communication devices. +ActorBuilder.add_comm_device(S2A, "isl_transmitter", 10000) +ActorBuilder.add_comm_device(S2B, "isl_transmitter", 10000) + + +# init simulation +cfg = load_default_cfg() +cfg.sim.start_time = today.mjd2000 * pk.DAY2SEC +sim = paseos.init_sim(S2A, cfg) +sim.add_known_actor(S2B) + + +anim = SpaceAnimation(sim) +import matplotlib.pyplot as plt + +dt = 100 +for t in range(10): + anim.animate(sim, dt) + plt.pause(0.05) +plt.show() diff --git a/paseos/visualization/space_animation.py b/paseos/visualization/space_animation.py index 86b122cd..10bc073c 100644 --- a/paseos/visualization/space_animation.py +++ b/paseos/visualization/space_animation.py @@ -207,7 +207,7 @@ def _plot_actors(self) -> None: obj.plot.trajectory.set_3d_properties(data[-n_points:, 2].T) # update satellite position - obj.plot.point.set_data_3d(data[-1, :]) + obj.plot.point.set_data_3d(data[-1, 0], data[-1, 1], data[-1, 2]) # update text box actor_info = self._populate_textbox(obj.actor) From 643ff17eba7a4c09da73a583a00dfee0c653b3fb Mon Sep 17 00:00:00 2001 From: johanos1 Date: Mon, 20 Feb 2023 15:59:49 +0100 Subject: [PATCH 4/6] Fixed visualization --- examples/visualization/example_sentinel2.py | 4 ++-- paseos/visualization/space_animation.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/examples/visualization/example_sentinel2.py b/examples/visualization/example_sentinel2.py index f5002391..dfd963aa 100644 --- a/examples/visualization/example_sentinel2.py +++ b/examples/visualization/example_sentinel2.py @@ -2,7 +2,6 @@ sys.path.append("../..") -import numpy as np from paseos.utils.set_log_level import set_log_level from paseos.utils.load_default_cfg import load_default_cfg import paseos @@ -53,7 +52,8 @@ # Adding orbits around Earth based on previously calculated ephemerides ActorBuilder.set_orbit(S2A, sentinel2A_eph[0], sentinel2A_eph[1], today, earth) -# To enable the communication between S2A and S2B, the velocity vector is multiplied by - 1 making the satellite to orbit with opposite direction. +# To enable the communication between S2A and S2B, the velocity vector is +# multiplied by - 1 making the satellite to orbit with opposite direction. ActorBuilder.set_orbit( S2B, sentinel2B_eph[0], diff --git a/paseos/visualization/space_animation.py b/paseos/visualization/space_animation.py index 10bc073c..a088a43f 100644 --- a/paseos/visualization/space_animation.py +++ b/paseos/visualization/space_animation.py @@ -207,7 +207,8 @@ def _plot_actors(self) -> None: obj.plot.trajectory.set_3d_properties(data[-n_points:, 2].T) # update satellite position - obj.plot.point.set_data_3d(data[-1, 0], data[-1, 1], data[-1, 2]) + data_point = list(map(lambda el:[el], data[-1, :])) + obj.plot.point.set_data_3d(data_point) # update text box actor_info = self._populate_textbox(obj.actor) From 3c433ac9cc8f81140a54219deaf08a1f4c161d1a Mon Sep 17 00:00:00 2001 From: johanos1 Date: Mon, 20 Feb 2023 16:01:23 +0100 Subject: [PATCH 5/6] linting --- paseos/visualization/space_animation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/paseos/visualization/space_animation.py b/paseos/visualization/space_animation.py index a088a43f..da36ae74 100644 --- a/paseos/visualization/space_animation.py +++ b/paseos/visualization/space_animation.py @@ -207,7 +207,7 @@ def _plot_actors(self) -> None: obj.plot.trajectory.set_3d_properties(data[-n_points:, 2].T) # update satellite position - data_point = list(map(lambda el:[el], data[-1, :])) + data_point = list(map(lambda el: [el], data[-1, :])) obj.plot.point.set_data_3d(data_point) # update text box From b11d0cb2169ee57271fc80c696027776635173df Mon Sep 17 00:00:00 2001 From: johanos1 <40794255+johanos1@users.noreply.github.com> Date: Mon, 20 Feb 2023 16:13:03 +0100 Subject: [PATCH 6/6] Delete example_sentinel2.py --- examples/visualization/example_sentinel2.py | 87 --------------------- 1 file changed, 87 deletions(-) delete mode 100644 examples/visualization/example_sentinel2.py diff --git a/examples/visualization/example_sentinel2.py b/examples/visualization/example_sentinel2.py deleted file mode 100644 index dfd963aa..00000000 --- a/examples/visualization/example_sentinel2.py +++ /dev/null @@ -1,87 +0,0 @@ -import sys - -sys.path.append("../..") - -from paseos.utils.set_log_level import set_log_level -from paseos.utils.load_default_cfg import load_default_cfg -import paseos -from paseos.visualization.space_animation import SpaceAnimation -from paseos.actors.spacecraft_actor import SpacecraftActor -from paseos.actors.actor_builder import ActorBuilder -import pykep as pk - -set_log_level("INFO") - -# Define central body -earth = pk.planet.jpl_lp("earth") -# Define today (27-10-22) -today = pk.epoch(8335.5, "mjd2000") - - -S2A = ActorBuilder.get_actor_scaffold("Satellite-A", SpacecraftActor, today) - -# Define local actor -S2B = ActorBuilder.get_actor_scaffold("Satellite-B", SpacecraftActor, today) - -sentinel2A_line1 = ( - "1 40697U 15028A 22300.01175178 -.00001065 00000+0 -38995-3 0 9999" -) -sentinel2A_line2 = ( - "2 40697 98.5650 12.8880 0001080 78.8662 281.2690 14.30806819383668" -) -sentinel2A = pk.planet.tle(sentinel2A_line1, sentinel2A_line2) - -# Calculating S2A ephemerides. -sentinel2A_eph = sentinel2A.eph(today) - -sentinel2B_line1 = ( - "1 42063U 17013A 22300.18652110 .00000099 00000+0 54271-4 0 9998" -) -sentinel2B_line2 = ( - "2 42063 98.5693 13.0364 0001083 104.3232 255.8080 14.30819357294601" -) -sentinel2B = pk.planet.tle(sentinel2B_line1, sentinel2B_line2) - -# Calculating S2B ephemerides. -sentinel2B_eph = sentinel2B.eph(today) - -# Define local actor -S2B = ActorBuilder.get_actor_scaffold("Satellite-B", SpacecraftActor, today) - - -# Adding orbits around Earth based on previously calculated ephemerides -ActorBuilder.set_orbit(S2A, sentinel2A_eph[0], sentinel2A_eph[1], today, earth) - -# To enable the communication between S2A and S2B, the velocity vector is -# multiplied by - 1 making the satellite to orbit with opposite direction. -ActorBuilder.set_orbit( - S2B, - sentinel2B_eph[0], - [-sentinel2B_eph[1][0], -sentinel2B_eph[1][1], -sentinel2B_eph[1][2]], - today, - earth, -) - -# Adding power devices -ActorBuilder.set_power_devices(S2A, 500, 10000, 1) -ActorBuilder.set_power_devices(S2B, 500, 10000, 1) -# Adding communication devices. -ActorBuilder.add_comm_device(S2A, "isl_transmitter", 10000) -ActorBuilder.add_comm_device(S2B, "isl_transmitter", 10000) - - -# init simulation -cfg = load_default_cfg() -cfg.sim.start_time = today.mjd2000 * pk.DAY2SEC -sim = paseos.init_sim(S2A, cfg) -sim.add_known_actor(S2B) - - -anim = SpaceAnimation(sim) -import matplotlib.pyplot as plt - -dt = 100 -for t in range(10): - anim.animate(sim, dt) - plt.pause(0.05) -plt.show()