Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

Commit

Permalink
Remove altair
Browse files Browse the repository at this point in the history
  • Loading branch information
spascou committed Jul 13, 2020
1 parent 9e10b9d commit 2316360
Show file tree
Hide file tree
Showing 10 changed files with 6 additions and 700 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ and exploitation is performed here in *ps2-analysis*.
- Currently supports infantry and vehicle weapons data
- Downloads datasets from the API and stores them locally as *ndjson* files
- Parses data and generates class objects suitable for further processing
- Generates *vega-lite* charts using [Altair](https://altair-viz.github.io/)

## Installation
```sh
Expand All @@ -30,8 +29,6 @@ Examples are available in the `examples` folder:
- `discover_vehicle_weapons.py`: updates the vehicle weapons datafile and outputs all different (nested) key paths as well as associated set of values encountered within the whole dataset; example output in `discover_vehicle_weapons.json`
- `generate_infantry_weapons.py`: no output; simply an example of `InfantryWeapon` objects generation
- `generate_vehicle_weapons.py`: no output; simply an example of `VehicleWeapon` objects generation
- `fire_simulation_plot.py`: generates a fire simulation plot for the TRAC-5 TR carbine, 100 runs of 10 shots
- `ttk_to_mhd_plot.py`: generates a plot of time to kill at 15meters to mean horizontal deviation for all SMGs

## Development

Expand All @@ -46,5 +43,5 @@ In order to develop *ps2-analysis*:

To run the examples in the `examples` folder:
- Add your Census API service ID to the `CENSUS_SERVICE_ID` environment variable
- Create two folders inside the `examples` folder of the cloned repository: `datafiles` and `plots`
- Create a folder inside the `examples` folder of the cloned repository: `datafiles`
- Run the scripts and check the outputs
55 changes: 0 additions & 55 deletions examples/generate_shot_simulation.py

This file was deleted.

250 changes: 5 additions & 245 deletions poetry.lock

Large diffs are not rendered by default.

46 changes: 0 additions & 46 deletions ps2_analysis/altair_utils.py

This file was deleted.

117 changes: 0 additions & 117 deletions ps2_analysis/fire_groups/fire_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@
from dataclasses import dataclass, field
from typing import Dict, Iterator, List, Literal, Optional, Tuple

import altair
import methodtools
from ps2_census.enums import FireModeType, PlayerState

from ps2_analysis.altair_utils import (
SIMULATION_POINT_TYPE_COLOR,
SIMULATION_POINT_TYPE_SELECTION,
X,
Y,
)
from ps2_analysis.enums import DamageLocation
from ps2_analysis.geometry_utils import planetman_hit_location
from ps2_analysis.utils import damage_to_kill, float_range
Expand Down Expand Up @@ -656,116 +649,6 @@ def simulate_shots(

previous_t = t

def altair_simulate_shots(
self,
shots: int,
runs: int = 1,
control_time: int = 0,
auto_burst_length: Optional[int] = None,
recentering: bool = False,
recentering_response_time: int = 1_000,
recentering_inertia_factor: float = 0.3,
player_state: PlayerState = PlayerState.STANDING,
width: Optional[int] = None,
height: Optional[int] = None,
) -> altair.HConcatChart:

assert (width or height) and not (width and height)

datapoints: List[dict] = []

simulation: Iterator[Tuple[int, Tuple[float, float], List[Tuple[float, float]]]]
for simulation in (
self.simulate_shots(
shots=shots,
control_time=control_time,
auto_burst_length=auto_burst_length,
recentering=recentering,
recentering_response_time=recentering_response_time,
recentering_inertia_factor=recentering_inertia_factor,
player_state=player_state,
)
for _ in range(runs)
):

t: int
cursor_coor: Tuple[float, float]
pellets_coors: List[Tuple[float, float]]
for t, cursor_coor, pellets_coors in simulation:

cursor_x, cursor_y = cursor_coor

datapoints.append(
{"Time": t, X: cursor_x, Y: cursor_y, "Type": "cursor"}
)

for pellet_x, pellet_y in pellets_coors:
datapoints.append(
{"Time": t, X: pellet_x, Y: pellet_y, "Type": "pellet"}
)

min_x: float = min((d[X] for d in datapoints))
max_x: float = max((d[X] for d in datapoints))
min_y: float = min((d[Y] for d in datapoints))
max_y: float = max((d[Y] for d in datapoints))

if height:

if max_y != min_y:

width = int(math.ceil((max_x - min_x) * height / (max_y - min_y)))

else:

width = 0

elif width:

if max_x != min_x:

height = int(math.ceil((max_y - min_y) * width / (max_x - min_x)))

else:

height = 0

dataset: altair.Data = altair.Data(values=datapoints)

chart: altair.Chart = (
altair.Chart(dataset)
.mark_point()
.encode(
x=altair.X(
f"{X}:Q",
axis=altair.Axis(title="horizontal angle (degrees)"),
scale=altair.Scale(domain=(min_x, max_x), zero=False),
),
y=altair.Y(
f"{Y}:Q",
axis=altair.Axis(title="vertical angle (degrees)"),
scale=altair.Scale(domain=(min_y, max_y), zero=False),
),
color=SIMULATION_POINT_TYPE_COLOR,
tooltip=["Time:Q", f"{X}:Q", f"{Y}:Q"],
)
.properties(width=width, height=height)
.interactive()
)

legend: altair.Chart = (
altair.Chart(dataset)
.mark_point()
.encode(
y=altair.Y("Type:N", axis=altair.Axis(orient="right")),
color=SIMULATION_POINT_TYPE_COLOR,
)
.add_selection(SIMULATION_POINT_TYPE_SELECTION)
)

result: altair.HConcatChart = altair.hconcat(chart, legend)

return result

def damage_inflicted_by_pellets(
self,
distance: float,
Expand Down
Empty file.
42 changes: 0 additions & 42 deletions ps2_analysis/visualizations/color_selections.py

This file was deleted.

68 changes: 0 additions & 68 deletions ps2_analysis/visualizations/fire_simulation.py

This file was deleted.

Loading

0 comments on commit 2316360

Please sign in to comment.