示例#1
0
def test_scans():
    return get_ptbase_tslice(session,
                             r_query,
                             team=Teams['Mad Lads'],
                             Type=Scan,
                             start=-2 * 60,
                             end=10 * 60)
示例#2
0
def do_scans(team: TeamInfo,
             r_query,
             metadata: dict,
             update_dire=True,
             update_radiant=True):
    '''Makes plots for the scan origin points for replays in r_query.
       update_dire and update_radiant control updating specific sides.
    '''
    if not update_dire and not update_radiant:
        return metadata

    team_path = Path(PLOT_BASE_PATH) / team.name / metadata['name']
    (team_path / 'dire').mkdir(parents=True, exist_ok=True)
    (team_path / 'radiant').mkdir(parents=True, exist_ok=True)

    s_dire, s_radiant = get_ptbase_tslice(session,
                                          r_query,
                                          team=team,
                                          Type=Scan)

    fig, _ = plt.subplots(figsize=(10, 13))
    fig.clf()

    def _plot_scans(query, side: Team):
        data = dataframe_xy_time(query, Scan, session)
        plot_object_position_scatter(data, fig_in=fig)

        team_str = 'dire' if side == Team.DIRE else 'radiant'
        output = team_path / '{}/scan_summary.jpg'.format(team_str)
        fig.savefig(output, bbox_inches='tight')
        fig.clf()
        relpath = str(output.relative_to(Path(PLOT_BASE_PATH)))
        metadata['plot_scan_{}'.format(team_str)] = relpath

    if update_dire:
        _plot_scans(s_dire, Team.DIRE)
    if update_radiant:
        _plot_scans(s_radiant, Team.RADIANT)

    return metadata
示例#3
0
# teamName = "Royal Never Give Up"
teamName = "Hippomaniacs"
team = get_team(team_session, teamName)
# Royal never give up test case for bad pos
# r_query = team.get_replays(session).filter(Replay.replayID == 4857623860)
r_query = team.get_replays(session).filter(Replay.replayID == 4901403209)
d_query = team.get_replays(session)
#d_query = team.get_replays(session).filter(Replay.replayID == 4901517396)
wards_radiant = get_ptbase_tslice_side(session, r_query, team=team,
                                       Type=Ward,
                                       side=Team.RADIANT,
                                       start=-2*60, end=20*60)
wards_radiant = wards_radiant.filter(Ward.ward_type == WardType.OBSERVER)
wards_dire, _ = get_ptbase_tslice(session, d_query, team=team,
                                  Type=Ward,
                                  start=-2*60, end=20*60)
wards_dire = wards_dire.filter(Ward.ward_type == WardType.OBSERVER)


from analysis.ward_vis import build_ward_table
data = build_ward_table(wards_radiant, session, team_session)
ddata = build_ward_table(wards_dire, session, team_session)
from analysis.ward_vis import plot_full_text, plot_num_table, plot_eye_scatter, plot_drafts, plot_drafts_above

fig, ax = plt.subplots(figsize=(10, 13))
plot_full_text(data, ax)
# plot_drafts(r_query, ax, r_name=teamName)
# fig.savefig("r_full_text.png", bbox_inches='tight')

