Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transportation emissions, 2002 - 2022 using territorial framework #104

Merged
merged 346 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
346 commits
Select commit Hold shift + click to select a range
0934a3c
read in and save EPA EQUATES data
eroten Aug 19, 2024
6f67a06
simplify
eroten Aug 19, 2024
803ad6c
update descriptions
eroten Aug 19, 2024
be13f46
ignore raw equates
eroten Aug 19, 2024
39204b7
troubleshoot EQUATES processing
eroten Aug 20, 2024
14ccaf2
break out EQUATES into reading and processing
eroten Aug 20, 2024
80100d9
add CNG motor homes
eroten Aug 20, 2024
5c7ba6f
add better comments, general cleanup
eroten Aug 21, 2024
9bae9b9
pull together data sources
eroten Aug 21, 2024
7a24fbc
ignore raw
eroten Aug 21, 2024
14c560c
pull in supplementary data from EQUATES dataverse
eroten Aug 21, 2024
6b99409
update bibliography
eroten Aug 21, 2024
eb6073f
start compiling nonroad
eroten Aug 21, 2024
a949ade
compare equates totals with other emissions
eroten Aug 21, 2024
2c98436
start VMT section
eroten Aug 21, 2024
f5ab35f
include more emis types and pollutants
eroten Aug 21, 2024
06c77cf
cross check values
eroten Aug 21, 2024
550cc61
save NEI VMT
eroten Aug 21, 2024
b721ed3
add more download files
eroten Aug 21, 2024
a5fec15
add higher level sector codes
eroten Aug 21, 2024
44ddded
ignore downloads
eroten Aug 21, 2024
1eeb11e
clarify unit of measurement in EQUATES
eroten Aug 22, 2024
3047b5d
move SCC EQUATES reading
eroten Aug 22, 2024
edf4257
update comments
eroten Aug 22, 2024
b25fd18
wrap to reduce re-running
eroten Aug 22, 2024
d8e247a
do not reference EQUATES with non-road
eroten Aug 22, 2024
ef0b863
save all emissions modeling for onroad
eroten Aug 22, 2024
1b51228
ignore various
eroten Aug 22, 2024
47e78e8
start index of downloaded EPA materials
eroten Aug 22, 2024
55c123b
update function names; complete some fixes
eroten Aug 22, 2024
d440d10
save onroad emissions (modeled)
eroten Aug 22, 2024
fa73993
save nonroad emissions (modeled)
eroten Aug 22, 2024
e48673a
compare different emissions sources
eroten Aug 22, 2024
ade77a0
work on comparisons
eroten Aug 24, 2024
4fda19e
update downloads table
eroten Aug 24, 2024
540c54a
update bib
eroten Sep 9, 2024
b31a294
complete compiling 2011, 2014, and 2015-2018 emissions modeling onroad
eroten Sep 10, 2024
0f65784
ignore raw
eroten Sep 10, 2024
d24b2aa
continue compilation and comparison
eroten Sep 10, 2024
231a3cd
style transportation code
eroten Sep 10, 2024
d46abeb
start prepping for combining datasets
eroten Sep 10, 2024
80e6d2f
make various updates and corrections
eroten Sep 10, 2024
2701984
complete base compilation
eroten Sep 10, 2024
4b55037
line breaks
eroten Sep 10, 2024
0c2b2df
add links to EQUATES activity data
eroten Sep 10, 2024
05c805b
include additional pollutants
eroten Sep 10, 2024
281cb4f
delete comparison script
eroten Sep 10, 2024
82846ff
move scc section
eroten Sep 10, 2024
ea8b8db
fix gas station scc codes, lingering SCC issues
eroten Sep 10, 2024
509851d
add comments, notes, data checks
eroten Sep 10, 2024
6ce09eb
save changes
eroten Sep 10, 2024
5f08bde
expand pollutants; add file_name column; specify join_by
eroten Sep 11, 2024
b80d75e
delete old versions
eroten Sep 11, 2024
78c297a
start documentation markdown
eroten Sep 11, 2024
6a1d7c8
re-save
eroten Sep 11, 2024
e6bb587
add comments; path updates; more pollutants
eroten Sep 11, 2024
145ebf1
delete old data
eroten Sep 11, 2024
95b6781
use clean and re-save method instead of holding everything in memory
eroten Sep 11, 2024
6b11303
re-run all EQUATES, air emissions modeling platform data
eroten Sep 11, 2024
88c1d90
update paths and pollutant descriptions
eroten Sep 11, 2024
875569f
update bib
eroten Sep 11, 2024
6af9933
use html output
eroten Sep 12, 2024
83f9c09
write consistent function for reading in transportation SMOKE/MOVES data
eroten Sep 12, 2024
62db8a4
replace auto-downloads with warning and link to documentation
eroten Sep 12, 2024
9fc41c0
re-run equates with new processing
eroten Sep 12, 2024
ca3fbf9
complete onroad re-run
eroten Sep 12, 2024
4630e1b
start emis section
eroten Sep 12, 2024
3cc7d60
add columns and save
eroten Sep 12, 2024
f4cca2b
do not filter my emis_type; re-run
eroten Sep 14, 2024
6faae82
read and save in SMOKE flat files
eroten Sep 14, 2024
da32311
re-run onroad
eroten Sep 14, 2024
d6b082b
create index of pollutants
eroten Sep 16, 2024
3f36d1d
save scc6 metadata
eroten Sep 16, 2024
bd671b1
expand pollutants included
eroten Sep 16, 2024
c9cb291
read in pollutants and scc codes instead of always re-running scripts
eroten Sep 16, 2024
1193ed8
add more pollutants
eroten Sep 16, 2024
31607e8
light plotting
eroten Sep 16, 2024
797c1ab
ignore misc downloads
eroten Sep 16, 2024
dcc7d5e
re-name file
eroten Sep 16, 2024
69303fd
update workbook
eroten Sep 16, 2024
1f06642
add more information and knit
eroten Sep 16, 2024
09f5214
compile emissions data sources and save
eroten Sep 16, 2024
693915a
update bib
eroten Sep 16, 2024
da25b6e
replace with better warning
eroten Sep 16, 2024
4e75961
re-run emissions compilation
eroten Sep 17, 2024
1344735
update comments
eroten Sep 17, 2024
d8e1e4e
change function name and subsequent references
eroten Sep 17, 2024
c352555
start cross-checking NEI regional and smoke
eroten Sep 17, 2024
ddfa6e0
update paths, make notes on attempts to cross check
eroten Sep 17, 2024
39b7360
add dynamic determination of how many rows to skip; record metadata rows
eroten Sep 18, 2024
7eab769
add comments, notes, and settle on which flat files to use
eroten Sep 18, 2024
2afe730
add general conclusions
eroten Sep 18, 2024
ada81f4
correct file exist checks
eroten Sep 18, 2024
1074124
re-run with changes from read_smokeff10
eroten Sep 18, 2024
d0e0f37
confirm that state separated 2014fd are the same as combined 2014fd
eroten Sep 18, 2024
8a560b1
add 2014 supplementary co2 and co file
eroten Sep 18, 2024
74d1a07
re-run nonroad with new read_smoke_ff10 options
eroten Sep 18, 2024
3cfd8df
increment/update epa downloads log
eroten Sep 18, 2024
87ec383
add notes, filter to ensure matching scc6
eroten Sep 18, 2024
ccdfb64
re-run EQUATES with new function
eroten Sep 18, 2024
9ff90ea
update source set
eroten Sep 18, 2024
d6645fb
update download log and documentation
eroten Sep 18, 2024
d596d17
compare other editions of same dataset
eroten Sep 18, 2024
9403575
start verification for NEI and Envirofacts
eroten Sep 18, 2024
cdd5553
Merge branch 'dev-2005-baseline' into 91-transportation-methodology-e…
eroten Sep 20, 2024
ea51bfd
style all
eroten Sep 20, 2024
596be9e
re-name to specify envirofacts source
eroten Sep 20, 2024
c3ead01
remove previous editions of same dataset
eroten Sep 20, 2024
93470b7
complete basic verification of NEI data across different sources
eroten Sep 20, 2024
15ae203
remove verify api alone
eroten Sep 20, 2024
e1966f9
also pull in envirofacts data
eroten Sep 20, 2024
a308e4e
add moves_edition column
eroten Sep 20, 2024
14d2b9b
various documentation updates
eroten Sep 20, 2024
2e77765
start documentation in Quarto
eroten Sep 23, 2024
9f1edc7
styling, small movements
eroten Sep 23, 2024
56f89ee
save in new location; ungroup()
eroten Sep 23, 2024
b9b0724
continue making various tables
eroten Sep 23, 2024
701d1ea
add listify function
eroten Sep 24, 2024
cec20d4
update bibliography
eroten Sep 24, 2024
f8e5263
fix typo
eroten Sep 24, 2024
2907c05
move limitations to other section
eroten Sep 24, 2024
41e7c15
update comments
eroten Sep 24, 2024
d0d6a71
make calc_year character
eroten Sep 24, 2024
4559e55
write section on SMOKE FF10, make first tables
eroten Sep 24, 2024
a040086
start and reference secondary data source scripts
eroten Sep 24, 2024
d0fe6e3
break out n2o deep dive into its own script
eroten Sep 24, 2024
1c8925c
add note on blank emis_type
eroten Sep 24, 2024
8a2a6c6
remove CNG single, combo unit short haul, motor homes, school buses
eroten Sep 24, 2024
286c7b1
move n2o comparison
eroten Sep 24, 2024
55d2e57
fix ipcc reference
eroten Sep 24, 2024
b73e41f
write section on N2O
eroten Sep 24, 2024
1750b31
update comment
eroten Sep 24, 2024
ea79839
re-knit with MOVES column
eroten Sep 24, 2024
3d46a11
update bib
eroten Sep 24, 2024
b2385aa
additional documentation; style transportation folder
eroten Sep 24, 2024
81fddc5
ignore CMAS data warehouse donwnload versions
eroten Sep 25, 2024
213a2c3
save CMAS data warehouse compilation of EQUATES
eroten Sep 25, 2024
0bed8f8
add 2019 data from EQUATES CMAS data warehouse
eroten Sep 25, 2024
e89156d
add direct CMAS data warehouse download links
eroten Sep 25, 2024
3d104dd
explain CMAS downloads, re knit
eroten Sep 25, 2024
b868da2
add explainer on why there is no N2O
eroten Sep 25, 2024
40d169a
check that CMAS and FTP download are identical
eroten Sep 25, 2024
a5d1536
add gas 2005
eroten Sep 25, 2024
c625cf5
update documentation
eroten Sep 25, 2024
f0ba254
update bib
eroten Sep 25, 2024
e307047
more documentation text
eroten Sep 25, 2024
cd6d418
start writing tests for compiled onroad emissions
eroten Sep 25, 2024
a4f7285
text edits
eroten Sep 25, 2024
a8f22fa
save PDF of email regarding SCCs
eroten Sep 26, 2024
8c0b650
add significant documentation of SCCs
eroten Sep 26, 2024
9f9c57a
update bib
eroten Sep 26, 2024
ca1cbea
move EQUATES processing to scrap
eroten Sep 26, 2024
322c788
delete old and move useful code to scrap; document
eroten Sep 26, 2024
40262f2
add comments
eroten Sep 26, 2024
11e474d
delete transportation specific processing script
eroten Sep 26, 2024
1cfadd3
process US GHG Emissions and Sinks (US GHGI)
eroten Sep 26, 2024
bdc0a7d
line breaks; style meta and transportation folders
eroten Sep 26, 2024
40a38fb
add comments
eroten Sep 30, 2024
72d7bfb
move scrap EPA NEI
eroten Sep 30, 2024
d3bdac6
delete obsolete
eroten Sep 30, 2024
b2041ab
delete, condense obsolete
eroten Sep 30, 2024
47a8bd9
start commenting out old documentation
eroten Sep 30, 2024
188cbab
Merge branch 'dev-2005-baseline' into 91-transportation-methodology-e…
eroten Sep 30, 2024
2e5a1bf
fetch and use full time series of EQUATES data
eroten Oct 1, 2024
3fe358b
use CMAS downloads and do not interpolate EQUATES
eroten Oct 1, 2024
7bfd312
re-run with fresh 2010 values
eroten Oct 2, 2024
33ae86f
move verification; start comparing interpolation results
eroten Oct 2, 2024
2935557
2010 emissions evened out
eroten Oct 2, 2024
30e7df5
update downloads log; re-run readme
eroten Oct 2, 2024
da88044
Merge remote-tracking branch 'origin/dev-2005-baseline' into 91-trans…
eroten Oct 2, 2024
43b7551
increase compression on equates_cmas_mn_wi
eroten Oct 2, 2024
3acb227
add vehicle weight and fuel type labels
eroten Oct 2, 2024
a8063ec
increase compression level
eroten Oct 2, 2024
598314b
include N2O in CO2e across all data sources;
eroten Oct 2, 2024
e481285
expand on N2O differences and comment verification script
eroten Oct 2, 2024
4f7276b
add labels, finesse plots
eroten Oct 2, 2024
5fbf06f
compile onroad emissions
eroten Oct 2, 2024
d00280d
update downloads log
eroten Oct 2, 2024
8d37f00
use xz on compression on next run
eroten Oct 2, 2024
46d5f3f
add pollutant type
eroten Oct 2, 2024
e028113
delete duplicate
eroten Oct 2, 2024
fdae94c
prep transportation emissions for compilation with other sectors
eroten Oct 2, 2024
0242375
integrate transportation onroad into all county emissions
eroten Oct 2, 2024
2de8784
add pollutant type column
eroten Oct 2, 2024
6d31584
use xz on next run
eroten Oct 2, 2024
d29ba1d
style all
eroten Oct 2, 2024
8ce6735
add warning for plotting more than one year of data in a single plot
eroten Oct 2, 2024
f374d7a
use different source labels
eroten Oct 2, 2024
0622530
update tests
eroten Oct 2, 2024
04f388c
remove gas stations and trucks and buses from primary emissions data
eroten Oct 2, 2024
cf6a5b9
start updating transportation documentation
eroten Oct 2, 2024
0529cd9
add more testing for character/factor columns
eroten Oct 3, 2024
9071572
make fuel ordered; specify join column
eroten Oct 3, 2024
899e7f0
add force_download option and implement
eroten Oct 3, 2024
e5ba34c
update source classification codes
eroten Oct 3, 2024
1c6dfca
update vehicle weight colors, source colors
eroten Oct 3, 2024
dd6d347
integrate current year throughout document
eroten Oct 3, 2024
f5a1c3c
add fuel type plot
eroten Oct 3, 2024
210addb
add fuel type colors
eroten Oct 3, 2024
2b40efd
create and use round_emissions_metric_tons_co2e()
eroten Oct 3, 2024
90448f0
use rm to clean up environment
eroten Oct 3, 2024
7a5b210
re-run with ordering
eroten Oct 3, 2024
f0b3414
start section on historical emissions; use fuel type colors
eroten Oct 3, 2024
75ce426
use purrr for air emissions modeling processing
eroten Oct 3, 2024
59c82e8
re-run onroad air emissions modeling
eroten Oct 3, 2024
c9195a9
re-run NEI
eroten Oct 3, 2024
d24d8a0
re-run and reduce EQUATES size
eroten Oct 3, 2024
96ec3a6
update category colors
eroten Oct 3, 2024
2f746ae
add year into visualization considerations
eroten Oct 3, 2024
e91f842
use onroad_emissions dataset to get transportation max year
eroten Oct 3, 2024
826775b
join population data with onroad_emissions
eroten Oct 3, 2024
ac7809f
comment out NEI section and LGGIT section
eroten Oct 3, 2024
c7cd481
get plotting helpers
eroten Oct 3, 2024
4fcab5c
style
eroten Oct 3, 2024
0c171be
fix source and re-knit
eroten Oct 3, 2024
b122142
hold off on aviation data for now
eroten Oct 3, 2024
cefd525
style
eroten Oct 3, 2024
8a9adf7
re-name scripts
eroten Oct 4, 2024
09809cb
delete un-used and obsolete
eroten Oct 4, 2024
5394203
update file names; delete obsolete
eroten Oct 4, 2024
1dc2341
comment out epa_moves.qmd
eroten Oct 4, 2024
7f6e512
comment out TBI datasets, pending updates
eroten Oct 4, 2024
f9a2aac
add comments
eroten Oct 4, 2024
429e5b8
create index of scripts with descriptions, whether they are active, etc
eroten Oct 4, 2024
2fb28f7
draft and render epa downloads
eroten Oct 4, 2024
55aee39
style all
eroten Oct 4, 2024
088acf9
un-comment line break
eroten Oct 4, 2024
79c8e68
remove text about kalman smoothing
eroten Oct 4, 2024
588908f
add comments
eroten Oct 4, 2024
d7293de
update bib
eroten Oct 8, 2024
f47998f
add comment
eroten Oct 8, 2024
6c25934
change name
eroten Oct 17, 2024
9bf7a27
remove contextual sentence
eroten Oct 18, 2024
0ed0b29
move status column up
eroten Oct 18, 2024
17b4349
re-group vehicles into Passenger, Buses, and Trucks
eroten Oct 18, 2024
21b2630
ignore live Excel workbook
eroten Oct 18, 2024
316f23e
finesse tables; ensure unique
eroten Oct 18, 2024
0da8a53
small edits
pawilfahrt Oct 18, 2024
60b71b1
Merge remote-tracking branch 'origin/91-transportation-methodology-ex…
eroten Oct 18, 2024
4473d92
fix summing issue in state and county nei calcs
pawilfahrt Oct 21, 2024
fb673ad
ignore NA while summing
pawilfahrt Oct 22, 2024
82cfbcb
update to call most recent county proportions and resave
pawilfahrt Oct 23, 2024
411356a
Notes on odd dataset differences
pawilfahrt Oct 23, 2024
44304b4
col group by update
pawilfahrt Oct 23, 2024
9540457
update path
pawilfahrt Oct 23, 2024
e8e06ef
create directories if they don't exist
eroten Oct 24, 2024
d8a64fc
update bib
eroten Oct 24, 2024
929b760
path_sanitize
pawilfahrt Oct 24, 2024
fa9186e
update gitignore with new downloaded file name
eroten Oct 24, 2024
d8f7def
style all; replace T with TRUE
eroten Oct 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,8 @@ _transportation/data-raw/epa/nei_pre_2008/

