Skip to content

Built in Functions

abraker95 edited this page Sep 8, 2021 · 7 revisions

This lists all the built-in functions available in the Embedded console.


Basic functions/variables

open_beatmap(beatmap_filepath) - Opens and loads specified beatmap file

load_beatmap(beatmap_data) - Loads provided beatmap data

open_replay(replay_filepath) - Opens and loads specified replay file

load_beatmap(replay_data) - Loads provided replay data

get_beatmap() - Returns a beatmap object of the currently loaded beatmap

get_replays() - Returns a list of data for currently loaded replays

add_layer_2d_data(name, data_2d) - Creates a scatter plot layer named name over the map view

add_graph_2d_data(name, data_2d, temporal, plot_type) - Creates a graph for data in the graph tab

timeline - Access to the timeline gui object

CmdUtils

CmdUtils.threaded(func, args) - Runs function func(args) in a separate thread which won't block the GUI while it's running

CmdUtils.run_script(filename, globals, locals) - Runs a python script from a file as if it was executed in the embedded console. Example usage: CmdUtils.run_script('scripts/download_replays.py', globals(), locals())

CmdUtils.print_numbered_list(lst) - Takes a list of strings and numbers them

CmdUtils.export_csv(name, data) - Exports 2D numpy data into csv file

CmdOnline

CmdOnline.get_latest_beatmapsets(gamemode, status) - Gets a list of WebBeatmapset objects representing the latest beatmapsets in with the specified MapStatus in GameMode.

def get_beatmap(beatmap_id) - Downloads a beatmap file. beatmap_id is the ID of the beatmap difficulty

CmdOnline.get_scores(beatmap_id, mode, name) - Gets a list of WebScore objects representing the top 50 replays for the specified beatmap id in GameMode. Name is the name of the map and is an optional parameter.

def get_scores_api(beatmap_id, mode, mods, name) - Gets a JSON containing score data associated with beatmap difficulty. Name is the name of the map and is an optional parameter.

CmdOnline.get_scores_from_beatmap(beatmap) - Provided a Beatmap object, gets a list of WebScore objects representing the top 50 replays

CmdOsu

CmdOsu.open_replay_file(replay_filepath) - Opens a replay file and returns a Replay object

CmdOsu.save_web_beatmaps(web_beatmaps) - Given a list of WebBeatmap objects, downloads all the maps into a folder tmp/beatmaps/

CmdOsu.save_web_replays(web_replays) - Given a list of WebScore objects, downloads all the replays into a folder tmp/replays/

CmdOsu.show_cursor_hit_offset_histogram(score_data, beatmap) - Given score data and Beatmap object, displays a histogram of distance of hits from center of hitcircles.

CmdOsu.create_score_offset_graph(replay_data) - Creates a scatter plot of hit offsets from 0ms in the graphs tab

CmdOsu.create_cursor_velocity_graph(replay_data) - Crates a line graph of cursor velocity over time in the graphs tab

CmdOsu.create_cursor_acceleration_graph(replay_data) - Crates a line graph of cursor acceleration over time in the graphs tab

CmdOsu.create_cursor_jerk_graph(replay_data) - Crates a line graph of cursor jerk over time in the graphs tab

StdMapData

StdMapData.get_map_data(std_hitobject) - Converts beatmap data into raw aimpoint data. Format of the data is the following pandas structure:

                        time      x      y  type  object
hitobject aimpoint                                      
0         0            557.0  300.0  324.0   1.0     1.0
          1            558.0  300.0  324.0   3.0     1.0
1         0            693.0  300.0  196.0   1.0     1.0
          1            694.0  300.0  196.0   3.0     1.0
2         0            829.0  410.0  260.0   1.0     2.0
                     ...    ...    ...   ...     ...
652       1         150952.0  460.0  112.0   3.0     2.0
653       0         151059.0  256.0  216.0   1.0     1.0
          1         151060.0  256.0  216.0   3.0     1.0