# fig, ax = plt.subplots(figsize=(10, 13))
示例#4
0
def do_wards(team: TeamInfo,
             r_query,
             metadata: dict,
             update_dire=True,
             update_radiant=True,
             replay_limit=20):

    if not update_dire and not update_radiant:
        return metadata
    team_path = Path(PLOT_BASE_PATH) / team.name / metadata['name']
    (team_path / 'dire').mkdir(parents=True, exist_ok=True)
    (team_path / 'radiant').mkdir(parents=True, exist_ok=True)
    vmin, vmax = (1, None)

    wards_dire, wards_radiant = get_ptbase_tslice(session,
                                                  r_query,
                                                  team=team,
                                                  Type=Ward,
                                                  start=-2 * 60,
                                                  end=12 * 60,
                                                  replay_limit=replay_limit)
    wards_dire = wards_dire.filter(Ward.ward_type == WardType.OBSERVER)
    wards_radiant = wards_radiant.filter(Ward.ward_type == WardType.OBSERVER)
    metadata['plot_ward_names'] = [
        "Pregame", "0 to 4 mins", "4 to 8 mins", "8 to 12 mins"
    ]
    fig, _ = plt.subplots(figsize=(10, 10))
    fig.clf()

    def _plot_wards(data: DataFrame, p_out: Path):
        plot_object_position(data, fig_in=fig, vmin=vmin, vmax=vmax)
        fig.tight_layout()
        fig.savefig(p_out)
        fig.clf()
        return

    if update_dire:
        metadata['plot_ward_dire'] = []
        output = team_path / 'dire'
        ward_df = dataframe_xy_time(wards_dire, Ward, session)

        p_out = output / 'wards_pregame.jpg'
        _plot_wards(ward_df.loc[ward_df['game_time'] <= 0], p_out)
        relpath = p_out.relative_to(Path(PLOT_BASE_PATH))
        metadata['plot_ward_dire'].append(str(relpath))

        p_out = output / 'wards_0to4.jpg'
        _plot_wards(
            ward_df.loc[(ward_df['game_time'] > 0)
                        & (ward_df['game_time'] <= 4 * 60)], p_out)
        relpath = (p_out).relative_to(Path(PLOT_BASE_PATH))
        metadata['plot_ward_dire'].append(str(relpath))

        p_out = output / 'wards_4to8.jpg'
        _plot_wards(
            ward_df.loc[(ward_df['game_time'] > 4 * 60)
                        & (ward_df['game_time'] <= 8 * 60)], p_out)
        relpath = (p_out).relative_to(Path(PLOT_BASE_PATH))
        metadata['plot_ward_dire'].append(str(relpath))

        p_out = output / 'wards_8to12.jpg'
        _plot_wards(
            ward_df.loc[(ward_df['game_time'] > 8 * 60)
                        & (ward_df['game_time'] <= 12 * 60)], p_out)
        relpath = (p_out).relative_to(Path(PLOT_BASE_PATH))
        metadata['plot_ward_dire'].append(str(relpath))

    if update_radiant:
        metadata['plot_ward_radiant'] = []
        output = team_path / 'radiant'
        ward_df = dataframe_xy_time(wards_radiant, Ward, session)

        p_out = output / 'wards_pregame.jpg'
        _plot_wards(ward_df.loc[ward_df['game_time'] <= 0], p_out)
        relpath = p_out.relative_to(Path(PLOT_BASE_PATH))
        metadata['plot_ward_radiant'].append(str(relpath))

        p_out = output / 'wards_0to4.jpg'
        _plot_wards(
            ward_df.loc[(ward_df['game_time'] > 0)
                        & (ward_df['game_time'] <= 4 * 60)], p_out)
        relpath = (p_out).relative_to(Path(PLOT_BASE_PATH))
        metadata['plot_ward_radiant'].append(str(relpath))

        p_out = output / 'wards_4to8.jpg'
        _plot_wards(
            ward_df.loc[(ward_df['game_time'] > 4 * 60)
                        & (ward_df['game_time'] <= 8 * 60)], p_out)
        relpath = (p_out).relative_to(Path(PLOT_BASE_PATH))
        metadata['plot_ward_radiant'].append(str(relpath))

        p_out = output / 'wards_8to12.jpg'
        _plot_wards(
            ward_df.loc[(ward_df['game_time'] > 8 * 60)
                        & (ward_df['game_time'] <= 12 * 60)], p_out)
        relpath = (p_out).relative_to(Path(PLOT_BASE_PATH))
        metadata['plot_ward_radiant'].append(str(relpath))

    return metadata