_transportation/data-raw/GPC/

_transportation/data-raw/GPC/

_transportation/data-raw/epa/nei_2005/

_transportation/data-raw/epa/SCCDownload-2024-0718-132502.csv
Expand Down Expand Up @@ -820,3 +822,183 @@ _transportation/data-raw/epa/smoke_flat_file_format_26apr2010_no_event.xls
_transportation/data-raw/epa/nei/SmokeFlatFile_MN_WI/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/CMAS_Data_Warehouse/

_meta/data-raw/population/co-est00int-01-27.xls

_meta/data-raw/population/co-est00int-01-55.xls

_meta/data-raw/population/

_transportation/data-raw/epa/nei_pre_2008/

_agriculture/data-raw/ag_constants.csv

_agriculture/data-raw/ag_control.csv

_agriculture/data-raw/ag_fertilizer.csv

_agriculture/data-raw/ag_manure_management.csv

_agriculture/data-raw/ag_nex.csv

_agriculture/data-raw/ag_residual_burning_ch4.csv

_agriculture/data-raw/ag_residual_burning_n2o.csv

_agriculture/data-raw/ag_soils_fertilizer_production.csv

_agriculture/data-raw/ag_soils_fertilizer.csv

_agriculture/data-raw/ag_soils_liming.csv

