Skip to content

Commit

Permalink
Released v2.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
Shiva-Iyer committed Mar 26, 2021
1 parent 5ea2d37 commit 8ec371b
Show file tree
Hide file tree
Showing 15 changed files with 299 additions and 395 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Installation
Development
-----------

1. Download and extract <https://github.com/ut-astria/orbdetpy/releases/download/2.0.5/orekit-data.tar.gz>
1. Download and extract <https://github.com/ut-astria/orbdetpy/releases/download/2.0.6/orekit-data.tar.gz>
under the `orbdetpy/` sub-folder.

2. Developers will need Apache Maven 3+ to build the Java library. Build
Expand Down
9 changes: 4 additions & 5 deletions examples/test_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@
# Propagate orbits and generate measurements
meas = list(m for m in propagate_orbits([cfg])[0].array)

# Zero valued measurements are ignored but they force the filters to output
# propagated states/covariances at arbitrary intermediate times
# Empty measurements are ignored in orbit estimation but they force the filters
# to output propagated states/covariances at arbitrary intermediate times
t0 = get_J2000_epoch_offset("2019-05-01T00:26:02.853Z")
for i in range(5):
meas.append(build_measurement(t0 + i*60.0, "Maui", [0.0, 0.0]))
meas.append(build_measurement(t0 + i*60.0, "", []))

# Measurements must be sorted in ascending chronological order
meas.sort(key=lambda m: m.time)
Expand All @@ -99,8 +99,7 @@

# Perturb truth initial state before running OD
cfg.prop_initial_state[:] = multivariate_normal(cfg.prop_initial_state, diag([1E6, 1E6, 1E6, 1E2, 1E2, 1E2]))
# Specify non-zero step to get propagated states/covariances between measurement updates
cfg.prop_step = 0.0
# Use Filter.EXTENDED_KALMAN for the EKF
cfg.estm_filter = Filter.UNSCENTED_KALMAN

