Skip to content

Commit ce36b65

Browse files
Manual conversion of Epoch to datetime
Warning persists, Plotly does it when it sees that any column is a bunch of datetime objects
1 parent ebf878d commit ce36b65

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

python/nyx_space/plots/od.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ def plot_estimates(
9696
epoch = epoch.replace("UTC", "").strip()
9797
if "." not in epoch:
9898
epoch += ".0"
99-
pd_ok_epochs += [epoch]
100-
time_col = pd.to_datetime(pd_ok_epochs)
99+
pd_ok_epochs += [datetime.fromisoformat(str(epoch).replace("UTC", "").strip())]
100+
time_col = pd.Series(pd_ok_epochs)
101101
x_title = "Epoch {}".format(time_col_name[-3:])
102102

103103
# Check that the requested covariance frame exists
@@ -336,8 +336,8 @@ def plot_covar(
336336
epoch = epoch.replace("UTC", "").strip()
337337
if "." not in epoch:
338338
epoch += ".0"
339-
pd_ok_epochs += [epoch]
340-
time_col = pd.to_datetime(pd_ok_epochs)
339+
pd_ok_epochs += [datetime.fromisoformat(str(epoch).replace("UTC", "").strip())]
340+
time_col = pd.Series(pd_ok_epochs)
341341
x_title = "Epoch {}".format(time_col_name[-3:])
342342

343343
# Check that the requested covariance frame exists
@@ -525,8 +525,8 @@ def overlay_measurements(
525525
epoch = epoch.replace("UTC", "").strip()
526526
if "." not in epoch:
527527
epoch += ".0"
528-
pd_ok_epochs += [epoch]
529-
time_col = pd.to_datetime(pd_ok_epochs)
528+
pd_ok_epochs += [datetime.fromisoformat(str(epoch).replace("UTC", "").strip())]
529+
time_col = pd.Series(pd_ok_epochs)
530530
x_title = "Epoch {}".format(time_col_name[-3:])
531531

532532
# Diff the epochs of the measurements to find when there is a start and end.
@@ -622,8 +622,8 @@ def plot_residuals(
622622
epoch = epoch.replace("UTC", "").strip()
623623
if "." not in epoch:
624624
epoch += ".0"
625-
pd_ok_epochs += [epoch]
626-
time_col = pd.to_datetime(pd_ok_epochs)
625+
pd_ok_epochs += [datetime.fromisoformat(str(epoch).replace("UTC", "").strip())]
626+
time_col = pd.Series(pd_ok_epochs)
627627
x_title = "Epoch {}".format(time_col_name[-3:])
628628

629629
plt_any = False

python/nyx_space/plots/traj.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import plotly.graph_objects as go
2020
from plotly.subplots import make_subplots
2121
import pandas as pd
22+
from datetime import datetime
2223

2324
from .utils import (
2425
radii,
@@ -219,8 +220,8 @@ def plot_orbit_elements(
219220
epoch = epoch.replace("UTC", "").strip()
220221
if "." not in epoch:
221222
epoch += ".0"
222-
pd_ok_epochs += [epoch]
223-
df["Epoch"] = pd.to_datetime(pd_ok_epochs)
223+
pd_ok_epochs += [datetime.fromisoformat(str(epoch).replace("UTC", "").strip())]
224+
df["Epoch"] = pd.Series(pd_ok_epochs)
224225

225226
if not isinstance(names, list):
226227
names = [names]
@@ -317,8 +318,8 @@ def plot_traj_errors(
317318
epoch = epoch.replace("UTC", "").strip()
318319
if "." not in epoch:
319320
epoch += ".0"
320-
pd_ok_epochs += [epoch]
321-
df["Epoch"] = pd.to_datetime(pd_ok_epochs)
321+
pd_ok_epochs += [datetime.fromisoformat(str(epoch).replace("UTC", "").strip())]
322+
df["Epoch"] = pd.Series(pd_ok_epochs)
322323

323324
if not isinstance(names, list):
324325
names = [names]

0 commit comments

Comments
 (0)