_agriculture/data-raw/ag_soils_manure.csv

_agriculture/data-raw/ag_soils_residuals.csv

_transportation/data-raw/epa/nei_2005/

_transportation/data-raw/epa/SCCDownload-2024-0718-132502.csv

_meta/data-raw/epa/state_ghg/

_meta/data-raw/epa/nei_2005/

_meta/data-raw/epa/SCCDownload-2024-0718-132502.csv

_transportation/data-raw/epa/nei/2020NEI_onroad/inputs/onroad/

_transportation/data-raw/epa/nei/2020_Documentation_of_CDB_Input_Data_20230118.xlsx

_transportation/data-raw/epa/nei/2020_RepCounty_Runspecs.zip

_transportation/data-raw/epa/nei/2020_Representative_Counties_Analysis_20220720.xlsx

_transportation/data-raw/epa/nei/2020NEI_onroad_activity_final_20230112.zip

_transportation/data-raw/epa/nei/onroad_activity_data_SCC_descriptions.xlsx

_transportation/data-raw/epa/nei/~$2020_Documentation_of_CDB_Input_Data_20230118.xlsx

_transportation/data-raw/epa/nei/~$2020_Representative_Counties_Analysis_20220720.xlsx

_transportation/data-raw/epa/nei/2020NEI_spdist.zip

