You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/User_Guide.md
+18-18Lines changed: 18 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,12 @@ From the root folder of your repository run `python3 setup.py install` (or if `p
5
5
6
6
## Parameter Files
7
7
In the directory from which you will run the system -- which can be outside your local repository-- create the main parameter files you'll need:
8
-
*`jurisdiction_prep.par` for the JurisdictionPrepper() class
9
-
*`multi.par` for loading data (DataLoader() class) and for pulling and analyzing results (the Analyzer()) class)
8
+
*`jurisdiction_prep.ini` for the JurisdictionPrepper() class
9
+
*`run_time.ini` for loading data (DataLoader() class) and for pulling and analyzing results (the Analyzer()) class)
10
10
11
-
There are templates in `templates/parameter_file_templates`.
11
+
There are templates with the suffix `.template`in `templates/parameter_file_templates`. These will need be renamed with the extension `.ini`. For example, from the `src` directory, running `cp templates/parameter_file_templates/run_time.ini.template ./run_time.ini` will create the `run_time.ini` parameter file with all the required fields to load analyze data.
12
12
13
-
In the directory indicated in `multi.par`, create a `.par` file for each results file you want to use. The results files and the `.par` files must both be in that directory. Follow the `templates/parameter_file_templates/results.par` template for the individual `.par` files. If all the files in a single directory will use the same munger, jurisdiction and election, you can create these `.par` files in batches. For example,
13
+
In the directory indicated in `run_time.ini`, create a `.ini` file for each results file you want to use. The results files and the `.ini` files must both be in that directory. Follow the `templates/parameter_file_templates/results.ini.template` template for the individual `.ini` files. If all the files in a single directory will use the same munger, jurisdiction and election, you can create these `.ini` files in batches. For example,
14
14
```
15
15
>>> dir = '/Users/singer3/Documents/Data/Florida/Precinct-Level Election Results/precinctlevelelectionresults2016gen'
16
16
>>> munger = 'fl_gen_by_precinct'
@@ -56,7 +56,7 @@ NB: for constants (like the CountItemType 'total' in this example), use 'row' fo
56
56
## Create or Improve a Jurisdiction
57
57
It's easiest to use the JurisdictionPrepper() object to create or update jurisdiction files.
58
58
59
-
1. From the directory containing `jurisdiction_prep.par`, open a python interpreter. Import the package and initialize a JurisdictionPrepper(), e.g.:
59
+
1. From the directory containing `jurisdiction_prep.ini`, open a python interpreter. Import the package and initialize a JurisdictionPrepper(), e.g.:
60
60
```
61
61
>>> import election_anomaly as ea
62
62
>>> jp = ea.JurisdictionPrepper()
@@ -65,7 +65,7 @@ It's easiest to use the JurisdictionPrepper() object to create or update jurisdi
65
65
```
66
66
>>> err = jp.new_juris_files()
67
67
```
68
-
The program will create the necessary files in a folder (at the location `jurisdiction_path` specified in `jurisdiction_prep.par`), and a 'starter dictionary.txt' in your current directory. If something does not work as expected, check the value of `jp.new_juris_files()`, which may contain some helpful information. If the system found no errors, this value will be an empty python dictionary.
68
+
The program will create the necessary files in a folder (at the location `jurisdiction_path` specified in `jurisdiction_prep.ini`), and a 'starter dictionary.txt' in your current directory. If something does not work as expected, check the value of `jp.new_juris_files()`, which may contain some helpful information. If the system found no errors, this value will be an empty python dictionary.
69
69
```
70
70
>>> err
71
71
{}
@@ -172,7 +172,7 @@ These will be added as precincts, unless another reporting unit type is specifie
172
172
173
173
12. Look at the newly added items in `ReportingUnit.txt` and `dictionary.txt`, and remove or revise as appropriate.
174
174
175
-
13. If you want to add elements (other than ReportingUnits) in bulk from all results files in a directory (with `.par` files in that same directory), use `add_elements_from_multi_results_file(<list of elements>,<directory>, <error>)`. For example:
175
+
13. If you want to add elements (other than ReportingUnits) in bulk from all results files in a directory (with `.ini` files in that same directory), use `add_elements_from_multi_results_file(<list of elements>,<directory>, <error>)`. For example:
@@ -195,7 +195,7 @@ Corresponding entries will be made in `dictionary.txt`, using the munged name fo
195
195
196
196
### The JurisdictionPrepper class details
197
197
There are routines in the `JurisdictionPrepper()` class to help prepare a jurisdiction.
198
-
*`JurisdictionPrepper()` reads parameters from the file (`new_jurisdiction.par`) to create the directories and basic necessary files.
198
+
*`JurisdictionPrepper()` reads parameters from the file (`jurisdiction_prep.ini`) to create the directories and basic necessary files.
199
199
*`new_juris_files()` builds a directory for the jurisdiction, including starter files with the standard contests. It calls some methods that may be independently useful:
200
200
*`add_standard_contests()` creates records in `CandidateContest.txt` corresponding to contests that appear in many or most jurisdictions, including all federal offices as well as state house and senate offices.
201
201
*`add_primaries_to_candidate_contest()` creates a record in `CandidateContest.txt` for every CandidateContest-Party pair that can be created from `CandidateContest.txt` entries with no assigned PrimaryParty and `Party.txt` entries. (Note: records for non-existent primary contests will not break anything.)
@@ -214,10 +214,10 @@ There are routines in the `JurisdictionPrepper()` class to help prepare a jurisd
214
214
then:
215
215
* `Florida;Alachua County;Precinct 1\tprecinct` will be added to `ReportingUnit.txt`
216
216
* `ReportingUnit\tFlorida;Alachua County;Precinct 1\tAlachua;Precinct 1` will be added to `dictionary.txt`
217
-
*`add_sub_county_rus_from_multi_results_file(directory,error)` does the same for every results file/munger in the directory named in a `.par` file in the directory.
217
+
*`add_sub_county_rus_from_multi_results_file(directory,error)` does the same for every results file/munger in the directory named in a `.ini` file in the directory.
218
218
* adding other elements automatically:
219
219
*`add_elements_from_results_file(result_file,munger,element`) pulls raw identifiers for all instances of the element from the datafile and inserts corresponding rows in `<element>.txt` and `dictionary.txt`. These rows may have to be edited by hand to make sure the internal database names match any conventions (e.g., for ReportingUnits or CandidateContests, but maybe not for Candidates or BallotMeasureContests.)
220
-
*`add_elements_from_multi_results_file(directory, error)` does the same for every file/munger in the directory named in a `.par` file in the directory
220
+
*`add_elements_from_multi_results_file(directory, error)` does the same for every file/munger in the directory named in a `.ini` file in the directory
221
221
222
222
## Load Data
223
223
Some routines in the Analyzer class are useful even in the data-loading process, so create an analyzer before you start loading data.
@@ -226,7 +226,7 @@ Some routines in the Analyzer class are useful even in the data-loading process,
226
226
>>>
227
227
```
228
228
229
-
The DataLoader class allows batch uploading of all data in a given directory. That directory should contain the files to be uploaded, as well as a `.par` file for each file to be uploaded. See `templates/parameter_file_templates/results.par`. You can use `make_par_files()` to create parameter files for multiple files when they share values of the following parameters:
229
+
The DataLoader class allows batch uploading of all data in a given directory. That directory should contain the files to be uploaded, as well as a `.ini` file for each file to be uploaded. See `templates/parameter_file_templates/results.ini.tempate`. You can use `make_par_files()` to create parameter files for multiple files when they share values of the following parameters:
230
230
* directory in which the files can be found
231
231
* munger
232
232
* jurisdiction
@@ -235,8 +235,8 @@ The DataLoader class allows batch uploading of all data in a given directory. Th
235
235
* source
236
236
* note
237
237
* auxiliary data directory (if any)
238
-
The `load_all()` method will read each `.par` file and make the corresponding upload.
239
-
From a directory containing a `multi.par` parameter file, run
238
+
The `load_all()` method will read each `.ini` file and make the corresponding upload.
239
+
From a directory containing a `run_time.ini` parameter file, run
240
240
```
241
241
import election_anomaly as ea
242
242
dl = ea.DataLoader()
@@ -246,12 +246,12 @@ err = dl.load_all()
246
246
If something doesn't work, error messages will print. Even when the upload has worked, there may be warnings about lines not loaded. The system will ignore lines that cannot be munged. For example, the only contests whose results are uploaded will be those in the `CandidateContest.txt` or `BallotMeasureContest.txt` files that are correctly described in `dictionary.txt`.
247
247
```
248
248
>>> err
249
-
{'BAK_PctResults20181106.par': {'fl_gen_by_precinct': {'munge_warning': 'Warning: Results for 720 rows with unmatched contests will not be loaded to database.'}}, 'ALA_PctResults20181106.par': {'fl_gen_by_precinct': {'munge_warning': 'Warning: Results for 6174 rows with unmatched contests will not be loaded to database.'}}}
249
+
{'BAK_PctResults20181106.ini': {'fl_gen_by_precinct': {'munge_warning': 'Warning: Results for 720 rows with unmatched contests will not be loaded to database.'}}, 'ALA_PctResults20181106.ini': {'fl_gen_by_precinct': {'munge_warning': 'Warning: Results for 6174 rows with unmatched contests will not be loaded to database.'}}}
250
250
```
251
251
252
-
If there are no errors, the results and their `.par` files will be moved to the archive directory specified in `multi.par`. Any warnings for the `*.par` will be saved in the archive directory in a file `*.warn`
252
+
If there are no errors, the results and their `.ini` files will be moved to the archive directory specified in `run_time.ini`. Any warnings for the `*.ini` will be saved in the archive directory in a file `*.warn`
253
253
254
-
Some results files may need to be munged with multiple mungers, e.g., if they have combined absentee results by county with election-day results by precinct. If the `.par` file for that results file has `munger_name` set to a comma-separated list of mungers, then all those mungers will be run on that one file.
254
+
Some results files may need to be munged with multiple mungers, e.g., if they have combined absentee results by county with election-day results by precinct. If the `.ini` file for that results file has `munger_name` set to a comma-separated list of mungers, then all those mungers will be run on that one file.
255
255
256
256
If every file in your directory will use the same munger(s) -- e.g., if the jurisdiction offers results in a directory of one-county-at-a-time files, such AZ or FL -- then you may want to use `make_par_files()`, whose arguments are:
257
257
* the directory holding the results files,
@@ -264,7 +264,7 @@ If every file in your directory will use the same munger(s) -- e.g., if the juri
264
264
* aux_data_dir (optional -- use it if your files have all have the same auxiliary data files, which might never happen in practice)
265
265
266
266
## Pull Data
267
-
The Analyzer class uses parameters in the file `multi.par`, which should be in the directory from which you are running the program.
267
+
The Analyzer class uses parameters in the file `run_time.ini`, which should be in the directory from which you are running the program.
268
268
269
269
To pull totals by vote type, use `top_counts_by_vote_type()`
270
270
```
@@ -273,7 +273,7 @@ Results exported to /Users/singer3/Documents/rollups/2018 General/Pennsylvania;P
273
273
>>>
274
274
```
275
275
276
-
Results are exported to the `rollup_directory` specified in `multi.par`.
276
+
Results are exported to the `rollup_directory` specified in `run_time.ini`.
277
277
278
278
Note that both arguments -- the name of the top reporting unit ('Pennsylvania;Philadelphia') and the reporting unit type for the breakdown of results ('ward') must be the internal database names. To see the list of options, use `display_options()`:
Using whatever editor you like, create a file called 'run_time.par` in the 'election_anomaly' directory using 'election_anomaly/src/templates/parameter_file_templates/run_time.par' as a template. For instance, replace '<path to project root>' with the path to your current directory, so the line will look like this:\
94
+
Using whatever editor you like, create a file called 'run_time.ini` in the 'election_anomaly' directory using 'election_anomaly/src/templates/parameter_file_templates/run_time.ini' as a template. For instance, replace '<path to project root>' with the path to your current directory, so the line will look like this:\
0 commit comments