655       0         153059.0  256.0  192.0   1.0     1.0
          1         153060.0  256.0  192.0   3.0     1.0

StdMapData.get_data_before(hitobject_data, time) -

StdMapData.get_data_after(hitobject_data, time) -

StdMapData.time_slice(hitobject_data, start_time, end_time) -

StdMapData.start_times(hitobject_data) -

StdMapData.end_times(hitobject_data) -

StdMapData.start_positions(hitobject_data) -

StdMapData.end_positions(hitobject_data) -

StdMapData.all_positions(hitobject_data, flat=True) -

StdMapData.all_times(hitobject_data, flat=True) -

StdMapData.start_end_times(hitobject_data) -

StdMapData.get_idx_start_time(hitobject_data, time) -

StdMapData.get_idx_end_time(hitobject_data, time) -

StdMapMetrics

StdMapMetrics.calc_tapping_intervals(hitobject_data) -

StdMapMetrics.calc_notes_per_sec(hitobject_data) -

StdMapMetrics.calc_distances(hitobject_data) -

StdMapMetrics.calc_velocity(hitobject_data) -

StdMapMetrics.calc_velocity_start(hitobject_data) -

StdMapMetrics.calc_intensity(hitobject_data) -

StdMapMetrics.calc_angles(hitobject_data) -

StdMapMetrics.calc_xy_vel(hitobject_data) -

StdMapMetrics.calc_perp_int(hitobject_data) -

StdMapMetrics.calc_lin_int(hitobject_data) -

StdReplayData

StdReplayData.get_event_data(replay_events) - Given replay event data from the Replay object, returns replay data with the following structure:

         time         x         y  m1  m2  k1  k2  smoke
0       -1217  120.5313  168.5313   1   0   0   0      0
1       -1213  119.1250  168.5313   2   0   0   0      0
2       -1196  117.2500  169.0000   2   0   0   0      0
3       -1179  116.3125  169.0000   2   0   0   0      0
4       -1178  116.3125  169.0000   2   1   0   1      0
      ...       ...       ...  ..  ..  ..  ..    ...
11434  153438  250.3750  185.4063   0   0   0   0      0
11435  153455  246.6250  185.4063   0   0   0   0      0
11436  153469  243.8125  185.4063   0   0   0   0      0
11437  153488  240.0625  191.5000   0   0   0   0      0
11438  153505  237.2500  193.8438   0   0   0   0      0

StdReplayData.press_start_times(replay_data, key=None) - Returns:

[ press_start_idxs, press_start_times ] = [ [ int, int, ... ], [ int, int, ... ] ]

Tuple with indices in event_data where a press ends and timings where press ends. press_start_idxs can be used on original event_data to get full data related to start times like so: event_data[press_start_idxs]

StdReplayData.press_end_times(replay_data, key=None) - Returns:

[ press_end_idxs, press_end_times ] = [ [ int, int, ... ], [ int, int, ... ] ]

Tuple with indices in event_data where a press ends and timings where press ends. press_end_idxs can be used on original event_data to get full data related to end times like so: event_data[press_end_idxs]

StdReplayData.press_start_end_times(replay_data, key=None) -

[ 
    [ press_start_idx, press_start_time, press_end_idx, press_end_time ],
    [ press_start_idx, press_start_time, press_end_idx, press_end_time ],
    ...
]

StdReplayData.get_idx_time(replay_data, time) -

StdReplayData.get_idx_press_start_time(replay_data, time, key=None) -

StdReplayData.get_idx_press_end_time(replay_data, time, key=None) -

StdReplayMetrics

StdReplayMetrics.cursor_velocity(replay_data) -

StdReplayMetrics.cursor_acceleration(replay_data) -

StdReplayMetrics.cursor_jerk(replay_data) -

StdReplayMetrics.cursor_vel_xy(replay_data) -

StdReplayMetrics.cursor_accel_xy(replay_data) -

