chadwick documentation

21
Chadwick Documentation Release 0.9.4 T. L. Turocy Apr 24, 2022

Upload: others

Post on 26-Apr-2022

21 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Chadwick Documentation

Chadwick DocumentationRelease 0.9.4

T. L. Turocy

Apr 24, 2022

Page 2: Chadwick Documentation
Page 3: Chadwick Documentation

Contents

1 Introduction 1

2 Command-line tools 3

i

Page 4: Chadwick Documentation

ii

Page 5: Chadwick Documentation

CHAPTER 1

Introduction

Chadwick is a collection of command-line utility programs for extracting information from baseball play-by-play andboxscore files in the DiamondWare format, as used by Retrosheet (http://www.retrosheet.org).

1.1 Author

Chadwick is written, maintained, and Copyright 2002-2022 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, contactthe 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, theoperating 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

Page 6: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

• 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. forsupport in the development of portions of Chadwick. The author also thanks David Smith of Retrosheet for hisalways-gracious assistance and guidance.

2 Chapter 1. Introduction

Page 7: Chadwick Documentation

CHAPTER 2

Command-line tools

Chadwick provides the following command-line programs for extracting information from Retrosheet play-by-playevent 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 versionsof these tools. The Chadwick documentation focuses on filling in gaps in the Retrosheet documentation, and ondetailing 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 thefollowing table.

3

Page 8: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 1: Common command-line options and their effectsSwitch 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 eventdescriptor 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 arespecified using the -x command-line flag.

Note: cwevent guarantees that the standard field numbers will match those used by BEVENT. Standard fieldnumbers therefore can be treated as stable, and it should be safe to write scripts referring to them. Extended fields areprovisional, and extended fields may be added or withdrawn in future versions. Extended fields are assigned numbersto maintain a logical cohesion, with related fields being grouped. Therefore, extended field numbers are not promisedto be stable. It is recommended to use the field labels instead in writing scripts to process the output of cweventextended fields.

Table 2: cwevent standard field numbersField num-ber

Description Header

0 Game ID GAME_ID1 Visiting team AWAY_TEAM_ID2 Inning INN_CT3 Batting team BAT_HOME_ID4 Outs OUTS_CT5 Balls BALLS_CT6 Strikes STRIKES_CT7 Pitch sequence PITCH_SEQ_TX8 Visitor score AWAY_SCORE_CT9 Home score HOME_SCORE_CT10 Batter BAT_ID11 Batter hand BAT_HAND_CD

Continued on next page

4 Chapter 2. Command-line tools

Page 9: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 2 – continued from previous pageField num-ber

Description Header

12 Result batter RESP_BAT_ID13 Result batter hand RESP_BAT_HAND_CD14 Pitcher PIT_ID15 Pitcher hand PIT_HAND_CD16 Result pitcher RESP_PIT_ID17 Result pitcher hand RESP_PIT_HAND_CD18 Catcher POS2_FLD_ID19 First baseman POS3_FLD_ID20 Second baseman POS4_FLD_ID21 Third baseman POS5_FLD_ID22 Shortstop POS6_FLD_ID23 Left fielder POS7_FLD_ID24 Center fielder POS8_FLD_ID25 Right fielder POS9_FLD_ID26 Runner on first BASE1_RUN_ID27 Runner on second BASE2_RUN_ID28 Runner on third BASE3_RUN_ID29 Event text EVENT_TX30 Leadoff flag LEADOFF_FL31 Pinch-hit flag PH_FL32 Defensive position BAT_FLD_CD33 Lineup position BAT_LINEUP_ID34 Event type EVENT_CD35 Batter event flag BAT_EVENT_FL36 Official time at bat flag AB_FL37 Hit value H_CD38 Sacrifice hit flag SH_FL39 Sacrifice fly flag SF_FL40 Outs on play EVENT_OUTS_CT41 Double play flag DP_FL42 Triple play flag TP_FL43 RBI on play RBI_CT44 Wild pitch flag WP_FL45 Passed ball flag PB_FL46 Fielded by FLD_CD47 Batted ball type BATTEDBALL_CD48 Bunt flag BUNT_FL49 Foul flag FOUL_FL50 Hit location BATTEDBALL_LOC_TX51 Number of errors ERR_CT52 1st error player ERR1_FLD_CD53 1st error type ERR1_CD54 2nd error player ERR2_FLD_CD55 2nd error type ERR2_CD56 3rd error player ERR3_FLD_CD57 3rd error type ERR3_CD58 Batter destination BAT_DEST_ID59 Runner on first destination RUN1_DEST_ID

Continued on next page

2.2. Documentation of individual tools 5

Page 10: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 2 – continued from previous pageField num-ber

Description Header

60 Runner on second destination RUN2_DEST_ID61 Runner on third destination RUN3_DEST_ID62 Play on batter BAT_PLAY_TX63 Play on runner on first RUN1_PLAY_TX64 Play on runner on second RUN2_PLAY_TX65 Play on runner on third RUN3_PLAY_TX66 Stolen base for runner on first RUN1_SB_FL67 Stolen base for runner on second RUN2_SB_FL68 Stolen base for runner on third RUN3_SB_FL69 Caught stealing for runner on first RUN1_CS_FL70 Caught stealing for runner on second RUN2_CS_FL71 Caught stealing for runner on third RUN3_CS_FL72 Pickoff of runner on first RUN1_PK_FL73 Pickoff of runner on second RUN2_PK_FL74 Pickoff of runner on third RUN3_PK_FL75 Pitcher charged with runner on first RUN1_RESP_PIT_ID76 Pitcher charged with runner on second RUN2_RESP_PIT_ID77 Pitcher charged with runner on third RUN3_RESP_PIT_ID78 New game flag GAME_NEW_FL79 End game flag GAME_END_FL80 Pinch-runner on first PR_RUN1_FL81 Pinch-runner on second PR_RUN2_FL82 Pinch-runner on third PR_RUN3_FL83 Runner removed for pinch-runner on first REMOVED_FOR_PR_RUN1_ID84 Runner removed for pinch-runner on second REMOVED_FOR_PR_RUN2_ID85 Runner removed for pinch-runner on third REMOVED_FOR_PR_RUN3_ID86 Batter removed for pinch-hitter REMOVED_FOR_PH_BAT_ID87 Position of batter removed for pinch-hitter REMOVED_FOR_PH_BAT_FLD_CD88 Fielder with first putout PO1_FLD_CD89 Fielder with second putout PO2_FLD_CD90 Fielder with third putout PO3_FLD_CD91 Fielder with first assist ASS1_FLD_CD92 Fielder with second assist ASS2_FLD_CD93 Fielder with third assist ASS3_FLD_CD94 Fielder with fourth assist ASS4_FLD_CD95 Fielder with fifth assist ASS5_FLD_CD96 Event number EVENT_ID

Table 3: cwevent extended field numbersField num-ber

Description Header

0 home team id HOME_TEAM_ID1 batting team id BAT_TEAM_ID2 fielding team id FLD_TEAM_ID3 half inning (differs from batting team if home team bats first) BAT_LAST_ID4 start of half inning flag INN_NEW_FL5 end of half inning flag INN_END_FL

Continued on next page

6 Chapter 2. Command-line tools

Page 11: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 3 – continued from previous pageField num-ber

Description Header

6 score for team on offense START_BAT_SCORE_CT7 score for team on defense START_FLD_SCORE_CT8 runs scored in this half inning INN_RUNS_CT9 number of plate appearances in game for team on offense GAME_PA_CT10 number of plate appearances in inning for team on offense INN_PA_CT11 start of plate appearance flag PA_NEW_FL12 truncated plate appearance flag PA_TRUNC_FL13 base state at start of play START_BASES_CD14 base state at end of play END_BASES_CD15 batter is starter flag BAT_START_FL16 result batter is starter flag RESP_BAT_START_FL17 ID of the batter on deck BAT_ON_DECK_ID18 ID of the batter in the hold BAT_IN_HOLD_ID19 pitcher is starter flag PIT_START_FL20 result pitcher is starter flag RESP_PIT_START_FL21 defensive position of runner on first RUN1_FLD_CD22 lineup position of runner on first RUN1_LINEUP_CD23 event number on which runner on first reached base RUN1_ORIGIN_EVENT_ID24 defensive position of runner on second RUN2_FLD_CD25 lineup position of runner on second RUN2_LINEUP_CD26 event number on which runner on second reached base RUN2_ORIGIN_EVENT_ID27 defensive position of runner on third RUN3_FLD_CD28 lineup position of runner on third RUN3_LINEUP_CD29 event number on which runner on third reached base RUN3_ORIGIN_EVENT_ID30 responsible catcher for runner on first RUN1_RESP_CAT_ID31 responsible catcher for runner on second RUN2_RESP_CAT_ID32 responsible catcher for runner on third RUN3_RESP_CAT_ID33 number of balls in plate appearance PA_BALL_CT34 number of called balls in plate appearance PA_CALLED_BALL_CT35 number of intentional balls in plate appearance PA_INTENT_BALL_CT36 number of pitchouts in plate appearance PA_PITCHOUT_BALL_CT37 number of pitches hitting batter in plate appearance PA_HITBATTER_BALL_CT38 number of other balls in plate appearance PA_OTHER_BALL_CT39 number of strikes in plate appearance PA_STRIKE_CT40 number of called strikes in plate appearance PA_CALLED_STRIKE_CT41 number of swinging strikes in plate appearance PA_SWINGMISS_STRIKE_CT42 number of foul balls in plate appearance PA_FOUL_STRIKE_CT43 number of balls in play in plate appearance PA_INPLAY_STRIKE_CT44 number of other strikes in plate appearance PA_OTHER_STRIKE_CT45 number of runs on play EVENT_RUNS_CT46 id of player fielding batted ball FLD_ID47 force play at second flag BASE2_FORCE_FL48 force play at third flag BASE3_FORCE_FL49 force play at home flag BASE4_FORCE_FL50 batter safe on error flag BAT_SAFE_ERR_FL51 fate of batter (base ultimately advanced to) BAT_FATE_ID52 fate of runner on first RUN1_FATE_ID53 fate of runner on second RUN2_FATE_ID

Continued on next page

2.2. Documentation of individual tools 7

Page 12: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 3 – continued from previous pageField num-ber

Description Header

54 fate of runner on third RUN3_FATE_ID55 runs scored in half inning after this event FATE_RUNS_CT56 fielder with sixth assist ASS6_FLD_CD57 fielder with seventh assist ASS7_FLD_CD58 fielder with eighth assist ASS8_FLD_CD59 fielder with ninth assist ASS9_FLD_CD60 fielder with tenth assist ASS10_FLD_CD61 unknown fielding credit flag UNKNOWN_OUT_EXC_FL62 uncertain play flag UNCERTAIN_PLAY_EXC_FL63 text of count as appears in event file COUNT_TX

Result batters and pitchers (fields 10-17)

In most cases, the pitcher and batter charged or credited with the event (when a batter event) are the ones in thegame when the event occurs. However, Rules 10.17 and 10.18 have special clauses discussing how to charge walksto pitchers when a relief pitcher enters in the middle of the plate appearance, and how to charge strikeouts to batterswhen a pinch hitter enters in the middle of the plate appearance. The batter and pitcher fields always give the identityof the batter and pitcher in the game at the time of the event; the result batter and result pitcher give the batter andpitcher credited or charged with the event.

There is one known bug in the Retrosheet-provided tools regarding the result pitcher. When a relief pitcher enters thegame, and then the next batter is retired on a fielder’s choice, the pitcher responsible for the runner put out is shownin the result pitcher field. While it is correct that the batter reaching base in this case would be charged to the formerpitcher should he score, the purpose of the result pitcher field is to indicate the pitcher charged with the outcome ofthis particular event. In this case, for example, the relief pitcher is awarded one-third of an inning pitched; therefore,he should be the result pitcher, and then the previous pitcher should be (and is) listed in the responsible pitcher fieldfor the batter in subsequent events.

In the case of switch-hitters, the batter hand and result batter hand fields are set to L or R, as appropriate, based uponthe hand with which the pitcher throws. If the pitcher’s throwing hand is unknown, or if the batter’s batting hand isunknown, a question mark appears in these fields.

Pinch-hit flag (field 31)

This field is T if the batter is a pinch-hitter, and F if he is not. If a player enters the game as a pinch-hitter, and then batsagain in the same inning because his team bats around, this field will be F for the player’s second plate appearance. Toidentify the cases where this occurs, consult the defensive position field (field 32), which will continue to be equal to11 (or 12 for a pinch-runner) until that player assumes a defensive position.

Event type code (field 34)

All plays are categorized by their primary event type. Here is a list of all types and the corresponding codes used inthis field. Codes marked “obsolete” are no longer used, or no longer appear in Retrosheet-produced play-by-play files.

8 Chapter 2. Command-line tools

Page 13: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 4: cwevent extended field numbersCode Primary event0 Unknown (obsolete)1 None (obsolete)2 Generic out3 Strikeout4 Stolen base5 Defensive indifference6 Caught stealing7 Pickoff error (obsolete)8 Pickoff9 Wild pitch10 Passed ball11 Balk12 Other advance/out advancing13 Foul error14 Walk15 Intentional walk16 Hit by pitch17 Interference18 Error19 Fielder’s choice20 Single21 Double22 Triple23 Home run24 Missing play (obsolete)

Sacrifice flags and eras (fields 36, 38, 39)

Chadwick in all cases applies the modern rules concerning the awarding of sacrifice hits, sacrifice flies, and officialtimes at bat, regardless of the year indicated with the -y flag.

Plays on runners (fields 58-65)

Fields 58 through 65 give the destination of all runners, including the batter, as well as the fielding play made onthem, if any. For the purposes of the destination fields, a code of 5 indicates the runner scored, and is charged asunearned, and a code of 6 indicates the runner scored, and is charged as unearned to the team, but earned to the pitcher.These codes only appear when the (NR) or (TUR) modifiers are explicitly used on the advancement code. There is nointernal logic in Chadwick to ferret out which runs should be earned or unearned, as in many cases there is insufficientinformation, or the situation requires the judgment of the official scorer. Runners which are put out are reported ashaving an advancement of 0.

New in 0.8.1: With the introduction of the automatic runner placement in extra innings as a tiebreaker for the 2020season in MLB (and earlier in the minor leagues and other leagues), a new code 7 is used for runner advancementin the case in which an automatic runner scores. The scoring rule for automatic runners is that they are charged tothe pitcher who starts the inning, as an unearned run. For the purposes of determining whether a run scored is dueto the automatic runner, Chadwick follows the same convention as is used for assigning responsibility for runners topitchers: in the event that an automatic runner is put out by batter action, then the subsequent runner becomes markedas an automatic runner.

2.2. Documentation of individual tools 9

Page 14: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

In most cases, the play on a runner indicates the fielding credits involved in putting him out. Chadwick also reports afielding play on a runner when the runner is safe on a dropped throw, such as 3E1 or FC6.1X2(6E4).

Fielding errors (fields 51-57)

Up to three errors can be indicated in cwevent output. Supported error types are F for generic fielding errors, and Tfor throwing errors; no distinction is made between bobbled batted balls, muffed throws or fly balls, and so forth.

Pitcher responsibility for runs (fields 75-77)

The Official Rules for charging runs to pitchers stipulate that if a pitcher is relieved in the middle of an inning withrunners left on base, he is charged with runs if those runners (or the ones who replace them in the event of fielder’schoices) subsequently score in the inning. The current rule is Rule 10.16(g), the comment on which in the rules states:

It is the intent of Rule 10.16(g) to charge each pitcher with the number of runners he put on base, ratherthan with the individual runners. When a pitcher puts runners on base and is relieved, such pitcher shallbe charged with all runs subsequently scored up to and including the number of runners such pitcher lefton base when such pitcher left the game, unless such runners are put out without action by the batter.

Chadwick implements this by assigning “responsibility” for runners, and shifting those runners after fielder’s choicesas appropriate to implement the rule. Fields 75 through 77 report the pitcher currently “charged” with runners on baseusing this method.

There is one special case to note in reporting these fields. As noted, a fielder’s choice does not absolve a departedpitcher for responsibility for a potential run. Ordinarily it is good enough to report the shift in responsibility at the startof the next play. However, consider the following scenario: The bases are loaded, with the runner on third (R3) theresponsibility of Pitcher A and runners on second and first (R2 and R1) the responsibility of Pitcher B. The batter hitsa ground ball and R3 is forced at home. Then, the catcher throws wildly trying to complete the double play, and as aresult R2 scores. In this case, the run scored by R2 is charged to Pitcher A, not Pitcher B, i.e., the responsibility shiftsin the middle of the play. In order to facilitate calculation of runs and earned runs allowed correctly from cweventoutput, in this case, the record for the play will report R2 as being the responsibility of Pitcher A, i.e., it will report theresponsibility after the mid-play shift.

This convention will not affect most applications. Indeed, the Official Rules technically do not have a concept ofassigning responsibility to particular runners, and the contents of fields 75-77 only have meaning on plays in whichthe corresponding runners score. This convention may confuse certain calculations, however, including those whichtry to track what happens to inherited runners, if one does not take appropriate care to handle this very unusual case.

Fielding credits (fields 88-95)

The order in which Chadwick and the Retrosheet-provided tools list putouts and assists may vary. The number ofplays on which this occurs is quite few, and generally in cases where there is a putout in the primary event as wellas one in the baserunning modifiers. The words “first”, “second” and so on do not necessarily indicate chronologicalorder of the credits, though in most cases they do.

Reporting of counts

The DiamondWare data model originally assumed that pitch-level data for a game was one of all pitches, count only, orno pitches (see the info,pitches metadata field). However, many Retrosheet files contain count data for selectedplate appearances, where known. In event files, a question mark is used when either the count of balls or strikes (orboth) is unknown. BEVENT` renders nulls in the number of balls or strikes as zero in fields 5 and 6 (BALLS_CTand STRIKES_CT), making it impossible to discern whether a play is marked as occurring on a count of 0-0 (even ifinfo,pitches is set to none), or on an unknown count.

10 Chapter 2. Command-line tools

Page 15: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Extended field 63, COUNT_TX, remedies this by reporting the count string as it appears in the file, as a parallelfacility to PITCH_SEQ_TX and EVENT_TX. With COUNT_TX, all three of the main elements of the play record areaccessible in cwevent output.

2.2.2 cwgame: Game information extractor

cwgame is a command-line tool which extracts summary information about each game in the data file. These fields aregrouped into two categories. There are 83 fields which are compatible with the Retrosheet BGAME game descriptortool. These are specified using the -f command-line flag. In addition, cwgame offers a number “extended” fieldswhich expand upon or give more detailed information not easily accessed via the standard fields. These are arespecified using the -x command-line flag. Many of these extended fields are defined to match fields which appear inthe Retrosheet gamelogs.

Note: cwgame guarantees that the standard field numbers will match those used by BGAME. Standard field numberstherefore can be treated as stable, and it should be safe to write scripts referring to them. Extended fields are provi-sional, and extended fields may be added or withdrawn in future versions. Extended fields are assigned numbers tomaintain a logical cohesion, with related fields being grouped. Therefore, extended field numbers are not promised tobe stable. It is recommended to use the field labels instead in writing scripts to process the output of cwgame extendedfields.

The following table gives the contents of each of the 84 fields cwgame outputs.

Table 5: cwgame standard field numbersField num-ber

Description Header

0 Game ID GAME_ID1 Date GAME_DT2 Game number GAME_CT3 Day of week GAME_DY4 Start time START_GAME_TM5 DH used flag DH_FL6 Day/night flag DAYNIGHT_PARK_CD7 Visiting team AWAY_TEAM_ID8 Home team HOME_TEAM_ID9 Game site PARK_ID10 Visitors starting pitcher AWAY_START_PIT_ID11 Home starting pitcher HOME_START_PIT_ID12 Home plate umpire BASE4_UMP_ID13 First base umpire BASE1_UMP_ID14 Second base umpire BASE2_UMP_ID15 Third base umpire BASE3_UMP_ID16 Left field umpire LF_UMP_ID17 Right field umpire RF_UMP_ID18 Attendance ATTEND_PARK_CT19 PS scorer SCORER_RECORD_ID20 Translator TRANSLATOR_RECORD_ID21 Inputter INPUTTER_RECORD_ID22 Input time INPUT_RECORD_TS23 Edit time EDIT_RECORD_TS24 How scored METHOD_RECORD_CD

Continued on next page

2.2. Documentation of individual tools 11

Page 16: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 5 – continued from previous pageField num-ber

Description Header

25 Pitches entered PITCHES_RECORD_CD26 Temperature TEMP_PARK_CT27 Wind direction WIND_DIRECTION_PARK_CD28 Wind speed WIND_SPEED_PARK_CT29 Field condition FIELD_PARK_CD30 Precipitation PRECIP_PARK_CD31 Sky SKY_PARK_CD32 Time of game MINUTES_GAME_CT33 Number of innings INN_CT34 Visitor final score AWAY_SCORE_CT35 Home final score HOME_SCORE_CT36 Visitor hits AWAY_HITS_CT37 Home hits HOME_HITS_CT38 Visitor errors AWAY_ERR_CT39 Home errors HOME_ERR_CT40 Visitor left on base AWAY_LOB_CT41 Home left on base HOME_LOB_CT42 Winning pitcher WIN_PIT_ID43 Losing pitcher LOSE_PIT_ID44 Save SAVE_PIT_ID45 Game-winning RBI GWRBI_BAT_ID46 Visitor batter 1 AWAY_LINEUP1_BAT_ID47 Visitor batter 1 position AWAY_LINEUP1_FLD_CD48 Visitor batter 2 AWAY_LINEUP2_BAT_ID49 Visitor batter 2 position AWAY_LINEUP2_FLD_CD50 Visitor batter 3 AWAY_LINEUP3_BAT_ID51 Visitor batter 3 position AWAY_LINEUP3_FLD_CD52 Visitor batter 4 AWAY_LINEUP4_BAT_ID53 Visitor batter 4 position AWAY_LINEUP4_FLD_CD54 Visitor batter 5 AWAY_LINEUP5_BAT_ID55 Visitor batter 5 position AWAY_LINEUP5_FLD_CD56 Visitor batter 6 AWAY_LINEUP6_BAT_ID57 Visitor batter 6 position AWAY_LINEUP6_FLD_CD58 Visitor batter 7 AWAY_LINEUP7_BAT_ID59 Visitor batter 7 position AWAY_LINEUP7_FLD_CD60 Visitor batter 8 AWAY_LINEUP8_BAT_ID61 Visitor batter 8 position AWAY_LINEUP8_FLD_CD62 Visitor batter 9 AWAY_LINEUP9_BAT_ID63 Visitor batter 9 position AWAY_LINEUP9_FLD_CD64 Home batter 1 HOME_LINEUP1_BAT_ID65 Home batter 1 position HOME_LINEUP1_FLD_CD66 Home batter 2 HOME_LINEUP2_BAT_ID67 Home batter 2 position HOME_LINEUP2_FLD_CD68 Home batter 3 HOME_LINEUP3_BAT_ID69 Home batter 3 position HOME_LINEUP3_FLD_CD70 Home batter 4 HOME_LINEUP4_BAT_ID71 Home batter 4 position HOME_LINEUP4_FLD_CD72 Home batter 5 HOME_LINEUP5_BAT_ID

Continued on next page

12 Chapter 2. Command-line tools

Page 17: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 5 – continued from previous pageField num-ber

Description Header

73 Home batter 5 position HOME_LINEUP5_FLD_CD74 Home batter 6 HOME_LINEUP6_BAT_ID75 Home batter 6 position HOME_LINEUP6_FLD_CD76 Home batter 7 HOME_LINEUP7_BAT_ID77 Home batter 7 position HOME_LINEUP7_FLD_CD78 Home batter 8 HOME_LINEUP8_BAT_ID79 Home batter 8 position HOME_LINEUP8_FLD_CD80 Home batter 9 HOME_LINEUP9_BAT_ID81 Home batter 9 position HOME_LINEUP9_FLD_CD82 Visitor finishing pitcher AWAY_FINISH_PIT_ID83 Home finishing pitcher HOME_FINISH_PIT_ID

Table 6: cwgame extended field numbersField num-ber

Description Header

0 visiting team league AWAY_TEAM_LEAGUE_ID1 home team league HOME_TEAM_LEAGUE_ID2 visiting team game number AWAY_TEAM_GAME_CT3 home team game number HOME_TEAM_GAME_CT4 length of game in outs OUTS_CT5 information on completion of game COMPLETION_TX6 information on forfeit of game FORFEIT_TX7 information on protest of game PROTEST_TX8 visiting team linescore AWAY_LINE_TX9 home team linescore HOME_LINE_TX10 visiting team AB AWAY_AB_CT11 visiting team 2B AWAY_2B_CT12 visiting team 3B AWAY_3B_CT13 visiting team HR AWAY_HR_CT14 visiting team RBI AWAY_BI_CT15 visiting team SH AWAY_SH_CT16 visiting team SF AWAY_SF_CT17 visiting team HP AWAY_HP_CT18 visiting team BB AWAY_BB_CT19 visiting team IBB AWAY_IBB_CT20 visiting team SO AWAY_SO_CT21 visiting team SB AWAY_SB_CT22 visiting team CS AWAY_CS_CT23 visiting team GDP AWAY_GDP_CT24 visiting team reach on interference AWAY_XI_CT25 number of pitchers used by visiting team AWAY_PITCHER_CT26 visiting team individual ER allowed AWAY_ER_CT27 visiting team team ER allowed AWAY_TER_CT28 visiting team WP AWAY_WP_CT29 visiting team BK AWAY_BK_CT30 visiting team PO AWAY_PO_CT31 visiting team A AWAY_A_CT

Continued on next page

2.2. Documentation of individual tools 13

Page 18: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 6 – continued from previous pageField num-ber

Description Header

32 visiting team PB AWAY_PB_CT33 visiting team DP AWAY_DP_CT34 visiting team TP AWAY_TP_CT35 home team AB HOME_AB_CT36 home team 2B HOME_2B_CT37 home team 3B HOME_3B_CT38 home team HR HOME_HR_CT39 home team RBI HOME_RBI_CT40 home team SH HOME_SH_CT41 home team SF HOME_SF_CT42 home team HP HOME_HP_CT43 home team BB HOME_BB_CT44 home team IBB HOME_IBB_CT45 home team SO HOME_SO_CT46 home team SB HOME_SB_CT47 home team CS HOME_CS_CT48 home team GDP HOME_GDP_CT49 home team reach on interference HOME_XI_CT50 number of pitchers used by home team HOME_PITCHER_CT51 home team individual ER allowed HOME_ER_CT52 home team team ER allowed HOME_TER_CT53 home team WP HOME_WP_CT54 home team BK HOME_BK_CT55 home team PO HOME_PO_CT56 home team A HOME_A_CT57 home team PB HOME_PB_CT58 home team DP HOME_DP_CT59 home team TP HOME_TP_CT60 home plate umpire name UMP_HOME_NAME_TX61 first base umpire name UMP_1B_NAME_TX62 second base umpire name UMP_2B_NAME_TX63 third base umpire name UMP_3B_NAME_TX64 left field umpire name UMP_LF_NAME_TX65 right field umpire name UMP_RF_NAME_TX66 visitors manager ID AWAY_MANAGER_ID67 visitors manager name AWAY_MANAGER_NAME_TX68 home manager ID HOME_MANAGER_ID69 home manager name HOME_MANAGER_NAME_TX70 winning pitcher name WIN_PIT_NAME_TX71 losing pitcher name LOSE_PIT_NAME_TX72 save pitcher name SAVE_PIT_NAME_TX73 batter with goahead RBI ID GOAHEAD_RBI_ID74 batter with goahead RBI GOAHEAD_RBI_NAME_TX75 visitor batter 1 name AWAY_LINEUP1_BAT_NAME_TX76 visitor batter 2 name AWAY_LINEUP2_BAT_NAME_TX77 visitor batter 3 name AWAY_LINEUP3_BAT_NAME_TX78 visitor batter 4 name AWAY_LINEUP4_BAT_NAME_TX79 visitor batter 5 name AWAY_LINEUP5_BAT_NAME_TX

Continued on next page

14 Chapter 2. Command-line tools

Page 19: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Table 6 – continued from previous pageField num-ber

Description Header

80 visitor batter 6 name AWAY_LINEUP6_BAT_NAME_TX81 visitor batter 7 name AWAY_LINEUP7_BAT_NAME_TX82 visitor batter 8 name AWAY_LINEUP8_BAT_NAME_TX83 visitor batter 9 name AWAY_LINEUP9_BAT_NAME_TX84 home batter 1 name HOME_LINEUP1_BAT_NAME_TX85 home batter 2 name HOME_LINEUP2_BAT_NAME_TX86 home batter 3 name HOME_LINEUP3_BAT_NAME_TX87 home batter 4 name HOME_LINEUP4_BAT_NAME_TX88 home batter 5 name HOME_LINEUP5_BAT_NAME_TX89 home batter 6 name HOME_LINEUP6_BAT_NAME_TX90 home batter 7 name HOME_LINEUP7_BAT_NAME_TX91 home batter 8 name HOME_LINEUP8_BAT_NAME_TX92 home batter 9 name HOME_LINEUP9_BAT_NAME_TX93 additional information ADD_INFO_TX94 acquisition information ACQ_INFO_TX95 scheduled length of game in innings SCHED_INN_CT96 tiebreaker rule type in use TIEBREAK_CD

How scored (field 24)

This field outputs a numeric code corresponding to the medium by which the play-by-play account was recorded.

Table 7: Numeric codes for how scored fieldCode Description0 unknown1 park2 tv3 radio

Pitches entered (field 25)

This field outputs a numeric code corresponding to the level of pitch detail in the file.

Table 8: Numeric codes for pitches entered fieldCode Description0 unknown1 pitches2 count3 none

Note: This field reports the contents of the info,pitches field in the game file. Some games with partial pitchinformation will have this field set to none or count.

2.2. Documentation of individual tools 15

Page 20: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Temperature (field 26)

The game-time temperature, in degrees Fahrenheit. The value 0 is used when the temperature is unknown.

Wind direction (field 27)

This field outputs a numeric code corresponding to the direction of the wind.

Table 9: Numeric codes for wind direction fieldCode Description0 unknown1 tolf2 tocf3 torf4 ltor5 fromlf6 fromcf7 fromrf8 rtol

Wind speed (field 28)

The game time wind speed, in miles per hour. The value -1 is used when the wind speed is unknown.

Field condition (field 29)

This field outputs a numeric code corresponding to the condition of the field.

Table 10: Numeric codes for field condition fieldCode Description0 unknown1 soaked2 wet3 damp4 dry

Precipitation (field 30)

This field outputs a numeric code corresponding to the precipitation level.

Table 11: Numeric codes for precipitation fieldCode Description0 unknown1 none2 drizzle3 showers4 rain5 snow

16 Chapter 2. Command-line tools

Page 21: Chadwick Documentation

Chadwick Documentation, Release 0.9.4

Sky (field 31)

This field outputs a numeric code corresponding to the sky conditions.

Numeric codes for sky field.

Table 12: Numeric codes for sky fieldCode Description0 unknown1 sunny2 cloudy3 overcast4 night5 dome

Tiebreaker rule type in use (extended field 96)

This field indicates games in which an extra-innings tiebreaker rule was in use. The only valid value for this fieldcurrently is 2, indicating that extra innings began with a runner on second base.

2.2.3 cwsub: Player substitution descriptor

cwsub extracts information about in-game player substitutions. It is designed to be used in conjunction withcwevent to mitigate a blind spot in the existing tools.

cwsub outputs up to ten pieces of information about each substitution. All are included by default; which ones aregenerated is controlled by the -f switch.

Table 13: cwevent standard field numbersField num-ber

Description Header

0 Game ID GAME_ID1 Inning INN_CT2 Batting team BAT_HOME_ID3 Substitute SUB_ID4 Team SUB_HOME_ID5 Lineup position SUB_LINEUP_ID6 Fielding position SUB_FLD_CD7 Removed player REMOVED_ID8 Position of removed player REMOVED_FLD_CD9 Event number EVENT_ID

2.2. Documentation of individual tools 17