Baseball Files
team_stats
Calculate Team Stats over Time.
classes:
gdStats - GameDay Stats Class
functions:
dispatch (cmd,..) - Module Command Dispatch
main (tc, dt0, dt1,...) - generate stats for given team and dates
do_years ([tc]) - generate tables for all seasons
do_teams ([yr]) - generate tables for all teams (this season)
histogram (lst)
Developer@Sonnack.com
April 2012
function dispatch
Dispatch Command.
usage:
team_stats {command} [{team-code} [{stat-year}]]
commands:
main - [tc [yr]]
args - [tc] {from-dt} {to-dt} [{title}] [{ftag}]
spcl - [tc]
AllTeams -
AllYears - [tc]
HomeGames - [tc]
AwayGames - [tc]
WonGames - [tc]
LostGames - [tc]
FirstHalf - [tc]
SecondHalf - [tc]
function do_teams
Generate Team Stats for all Teams.
function do_years
Generate Team Stats for all years.
function histogram
Generate a histogram from a list.
function main
Generate Team Stats for given date range.
Writes the Stats TAB and HTML files for the date range provided.
Returns Stats object.
type gdStats
GameDay Stats Class.
properties:
.dt0 - First Date of sequence
.team_code - Team Code (e.g. "min")
.team_name - Team Name Tuple
.nbr_games - Number of games
.win, .lose - Win/Lose Record - Overall
.win_home, .lose_home - Win/Lose Record - Home Games
.win_away, .lose_away - Win/Lose Record - Away Games
.pct - Win/Lose Percent - Overall
.pct_home - Win/Lose Percent - Home Games
.pct_away - Win/Lose Percent - Away Games
.lt6_w, .lt6_l - Games w/ < 6 Runs (i.e. <= 5)
.gt5_w, .gt5_l - Games w/ > 5 Runs
.by1_w, .by1_l - Run Diff == 1
.by6_w, .by6_l - Run Diff <= 6 (i.e. > 5)
.sp_bf , .bp_bft - Starter/Bullpen Batters Faced
.sp_out, .bp_out - Starter/Bullpen Outs
.sp_er , .bp_er - Starter/Bullpen Earned Runs
.sp_h , .bp_h - Starter/Bullpen Hits
.sp_r , .bp_r - Starter/Bullpen Runs
.sp_hr , .bp_hr - Starter/Bullpen Home Runs
.sp_so , .bp_so - Starter/Bullpen Strike Outs
.sp_bb , .bp_bb - Starter/Bullpen Walks
.sp_era, .bp_era - Starter/Bullpen ERA
.t_era - Pitchers' ERA
.dif_runs[] - List of Run Deltas
.dif_hits[] - List of Hit Deltas
.dif_rmax, .dif_rmin - Max, Min Run Delta
.dif_hmax, .dif_hmin - Max, Min Hit Delta
.xxx_runs[] - List of Runs
.xxx_hits[] - List of Runs
.xxx_errs[] - List of Runs
.xxx_r - Total Runs
.xxx_h - Total Hits
.xxx_e - Total Errs
.xxx_rpg - Runs Per Game
.xxx_hpg - Hits Per Game
.xxx_epg - Errs Per Game
.xxx_rmax, .xxx_rmin - Max, Min Runs
.xxx_hmax, .xxx_hmin - Max, Min Hits
.xxx_emax, .xxx_emin - Max, Min Errs
.xxx_rhg - Runs Per Hit (game average)
.xxx_rha - Runs Per Hit (season average)
.xxx_rstdev - Runs - Standard Deviation
.xxx_hstdev - Hits - Standard Deviation
.xxx_rhist[] - Runs Histogram
.xxx_hhist[] - Hits Histogram
.xxx_ehist[] - Errs Histogram
.xxx_nhist[] - Inning Runs Histogram
(where xxx is min and opp)
methods:
.write_text () - write output file
.write_html () - write HTML page
.write2file (fp) - write stats to fp
.write2html (fp,tag) - write HTML stats to fp
.writepage (fp) - HTML page
str(obj) - stats Dump string
repl(obj) - JSON-like string