-
Notifications
You must be signed in to change notification settings - Fork 9
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
3DView support #80
3DView support #80
Conversation
# -*- coding: utf-8 -*- | ||
|
||
"""Tests for `cdpp_3dview` package.""" | ||
import os |
Check notice
Code scanning / CodeQL
Unused import
|
||
from ddt import data, ddt, unpack | ||
|
||
import speasy as spz |
Check notice
Code scanning / CodeQL
Unused import
tests/test_3dview.py
Outdated
from ddt import data, ddt, unpack | ||
|
||
import speasy as spz | ||
from speasy.inventories import flat_inventories |
Check notice
Code scanning / CodeQL
Unused import
e4c54ab
to
335aecb
Compare
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
just for the record the script used to produce plots (using speasy private API): from datetime import timedelta
import numpy as np
import matplotlib.pyplot as plt
import speasy as spz
from speasy.webservices.cdpp_3dview.ws import _WS_impl
_ws = _WS_impl()
def find_body(name: str):
bodies = _ws.get_spacecraft_list()
for body in bodies:
if body.name == name or body.name.lower() == name.lower():
return body
return None
def find_frame(name: str):
frames = _ws.get_frame_list()
for frame in frames:
if frame.name == name or frame.name.lower() == name.lower():
return frame
return None
def compare_ssc_trajectory(ssc_index, coordinate_system, cdpp_coordinate_system=None):
cdpp_coordinate_system = cdpp_coordinate_system or coordinate_system
start_time = spz.core.make_utc_datetime("2021-01-01")
stop_time = spz.core.make_utc_datetime("2021-01-05")
ssc_data = spz.get_data(ssc_index, start_time, stop_time,
coordinate_system=coordinate_system)
ssc_data = ssc_data.to_dataframe()
cdpp_3DView_data = _ws.get_orbit_data(body=find_body(ssc_index.Id),
start_time=start_time,
stop_time=stop_time,
frame=find_frame(coordinate_system),
time_vector=list(
map(spz.core.make_utc_datetime, ssc_data.index.to_pydatetime())))
cdpp_3DView_data = cdpp_3DView_data.to_dataframe()
ssc_data.columns = cdpp_3DView_data.columns
abs_error = abs(ssc_data - cdpp_3DView_data)
percent_error = 100 * abs((ssc_data - cdpp_3DView_data) / ssc_data)
fig, axs = plt.subplots(3, 1, sharex=True)
axs[0].set_title(f"{ssc_index.Id} Trajectories from SSCWeb and 3DView in {coordinate_system} frame")
axs[0].plot(ssc_data, label=ssc_data.columns)
axs[0].plot(cdpp_3DView_data, label=cdpp_3DView_data.columns)
axs[0].set_ylabel('Spacecraft position (km)')
axs[0].legend()
axs[1].set_title(f"Relative error of 3DView trajectory vs SSC")
axs[1].plot(percent_error, label=percent_error.columns)
axs[1].set_ylabel('Error (%)')
axs[1].set_ylim(0, 10)
axs[1].legend()
axs[2].set_title(f"Absolute error of 3DView trajectory vs SSC")
axs[2].plot(abs_error, label=abs_error.columns)
axs[2].set_ylabel('Error (km)')
axs[2].legend()
plt.show()
compare_ssc_trajectory(spz.inventories.tree.ssc.Trajectories.mms1, "GSM")
compare_ssc_trajectory(spz.inventories.tree.ssc.Trajectories.mms1, "GSE") |
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
Signed-off-by: Alexis Jeandet <alexis.jeandet@member.fsf.org>
Quality Gate failedFailed conditions |
No description provided.