_transportation/data-raw/~$source_method_compare.xlsx

_transportation/data-raw/epa/nei/2020NEI_spdist/

_transportation/data-raw/epa/nei/2020NEI_RepCounty_Temperatures.zip

_transportation/data-raw/epa/nei/2008NEI/

_transportation/data-raw/epa/nei/2014NEI/

_transportation/data-raw/epa/nei/2017NEI/

_transportation/data-raw/epa/nei/2011NEI/

_transportation/data-raw/epa/nei/2020NEI/

_transportation/data-raw/epa/SCCDownload-2024-0805-165321.csv

_transportation/data-raw/epa/emismod/

_transportation/data-raw/epa/scc_missing_values.csv

_transportation/data-raw/epa/SCCDownload-2024-0812-144242.csv

_transportation/data-raw/epa/air_emissions_modeling/2022v1/

_transportation/data-raw/epa/air_emissions_modeling/2021/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2017/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2014/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2011/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2008_inventory_onroad_11may2021.zip

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2008/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2005_inventory_onroad_23jun2021.zip

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2011_inventory_onroad_20apr2021.zip

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2014_inventory_onroad_01mar2021.zip

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2017_inventory_onroad_inv_25jan2021.zip

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2002_inventory_onroad_01jun2021.zip

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2002_inventory_onroad_23jun2021.zip

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2005/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2002/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2017_inventory_onroad_activity_11jan2021.zip

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_2017 2/