StdReplayMetrics.cursor_jerk_xy(replay_data) -

StdReplayMetrics.press_intervals(replay_data) -

StdScoreData

StdScoreData.get_score_data(replay_data, map_data) - pandas object; ex:

     replay_t     map_t  replay_x  replay_y       map_x       map_y  type  action  map_idx
0       568.0     557.0  301.9375  340.0938  300.000000  324.000000   0.0     1.0      0.0
1       677.0     693.0  289.2813  185.4063  300.000000  196.000000   0.0     1.0      1.0
2       806.0     829.0  410.6875  261.3438  410.000000  260.000000   0.0     1.0      2.0
3       919.0     897.0  351.1563  262.7500  413.714286  260.000000   1.0     3.0      2.0
4       949.0     966.0  346.9375  265.5625  336.000000  260.000000   0.0     1.0      3.0
..        ...       ...       ...       ...         ...         ...   ...     ...      ...
977  150791.0  150737.0  292.5625  155.4063   55.993911  115.684851   1.0     3.0    651.0
978  150844.0  150845.0  371.7813  156.8125  364.000000  164.000000   0.0     1.0    652.0
979  151009.0  150952.0  267.7188  213.5313  460.000000  112.000000   1.0     3.0    652.0
980  151058.0  151059.0  258.8125  221.0313  256.000000  216.000000   0.0     1.0    653.0
981  153089.0  153059.0  277.5625  184.4688  256.000000  192.000000   0.0     1.0    655.0

StdScoreData.tap_offset_mean(score_data) -

StdScoreData.tap_offset_var(score_data) -

StdScoreData.tap_offset_stdev(score_data) -

StdScoreData.cursor_pos_offset_mean(score_data) -

StdScoreData.cursor_pos_offset_var(score_data) -

StdScoreData.cursor_pos_offset_stdev(score_data) -

StdScoreData.odds_some_tap_within(score_data, offset) - Creates a gaussian distribution model using avg and var of tap offsets and calculates the odds that some hit is within the specified offset

Returns: probability one random value [X] is between -offset <= X <= offset

TL;DR: look at all the hits for scores; What are the odds of you picking a random hit that is between -offset and offset?

StdScoreData.odds_some_cursor_within(score_data, offset) - Creates a 2D gaussian distribution model using avg and var of cursor 2D position offsets and uses it to calculates the odds that some cursor position is within the specified distance from the center of any hitobject

Returns: probability one random value [X, Y] is between (-offset, -offset) <= (X, Y) <= (offset, offset)

TL;DR: look at all the cursor positions for score; What are the odds of you picking a random hit that has a cursor position between an area of (-offset, -offset) and (offset, offset)?

StdScoreData.odds_all_tap_within(score_data, offset) - Creates a gaussian distribution model using avg and var of tap offsets and calculates the odds that all hits are within the specified offset

Returns: probability all random values [X] are between -offset <= X <= offset

TL;DR: look at all the hits for scores; What are the odds all of them are between -offset and offset?

StdScoreData.odds_all_cursor_within(score_data, offset) - Creates a 2D gaussian distribution model using avg and var of cursor 2D position offsets and uses it to calculates the odds that all cursor positions are within the specified distance from the center of all hitobject

Returns: probability all random values {[X, Y], ...} are between (-offset, -offset) <= (X, Y) <= (offset, offset)

TL;DR: look at all the cursor positions for score; What are the odds all of them are between an area of (-offset, -offset) and (offset, offset)?

StdScoreData.odds_all_conditions_within(score_data, tap_offset, cursor_offset) - Creates gaussian distribution models using tap offsets and cursor offsets for hits. That is used to calculate the odds of the player consistently tapping and aiming within those boundaries for the entire play. Be weary of survivorship bias.

StdScoreMetrics

StdScoreMetrics.get_per_hitobject_score_data(score_data_array) - Takes arrays of score data pertaining to various players and transposes it to be an array of per-hitobject score data from various players

