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
790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 | |
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
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 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 | |
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
919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 | |
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
935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 | |
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
951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 | |
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
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 | |
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
987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 | |
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
1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 | |
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
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 | |
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
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | |