diff --git a/scripts/matlab/compare_ecef2eci.py b/scripts/matlab/compare_ecef2eci.py index c2f7aff..8aeb856 100644 --- a/scripts/matlab/compare_ecef2eci.py +++ b/scripts/matlab/compare_ecef2eci.py @@ -4,6 +4,7 @@ """ from __future__ import annotations +import argparse import logging from datetime import datetime @@ -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") diff --git a/scripts/matlab/compare_lox.py b/scripts/matlab/compare_lox.py index 2673146..f14a279 100644 --- a/scripts/matlab/compare_lox.py +++ b/scripts/matlab/compare_lox.py @@ -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 @@ -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") diff --git a/scripts/matlab/compare_vdist.py b/scripts/matlab/compare_vdist.py index 75d3c97..00d9ceb 100644 --- a/scripts/matlab/compare_vdist.py +++ b/scripts/matlab/compare_vdist.py @@ -4,7 +4,7 @@ """ from __future__ import annotations - +import argparse import logging from math import isclose, nan import numpy as np @@ -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") diff --git a/scripts/matlab/compare_vreckon.py b/scripts/matlab/compare_vreckon.py index 034bf12..a557b83 100644 --- a/scripts/matlab/compare_vreckon.py +++ b/scripts/matlab/compare_vreckon.py @@ -4,7 +4,7 @@ """ from __future__ import annotations - +import argparse import logging from math import isclose, nan import numpy as np @@ -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") diff --git a/scripts/matlab/matlab_engine.py b/scripts/matlab/matlab_engine.py index cc2fd27..12380d2 100644 --- a/scripts/matlab/matlab_engine.py +++ b/scripts/matlab/matlab_engine.py @@ -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 @@ -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