[
    [
a0      [ time, (cursor_pos_x, cursor_pos_y), hit_offset, (pos_offset_x, pos_offset_y), hitobject_idx ],
a2      [ time, (cursor_pos_x, cursor_pos_y), hit_offset, (pos_offset_x, pos_offset_y), hitobject_idx ],
aN      ...  N events
    ],
    [
b0      [ time, (cursor_pos_x, cursor_pos_y), hit_offset, (pos_offset_x, pos_offset_y), hitobject_idx ],
b1      [ time, (cursor_pos_x, cursor_pos_y), hit_offset, (pos_offset_x, pos_offset_y), hitobject_idx ],
bN      ...  N events
    ],
    ...
]

gets turned into

[
    [
a0      [ time, (cursor_pos_x, cursor_pos_y), hit_offset, (pos_offset_x, pos_offset_y), hitobject_idx ],
b0      [ time, (cursor_pos_x, cursor_pos_y), hit_offset, (pos_offset_x, pos_offset_y), hitobject_idx ],
N0      ...  N events
    ],
    [
a1      [ time, (cursor_pos_x, cursor_pos_y), hit_offset, (pos_offset_x, pos_offset_y), hitobject_idx ],
b1      [ time, (cursor_pos_x, cursor_pos_y), hit_offset, (pos_offset_x, pos_offset_y), hitobject_idx ],
N1      ...  N events
    ],
    ...
]

StdScoreMetrics.get_percent_below_offset(per_hitobject_score_data, hitobject_idx, offset) -

StdScoreMetrics.trans_percent_players_taps(per_hitobject_score_data, offset) - Gives the percent of players tapping within the specified offset for each hitobject

StdScoreMetrics.solve_for_hit_offset(per_hitobject_score_data, hitobject_idx, target_percent) - Solves for the tapping offset for the note that 50% of players are able to do

StdScoreMetrics.trans_solve_for_hit_offset(per_hitobject_score_data) - Solves for the tapping offset for the note that 50% of players are able to do

ManiaMapData

ManiaMapData.get_hitobject_data(hitobjects) -

ManiaMapData.start_times(hitobject_data, column=None) -

ManiaMapData.end_times(hitobject_data, column=None) -

ManiaMapData.all_times(flat=True) -

ManiaMapData.start_end_times(hitobject_data, column) -

ManiaMapData.get_idx_start_time(hitobject_data, column, time) -

ManiaMapData.get_idx_end_time(hitobject_data, column, time) -

ManiaMapMetrics

ManiaMapMetrics.calc_tapping_intervals(hitobject_data, column) -

ManiaMapMetrics.calc_notes_per_sec(hitobject_data, column=None) -

ManiaReplayData

ManiaReplayData.get_replay_data(replay_events, columns) -

ManiaReplayData.start_times(event_data, column) -

ManiaReplayData.end_times(event_data, column) -

ManiaReplayData.all_times(flat=True) -

ManiaReplayData.start_end_times(event_data, column) -

ManiaReplayData.get_idx_start_time(event_data, column, time) -

ManiaReplayData.get_idx_end_time(event_data, column, time) -

ManiaScoreData

ManiaScoreData.get_score_data(replay_data, map_data) -

ManiaScoreData.tap_offset_mean(score_data) -

ManiaScoreData.tap_offset_var(score_data) -

ManiaScoreData.tap_offset_stdev(score_data) -

ManiaScoreData.model_offset_prob(mean, stdev, offset) -

ManiaScoreData.odds_some_tap_within(score_data, offset) -

ManiaScoreData.odds_all_tap_within(score_data, offset) -

ManiaScoreData.odds_all_tap_within_trials(score_data, offset, trials) -

ManiaScoreData.model_ideal_acc(mean, stdev, num_notes, score_point_judgements=None) -

ManiaScoreData.model_ideal_acc_data(score_data, score_point_judgements=None) -

ManiaScoreData.model_num_hits(mean, stdev, num_notes) -