Chadwick Documentation Release 0.9.0
Total Page:16
File Type:pdf, Size:1020Kb
Chadwick Documentation Release 0.9.0 T. L. Turocy Jan 04, 2021 Contents 1 Introduction 1 2 Command-line tools 3 i ii CHAPTER 1 Introduction Chadwick is a collection of command-line utility programs for extracting information from baseball play-by-play and boxscore files in the DiamondWare format, as used by Retrosheet (http://www.retrosheet.org). 1.1 Author Chadwick is written, maintained, and Copyright 2002-2020 by Dr T. L. Turocy (ted.turocy <aht> gmail <daht> com) at Chadwick Baseball Bureau (http://www.chadwick-bureau.com). 1.2 License Chadwick is licensed under the terms of the GNU General Public License. If the GPL doesn’t meet your needs, contact the author for other licensing possibilities. 1.3 Development The Chadwick source code is managed using git, at https://github.com/chadwickbureau/chadwick. Bugs in Chadwick should be reported to the issue tracker on github at https://github.com/chadwickbureau/chadwick/ issues. Please be as specific as possible in reporting a bug, including the version of Chadwick you are using, the operating system(s) you’re using, and a detailed list of steps to reproduce the issue. 1.4 Community To get the latest news on the Chadwick tool suite, you can: • Subscribe to the Chadwick Baseball Bureau’s twitter feed (@chadwickbureau); 1 Chadwick Documentation, Release 0.9.0 • Like the Chadwick Baseball Bureau on Facebook; • Read the Chadwick Baseball Bureau’s blog at (http://www.chadwick-bureau.com/blog/) 1.5 Acknowledgments The author thanks Sports Reference, LLC, the Society for American Baseball Research, and XMLTeam, Inc. for support in the development of portions of Chadwick. The author also thanks David Smith of Retrosheet for his always-gracious assistance and guidance. 2 Chapter 1. Introduction CHAPTER 2 Command-line tools Chadwick provides the following command-line programs for extracting information from Retrosheet play-by-play event files: • cwevent, an expanded event descriptor, which replaces and extends the DiamondWare program BEVENT. • cwgame, a game information extractor, which replaces and extends the DiamondWare program BGAME. • cwbox, a boxscore generator, which replaces and extends the DiamondWare program BOX. • cwdaily, which produces day-by-day player statistical totals. This program is unique to Chadwick. • cwsub, which extracts information about in-game player substitutions. This program is unique to Chadwick. • cwcomment, which extracts comment fields from event files. This program is unique to Chadwick. This documentation is intended to be read in conjunction with the materials provided by Retrosheet (see https://www. retrosheet.org/game.htm) summarizing the contents of play-by-play files and operation of the DiamondWare versions of these tools. The Chadwick documentation focuses on filling in gaps in the Retrosheet documentation, and on detailing Chadwick-specific extensions the toolset. 2.1 Command-line options Each of the command-line tools shares a common set of options controlling their behavior. These are detailed in the following table. 3 Chadwick Documentation, Release 0.9.0 Table 1: Common command-line options and their effects Switch Description -a Generate ASCII comma-delimited files (default) -d Print a list of the available fields and descriptions (for use with -f) -e mmdd The latest date to process (inclusive) -f flist List of fields to output. The default list can be viewed with -h; the list of available fields can be viewed with -d -ft Generate FORTRAN format files. -h Prints description and usage information for the tool. -i *gameid* Only process the game with ID gameid -n If in ASCII mode (the default), the first row of the output is a comma-separated list of column headers. -s mmdd The earliest date to process (inclusive) -y Specifies the year to use (four digits) 2.2 Documentation of individual tools 2.2.1 cwevent: Expanded event descriptor cwevent is a command-line tool which extracts detailed information about individual events (plays) in the data file. These are grouped into two categories. There are 97 fields which are compatible with the Retrosheet BEVENT event descriptor tool. These are specified using the -f command-line flag. In addition, cwevent offers a number “extended” fields which expand upon or give more detailed information not easily accessed via the standard fields. These are are specified using the -x command-line flag. Note: cwevent guarantees that the standard field numbers will match those used by BEVENT. Standard field numbers therefore can be treated as stable, and it should be safe to write scripts referring to them. Extended fields are provisional, and extended fields may be added or withdrawn in future versions. Extended fields are assigned numbers to maintain a logical cohesion, with related fields being grouped. Therefore, extended field numbers are not promised to be stable. It is recommended to use the field labels instead in writing scripts to process the output of cwevent extended fields. Table 2: cwevent standard field numbers Field num- Description Header ber 0 Game ID GAME_ID 1 Visiting team AWAY_TEAM_ID 2 Inning INN_CT 3 Batting team BAT_HOME_ID 4 Outs OUTS_CT 5 Balls BALLS_CT 6 Strikes STRIKES_CT 7 Pitch sequence PITCH_SEQ_TX 8 Visitor score AWAY_SCORE_CT 9 Home score HOME_SCORE_CT 10 Batter BAT_ID 11 Batter hand BAT_HAND_CD Continued on next page 4 Chapter 2. Command-line tools Chadwick Documentation, Release 0.9.0 Table 2 – continued from previous page Field num- Description Header ber 12 Result batter RESP_BAT_ID 13 Result batter hand RESP_BAT_HAND_CD 14 Pitcher PIT_ID 15 Pitcher hand PIT_HAND_CD 16 Result pitcher RESP_PIT_ID 17 Result pitcher hand RESP_PIT_HAND_CD 18 Catcher POS2_FLD_ID 19 First baseman POS3_FLD_ID 20 Second baseman POS4_FLD_ID 21 Third baseman POS5_FLD_ID 22 Shortstop POS6_FLD_ID 23 Left fielder POS7_FLD_ID 24 Center fielder POS8_FLD_ID 25 Right fielder POS9_FLD_ID 26 Runner on first BASE1_RUN_ID 27 Runner on second BASE2_RUN_ID 28 Runner on third BASE3_RUN_ID 29 Event text EVENT_TX 30 Leadoff flag LEADOFF_FL 31 Pinch-hit flag PH_FL 32 Defensive position BAT_FLD_CD 33 Lineup position BAT_LINEUP_ID 34 Event type EVENT_CD 35 Batter event flag BAT_EVENT_FL 36 Official time at bat flag AB_FL 37 Hit value H_CD 38 Sacrifice hit flag SH_FL 39 Sacrifice fly flag SF_FL 40 Outs on play EVENT_OUTS_CT 41 Double play flag DP_FL 42 Triple play flag TP_FL 43 RBI on play RBI_CT 44 Wild pitch flag WP_FL 45 Passed ball flag PB_FL 46 Fielded by FLD_CD 47 Batted ball type BATTEDBALL_CD 48 Bunt flag BUNT_FL 49 Foul flag FOUL_FL 50 Hit location BATTEDBALL_LOC_TX 51 Number of errors ERR_CT 52 1st error player ERR1_FLD_CD 53 1st error type ERR1_CD 54 2nd error player ERR2_FLD_CD 55 2nd error type ERR2_CD 56 3rd error player ERR3_FLD_CD 57 3rd error type ERR3_CD 58 Batter destination BAT_DEST_ID 59 Runner on first destination RUN1_DEST_ID Continued on next page 2.2. Documentation of individual tools 5 Chadwick Documentation, Release 0.9.0 Table 2 – continued from previous page Field num- Description Header ber 60 Runner on second destination RUN2_DEST_ID 61 Runner on third destination RUN3_DEST_ID 62 Play on batter BAT_PLAY_TX 63 Play on runner on first RUN1_PLAY_TX 64 Play on runner on second RUN2_PLAY_TX 65 Play on runner on third RUN3_PLAY_TX 66 Stolen base for runner on first RUN1_SB_FL 67 Stolen base for runner on second RUN2_SB_FL 68 Stolen base for runner on third RUN3_SB_FL 69 Caught stealing for runner on first RUN1_CS_FL 70 Caught stealing for runner on second RUN2_CS_FL 71 Caught stealing for runner on third RUN3_CS_FL 72 Pickoff of runner on first RUN1_PK_FL 73 Pickoff of runner on second RUN2_PK_FL 74 Pickoff of runner on third RUN3_PK_FL 75 Pitcher charged with runner on first RUN1_RESP_PIT_ID 76 Pitcher charged with runner on second RUN2_RESP_PIT_ID 77 Pitcher charged with runner on third RUN3_RESP_PIT_ID 78 New game flag GAME_NEW_FL 79 End game flag GAME_END_FL 80 Pinch-runner on first PR_RUN1_FL 81 Pinch-runner on second PR_RUN2_FL 82 Pinch-runner on third PR_RUN3_FL 83 Runner removed for pinch-runner on first REMOVED_FOR_PR_RUN1_ID 84 Runner removed for pinch-runner on second REMOVED_FOR_PR_RUN2_ID 85 Runner removed for pinch-runner on third REMOVED_FOR_PR_RUN3_ID 86 Batter removed for pinch-hitter REMOVED_FOR_PH_BAT_ID 87 Position of batter removed for pinch-hitter REMOVED_FOR_PH_BAT_FLD_CD 88 Fielder with first putout PO1_FLD_CD 89 Fielder with second putout PO2_FLD_CD 90 Fielder with third putout PO3_FLD_CD 91 Fielder with first assist ASS1_FLD_CD 92 Fielder with second assist ASS2_FLD_CD 93 Fielder with third assist ASS3_FLD_CD 94 Fielder with fourth assist ASS4_FLD_CD 95 Fielder with fifth assist ASS5_FLD_CD 96 Event number EVENT_ID Table 3: cwevent extended field numbers Field num- Description Header ber 0 home team id HOME_TEAM_ID 1 batting team id BAT_TEAM_ID 2 fielding team id FLD_TEAM_ID 3 half inning (differs from batting team if home team bats first) BAT_LAST_ID 4 start of half inning flag INN_NEW_FL 5 end of half inning flag INN_END_FL Continued on next page 6 Chapter 2. Command-line tools Chadwick Documentation, Release 0.9.0 Table 3 – continued from previous page Field num- Description Header ber 6 score for team on offense START_BAT_SCORE_CT 7 score for team on defense START_FLD_SCORE_CT 8 runs scored in this half inning INN_RUNS_CT 9 number of plate appearances in game for team on offense GAME_PA_CT 10 number of plate appearances in inning for team on offense INN_PA_CT 11 start of plate appearance flag PA_NEW_FL 12 truncated plate appearance flag PA_TRUNC_FL 13 base state at start of play START_BASES_CD 14 base state at end of play END_BASES_CD