_transportation/data-raw/mndot/county_functional_class/

_transportation/data-raw/epa/air_emissions_modeling/2002ac/

_transportation/data-raw/epa/air_emissions_modeling/air_emismod.csv

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/~$app-4-4-2016-2023-nj-modeling-inventory-statewide-5-13-24.xlsx

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/2011-Alpha2-Appendix-GG-SCC-Assignments-to-MARAMA-Sectors-2016.xlsx

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/app-4-4-2016-2023-nj-modeling-inventory-statewide-5-13-24.xlsx

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_M3_bySCC.zip

_transportation/data-raw/epa/air_emissions_modeling/2002_neiv3CAP_orl_nonroad.zip

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/Dataverse/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/nonroad/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_M3_bySCC/

_transportation/data-raw/epa/air_emissions_modeling/onroad_activity_data_SCC_descriptions.xlsx

_transportation/data-raw/epa/air_emissions_modeling/2020/

_transportation/data-raw/epa/air_emissions_modeling/2011/
_transportation/data-raw/epa/air_emissions_modeling/2015/
_transportation/data-raw/epa/air_emissions_modeling/2014/
_transportation/data-raw/epa/air_emissions_modeling/2016/
_transportation/data-raw/epa/air_emissions_modeling/2017
_transportation/data-raw/epa/air_emissions_modeling/2018/
_transportation/data-raw/epa/air_emissions_modeling/2019/