# Run OD on simulated measurements
Expand Down
28 changes: 14 additions & 14 deletions orbdetpy/plotting/estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def plot(cfg: Settings, measurements, orbit_fit, interactive: bool=False,
parnames.append(f"{sk}-{meas_names[m]}")

diag_pos = [0, 2, 5, 9, 14, 20]
has_truth = len(inp) > 0 and hasattr(inp[0], "true_state") and len(inp[0].true_state) >= 6
tstamp,prefit,posfit,inocov,params,estmacc,estmcov,colors,state_err,state_cov = [],[],[],[],[],[],[],[],[],[]

for i, o in zip(inp, out):
tstamp.append(i.time)
colors.append(cmap[o.station if len(o.station) else None])
Expand All @@ -83,7 +83,7 @@ def plot(cfg: Settings, measurements, orbit_fit, interactive: bool=False,
else:
inocov.append([0.0]*len(prefit[0]))

if (has_truth):
if (hasattr(i, "true_state") and len(i.true_state) >= 6):
state_err.append([ix - ox for ix, ox in zip(i.true_state, o.estimated_state)])
state_cov.append([3.0*numpy.sqrt(o.estimated_covariance[m]) for m in diag_pos if (m < len(o.estimated_covariance))])

Expand All @@ -103,9 +103,9 @@ def plot(cfg: Settings, measurements, orbit_fit, interactive: bool=False,

if (len(tstamp) > 0):
start = tstamp[0] if (tstamp[0] < tstamp[-1]) else tstamp[-1]
tim = [(t - start)/3600 for t in tstamp]
times = [(t - start)/3600 for t in tstamp]
else:
tim = []
times = []

angles = [MeasurementType.AZIMUTH, MeasurementType.ELEVATION, MeasurementType.RIGHT_ASCENSION, MeasurementType.DECLINATION]
if (MeasurementType.POSITION in key):
Expand Down Expand Up @@ -136,7 +136,7 @@ def plot(cfg: Settings, measurements, orbit_fit, interactive: bool=False,
plt.subplot(3, 2, order[i])
else:
plt.subplot(pre.shape[-1], 1, i + 1)
plt.scatter(tim, pre[:,i], color=colors, marker="o", s=7)
plt.scatter(times, pre[:,i], color=colors, marker="o", s=7)
plt.legend(handles=patches, loc="best")
plt.xlabel("Time [hr]")
plt.ylabel(f"{ylabs[i]} [{units[i]}]")
Expand All @@ -156,10 +156,10 @@ def plot(cfg: Settings, measurements, orbit_fit, interactive: bool=False,
plt.subplot(3, 2, order[i])
else:
plt.subplot(pos.shape[-1], 1, i + 1)
plt.scatter(tim, pos[:,i], color=colors, marker="o", s=7)
plt.scatter(times, pos[:,i], color=colors, marker="o", s=7)
plt.legend(handles=patches, loc="best")
plt.plot(tim, -cov[:,i], "-r")
plt.plot(tim, cov[:,i], "-r")
plt.plot(times, -cov[:,i], "-r")
plt.plot(times, cov[:,i], "-r")
plt.xlabel("Time [hr]")
plt.ylabel(f"{ylabs[i]} [{units[i]}]")
plt.grid(True)
Expand All @@ -175,7 +175,7 @@ def plot(cfg: Settings, measurements, orbit_fit, interactive: bool=False,
plt.figure(2)
plt.suptitle("Estimated Parameters")
plt.subplot(par.shape[1], 1, i + 1)
plt.scatter(tim, par[:,i], marker="o", s=7)
plt.scatter(times, par[:,i], marker="o", s=7)
plt.xlabel("Time [hr]")
plt.ylabel(parnames[i])
plt.grid(True)
Expand All @@ -192,7 +192,7 @@ def plot(cfg: Settings, measurements, orbit_fit, interactive: bool=False,
for i in range(3):
plt.subplot(3, 1, i+1)
if (len(estmacc) > 0):
plt.plot(tim, estmacc[:,i])
plt.plot(times, estmacc[:,i])
plt.xlabel("Time [hr]")
plt.ylabel(lab[i])
plt.grid(True)
Expand All @@ -202,7 +202,7 @@ def plot(cfg: Settings, measurements, orbit_fit, interactive: bool=False,
outfiles.append(output_file_path + "_estacc.png")
plt.savefig(outfiles[-1], format="png")

if (has_truth):
if (len(times) == len(state_err)):
state_err = numpy.array(state_err)
state_cov = numpy.array(state_cov)
order = [1, 3, 5, 2, 4, 6]
Expand All @@ -212,9 +212,9 @@ def plot(cfg: Settings, measurements, orbit_fit, interactive: bool=False,
plt.suptitle("Position and Velocity Errors")
for i in range(6):
plt.subplot(3, 2, order[i])
plt.scatter(tim, state_err[:,i], color=colors, marker="o", s=7)
plt.plot(tim, -state_cov[:,i], "-r")
plt.plot(tim, state_cov[:,i], "-r")
plt.scatter(times, state_err[:,i], color=colors, marker="o", s=7)
plt.plot(times, -state_cov[:,i], "-r")
plt.plot(times, state_cov[:,i], "-r")
plt.xlabel("Time [hr]")
plt.ylabel(f"{ylabs[i]} [{units[i]}]")
plt.grid(True)
Expand Down
12 changes: 10 additions & 2 deletions orbdetpy/rpc/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from os import path
from socket import socket
from atexit import register
from os import environ, path
from psutil import Popen, process_iter
from grpc import channel_ready_future, insecure_channel

Expand All @@ -41,7 +41,15 @@ def connect(cls, data_dir, jar_file):
sock.bind((rpc_host, 0))
rpc_port = f"{sock.getsockname()[1]}"
sock.close()
cls.rpc_server = Popen(["java", "-Xmx2G", "-XX:+UseG1GC", "-jar", jar_file, rpc_port, data_dir])

java_home = environ.get("JAVA_HOME")
if (java_home and path.isdir(path.join(java_home, "bin"))):
java_exec = path.join(java_home, "bin", "java")
else:
java_exec = "java"

cls.rpc_server = Popen([java_exec, "-Xmx2G", "-XX:+UseG1GC", "-jar", jar_file, rpc_port, data_dir])

rpc_uri = f"{rpc_host}:{rpc_port}"
cls.rpc_channel = insecure_channel(rpc_uri, options=[("grpc.max_send_message_length", 2147483647),
("grpc.max_receive_message_length", 2147483647)])
Expand Down
Loading

0 comments on commit 8ec371b

Please sign in to comment.