diff --git a/py_ballisticcalc/__init__.py b/py_ballisticcalc/__init__.py index 5f22da4..5ccd8f5 100644 --- a/py_ballisticcalc/__init__.py +++ b/py_ballisticcalc/__init__.py @@ -4,7 +4,7 @@ __copyright__ = ("",) __credits__ = ["o-murphy"] -__version__ = "1.1.0b7" +__version__ = "1.1.0b8" from .drag_model import * # pylint: disable=import-error from .drag_tables import * diff --git a/py_ballisticcalc/interface.py b/py_ballisticcalc/interface.py index eb0f722..e5b62b5 100644 --- a/py_ballisticcalc/interface.py +++ b/py_ballisticcalc/interface.py @@ -96,20 +96,17 @@ def to_dataframe(trajectory: list[TrajectoryData]): trajectory = [p.in_def_units() for p in trajectory] return pd.DataFrame(trajectory, columns=col_names) - def show_plot(self, shot, winds): + def show_plot(self, shot, current_atmo, winds): import matplotlib import matplotlib.pyplot as plt + matplotlib.use('TkAgg') self._calc = TrajectoryCalc(self.ammo) - # self.update_elevation() - data = self._calc.trajectory(self.weapon, self.zero_atmo, shot, winds, + data = self._calc.trajectory(self.weapon, current_atmo, shot, winds, TrajFlag.ALL.value) # Step in 10-yard increments to produce smoother curves df = self.to_dataframe(data) ax = df.plot(x='distance', y=['drop'], ylabel=Set.Units.drop.symbol) - # zero_d = self.weapon.zero_distance >> Set.Units.distance - # zero = ax.plot([zero_d, zero_d], [df['drop'].min(), df['drop'].max()], linestyle='--') - for p in data: if TrajFlag(p.flag) & TrajFlag.ZERO: @@ -120,11 +117,8 @@ def show_plot(self, shot, winds): [df['drop'].min(), p.drop >> Set.Units.drop], linestyle='--', label='mach') ax.text(p.distance >> Set.Units.distance, df['drop'].min(), " Mach") - #sh = self.weapon.sight_height >> Set.Units.drop - # # scope line x_values = [0, df.distance.max()] # Adjust these as needed - # y_values = [sh, sh - df.distance.max() * math.tan(self.elevation >> Angular.Degree)] # Adjust these as needed y_values = [0, 0] # Adjust these as needed ax.plot(x_values, y_values, linestyle='--', label='scope line') ax.text(df.distance.max() - 100, -100, "Scope") diff --git a/py_ballisticcalc/munition.py b/py_ballisticcalc/munition.py index 622445c..bba77ea 100644 --- a/py_ballisticcalc/munition.py +++ b/py_ballisticcalc/munition.py @@ -27,8 +27,8 @@ class Weapon(TypedUnits): """ sight_height: [float, Distance] = field(default_factory=lambda: Set.Units.sight_height) zero_distance: [float, Distance] = field(default_factory=lambda: Set.Units.distance) - zero_look_angle: [float, Angular] = field(default_factory=lambda: Set.Units.angular) twist: [float, Distance] = field(default_factory=lambda: Set.Units.twist) + zero_look_angle: [float, Angular] = field(default_factory=lambda: Set.Units.angular) def __post_init__(self): if not self.twist: diff --git a/py_ballisticcalc/trajectory_data.py b/py_ballisticcalc/trajectory_data.py index 30bebf3..694840d 100644 --- a/py_ballisticcalc/trajectory_data.py +++ b/py_ballisticcalc/trajectory_data.py @@ -94,6 +94,5 @@ def in_def_units(self) -> tuple: self.angle >> Set.Units.angular, self.energy >> Set.Units.energy, self.ogw >> Set.Units.ogw, - - self.flag + TrajFlag(self.flag) ) diff --git a/tests/test_plot.py.bak b/tests/plot.py similarity index 63% rename from tests/test_plot.py.bak rename to tests/plot.py index 033354a..b986f34 100644 --- a/tests/test_plot.py.bak +++ b/tests/plot.py @@ -6,10 +6,11 @@ dm = DragModel(0.22, TableG7, 168, 0.308) ammo = Ammo(dm, 1.22, Velocity(2600, Velocity.FPS)) atmosphere = Atmo.icao() -weapon = Weapon(3, 100, 11.24) +weapon = Weapon(4, 100, 11.24) calc = Calculator(weapon, ammo, atmosphere) calc.update_elevation() -shot = Shot(1200, Distance.Foot(0.2), sight_angle=calc.elevation, shot_angle=Angular.Mil(0)) +atmo = Atmo.icao() -calc.show_plot(shot, [Wind()]) +shot = Shot(1200, Distance.Foot(0.2), zero_angle=calc.elevation, relative_angle=Angular.MOA(0)) +calc.show_plot(shot, atmo, [Wind()])