_transportation/data-raw/epa/~$epa_downloads.xlsx

_transportation/data-raw/epa/air_emissions_modeling/2008/

_transportation/data-raw/epa/air_emissions_modeling/2007/

_transportation/data-raw/epa/air_emissions_modeling/air_emissions_modeling_mn_wi/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/EQUATES_MN_WI/

_transportation/data-raw/epa/27Nov07 Valid Protocols Sampl Meth - All.xls

_transportation/data-raw/epa/methods_all.csv

_transportation/data-raw/epa/Parms by Desc.xls

_transportation/data-raw/epa/smoke_flat_file_format_26apr2010_no_event.xls

_transportation/data-raw/epa/nei/SmokeFlatFile_MN_WI/

_transportation/data-raw/epa/air_emissions_modeling/EQUATES/CMAS_Data_Warehouse/

_transportation/data-raw/epa/SCC\?format=CSV&sortFacet=scc%20level%20one&filename=SCCDownload-2024-0812-144242.csv

_transportation/data-raw/epa/SCC\?format=CSV&sortFacet=scc%20level%20one&filename=SCCDownload-2024-0926-141750.csv

_meta/data-raw/epa/us_ghgi/
Expand Down
8 changes: 8 additions & 0 deletions R/_plotting_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
source(file.path(here::here(), "R/cprg_colors.R"))
source(file.path(here::here(), "R/plot_county_emissions.R"))
source(file.path(here::here(), "R/plot_sector_county_emissions.R"))

