Shotprops
ShotProps
dataclass
¶
ShotProps(
shot: Shot,
bc: float,
curve: List[CurvePoint],
mach_list: List[float],
look_angle_rad: float,
twist_inch: float,
length_inch: float,
diameter_inch: float,
weight_grains: float,
barrel_elevation_rad: float,
barrel_azimuth_rad: float,
sight_height_ft: float,
cant_cosine: float,
cant_sine: float,
alt0_ft: float,
muzzle_velocity_fps: float,
)
Shot configuration and parameters for ballistic trajectory calculations.
Contains all shot-specific data converted to internal units for high-performance ballistic calculations. This class serves as the computational interface between user-friendly Shot objects and the numerical integration engines.
The class pre-computes expensive calculations (ballistic coefficient curves, atmospheric data, projectile properties) and stores them in optimized formats for repeated use during trajectory integration. All values are converted to internal units (feet, seconds, grains) for computational efficiency.
Examples:
from py_ballisticcalc import Shot, ShotProps
# Create shot configuration
shot = Shot(weapon=weapon, ammo=ammo, atmo=atmo)
# Convert to ShotProps
shot_props = ShotProps.from_shot(shot)
# Access pre-computed values
print(f"Stability coefficient: {shot_props.stability_coefficient}")
# Get drag coefficient at specific Mach number
drag = shot_props.drag_by_mach(1.5)
# Calculate spin drift at flight time
time = 1.2 # seconds
drift = shot_props.spin_drift(time) # inches
# Get atmospheric conditions at altitude
altitude = shot_props.alt0_ft + 100 # 100 feet above initial altitude
density_ratio, mach_fps = shot_props.get_density_and_mach_for_altitude(altitude)
Computational Optimizations
- Drag coefficient curves pre-computed for fast interpolation
- Trigonometric values (cant_cosine, cant_sine) pre-calculated
- Atmospheric parameters cached for repeated altitude lookups
- Miller stability coefficient computed once during initialization
Note
This class is designed for internal use by ballistic calculation engines. User code should typically work with Shot objects and let the Calculator handle the conversion to ShotProps automatically.
The original Shot object is retained for reference, but modifications to it after ShotProps creation will not affect the stored calculations. Create a new ShotProps instance if Shot parameters change.
Methods:
Name | Description |
---|---|
from_shot |
Initialize a ShotProps instance from a Shot instance. |
get_density_and_mach_for_altitude |
Get the air density and Mach number for a given altitude. |
drag_by_mach |
Calculate a standard drag factor (SDF) for the given Mach number. |
spin_drift |
Litz spin-drift approximation. |
calculate_curve |
Piecewise quadratic interpolation of drag curve. |
Functions¶
from_shot
classmethod
¶
Initialize a ShotProps instance from a Shot instance.
Source code in py_ballisticcalc/conditions.py
745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
|
get_density_and_mach_for_altitude
¶
Get the air density and Mach number for a given altitude.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
drop
|
float
|
The change in feet from the initial altitude. |
required |
Returns:
Type | Description |
---|---|
Tuple[float, float]
|
A tuple containing the air density (in lb/ft³) and Mach number at the specified altitude. |
Source code in py_ballisticcalc/conditions.py
767 768 769 770 771 772 773 774 775 776 |
|
drag_by_mach
¶
Calculate a standard drag factor (SDF) for the given Mach number.
Formula:
Drag force = V^2 * AirDensity * C_d * S / 2m
= V^2 * density_ratio * SDF
Where:
- density_ratio = LocalAirDensity / StandardDensity = rho / rho_0
- StandardDensity of Air = rho_0 = 0.076474 lb/ft^3
- S is cross-section = d^2 pi/4, where d is bullet diameter in inches
- m is bullet mass in pounds
- bc contains m/d^2 in units lb/in^2, which is multiplied by 144 to convert to lb/ft^2
Thus:
- The magic constant found here = StandardDensity * pi / (4 * 2 * 144)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mach
|
float
|
The Mach number. |
required |
Returns:
Type | Description |
---|---|
float
|
The standard drag factor at the given Mach number. |
Source code in py_ballisticcalc/conditions.py
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 |
|
spin_drift
¶
Litz spin-drift approximation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time
|
float
|
Time of flight |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
Windage due to spin drift, in inches |
Source code in py_ballisticcalc/conditions.py
805 806 807 808 809 810 811 812 813 814 815 816 817 818 |
|
calculate_curve
staticmethod
¶
calculate_curve(
data_points: List[DragDataPoint],
) -> List[CurvePoint]
Piecewise quadratic interpolation of drag curve.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_points
|
List[DragDataPoint]
|
List[{Mach, CD}] data_points in ascending Mach order |
required |
Returns:
Type | Description |
---|---|
List[CurvePoint]
|
List[CurvePoints] to interpolate drag coefficient |
Source code in py_ballisticcalc/conditions.py
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 |
|