HitResult
HitResult
dataclass
¶
HitResult(
props: ShotProps,
trajectory: list[TrajectoryData],
base_data: Optional[list[BaseTrajData]],
extra: bool = False,
error: Optional[RangeError] = None,
)
Computed trajectory data of the shot.
Attributes:
Name | Type | Description |
---|---|---|
shot |
The parameters of the shot calculation. |
|
trajectory |
list[TrajectoryData]
|
Computed TrajectoryData points. |
base_data |
Optional[list[BaseTrajData]]
|
Base trajectory data points for interpolation. |
extra |
bool
|
[DEPRECATED] Whether extra_data was requested. |
error |
Optional[RangeError]
|
RangeError, if any. |
Methods:
Name | Description |
---|---|
flag |
Get first TrajectoryData row with the specified flag. |
get_at |
Get TrajectoryData where key_attribute==value. |
zeros |
Get all zero crossing points. |
index_at_distance |
Deprecated. Use get_at() instead. |
get_at_distance |
Deprecated. Use get_at('distance', d) instead. |
get_at_time |
Deprecated. Use get_at('time', t) instead. |
danger_space |
Calculate the danger space for a target. |
dataframe |
Return the trajectory table as a DataFrame. |
plot |
Return a graph of the trajectory. |
Functions¶
flag
¶
flag(
flag: Union[TrajFlag, int],
) -> Optional[TrajectoryData]
Get first TrajectoryData row with the specified flag.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flag
|
Union[TrajFlag, int]
|
The flag to search for. |
required |
Returns:
Type | Description |
---|---|
Optional[TrajectoryData]
|
First TrajectoryData row with the specified flag. |
Raises:
Type | Description |
---|---|
AttributeError
|
If flag was not requested. |
Source code in py_ballisticcalc/trajectory_data.py
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 |
|
get_at
¶
get_at(
key_attribute: TRAJECTORY_DATA_ATTRIBUTES,
value: Union[float, GenericDimension],
*,
epsilon: float = 1e-09,
start_from_time: float = 0.0,
) -> TrajectoryData
Get TrajectoryData where key_attribute==value.
Interpolates to create new object if necessary. Preserves the units of the original trajectory data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key_attribute
|
TRAJECTORY_DATA_ATTRIBUTES
|
The name of the TrajectoryData attribute to key on (e.g., 'time', 'distance'). |
required |
value
|
Union[float, GenericDimension]
|
The value of the key attribute to find. If a float is provided for a dimensioned attribute, it's assumed to be a .raw_value. |
required |
epsilon
|
float
|
Allowed key value difference to match existing TrajectoryData object without interpolating. |
1e-09
|
start_from_time
|
float
|
The time to center the search from (default is 0.0). If the target value is at a local extremum then the search will only go forward in time. |
0.0
|
Returns:
Type | Description |
---|---|
TrajectoryData
|
TrajectoryData where key_attribute==value. |
Raises:
Type | Description |
---|---|
AttributeError
|
If TrajectoryData doesn't have the specified attribute. |
KeyError
|
If the key_attribute is 'flag'. |
ValueError
|
If interpolation is required and len(self.trajectory) < 3. |
ArithmeticError
|
If trajectory doesn't reach the requested value. |
Notes
- Not all attributes are monotonic: Height typically goes up and then down. Velocity typically goes down, but for lofted trajectories can begin to increase. Windage can wander back and forth in complex winds. We even have (see ExtremeExamples.ipynb) backward-bending scenarios in which distance reverses!
- The only guarantee is that time is strictly increasing.
Source code in py_ballisticcalc/trajectory_data.py
738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 |
|
zeros
¶
zeros() -> list[TrajectoryData]
Get all zero crossing points.
Returns:
Type | Description |
---|---|
list[TrajectoryData]
|
Zero crossing points. |
Raises:
Type | Description |
---|---|
AttributeError
|
If extra_data was not requested. |
ArithmeticError
|
If zero crossing points are not found. |
Source code in py_ballisticcalc/trajectory_data.py
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 |
|
index_at_distance
¶
Deprecated. Use get_at() instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d
|
Distance
|
Distance for which we want Trajectory Data. |
required |
Returns:
Type | Description |
---|---|
int
|
Index of first trajectory row with .distance >= d; otherwise -1. |
Source code in py_ballisticcalc/trajectory_data.py
861 862 863 864 865 866 867 868 869 870 871 872 873 |
|
get_at_distance
¶
get_at_distance(d: Distance) -> TrajectoryData
Deprecated. Use get_at('distance', d) instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
d
|
Distance
|
Distance for which we want Trajectory Data. |
required |
Returns:
Type | Description |
---|---|
TrajectoryData
|
First trajectory row with .distance >= d. |
Raises:
Type | Description |
---|---|
ArithmeticError
|
If trajectory doesn't reach requested distance. |
Source code in py_ballisticcalc/trajectory_data.py
875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 |
|
get_at_time
¶
get_at_time(t: float) -> TrajectoryData
Deprecated. Use get_at('time', t) instead.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
t
|
float
|
Time for which we want Trajectory Data. |
required |
Returns:
Type | Description |
---|---|
TrajectoryData
|
First trajectory row with .time >= t. |
Raises:
Type | Description |
---|---|
ArithmeticError
|
If trajectory doesn't reach requested time. |
Source code in py_ballisticcalc/trajectory_data.py
894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 |
|
danger_space
¶
danger_space(
at_range: Union[float, Distance],
target_height: Union[float, Distance],
) -> DangerSpace
Calculate the danger space for a target.
Assumes that the trajectory hits the center of a target at any distance.
Determines how much ranging error can be tolerated if the critical region
of the target has target_height *h*. Finds how far forward and backward along the
line of sight a target can move such that the trajectory is still within *h*/2
of the original drop at_range.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
at_range
|
Union[float, Distance]
|
Danger space is calculated for a target centered at this sight distance. |
required |
target_height
|
Union[float, Distance]
|
Target height (h) determines danger space. |
required |
Returns:
Name | Type | Description |
---|---|---|
DangerSpace |
DangerSpace
|
The calculated danger space. |
Raises:
Type | Description |
---|---|
ArithmeticError
|
If trajectory doesn't reach requested distance. |
Source code in py_ballisticcalc/trajectory_data.py
916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 |
|
dataframe
¶
dataframe(formatted: bool = False) -> DataFrame
Return the trajectory table as a DataFrame.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
formatted
|
bool
|
False for values as floats; True for strings in PreferredUnits. Default is False. |
False
|
Returns:
Type | Description |
---|---|
DataFrame
|
The trajectory table as a DataFrame. |
Raises:
Type | Description |
---|---|
ImportError
|
If pandas or plotting dependencies are not installed. |
Source code in py_ballisticcalc/trajectory_data.py
961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 |
|
plot
¶
plot(look_angle: Optional[Angular] = None) -> Axes
Return a graph of the trajectory.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
look_angle
|
Optional[Angular]
|
Look angle for the plot. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
Axes
|
The plot Axes object. |
Raises:
Type | Description |
---|---|
ImportError
|
If plotting dependencies are not installed. |
Source code in py_ballisticcalc/trajectory_data.py
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
|
DangerSpace
¶
Bases: NamedTuple
Stores the danger space data for distance specified.
Methods:
Name | Description |
---|---|
overlay |
Highlights danger-space region on plot. |
Functions¶
overlay
¶
overlay(ax: Axes, label: Optional[str] = None) -> None
Highlights danger-space region on plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ax
|
Axes
|
The axes to overlay on. |
required |
label
|
Optional[str]
|
Label for the overlay. Defaults to None. |
None
|
Raises:
Type | Description |
---|---|
ImportError
|
If plotting dependencies are not installed. |
Source code in py_ballisticcalc/trajectory_data.py
655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 |
|