round_emissions_metric_tons_co2e <- function(x) {
ifelse(
max(x) > 1000000,
paste0(round(x / 1000000, digits = 2), " million metric tons CO<sub>2</sub>e", "<br>"),
paste0(round(x / 1000, digits = 0), " thousand metric tons CO<sub>2</sub>e", "<br>")
)
}
21 changes: 21 additions & 0 deletions R/_quarto_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -252,3 +252,24 @@ save_plotly <- function(a_plotly, fmt = c("png", "pdf", "svg"),
)
}
}


# thanks to R for the Rest of Us
# https://rfortherestofus.com/2022/10/automating-sentences-with-r
# Example:
# > 1:4 %>% listify()
# "1, 2, 3 and 4"
listify <- function(my_vector) {
if (length(my_vector) > 1) {
paste(
paste(my_vector[1:length(my_vector) - 1],
collapse = ", "
),
"and",
my_vector[length(my_vector)]
)
} else {
# if length == 1, we don't want to print "and blah"
paste(my_vector)
}
}
35 changes: 24 additions & 11 deletions R/cprg_colors.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ category_colors <-


# YlOrBr
"Passenger vehicles" = "#ec7014",
"Commercial vehicles" = "#fec44f",
"Passenger vehicles" = "#993404",
"Medium-duty vehicles" = "#fe9929",
"Heavy-duty vehicles" = "#fee391",
"Transit vehicles" = "#E9967A",
"Other vehicles" = "#eaeded",

