Skip to content

Commit

Permalink
compare: allow force matmap3d
Browse files Browse the repository at this point in the history
  • Loading branch information
scivision committed Nov 24, 2023
1 parent fb179d4 commit 1ad6a04
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 12 deletions.
13 changes: 10 additions & 3 deletions scripts/matlab/compare_ecef2eci.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"""

from __future__ import annotations
import argparse
import logging
from datetime import datetime

Expand Down Expand Up @@ -56,13 +57,19 @@ def compare_eci2ecef(eng, eci, utc) -> bool:
return ok


eng = matlab_engine()

ecef = [-5762640.0, -1682738.0, 3156028.0]
eci = [-3009680.518620539, 5194367.153184303, 3156028.0]
utc_py = datetime(2019, 1, 4, 12)

print("Aerospace Toolbox:", has_aerospace(eng))
p = argparse.ArgumentParser(description="compare ecef eci")
p.add_argument(
"-f", "--force_matmap3d", help="use matmap3d instead of Matlab OEM Toolbox", action="store_true"
)
P = p.parse_args()

eng = matlab_engine()

print("Mapping Toolbox:", has_aerospace(eng, P.force_matmap3d))

if ecef2eci_ok := compare_ecef2eci(eng, ecef, utc_py):
print("OK: PyMap3d ecef2eci vs. Matlab ecef2eci")
Expand Down
13 changes: 10 additions & 3 deletions scripts/matlab/compare_lox.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"""
Compare with Matlab Mapping toolbox reckon()
"""
from __future__ import annotations

from __future__ import annotations
import argparse
import logging
from math import isclose

Expand Down Expand Up @@ -41,11 +42,17 @@ def stability(eng) -> bool:
return ok


p = argparse.ArgumentParser(description="compare reckon loxodrome")
p.add_argument(
"-f", "--force_matmap3d", help="use matmap3d instead of Matlab OEM Toolbox", action="store_true"
)
P = p.parse_args()

eng = matlab_engine()

print("Mapping Toolbox:", has_mapping(eng))
print("Mapping Toolbox:", has_mapping(eng, P.force_matmap3d))

if stability(eng):
print("OK: lox_stability: comparison: Mapp")
print("OK: lox_stability: comparison")
else:
raise ValueError("FAIL: lox_stability comparison")
10 changes: 8 additions & 2 deletions scripts/matlab/compare_vdist.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from __future__ import annotations

import argparse
import logging
from math import isclose, nan
import numpy as np
Expand Down Expand Up @@ -53,9 +53,15 @@ def stability(eng) -> bool:
return ok


p = argparse.ArgumentParser(description="compare vdist")
p.add_argument(
"-f", "--force_matmap3d", help="use matmap3d instead of Matlab OEM Toolbox", action="store_true"
)
P = p.parse_args()

eng = matlab_engine()

print("Mapping Toolbox:", has_mapping(eng))
print("Mapping Toolbox:", has_mapping(eng, P.force_matmap3d))

if stability(eng):
print("OK: vdist compare")
Expand Down
10 changes: 8 additions & 2 deletions scripts/matlab/compare_vreckon.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""

from __future__ import annotations

import argparse
import logging
from math import isclose, nan
import numpy as np
Expand Down Expand Up @@ -80,9 +80,15 @@ def unit(eng) -> bool:
return ok


p = argparse.ArgumentParser(description="compare vreckon")
p.add_argument(
"-f", "--force_matmap3d", help="use matmap3d instead of Matlab OEM Toolbox", action="store_true"
)
P = p.parse_args()

eng = matlab_engine()

print("Mapping Toolbox:", has_mapping(eng))
print("Mapping Toolbox:", has_mapping(eng, P.force_matmap3d))

if unit(eng) and stability(eng):
print("OK: vreckon compare")
Expand Down
16 changes: 14 additions & 2 deletions scripts/matlab/matlab_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,14 @@ def has_matmap3d(eng) -> bool:


@functools.cache
def has_aerospace(eng: matlab.engine.matlabengine.MatlabEngine) -> bool:
def has_aerospace(
eng: matlab.engine.matlabengine.MatlabEngine, force_matmap3d: bool = False
) -> bool:
if force_matmap3d:
if not has_matmap3d(eng):
raise EnvironmentError("did not find MatMap3d")
return False

if eng.matlab_toolbox()["aerospace"]:
return True

Expand All @@ -51,7 +58,12 @@ def has_aerospace(eng: matlab.engine.matlabengine.MatlabEngine) -> bool:
return False


def has_mapping(eng: matlab.engine.matlabengine.MatlabEngine) -> bool:
def has_mapping(eng: matlab.engine.matlabengine.MatlabEngine, force_matmap3d: bool = False) -> bool:
if force_matmap3d:
if not has_matmap3d(eng):
raise EnvironmentError("did not find MatMap3d")
return False

if eng.matlab_toolbox()["mapping"]:
return True

Expand Down

0 comments on commit 1ad6a04

Please sign in to comment.