# PuRd
"Solid waste" = "#ce1256",
Expand All @@ -43,9 +46,14 @@ category_colors <-
# source
source_colors <- list(
# transportation levels
"Light-duty vehicles" = "#993404",
"Medium-duty vehicles" = "#fe9929",
"Heavy-duty vehicles" = "#fee391",
# "Light-duty vehicles" = "#993404",
# "Medium-duty vehicles" = "#fe9929",
# "Heavy-duty vehicles" = "#fee391",
"Gasoline fueled vehicles" = "#db4a33",
"Diesel fueled vehicles" = "#feb24c",
"Other fueled vehicles" = "#ffeda0",



# waste levels
"Landfill" = "#ae017e",
Expand All @@ -70,12 +78,17 @@ source_colors <- list(


vehicle_weight_colors <- list(
"Passenger" = source_colors$`Light-duty vehicles`,
"Medium" = source_colors$`Medium-duty vehicles`,
"Heavy" = source_colors$`Heavy-duty vehicles`,
"Light-duty" = source_colors$`Light-duty vehicles`,
"Medium-duty" = source_colors$`Medium-duty vehicles`,
"Heavy-duty" = source_colors$`Heavy-duty vehicles`
"Passenger" = category_colors$`Passenger vehicles`,
"Medium-duty" = category_colors$`Medium-duty vehicles`,
"Heavy-duty" = category_colors$`Heavy-duty vehicles`,
"Transit" = category_colors$`Transit vehicles`,
"Other" = category_colors$`Other vehicles`
)

fuel_type_colors <- list(
"Gasoline" = "#ffc300",
"Diesel" = "#9f7a00",
"Other" = "#604900"
)

management_method_colors <- list(
Expand Down
18 changes: 12 additions & 6 deletions R/download_read_table.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#'
#' @param url character, file location URL. Must end with either ".xlsx" or ".xls"
#' @param exdir character, directory location where to save downloaded document
#' @param force_download logical, whether to force a fresh download, regardless
#' of whether the file exists already. Default value is `FALSE`.
#' @param ... Additional arguments passed to readxl::read_excel() or readr::read_csv
#'
#' @return tibble
Expand All @@ -15,17 +17,21 @@
#'
download_read_table <- function(url,
exdir,
force_download = FALSE,
...) {
# split URL to get file name
url_split <- strsplit(url, split = "/")
file_name <- tail(url_split[[1]], n = 1)


# download file and save in exdir
download.file(url,
destfile = file.path(exdir, file_name),
mode = "wb"
)
# if the downloaded file does not already OR
# we are forcing a fresh download
# download the file and save in exdir
if (!file.exists(file.path(exdir, file_name)) | force_download == TRUE) {
download.file(url,
destfile = file.path(exdir, file_name),
mode = "wb"
)
}

# read and return file
if (fs::path_ext(file_name) == "csv") {
Expand Down
17 changes: 8 additions & 9 deletions R/plot_county_emissions.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#' @importFrom dplyr filter
#' @importFrom stringr str_to_title
#' @importFrom councilR plotly_layout
#' @importFrom cli cli_alert_warning
plot_county_emissions <- function(county_emissions,
.sector,
.plotly_source) {
Expand All @@ -27,16 +28,14 @@ plot_county_emissions <- function(county_emissions,
))
}

plot_data <- plot_data %>%
mutate(
rounded_tons = ifelse(
max(emissions_metric_tons_co2e) > 1000000,
paste0(round(emissions_metric_tons_co2e / 1000000, digits = 2), " million metric tons CO<sub>2</sub>e", "<br>"),
paste0(round(emissions_metric_tons_co2e / 1000, digits = 0), " thousand metric tons CO<sub>2</sub>e", "<br>")
)
)

if ("year" %in% names(plot_data)) {
if (length(unique(plot_data$year)) > 1) {
cli::cli_alert_warning("Plotting more than one year of data")
}
}

plot_data <- plot_data %>%
mutate(rounded_tons = round_emissions_metric_tons_co2e(emissions_metric_tons_co2e))

plot_ly(
data = plot_data,
Expand Down
Loading